Commands that Linux must master! 2020-09-15

 

RPM Red Hat Software Manager

Collection of source code + installation regulations Purpose: to reduce the difficulty of installation RPM

rpm -ivh filenme.rpm Install software
rpm -Uvh flienme.rpm Upgrade software
rpm -e flienme.rpm Uninstall software
rpm -qpi flienme.rpm Query software description information
rpm -qpl flienme.rpm List software file information
rpm -qf flienme. rpm query file belongs to which RPM

YUM software warehouse  

Pack a lot of RPM together. Reduce installation difficulty and automatically resolve dependencies

Shell (also known as terminal or shell) is a command line tool. The difference between it and bash is:

1. Use the up and down arrow keys to retrieve the previously executed Linux commands (↑↓);
2. Only the first few digits of the command or parameter can be completed with the Tab key (not all parameters can be automatically completed at any time) ;
3. Has a powerful batch script;
4. Has a practical environment variable function;

Common command rules
Common command execution format: command name [command parameter] [command object]

Use the space bar to separate the command name, command parameters, and command objects.

Command object: generally refers to resources such as files, directories, and users to be processed;

Command parameters are divided into long format and short format. If multiple parameters are used in a command, the short format can be combined, and only one "-" is required. Long format parameters cannot be combined with long format or short format parameters, but Examples that can be used at the same time: ls --help -l = ls -hl

LINUX system commands

1. The man command is used to view the help information of the command.

Common system commands

1.. echo command: used to output string or variable extracted value in the terminal. (Variables are generally all uppercase letters, with a $ sign in front)

2.date command: used to display and set the system time or date. Format: date [option] [+specify format]

.3.reboot command: Restart the system (restart). The restart operation involves the management authority of hardware resources, and only the root administrator can execute it by default

4.4. poweroff command: turn off the system (shut down). The shutdown operation involves the management authority of hardware resources, and only the root administrator can execute it by default.

5. wget command: used to download network files in the terminal. Format: wget [parameter] download link

6. ps command: used to view the process status in the system. Format: ps [parameter]. It is not necessary to add the "-" sign when using the parameters of the ps command.

ps aux #-a displays all processes (including processes of other users); -u displays users and other detailed information; -x displays processes that do not control the terminal

R (running): The process is running or waiting in the run queue.
S (interrupt): the process is in sleep, when a certain condition is formed or a signal is received, it will leave this state.
D (Uninterruptible): The process does not respond to system asynchronous signals, and it cannot be interrupted even with the kill command.
Z (Zombie): The process has been terminated, but the process descriptor still exists, until the parent process calls the wait4() system function to release the process.
T (stop): The process stops running after receiving a stop signal.

7.top command: used to dynamically monitor information such as process activity and system load. The interface is as follows after executing top, and q exits.

The top 5 lines of the execution result of the top command are the overall system statistics. The specific meaning is as follows:

Line 1: System time, running time, number of login terminals, system load (the three values ​​are the average value of 1 minute, 5 minutes, and 15 minutes, respectively. From right to left, the smaller the value means that the system load is increasing Lower).
Line 2: The total number of processes, the number of running processes, the number of sleeping processes, the number of stopped processes, and the number of dead processes.
Line 3: The percentage of resources occupied by users, the percentage of resources occupied by the system kernel, the percentage of process resources whose priority has been changed, the percentage of idle resources, etc. The data are all CPU data and displayed in percentage format. For example, "98.4 id" means that 98.4% of CPU processor resources are idle.
Line 4: Total physical memory, memory usage, free memory, and memory used as kernel cache.
Line 5: Total virtual memory, virtual memory usage, free virtual memory, and memory that has been loaded in advance.

8. pidof command: used to query the process ID number (PID) of a specified service process. Format: pidof [parameter] [service name]

9. Kill command: used to terminate a service process with a specified PID. Format: kill [parameter] [process PID]

pidof sshd #View the PID of the sshd service

kill process number# Terminate the process with PID *

 

 v10, killall command: used to terminate all processes corresponding to a service with a specified name. Format: killall [parameter] [service name] #End all processes of a service


System status monitoring command

 

