Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to understand the Linux operating system in CentOS

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

How to understand the Linux operating system in CentOS, many novices are not very clear about this, in order to help you solve this problem, the following editor will explain for you in detail, people with this need can come to learn, I hope you can gain something.

A brief introduction to Linux

Linux definition: Linux is a free-to-use and free-spread Unix-like operating system. It is a multi-user, multi-task, multi-threaded and multi-CPU operating system based on POSIX and UNIX.

The main use of Linux operating system: mainly used for servers, especially network servers.

Second, install Linux system

The effects of installing the Linux system are as follows:

Enter the Linux system (turn on the virtual machine):

Log in to root users, and the results are as follows:

Linux terminal: Linux terminal is also called virtual console. The Linux terminal uses the character command line mode to work, the user inputs the command through the keyboard, and controls the system through the Linux terminal.

Master the method of switching virtual terminal: Ctrl+Alt+F [1x6]. If you want to switch to the second virtual terminal, press Ctrl+Alt+F2 at the same time.

The prompt of the system after the ordinary user logs in: $

Prompt for the system after the root user logs in: #

Exit command (shutdown): exit

3. The basic command ① of Linux

The syntax format of the Linux command:

Command [options] [parameters]

Command: tell the Linux (UNIX) operating system what to do (execute).

Options: describe how the command runs (you can change the function of the command). The option section starts with the "-" character.

Parameters: describe what the command affects (operation) (such as a file, a directory, or a paragraph of text).

Basic commands:

The function of the whoami command: list the user name (account number) currently used to log in to the Linux system.

The function of the useradd command: create a user, followed by a user name.

The function of the passwd command: set or change the password for the user, followed by a user name.

The function of the who command: lists which users are currently working on the system.

Output of the who command: displays all users who are currently logged in, as well as the current date and time.

The function of the date command: displays the current date and time of the system. 、

The date command sets the format of the time and time: date month, day, hour, year.

For example: command to set the time to 10: 18 a.m. on December 24, 2018: (date 122410182018)

(synchronization time: hwclock-s synchronization hardware-w synchronization system)

The function of the cal command: to display the calendar of a month. For example, the command to display the calendar for August 2008 is: cal 8 2018

Function of the clear command: clear the screen

Screen-clearing shortcut key: ctrl+l

The function of the su command: switch from the current user to another specified user. For example, the command that cuts to the root user: su-root

The function of the man command: get the instructions for the use of a Linux command, followed by the command name. The command to view the instructions for using the su command is: man su

Man useradd is equivalent to useradd-- help

Four Linux directory structure: Linux everything is a file

Bin directory: used to store commonly used executable files

Sbin directory: the executable files used to store the system

Home directory: used to store the user's own files or directories, in which the superuser root's home directory is / root, while the ordinary user's home directory is stored in the / home directory and uses the user name as the name of the last level directory (home directory), such as cat users' home directory is / home/cat.

Dev directory: device file directory

Etc directory: configuration file directory

Mount point (directory): usually removable hardware is mounted under the / media or / mnt directory.

Definition of absolute path: must start with a forward slash (/).

Definition of relative path: does not start with a forward slash (/).

The basic command ② for browsing and using directory files

The function of the pwd command: determine the working directory you are now in

The function of the cd command: switch the current directory ("cd.." Command: enter a higher-level directory "cd ~" command or "cd" command: change to the user's home directory "cd -" command: switch to the user's previous working directory "cd directory name" command: switch to the specified directory. For example, the command to change to the / home/dog directory is: cd / home/dog)

The function of the ls command: list the contents of the current directory (default is current directory) or specified directory

Ls-a command: lists all files in the directory, including "." The beginning of the implicit file, for example: list all files in the / home/dog directory, including the command to hide files: ls-a / home/dog. (ls-all command: same as ls-a)

The ls-l command (equivalent to ll): lists the details of each file in a directory, for example: the command that lists the details of all non-hidden files in the / home/dog directory: ls-l / home/dog.

The function of the cp command: to copy files (which can be multiple) into a specified destination file or to a specified destination directory.

Cp source file target file

Cp-r (recursive, recursive): copy directories recursively. When you copy a directory, copy everything in that directory, including the entire contents of the subdirectory. For example: copy everything in the / home/dog directory to the command in the directory / home/cat:

Cp-r / home/dog / home/cat,cp-f (force, mandatory): force a copy directly without asking when the target file already exists.

The function of the mv command: you can move files and directories between different directories or rename files and directories.

