“This is the 16th day of my participation in the Gwen Challenge in November. Check out the details: The Last Gwen Challenge in 2021.”

Summary of Common Commands

1. Mkdir make diretory create a new directory

Mkdir /data <-- create an empty data directory under the root directory -p <-- create a multi-level directoryCopy the code

2. Ls list Information about list files or directories

Ls /data <-- Displays the data information under the data directory ls -l /data <-- displays the detailed information about the file directory ls -d /data <-- displays only the information about the specified directory (d stands for diretory directory) ls -dl /data <-- displays only the details of the specified directory ls -a <-- displays all hidden information in the directoryCopy the code

3. CD change diretory Switch the current path information

CD /data <-- Switch CD.. <-- returns the previous directoryCopy the code

4. PWD print working Diretort Displays information about the current path

5. Touch Create file Modify file time information

TXT <-- Create files in relative path touch /data/fu. TXT <-- Create files in absolute pathCopy the code

6. Run the vi /vim command to edit file contents

TXT. To save the configuration, press Esc --> and then :wq! , you can save and exit the editing mode. To exit the file, press ESC --> and then q to exit the editing mode. I <-- To enter the insert editing mode, compile from the cursor position. I <-- To edit from the beginning of the current line Return to the first line of the file3Gg quickly switch to the third line of the file dd <-- cut one line3Dd <-- cut three lines yy <-- copy one line of content3Yy <-- copy three lines of content P <-- indicates cut or copied content3P <-- paste three times u <-- Restore the file (if no save is available) O <-- Edit the file from the next line of the current cursor o <-- edit the file from the previous line of the current cursor Exit wq without saving! <-- force the file to save and exit the editing mode. <-- force exit without saving:setNu (number) displays line number Settings:setNonu (no number) Unset line number display:setList displays the end symbol vi <-- vim <-- nodepad++, the notepad function of Windowsemeditor   sublime text (Professional text compiler software)
Copy the code

7. Echo displays the input content on the screen

echo "hello world">/data/fu.txt -- Put the written content in a file -n <-- indicates the end of the output information, no newline processing -e <-- Identify regular symbols recognize some special symbols /n(newline) /t (space)Copy the code

8. Cat <– View the displayed file content

TXT <- View the contents of the fu. TXT file cat >fu. TXT <<EOF01.fu
02.fU EOF <-- Edit multiple lines of content at one time -n <-- display the contents of the file line number -a <-- display some special markers in the file ($)Copy the code

9. Cp Copy or back up file information

-r -- Recursively copy directory data information -a -- archive parameter, including the function of -r -d -p parameterCopy the code

10. Mv Command to move or cut data

11. Rm Removes data information (directory or file)

-r -- Deletes the data information in the directory recursively. -f -- Deletes the data information forciblyCopy the code

12. Find find data information command == everthing software similar

Type f -- Specifies the type of the file to be searched. F indicates the file. D indicates the directoryCopy the code

13. Which Searches for the absolute path of the command file

14. Mount <– Command to mount device files

Mount Device file information Mount directory (mount point)Copy the code

15. Tree <– Displays directory structure information

-l <-- Displays the level-1 directory levelCopy the code

16. Grpe <– indicates file data filtering command (AWK three Musketeers old three)

-v indicates that the matched file information is excluded. -A indicates that it is equivalent to after, and several lines of information after the filtered content are extracted. -b indicates that it is equivalent to before, and several lines of information before the filtered content is extracted. -i indicates that the filtered content is case-insensitive. -e identifies the extended regular information0Can display the process of command matching (display only the matching information, displayed by line)Copy the code

Sed <– processing lines in a file

You can edit and modify the file. -p Displays the searched information. -n Cancells the default operation'20, 30 p'File information <-- retrieves a specified file20to30-s Searches for the file to be replaced. -g Searches for the file to be replaced globallyCopy the code

Awk <– column processing in multiple files

MR==20-f Specifies the separatorCopy the code

17. Head <– Displays the first few lines of the file. By default, the first 10 lines are displayed

head - 5== head-n5 Before the file is displayed5lineCopy the code

Tail <– Displays the last few lines of the file. By default, the last 10 lines are displayed

tail - 5== tail -n5 Displays the file5lineCopy the code

Alias <– Displays or sets the alias function

-p <-- View alias information and modify the configuration. <-- vim ~/. Bashrc or vim /etc/bashrcCopy the code

20. Source <– loads /etc/profile of the system configuration file

21. Seq <– Displays numeric sequence information

seq 30< - shows1to30Line digital informationCopy the code

22. Unmae <– View system information

-r <-- View kernel information. -m <-- View system architecture information. -A <-- View all system informationCopy the code

23. Su – <– indicates the command to change the user identity

Su - <-- Switch the user from root and the user path is still in the root user path su - <-- By default, the user information is not specifiedCopy the code

24. Mount <– mount command

Mount What to mount to where (directory - mount point)Copy the code

25. Umount <– unmount command

Umount mount point information (gate)Copy the code

26. Df <– Check disk usage: Check device mount status

-h <-- displays the output in a human-readable wayCopy the code

27. Date <– Displays or modifies the time information

Date -s Time to change Date Output format %F %T man dateCopy the code

28. Xarge <– displays the message content in line, using Spaces as separators by default

-n2 <-- Specifies that only one line is displayed2-i <-- puts the resulting information in the command line after the {} -i <-- copies the resulting information to the parameter dimension {}, and then calls {} with the corresponding command.Copy the code

29. Init <– Sets the system runtime level

 init  4
Copy the code

30. Runlevel <– View the current operating level of the system, and view the operating level of the system before modification

31. Chkconfig <– checks or configures whether the system service starts automatically