1. ifconfig command: used to obtain information such as network card configuration and network status. Format: ifconfig [network card name] [parameter].

2. uname command: used to view information such as system kernel and system version. Format: uname [parameter].

When using the uname command, the -a parameter is usually fixed to view the current system's kernel name, host name, kernel release version, node name, system time, hardware name, hardware platform, processor type, and operating system name. And other information.

3. uptime command: used to view the load information of the system.

The uptime command is used by bai to query the du of the Linux system load.
You can use the command zhi to view the login user information to view the login status, such as dao: The
w command is used to display the names of users
who have logged in to the system and what they are doing. The who command is used to list the names of users who are currently logged in to the system.
The last command can be used to display the history of a specific user login system

The uptime command actually displays the first line of the top command. The lower the system load value, the better, try not to exceed 1 for a long time, and do not exceed 5 in a production environment.

4. free command: used to display the current system memory usage information. Format: free [parameter].

free -h #Output the current real-time memory usage information

Meaning of free -h output information title:

Insert picture description here

5. Who command: used to view the information of the user terminal currently logged into the host. Format: who [parameter].

The execution result of who will display the names of all users who are logging in to the machine and the terminal information they are opening.

6.last command: used to view the login records of all systems. Format: last [parameter].

 

note! The login record information retrieved using the last command is saved in the system in the form of log files. Therefore, the output information of the last command cannot be used to determine whether the system has been maliciously invaded! Because hackers can easily tamper with the content.

7. History command: used to display the commands executed in history. Format: history -c.

History can display the last 1000 command records executed by the current user on the local computer. History commands will be saved to the .bash_history file in the user's home directory. You can customize the value of the HISTSIZE variable in the /etc/profile file to modify the number of historical records that can be displayed.

8.sosreport command: used to collect system configuration and architecture information and output diagnostic documents. The purpose of this command is to use this command to generate a simple diagnostic document and send it to the technical support staff when there is a problem in the system and you need to contact the technical support staff. If it is a small problem, they can solve it remotely without having to go to the technical support staff. on site.

Working directory switch command

1. pwd command: used to display the working directory of the current user. Format: pwd [option].

2. cd command: used to switch the working path. Format: cd [path].

3.ls command: used to display file information in the current directory. Format: ls [options] [file].

ls -a all files ls -l is used to view the file attribute size and detailed information

 ls -al all detailed files ls -ld view the detailed information of the current directory,

ls -ld /etc Query all information in the /etc file  

Text file editing commands

1.cat command: used to view plain text files with less content. Format; cat [options] [file].

cat -n join number

2.more command: used to view plain text files with more content. This command can use the space bar or enter key to page down, q to exit

3.head command: used to view the first N lines of a plain text file. Format: head [options] [file].

4. Tail command: used to view the last N lines of a plain text file or continuously refresh the content. Format: tail [option] [file].

tail -n 10 /rpm view the last ten of the file tail -f /rpm dynamic real-time refresh view file You can use the tail command to continuously refresh the file content function to view the latest information of the log file in real time.

5.tr command: used to replace characters in text files. Format: tr [original character] [target character].

| Pipe character The output of the previous command is used as the standard input of the next command

6.wc command: used to specify the number of lines, words, and bytes of text. Format: wc [parameter] text. 

wc -l /rpm displays only the horizontal number. wc -w /rpm displays the number of words. wc -c /rmp displays the number of bytes. Note: One Chinese is two bytes 

7. stat command: used to view the specific storage information and time (atime, mtime, ctime) and other information of the file. Format: stat file name.

File File name 
size Number of bytes
Access View time The last time the file was viewed
Modify the time to modify the text content at the
most time Change The time to modify the file attributes at the most time 

8. Cut command: used to extract text characters by "column", format: cut [parameter] text.

cut -f sets the number of columns to be viewed cut -d sets the spacer 

9.diff command: used to compare the differences between two text files. Format: diff [parameter] file.

diff compares the differences between multiple text files Example: diff --brief a.txt b.txt
diff -c a.txt b.txt can describe the specific differences in files

Guess you like

Origin blog.csdn.net/SYH885/article/details/108609577