Basic linux commands
Basic Linux commands (all files)
Command Format:
Command [Option] [parameter]
Note: Use spaces to separate commands, options, and parameters. The limit can only be 256 characters.
Help
Man manual eg. man
Man command/function name/header file
Ls list content list directory content (windows: dr)
Ls-a displays all files (including hidden files, which usually start)
Ls-l displays detailed information about the file.
Drwxrwxr-x 2 tarena 4096 April 23 11:10 Pre
--A common file that stores data in a certain format (binary or text)
D: directory file. B: block device files that provide buffer direction for the device. C: character device file, without caching. P: MPS queue file for inter-process communication.
S: socket file, network communication between processes. L: a symbolic link file pointing to another file (equivalent to a shortcut in windows ).
Owner group others
Tarena others
Rwx r-x
R: 4 0100 read
W: 2 0010 write
X: 1 0001 executed
Clear screen ctrl + L (windows: cls)
Pwd prints the current working directory
Cd change directory switch path switch directory
/: Root directory
./: Current Directory
../: Upper-level directory/parent directory
~ : Main directory of the current user
1) absolute path: Path to be traversed from the root directory
2) Relative Path: Path to be traversed from the current directory
Create a folder using mkdir
Touch creates a file and modifies the last modification time of the file.
Rm delete file
Rm-r: delete a non-empty folder
Rmdir Delete empty folder
Cp copy
Cp file_name dir_name: copy the file to the specified path
Cp file_name dir_name/newfile_name rename or overwrite copy
Cp-r dir_name another_name is required to copy the directory-r
Cp-all dir_name another_name: Copy all content to the specified directory according to the original dependency.
Mv move rename (rename)
Mv file_name dir_name
Mv file_name dir_name/newfile_name
Mv file_name newfile-name
Chmod
Chmod [u/g/o/a] [+-=] [r/w/x] filename
=: Only one of the permissions is retained. Others are deleted.
Cat file_name display file content
Head file_name displays the first 10 lines of File Content
Head-n file_name: N rows
Tail file_name displays the last 10 lines of File Content
More file_name split display file content
Space: one screen flip down
Press Enter: Next line
History displays executed commands
!! Repeat the previous command
! N repeat the n-line command
! First letter search up, last executed command
Wc file statistics
Count and display the number of bytes, characters, and rows of the specified file.
Wc [Option] file_name
Wc-l file_name: number of lines displayed line
Wc-w file_name: number of characters displayed in word
Wc-c file_name: number of bytes displayed
; The end of a semicolon statement, usually used to link Multiple commands for execution
| The pipeline uses the output result of the previous program or command as the input of the next program or command
History | more
Users
Who logon to the local system user details
Who am I displays information of the current user
Whoami displays the name of the current user
Ps detects the working status of a process
-E: display all processes
-F: displays detailed processes.
-H: No title is displayed.
A. display the program running on the terminal.
R: displays running processes.
X displays the processes without control terminals.
Detailed format of u display
Aux displays details of all processes
Top
Kill the PID to terminate the specified PID Process
-9 The SIGKILL signal forces the killing Program
Redirection
> Write Truncation
> Append data to the end
File Link
Ln [options] source [dest]
Ln [options] source [dest]
Ln [options] source... directory
Hard Link
Ln [path name]/[file name] [path name]/hard link name
Bash shortcut
Ctrl + l clear screen
Ctrl + a locate the start of the command
Ctrl + e go to the end of the command
Ctrl + d Exit and end command
Ctrl + c interrupt program
Ctrl + z hangs the command being executed
Ctrl + shift + c copy
Ctrl + shift + v Paste