Chkconfig [--level Run level] Service nameon/off chkconfig -- list service name <-- Only view the runlevel status of the specified serviceCopy the code

32. Ps -ef <– View the process information in the system

33. Wc <– Count file system command

Wc-l <-- Count the number of file linesCopy the code

34. Tar <– Compressed and decompressed data information command

-z Compresses the package in gzip mode. -j Compresses the package in bzip mode. -c Creates compressed package informationCopy the code

35. Cut <– Cuts a line of string information

-d ""<-- specifies what character to use for cutting column information -f3,5<-- Take out the information of the cut column. When the comma separates the numeric information, it indicates that the third and fifth columns -f3 are taken out- 5<-- When a dash is used to divide digital information, the third to fifth columns are taken outCopy the code

36. RPM <– Mainly management system packages

-q <-- Queries the software package. -A <-- Queries whether the specified software package exists. -l <-- Lists the installed data in the software packageCopy the code

37. Yum <– install package command

Try running Scandisk again and install software parameters -y without prompting for confirmationCopy the code

38. Sz-y/rz-y <– Upload and download data file commands

39. Lsof <– checks whether files in the system are called by the corresponding process

[root@fu ~]# lsof |head -2
COMMAND    PID      USER   FD      TYPE             DEVICE SIZE/OFF       NODE NAME
init         1      root  cwd       DIR                8.3     4096          2 /
Copy the code

40. Du <– looks at how much disk space a file or directory takes up

41. Stat <– View file properties (event information file size permission)

42. Tr <– a command to replace character information (similar to sed)

43. Ntpdate <– Synchronize time command

Ntpdate <-- Specifies the domain name of the time serverCopy the code

44. Du <– looks at how much disk space a file or directory takes up

Less /more View file information

46. Stat <– View file properties (time information, file size permission)

46. Tr <– a command to replace character information (similar to sed)

Replace the characters one by oneCopy the code

Commands to monitor system information

01.Uptime Command to view the load information02.Top Viewing system running status (real-time monitoring)03.W View the login information of a system user04.Lscpu Command for viewing CPU information05.Free-m Displays memory informationCopy the code

Help methods of common commands

Man manual View the command manual information to obtain the command usage man touch <-- View the command usage /-r <-- Search for specified parameters N <-- Search down N <-- Search up Q <-- Exit the MAN manual modeCopy the code

Common shortcuts

CTRL + L (clear) <-- Clear the screen CTRL + D <-- Exit/disconnect the current connection or login state (the user exits the current login state) CTRL + C <-- Operate the terminal or terminate TAB <-- Complete the command shortcut Press, Press twice (consecutively) to display all similar commands. Arrow keys Up and down <---- Query information about entered historical commands. CTRL + R <---- The command line search mode is displayedCopy the code

Common symbol information

Puts a content message into the specified file

<< When a file is opened, the specified information is put into the file

Extend common symbols

> or1The standard output (correct content) redirection symbol (caution) overwrites the content of the original file to add new information >> or1>> Standard output appends the redirection symbol to the following file without erasing the original content of the file. Last line is appended to the file < standard input redirection < < standard is additional input redirection * matches all information (regular expression) | pipe symbol behind the previous command output to pipeline orders processed ` ` backquotes backquotes inside the command first, $() Executes the command inside $() first, and sends the result to the external command for processing.. <-- indicates the upper level directory information CD.. Return to the parent directory CD /.. /.. <-- indicates that the current directory information starts with the file is hidden files! <-- take the inverse sign# <-- appears at the beginning of a line to comment out configuration functionality\ <-- Restore the original meaning of the character information translation symbolCopy the code
/var/log/messages <-- System default log message file /var/log/secure <-- user login information record file /etc/fstab <-- Automatic mount list, /etc/hosts <-- Used to obtain the mapping between IP addresses and domain names./etc/profile <-- Set environment variables or alias information source==./etc/profile /etc/spool/cron/root <-- Configuration file of the scheduled taskCopy the code

Enterprise Case:

Method 1: echo/empty file >/data/fu.txt# Use to empty files with a lot of contentMethod 2: ca/empty file >/data/fu.txtUse error commands to empty files with large contentsMethod 3: >/data/fu.txt# Use empty command to clear heavy files
2Error redirection Input error information to the following folder, will delete the original folder content2>>: Error append Redirection Appends the previous error information to the following file without erasing the original file contentCopy the code

Common error summary

01.The file has an error [root@shhaioldboy02-LNB data]# mkdir /data
   mkdir: cannot create directory `/data': File exists 02. Command could not be found [root@shhaioldboy02-LNB data]# mkdi-bash: mkdi: command not found 03. [root@shhaioldboy02-LNB ~]# cat /data/alex.txt No such file or directory [root@shhaioldboy02-LNB ~]# cd /data01 -bash: cd: /data01: [root@shhaioldboy02-LNB ~]# vim/ data" /data" is a directory 05. [root@shhaioldboy02-LNB ~]# vim /data1/oldboy. TXT ---- "/data1/oldboy. TXT "E212: Can't open file for writing

06.$()[root@shhaioldboy02-LNB ~]# tail -11 $(head -30 /root/data/ett.txt|tail -11)
  tail: option used in invalid context -- 1
  [root@shhaioldboy02-LNB ~]# tail -11 `head -30 /root/data/ett.txt|tail -11`
  tail: option used in invalid context -- 1
  
07.The current user is not authorized to log in to the system. The operation is rejected.oldboy@shhaioldboy02-LNB ~]$ mv /etc/profile /tmp/
   mv: cannot move `/etc/profile' to `/tmp/profile': Permission denied

Copy the code