Linux————Use common Linux commands

(1) Characteristics of Linux commands

            In early versions of Linux systems, since graphical user interfaces were not supported, the command line became the main means of operation. For those users who need to view system status and monitor system operations in text mode and terminal mode, it is crucial to be familiar with commonly used Linux commands. The following are the characteristics and usage tips of some Linux commands:

  1. Case-sensitive: Commands in Linux systems are case-sensitive.

  2. Command auto-completion: When entering a command, you can type the first few letters of the command and then press the Tab key. The system will attempt to autocomplete the command. For example, enter mou and then press the Tab key, and the system will automatically complete it as mount. If there are multiple matching options, pressing the Tab key twice will list all matches.

  3. History commands: Use the up or down arrow keys to view and re-execute previously entered commands.

  4. Execution of multiple commands: To execute multiple commands on the same line, you can use semicolons; to separate them, such as: cd /; ls.

  5. Long command lines: If the command is too long, you can use backslashes\ to break the command into multiple lines to enhance readability. This will display the> prompt while typing, indicating that you are continuing to enter the other parts of the command.

  6. Background running program: A text console or a simulation terminal can only run one program or command at the same time. Generally, no other operations can be performed before the execution is completed. At this timeYou can execute the program in the background to release the console or terminal so that it can still perform other operations. To make the program execute in the background, just follow the command to be executed with a "&." symbol, such as "top &.".

(2) File directory file commands

Browse directory categories

pwd: Displays the user's current location:

cd: Switch between different directories

Note:

          In the Linux operating system, the representation of directory and file paths is very intuitive. Here are some basic concepts about directory paths:

  1. Current directory: The symbol "." represents the current directory. No matter where you are in the file system, you can use this symbol to refer to the directory you are currently in.

  2. Parent directory: The symbol ".." indicates the upper-level directory of the current directory. It allows you to quickly navigate from your current location to the parent directory.

  3. User home directory: The symbol "~" represents the user's personal home directory, which is also often called the home directory. Each user has a dedicated home directory in Linux for storing personal files and settings. For example, the system administratorroot's home directory path is/root. This means that when the root user executes the cd command (without any parameters) or the cd ~ command, he will be immediately navigated to < /span>/root directory.

ls: List file or directory information

Browse file commands

cat command: scroll to display file contents or merge multiple files into one file.

 tac (display file contents upside down)

The tac command is just the opposite of the cat command. The file content is displayed from the last line. It can be seen that tac is the reverse spelling of cat.

nl (display line number):

more command: display the file contents page by page

less command: turn pages forward, page by page

head command (only look at the first few lines): take out the first few lines of the file

tail command (only look at the last few lines): take out the last few lines of the file

Directory operation commands

mkdir: used to create a directory,

-p: When creating a directory, if the parent directory does not exist, create the parent directory and the parent directory of the directory at the same time.

rmdir: used to delete empty directories

-p: When deleting a directory, delete the parent directory as well, but there must be no other directories and files in the parent directory.

cp command:

The cp command is mainly used to copy files or directories. The syntax of this command is:
cp[parameter] source file Japanese standard file

The common parameter options of the cp command are as follows.
-a: Copy the file status, permissions and other attributes as they are as much as possible.
-f: If the target files or directories exist, delete them before copying (i.e. overwriting) without prompting the user. If the user is still prompted, the alias has been set and the unalias cp command can be used to cancel the alias.
-i: If the target file or directory exists, prompt whether to overwrite the existing file.
-r: Recursively copy the directory, that is, include subdirectories at all levels under the directory.

Note:

      The cp command is very important. People with different identities will produce different results when executing this command, especially the -a and p options. For different identities, , the difference is very big. 


2. Example of using cp command

File operation commands:

Use the mv command: mainly used to move or rename files or directories

The common parameter options of the mv command are as follows.
-i: If the target file or directory exists, prompt whether to overwrite the target file or directory.

-f: Regardless of whether the target file or directory exists, directly overwrite the target file or directory without prompting.

rm command:

Common parameter options of the rm command are as follows.

-i: Prompt the user when deleting files or directories.

-f: Do not prompt the user when deleting files or directories
-R: Recursively delete directories, that is, include files under the directory and subdirectories at all levels.

(3) System information commands

System information commands are commands that display and set various system information.

dmesg command 

free command

timedatectl command

cal command

clock command

(4) Process management commands

Process management commands are commands for displaying and setting various processes.

ps command

pidof command

kill command

killal command

nice command

top command

jobs,fg,bg command

(5) Other commonly used commands

clear command

uname command

man command

shutdown command

halt command

reboot command

poweroff command

alias command

history command

wget command

who command

last command

echo command

Guess you like

Origin blog.csdn.net/qq_63976098/article/details/133972616