Finished the book “Linux Network Operating System Application Basic Course” in one day

Original link: http://weepingdogel.github.io/posts/%E4%B8%80%E5%A4%A9%E5%88%B7%E5%AE%8Clinux%E7%BD%91%E7%BB% 9C%E6%93%8D%E4%BD%9C%E7%B3%BB%E7%BB%9F%E5%BA%94%E7%94%A8%E5%9F%BA%E7%A1%80% E6%95%99%E7%A8%8B%E8%BF%99%E6%9C%AC%E4%B9%A6/

photo_2022-09-30_20-14-56.jpg

sequence

I haven’t seen you for a long time, I miss you so much.

During this period of time, school has started, I have been busy for a while, and I haven’t updated my blog for a long time.

In the textbook, I saw such a book (above), called “Linux Network Operating System Application Basic Course”. At first glance, the cover looks good, and this simple color scheme makes this book have a high-level sense… However, after turning over a few pages, I found that this is a basic book.

For a person who has been using Arch for two years and doesn’t like reading books, the content in this book should be learned quickly.

With the attitude of trying it out, I want to finish this book in one day.

full book catalog

First look at the catalog and almost laughed.

Obviously, this is really some basic content. Most of them have also been exposed in two years of Arch experience.

It seems to be some concepts + foundation + practical operation

Conceptual content

It is probably the content of 2.1 of Project 1 to Project 2, which talks about the case, history, and popular distributions of Linux.

There is no Arch in the book, bad review.

But it also describes that Linux can be used to run various services, such as DNS ( Domain Name System ) services, Web servers (Apache Nginx, which provide web services based on HTTP protocol), mail servers based on SMTP protocol, and FTP protocol files Transport server, file sharing server based on Samba protocol, DHCP server and VPN server.

In short, it talks about what Linux can do, the advantages of Linux, etc. These can be found through search engines, so I won’t go into details.

practical content

In the future, it will be some operational content, such as Linux installation and building various services, etc.

Install the Linux operating system

The book talks about installing a CentOS virtual machine with VMware.

In high school it will, skip it.

Linux basic operation

Regarding basic operations, I wrote a few notes on basic commands when I was in junior high school.

The book also introduces two ways to open the terminal, one is to open the terminal in the graphical interface, and the other is to switch tty by pressing Ctrl + Alt + (F1 ~F6) .

Then there are the commands, most of which are Chinese translations after adding the -h parameter. For those who are not very good at English, it is also a good thing to read them when needed.

In addition, I need to add some commands that were not written in the article sent by the junior high school.

cat

Output the content of a file, the usage written in the book is

 1
 cat [选项] [文件名]

But our general usage is

 1
 cat [文件名]

This is nothing to say and is commonly used, but it is not very good when encountering too long text.

less and more

I have hardly seen anyone using more, the commands are used in the same way, but the effect may be different.

 1
 more [选项] [文件名]
 1
 less [选项] [文件名]

Usually we don’t add any options…

head and tail

There is nothing to say about this, the parameter usage is the same, but The former looks at the head, the latter looks at the butt .

 1
 head [option] [文件名]
 1
 tail [option] [文件名]

parameter options

  • -n num display the last num lines of the specified file
  • -c num Display the last num characters of the specified file.

rmdir

Used to delete a directory. With this, the deleted directory must be empty.

Otherwise, an error will be reported. Like mkdir , you can add -p for recursive deletion.

What does recursion mean? It is to delete one level at a time.

 1
 rmdir [option] [文件名]

However, I usually don’t like to use this, I like to use rm -r or rm -rfv .

touch

The touch command can generate a normal file.

 1
 touch [文件名]

grep

This is used to view the lines in the file that contain the specified string, commonly used.

 1
 grep [选项] [要查找的字符串] [文件名]

tar

I usually use this tar to decompress.

 1
 tar xvf [文件名]

