Common Linux commands,
Common commands
Ls display file or directory
-L list file DETAILS l (list)
-A: List all files and directories in the current directory, including hidden a (all)
Mkdir create directory
-P: Creates a directory. If no parent directory exists, p (parent) is created)
Cd switch directory
Touch creates an empty file
Echo creates a file with content.
Cat View File Content
Cp copy
Move or rename music videos
Rm delete file
-R recursively deletes sub-directories and files.
-F force Delete
Find searches for a file in the file system
Wc counts the number of rows, words, and characters in the text
Grep searches for a string in a text file.
Rmdir Delete empty directory
Tree structure display directory, you need to install the tree package
Pwd displays the current directory
Ln create link file
More and less display text file content by PAGE
Head and tail show file header and tail content
Ctrl + alt + F1 command line full screen mode
System Management commands
Stat displays the details of the specified file, which is more detailed than ls.
Who displays online login users
Whoami displays the current user
Hostname display Host Name
Uname: displays system information
Top dynamically displays the process information that currently consumes the most resources
Ps displays the Instantaneous Process status ps-aux
Du: view the directory size. du-h/home displays the directory information in units.
Df view disk size df-h Displays disk information in units
Ifconfig
Ping test network connection
Netstat displays network status information
The man Command won't be used anymore. Look for a man like man ls.
Clear Screen
Alias rename the command, for example, alias showmeit = "ps-aux", and unaliax showmeit
Kill to kill a process. You can view the process id with the ps or top command, and then kill the process with the kill command.
Compress related commands
Gzip:
Bzip2:
Tar: Package and Compression
-C. archive file
-X compressed file
-Z gzip compressed file
-J bzip2: compressed file
-V shows the compression or decompression process v (view)
-F indicates the file name.
Example:
Tar-cvf/home/abc.tar/home/abc Package only, not compressed
Package tar-zcvf/home/abc.tar.gz/home/abc and compress it with gzip
Package tar-jcvf/home/abc.tar.bz2/home/abc and compress it with bzip2
If you want to decompress the package, replace "c" in the tar-cvf/tar-zcvf/tar-jcvf command with "x.
Shut down/restart the machine
Shutdown
-R: shutdown and restart
-H Shutdown without restarting
Now shut down immediately
Halt Shutdown
Reboot restart
Use vim
Vim mode: Command mode, insert mode, and edit mode. Use ESC or I or: to switch the mode.
In command mode:
: Q exit
: Q! Force exit
: Wq save and exit
: Set number: displays the row number.
: Set nonumber hide row number
/Apache finds in the document that apache jumps to the next one by pressing n, shift + n
Copy and paste the row where the cursor is located.
H (move one character to the left), j (next line), k (last line), l (move one character to the right →)
File Permission Management
Three basic Permissions
The R read value is 4.
W write value is expressed as 2
X executable value is 1