1. file management commands mainly include ls, rm, mv, ln, mkdir, touch, cat & hellip; ls to view the file list. for example, to view the current directory: ls view the file list and display the file attributes, including time, group, and user. use: ls-l to sort by time: ls
1. file management
File management commands include ls, rm, mv, ln, mkdir, touch, cat ......
Ls to view the file list
For example, to view the current directory: ls
View the file list and display the file attributes, including time, group, and user. use: ls-l.
Sort by time: ls-lctr
View the files in the root directory: ls/
Rm delete File
For example, deleting a file f: rm f
Delete directory d: rm-r d
Mv mobile/renamed files
For example, change file name a to B: mv a B (note: If file B already exists, the previous file will be overwritten)
Move File a to the directory/temp: mv a/temp
Mkdir create Directory
For example, create Directory a: mkdir
Touch modify File time/generate new file
For example, generate a new empty file a: touch.
Modify file B to the current time: touch B
Cat output file content
For example, enter the config content of the file to the screen: cat config
2. Process Management
Ps: View system processes
For example, to view the process of the current user: ps
View all processes, including active and inactive: ps-ef
View all java processes: ps-ef | grep java
The second column is the process number.
Kill/killall terminate the process
For example, kill 300
Killall java
Bg/fg switch process to background/foreground
When a process runs in the current command line, you can press Ctrl + z to pause the process, and then use the bg command to switch the process to the background. On the contrary, you can use the fg command to switch the background process to the foreground, sometimes we use the & symbol to run the process on the background. This means we can use the fg command to switch it to the foreground.
View the process tree of the system
Run pstree to output the current process tree.
3. user management
Who view logged-in users
Adduser creates a new user for the system (root permission is required, the same below)
For example, add user james: adduser james.
Add user james, password 123456: add-p 123456 james
Passwd change user password
For example, if you change the password of james to 888888: passwd james, the system prompts you to enter the old password and then enter the new password.
Userdel delete user
For example, delete user james: userdel james.
Usermod modify user attributes
For example, modify james to the admin group: usermod-p admin james.
4. resource management
Top view system resource status
Top is the most commonly used tool to view the current status of the system. You can view CPU, memory, load, etc.
View host CPU information
Run cat/proc/cpuinfo
Query System memory information
Run cat/proc/meminfo
Fdisk view hard disk partitions
Fdisk-l/dev/sda can output the list of hard disk/dev/sda partitions.
Df view in-use file system
Run df-h
Hdparm view hard disk information
For example, you can view the hda speed of a hard disk and run hdparm-I/dev/hda.
Query usb interface information
Run the command lsusb to know how many usb interfaces the current system has.