However, this is a packing command, which is equivalent to compressing a file.

 1
 tar [选项] [档案文件] [文件列表]
  • -c generate archive file
  • -v list the detailed process of unarchiving the archive
  • -f specifies the archive file name
  • -r append the file to the end of the archive
  • -z compress or decompress in gzip format
  • -j compress or decompress in bzip2 format
  • -d compare archive with files in current directory
  • -x unzip archive

You can use man to see more information about tar .

 1
 man tar

rpm

Offline package installer for rpm-based distributions. At least that’s how I understand it.

 1
 rpm [选项] [软件包名字]

The name of the package refers to a file name, and some files ending with .rpm suffix are rpm-based software packages.

The installation looks like this

 1
 rpm -i [软件包名字]

other parameters

  • -v install process show details
  • -h Show progress bar with # during installation
  • -e remove package
  • -q to see if the package is already installed

You can also read the manual through man

 1
 man rpm

Now we use package managers such as yum or dnf directly, and use remote repositories to install and manage packages.

document editing

As for document editing, you need to use vi or vim .

This is also common

 1
 vim [文件名]

Quote a link to a rookie tutorial

I usually use i to edit documents, ESC to exit edit mode, :w to save, and :q to quit.

Sometimes it is necessary to add a ! Enforcement.

Save and exit is :wq

If there are other needs I will use man to look at the documentation.

 1
 man vim

User and group management

The thing to do when installing Arch is to add users with useradd .

Desktop systems often do not use the root user and add one or more regular users.

Some collaboratively deployed servers also take advantage of the multi-user nature of Linux.

hint

Every file in a GNU/Linux system belongs to a user (owner) and a user group (owner). In addition, there are three types of access rights: read, write, and execute. We can set the corresponding access permissions for the owner and group of the file.

—— Excerpted from && see ArchWiki

useradd

This command is used to add users

 1
 useradd [选项] 用户名

Paste the parameter usage first

  • -m / --create-home Create user home directory /home/[用户名] ; within its own home directory, even non-root users can read and write files, install programs, etc.
  • -G / --groups List of additional groups the user wants to join; use commas to separate multiple groups, do not add spaces; if not set, the user only joins the initial group.
  • -s / --shell The path of the user’s default login shell; after the startup process is over, the default login shell is set here; please make sure that the shell used has been installed, the default is Bash.
hint

Use useradd --defaults to view the shell defaults. The default is Bash. Additional values ​​can be set with the -s / --shell option. /etc/shells records the login shells that can be used.

– Excerpted from ArchWiki

For example, if I want to create a user on a new machine, the user name is weepingdogel and I need to create the user’s home directory /home/weepingdogel , and add it to the wheel group , and the default shell is set to Bash .

I will execute this command:

 1
 useradd -G wheel -m -s /bin/bash weepingdogel

What if I want zsh ?

 1
 useradd -G wheel -m -s /bin/bash weepingdogel

Just like this~

warn
  1. The new user cannot be the same as the user name of the existing user;
  2. After the user is created, the user name or group must be included in the /etc/sudoers file, otherwise the root authority cannot be invoked using sudo ;
  3. Don’t create a bunch of useless users
  4. Make sure the shell you are using is installed, the default is Bash. Uninstalled shells cannot be used, and users cannot create them.

userdel

This command is used to delete a user

 1
 userdel [选项] 用户名

Add the -r option to delete the user’s home directory

 1
 userdel -r 用户名
warn
Don’t be blind j8 delete users

Not much to say, see man userdel for details.

groups

This command is used to see which groups a user belongs to.

 1
 groups [用户名]

Of course, we can also view all groups by looking at /etc/group .

 1
 cat /etc/group

id

This command can display some additional information about the user, such as UID , GID , etc.

 1
 id [用户名]

groupadd and groupdel

The former is to create a new group, the latter is to delete a group.

Create a new group:

 1
 groupadd [组名]

Delete a user group:

 1
 groupdel [组名]
warn
Don’t be blind j8 delete groups

groupmod

