Common Linux system commands
# basic Linux commands
Classic quotations of Linux system:
After the command operation, there is no message, which is the best news.
The system starts from the root.
Everything in the system is a file.
I. Linux system command structure
Command + space + condition / parameter + space + object / directory / file
For example: rm-f / oldboy
Two. Shutdown or restart command
Shutdown command
[- r] restart
[- h] shutdown
[- c] cancel shutdown / restart
[- t] automatically after a certain period of time
For example:
Shutdown-r restarts in a minute.
Shutdown-h shuts down the system in a minute.
Reboot / shutdown in 10 minutes after shutdown-RRAMUBER
Shutdown-Randall Murh now now restart / shut down immediately
Generally, the default unit is minutes.
Halt
-n: do not write the memory data back to the hard disk before shutting down
-W: it doesn't really turn off, just write the record in / var/log/wtmp file.
-d: do not write records to / var/log/wtmp file (- n parameter contains-d)
-f: forced shutdown, do not call the command shutdown
-I: stop all network-related devices before shutting down
-p: turn off the power supply (poweroff) by the way when you turn it off
For example:
Halt shuts down the system
Halt-p shut down the system and power off
Halt-d shuts down the system without leaving a record
InIt
0: shutdown
1: single-user mode, only root is used for maintenance
2: multi-user, no network
3: completely multi-user
4: multi-user-unused
5: graphical
6: the restart usage is simple.
three。 Switch directories
Cd-
Cd-switch directories cd.. -return to the previous directory cd.. /.. /-return to the previous two and directories cd ~ / cd-- return to the home directory cd-return to the last directory such as: cd /-switch to / (root directory) cd / oldboy-cut Change to the oldboy directory under / (root directory)
four。 Create a directory / file
Mkdir (create directory)
For example: mkdir / oldboy-create an oldboy directory under the root directory
Mkdir-p-create a multilevel directory
Mkdir-v-displays directory creation prompts
Mkdir-m-set directory permissions when creating a directory
Touch (create or update files)
For example
[root@yu yuxi] # touch 123
[root@yu yuxi] # ll
Total 0
-rw-r--r--. 1 root root 0 Oct 21 19:18 123
[root@yu yuxi] # touch 123
[root@yu yuxi] # ll
Total 0
-rw-r--r--. 1 root root 0 Oct 21 19:19 123
five。 View directories / files
Ls View Catalog
Ls-list showing data information
Ls-d-only check whether the specified directory exists
Ls-l-View detailed attribute information of the data
Ls-a-View all file information (including hidden files)
Ls-t-View data information sorted by time
Ls-r-View data information in reverse order
Ls-S-View data information sorted by size
Ls-F-check the directory information will be followed by / tag
Cat View Files
Cat-View file information
-n-view file line number information
Less (read the document as you read, enter ↓ / ↑ up, press the page space ↓ / b ↑)
More (read as if you read the document enter by line ↓ / up shift+ ↑ press page space ↓ / b ↑)
six。 Edit a file
1.vi-Editing file information
Basic usage
01 enter I and start editing
02 Press esc after content editing is finished
03: W-quit editing
PS:% s#oldboy#oldgirl#g-replace the specified information in the file
Echo-output information to the screen
Echo "hello world" > / oldboy/oldboy.txt
First empty the contents of the file and edit the contents of the file
Echo "I love you" > > / oldboy/oldboy.txt
Append the edited content to the end of the file content
seven。 Check the network
Ping-check if the network link is open
View URL address information
Ip address show eth0-View the address information of the eth0 network card
Abbreviation:
Ip a s eth0
Ip a
Test the corresponding port of the server
Telnet-Test whether the corresponding port of the server is accessible
Telnet host IP address port number
eight。 Delete directory / file
Rm- delete data information
Rm-f delete file information
Rm-rf delete directory information
Rm-rf /. * Delete everything in the root directory (bloody try not to try)