I. Common linux operating commands
User switches SU (Super User)
(1) Role: change to another user, which is used to switch common users to Super Users and enter the corresponding password.
(2) Format: su [Options] [Change-username]
(3) common parameters:
-,-L,-login [the working directory, home, Shell, user, and LOGNAME are also changed when the identity is changed. In addition, the PATH variable is also changed. If no ch-user is specified, the default value is root]
-M,-P [do not change the environment variable when executing Su]
-C <command>, -- command <command> after the specified command is executed, the original identity is returned. For example: su-c pwd root. After you enter the correct root password, you can enter the file location after the root command is changed and return the original identity.
Use the exit command or the shortcut key [Ctrl + D] to return to the original logon user.
User Management (useradd and passwd)
Useradd add useradd [Options] Username
Usermod sets the usermod [Options] attribute name of the user account.
Userdel Delete userdel [Options] Username
Groupadd add group account groupadd [Options] group account
Groupmod: sets the group account attribute groupmod [Options] attribute name.
Groupdel deletes the corresponding group account groupdel [Options] group account
Gpasswd: Change the group password. (after adding the-M parameter to the command, you can add all the users in the group, for example, gpasswd-m a, B, C root, and, B and C are added to the root group at the same time)
Passwd: Set the account password passwd [corresponding account]
ID: displays the user ID group ID and all user property IDs. [user name]
Groups displays the group groups [group account] to which the user belongs
Who displays all users logged on to the system who
Common Parameters
(1) useradd
-G [group to which the user belongs]
-M [automatic resume User Logon Directory]
-N: cancel the creation. The user name is called a group]
(2) userdel
-R [Delete the user's folder, email, and other related information when deleting the user]
Instructions for use:
When adding a user, useradd and passwd must be used together. useradd must use the root permission. In addition, the account created by sueradd is actually saved in the "/ECT/passwd" text file. Each line in the file contains an account.
By default, useradd creates a home directory with the same name for the corresponding account in the "/home" directory, and creates a group with the same name as the user name.
Adduser is only a symbolic link of useradd.
Passwd can also be used to change the password of a common user.
System Management commands (PS (Process status) and kill)
PS: displays the list of processes run by the user in the current system. PS [Options]
Top dynamically displaysProgram(Generally 5 seconds) Top
Kill the output signal to the specified PID (process number) process kill [Options] process number [pid]
Uname: displays system information (add option-a) uname [Options]
Configure setup on the GUI of the setup system
Crontab loop execution routine command crontab [Options]
Shutdown shut down or restart the Linux system shutdown [Options] [time]
Uptime shows how long the system has been running uptime
(1) Role
① PS: displays the list of processes run by the user in the current system
② Kill: outputs a specific signal to the process with the specified PID (process number) and completes the specified Behavior Based on the signal. The possible signal is the process suspension, process waiting, and Process Termination.
(2) Format
① PS: PS [Options].
② Kill: Kill [Options] PID
(3) Common Parameters
① PS common parameters:
-EF: view all processes and their process numbers, system time, command details, and executors
-In addition to "-Ef", "Aux" also displays CPU, memory usage, and process status.
-W: The display is widened and more information can be displayed.
② Common kill Parameters
-S sends the signal to the process based on the specified signal
-P prints the process number, but does not send a signal.
(4) Instructions for use
PS is usually used in combination with other commands to improve efficiency.
The parameter w in the ps option can be written multiple times, usually three times at most. Its Meaning indicates that it is widened three times, which is enough to show enough command lines. Example: PS-auxwww.
Pipelines are an important way of Information Communication in Linux. it connects the output of a program directly to the input of another program without passing through any intermediate file. A pipe line is a channel that connects to two or more program pipelines. in Shell, "|" indicates the pipe line.
Disk-related commands (fdisk)
Common Linux system commands:
Free view the current system usage free [Options]
DF: view disk space occupied by the file system DF [Options]
Size of the disk space occupied by the du statistics directory (or file) du [Options]
Fdisk: View hard disk partitions and manage hard disks. fdisk [-L]
(1) Role
Fdisk allows you to view hard disk partitions and manage partitions on the hard disk (fdisk is a good hard disk partitioning tool ).
(2) Format
Fdisk [-L]
(3) Instructions for use
Fdisk must have root permission
The device names of the IDE Hard Disk are hda, HDB, HDC, and HDD respectively. The device names of the SCSI hard disk are SDA, SDB... in addition, hda1 represents the first hard disk partition of hda, hda2 represents the second hard disk partition of hda, and so on.
You can view the/var/log/messages file to find the device number identified by the Linux system.
Mount command)
(1) Role
Mount the file system. The permission is granted to a Super User or a user allowed in/etc/fstab. mounting refers to the process of corresponding partitions and directories, and the mount point refers to the location mounted in the file tree. in Linux, the "MNT" directory is used to mount different file systems.
(2) Format
Mount [Options] [type] device file name mount point directory
The type indicates the type of the device file.
(3) Common Parameters
-A: load all related hard disks according to/etc/fstab.
-L list the current device, file system name, and mount point.
The-T type mounts the devices to the mount point in the specified file format. Common types include vfat, ext3, ext2, iso9660, and NFS.
-F is usually used for debugging. It will make mount do not execute the actual hanging action, but simulate the entire hanging process. It is usually used with-v.