Often used to change the name of the group to which the user belongs, but not the GID .

 1
 groupmod -n [新名字] [旧名字]

gpasswd

Often used to change which group a user belongs to.

For example to add a user to a group:

 1
 gpasswd -a [用户名] [组名]

Or remove a user from a group:

 1
 gpasswd -d [用户名] [组名]

Other usage can also refer to man gpasswd

hint
If the user is already logged in, they must log in again for the change to take effect.

A list of some related documents

  • /etc/shadow holds user security information
  • /etc/passwd user account information
  • /etc/gshadow holds security information for group accounts
  • /etc/group defines the group to which the user belongs
  • /etc/sudoers Users who can run sudo
  • /home/* home directory

Remember them well.

Basic Disk Management

Of course, it also involves disk management, which can be touched a lot when installing Arch.

View partition status

When Linux recognizes the disk, it allocates it as a block device, which in the system is a file, such as /dev/sda , /dev/nvme0n1 , or /dev/mmcblk0 . You can use lsblk or fdisk to view:

 1
 fdisk -l
hint
Among different devices, the block device representation of the disk is also different. For example, the hard disk using SATA interface will be displayed as /dev/sd*X , while the hard disk using NVME will be displayed as /dev/nvme*n*

Create edit section

You can go to the search engine to find instructions for fdisk , follow it to create and edit partitions, you can use simple cfdisk .

You can even use the graphical partitioning tools that come with some distributions.

format

After the partition is created, it is necessary to select the appropriate file system for formatting.

What are the file systems? Please refer to this page for details

Linux often uses EXT4

use mkfs

 1
 mkfs.ext4 /dev/partition

mount partition

 1
 mount [被挂载的分区] [要挂载到的地方]

Of course, you can also write /etc/fstab for automatic mounting, details can be found here

resource sharing service

FTP

Build an FTP server

First install vsftpd using the package manager

deb

 1
 sudo apt install vsftpd

centos

 1
 sudo yum install vsftpd

Configure by editing /etc/vsftpd.conf

Such as allowing anonymous login, and allowing passwordless login

 1 2
 anonymous_enable=YES no_anon_password=YES

Then start via systemd

 1
 sudo systemctl start vsftpd

connect via client

Refer to the Arch Wiki , the configuration can be adjusted according to the actual situation.

Samba

Don’t do this stuff, it’s too dangerous.

DHCP server

Install dhcpd directly

deb

 1
 sudo apt install dhcpd

centos

 1
 yum install -y dhcpd

pacman

 1
 sudo pacman -S dhcpd

Write the configuration file /etc/dhcpd.conf :

 1 2
 # No DHCP service in DMZ network (192.168.2.0/24) subnet 192.168.2.0 netmask 255.255.255.0

Then start the service through systemd

 1
 sudo systemctl start dhcpd4

DNS server

I’m too lazy to do it, it’s not difficult

Reference https://wiki.archlinux.org/title/BIND_(%E7%AE%80%E4%BD%93%E4%B8%AD%E6%96%87)

Apache server

this simple

deb

 1
 sudo apt install apache2

pacman

 1
 sudo pacman -S apache

rpm

 1
 sudo yum install -y apache2

Start the service directly

 1
 sudo systemctl start httpd

Then visit http://127.0.0.1:80 .

Summarize

What a rubbish book!

Simple, but too old to keep up with the times.

Or find information on the Internet by yourself.

This article is reprinted from: http://weepingdogel.github.io/posts/%E4%B8%80%E5%A4%A9%E5%88%B7%E5%AE%8Clinux%E7%BD%91%E7%BB% 9C%E6%93%8D%E4%BD%9C%E7%B3%BB%E7%BB%9F%E5%BA%94%E7%94%A8%E5%9F%BA%E7%A1%80% E6%95%99%E7%A8%8B%E8%BF%99%E6%9C%AC%E4%B9%A6/
This site is for inclusion only, and the copyright belongs to the original author.