Detailed linux basic commands

Basic knowledge

Shell

·A special program running in the Linux system
· Acting as a "translator" between the user and the kernel
· When the user logs in to the Linux system, a Shell program
is automatically loaded · Bash is the shell program used by default in the Linux system

Linux command classification

·Internal commands and external commands

Internal command External instructions
Some special instructions integrated in the Shell interpreter program, also known as built-in instructions Script file or binary program that can complete specific functions in Linux system
Part of Shell Commands outside of the Shell interpreter program
There is no separate corresponding system file Each external command corresponds to a file in the system
Automatically load into memory and can be used directly The corresponding file location must be known and can be executed after being loaded by Shell

Universal command line usage format

Command word [options] [parameters]
command word
·is the most critical part of the entire command
·only one command is determined
Option
·short format option: use "-" symbol to guide
· long format option: use “–” symbol to guide
parameter
· The processing object
of the command word can be a file name, a directory (path) name or a user name, etc.
The number can be zero or more

Edit the Linux command line

Auxiliary operations for editing the Linux command line

Tab key: automatic completion
●Backslash "\": forced line break
●Ctrl+U key combination: empty to the beginning of the line
●Ctrl+K key combination: empty to the end of the line
●Ctrl+L key combination: clear the screen
●Ctrl+ C key combination: cancel this command editing
Ctrl + a key combination: switch to the beginning of the line
Ctrl + e key combination: switch to the end of the line

Internal command help

●View the help information of Shell internal commands. The "–help" option of the command
●Suitable for most Linux external commands. Use the man command to read the manual page.
●Use the "⬆" and "⬇" (ENTER) arrow keys to scroll a line of text
●Use Page Up Turn pages with Page Down (space) key
● Press Q or q key to exit the reading environment
● Press "" key to find content, n key to find down, N key to find up

Switch working directory -cd

Change the user's working directory to another location
Format|Description
|–|--|m
cd target location|Switch to target location
cd cd~ |If you do not specify the target location, switch to the current user's home directory
-cd|Switch to The directory where the cd command was executed one time
Absolute path
Relative path

The manifestation of the relative path

Manifestations Description Example
Use the directory name or file name directly Indicates the location of subdirectories and files in the current working directory grub.conf
Start with a period "." Indicates that the current working directory is used as the starting point ./grub.conf
Start with two periods "..." Indicates to take the upper level directory (parent directory) of the current directory as the starting point …/vmlinu
Start with "~Username" Indicates that the home directory of the specified user is used as the starting point ~tracher
Start with "~" Indicates that the current user's home directory is used as the starting point ~

List the contents of the directory -ls

Common options for ls

-l: Display a list of files and directories in long format (Long), including detailed information such as permissions, sizes, and last update time. The 11 command has the same function as ls -l
-a: Display the information of all (All) subdirectories and files, including hidden directories and hidden files whose names start with a dot ".".
-A: The function is basically similar to the -a option, but there are two special hidden directories that will not be displayed, namely "." for the current directory and "..." for the parent directory.
-d: Display the attributes of the directory (Directory) itself, instead of displaying the contents of the directory.
-h: Display the size of the directory or file in a more humane way. The default size unit is byte (B). After using the -h option, it will be displayed in units of KB, MB, etc. This option needs to be used in conjunction with the -l option.
-R: Display all contents in the specified directory and its subdirectories in a recursive manner.
-Color: Different files are distinguished by color in character mode. It is enabled by default
. Under normal circumstances, dark blue indicates directories, white indicates general files, green indicates executable files, yellow indicates device files, and red indicates compressed files.
-i: Display the inode number of files and directories.
Insert picture description here

The meaning of each segment

Behind the first character of the nine letters of the file or directory's permission bits:
r for read (to view, download), w represents the write (add, change, delete, upload), x represents the execution (run the file, change directory)
in which The first three represent the permissions of the file owner (owner), the middle three represent the permissions of the group to which the file belongs, and the last three represent the permissions of other users.

The second field: the number of file hard links.
If a file is not a directory, this field indicates the number of hard links that the file has.
If it is a directory, the second field indicates the number of subdirectories contained in the directory.
If you create a new empty directory, the second field of this directory is 2, indicating that there are two subdirectories under the directory.

Field 3: File\Directory Owner

Field 4: The group of the file\directory owner

Field 5: The space occupied by the file (in bytes by default).
If it is a directory, it indicates the size of the directory, not the total size of the directory and the files below it.
Everything in a Linux system is a file, so a directory is also a kind of file.

Field 6: File\Directory last accessed or modified time

Field 7: File name.
If it is a symbolic link (soft link file), then there will be a "->" arrow symbol followed by a file name it points to.
Set aliases-
aliases simplify commonly used ones through the alias mechanism. Compare Long command
alias command alias='command' (=no spaces on both sides)
cancel alias
unalias command alias

Guess you like

Origin blog.csdn.net/weixin_51614581/article/details/109723260