Example of moving files and directories: a command to move lists files in the current directory to its subdirectory babydog:

Mv lists babydog

Example of renaming files and directories: the command to change the bigdog directory name to babydog:

Mv bigdog babydog

The function of the mkdir command: create a new directory, followed by the new directory name and path.

The function of the touch command: you can create an empty file or multiple files at the same time, followed by a file name.

The function of the rm command: permanently delete a file or directory from the file system.

Rm-r (recursive, recursive): deletes a directory recursively. When you delete a directory, delete everything in that directory, including everything in a subdirectory.

Rm-f (force, mandatory): the system does not ask but force deletion, that is, delete the original file directly.

Rm-rf: force the deletion of files and directories without asking.

The function of the cat command: to display the contents of one or more files on the screen, the command will continue to display the contents of the entire file in a read-only manner.

The function of the head command: the first 10 lines of a file are displayed by default. Head-n changes the number of rows displayed

The function of the tail command: the last 10 lines of the file are displayed by default. Tail-n changes the number of rows displayed

The function of the more command: after using the more command, one screen (one page) of the file content is displayed on the screen at a time, and a "- More-- (n%)" message will appear at the end of the screen, where n% is the percentage of the file content that has been displayed.

Basic commands for Linux users, groups, and permissions ③

The function of / etc/passwd file: stores information about all users, which is also known as user Information Database (Database).

The specific meaning of each field in / etc/passwd file:

A) the first field (column) records the user's name (given by the root user when the user was created).

B) the second field (column), if x, indicates that the user must use a password when logging in to the Linux system; if empty, the user does not need to provide a password when logging in.

C) the third field (column) records the user's uid.

D) the fourth field (column) records the gid of the group to which the user belongs.

E) the fifth field (column) records comment information about the user (such as full name or mailing address).

F) the sixth field (column) records the path of the user's home directory.

G) the seventh field (column) records the first process to be executed after the user logs in.

The function of / etc/shadow file: store the passwords of all users, each user occupies a row of records, the file is actually the database where the user's passwords are stored.

The specific meaning of each field in / etc/shadow file:

A) the first field (column) is the user name.

B) the second field (column) is the password, which is encrypted by the MD5 encryption algorithm.

The function of / etc/group file: it stores the information of all groups in the Linux system, which is actually a database (Database) for storing group information.

The specific meaning of each field in / etc/group file:

A) the first field is the name of the group

B) the x in the second field indicates that the group must use a password when logging in to the Linux system.

C) the third field records the gid of this group.

D) the fourth field records which other group members are in this group.

The function of the useradd command: add a user.

Common options for the useradd command:

A)-u: specify the UID of the user

B)-g: specify the group to which the user belongs

C)-d: specify the user's home directory

D)-c: specify the comments for the user

E)-s: specify the shell used by the user

For example, add a user user01 to the system, and the group is police and the command uid is 600:

Useradd-u 600-g police user01

The function of the usermod command: modify the user's account information.

Common options for the usermod command:

A)-u: modify the user's UID

B)-g: modify the user's GID

C)-G: adds a user to a specified group

D)-d: modify the user's home directory

E)-c: modify the user's remarks

F)-s: modify the shell used by the user

An example of the usermod command:

A) modify the babydog4 user's home directory to / home/babies:

Usermod-d / home/babies babydog4

B) add the user babydog4 to the group babydog6:

Usermod-G babydog6 babydog4

C) change the user's gid of babydog4 to dog group:

Usermod-g dog babydog4

Function of usermod-L order: lock user's account, for example: command to lock babydog6 user's account: usermod-L babydog6

Usermod-U command function: unlock the user's account, for example: the command to unlock the babydog6 user's account: usermod-U babydog6

The function of the userdel command: delete the user.

Userdel-r: delete the user's home directory and its mailbox while deleting the user.

The function of the groupadd command: create a new group account. Groupadd-g: specify the GID of the group.

The function of the groupmod command: modify the information of a group account, groupmod-g: modify the GID of the group

Groupmod-n: modify the name of the group. An example of the groupmod command:

A) for example: the command that modifies the gid of the police group to 521:

Groupmod-g 521 police

B) for example: the command to rename the group boydogs to daddogs:

Groupmod-n daddogs boydogs

Function of the groupdel command: delete a group account. An example of the groupdel command:

For example, the command to delete the daddogs group: groupdel daddogs

Is it helpful for you to read the above content? If you want to know more about the relevant knowledge or read more related articles, please follow the industry information channel, thank you for your support.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report