Shell command
Basic use of the 1.Linux command format
command [-options] Parameter1 Parameter3
Command name option parameter 1 attendees 2
Note: (1) Linux is strictly case-sensitive.
(2) Command office must fill in "commands" or "Executable file names"
(3)-options is a special definition of the command, starting with "-", multiple options can be "-" linked, such as Ls-l-a and Ls-la the same
(4) Paramerter1 parameter2 ..... Run information for the command, or the file name used during the execution of the command
(5) in the command format, several of the above options are separated by a space, and the shell is treated as a space, regardless of the empty squares.
(6) Use the semicolon ";" to separate the two commands so that you can enter multiple commands in one line, and the command executes in the same order as the input order
(7) When the ENTER key is pressed, the command executes immediately. If the command is too long, you need to use a backslash "\" with multiple lines to implement a longer command into a multiline expression to enhance the readability of the command. After wrapping, the shell automatically prompts
Line Break ">"
2.BASH Shell Key Hotkey
(1) Tab--command complete, file completion function
(2) Ctrl + C shortcut--Stop command or program function
(3) Ctrl + D shortcut key--keyboard input end, file input End Function, can also be used to replace exit input
Using the Linux Basic Operations Command
(1) SU command--Switch User account command
Format: su [options] [user name]
(2) Exit command--exit the current user or command line execution
(3) Shutdown command--restart or shut down Linux system commands
Format: Shutdown [options] [TIME] [warning message]
(The shutdown command can only be performed by the root user)
(4) Man command--online help command
(5) help--system help document for viewing the use of all shell commands
(6) date--display or set the date and time of the system
(7) clear--Clear Screen command
(8) history--Show user recently executed command
Log off the system using the logout command
To exit the system using the shutdown command
Using the Directory Operations Command
Special Directories in Linux
| Special Catalogue |
Role |
| . |
Current directory |
| - |
Previous working directory |
| .. |
Previous level Directory |
| ~ |
Home directory of the current user |
| ~account |
Home Directory for account users |
Common Linux Directory Operations commands
(1) mkdir command--Create a new directory command
(2) rmdir command--delete "empty" directory command
rmdir [Options] Directory name
Note: The directory must be empty before it is deleted
Rm-r dir command can replace rmdir regardless of whether the directory is empty, is deleted, so there is a danger
You must have write permission to the parent directory when you delete a directory
(3) CD command--Switch working directory command
Format: CD [directory name]
(4) PWD command--Displays the full path of the current directory where the user is located
Format: pwd
(5) LS command--list Directory Contents command
Format: LS [options] [directory or file]
Example:
1. Create a directory TEST1/TEST2/TEST3/TEST4 command
[[email protected] test] mkdir-p Test1/test2/test3/test4
2. Create TEST5, and set properties, user Read and write execute permissions, group and others execute permissions
[[email protected] test] mkdir-m chmod 711 Test5
Using the Action File command
Common Linux File Operations commands
(1) Touch command--Create a new File command (empty file contents)
(2) CP command--copy file or directory command
Format: CP [option] source file or directory destination file or directory
(3) MV command--move a file or directory command, rename command
Format: MV [option] source file or directory destination file or directory
(4) RM command--delete file or directory commands
Format: RM [options] File ...
(5) Cat command--Output text file contents to screen or terminal window command
Format: Cat [options] File name
(6) grep command--in the specified file, find and display the command with the specified string
Format: grep to find the string text file ming
(7) Whereis command--Find specific file location commands
Format: whereis [options] Command name
(8) More command--split screen display file content (page backward)
Format: more[options] File
(9) Less command-split screen display file contents (forward, backward page)
Format: less [options] File
(Ten) Head command--Displays the first few lines of the file
Format: Head [options] File
(one) Tail command-writes the specified file to standard output starting at the specified location
Format: tail [options] File
Example:
1. split screen display testfile file contents
[[email protected] test] cat Testfile|more
2. Copy the. bashrc file under Home directory to the directory exp, and rename it to BASHRC
[[email protected] test] CP ~/.BASHRC/EXP/BASHRC
3. In the Test.txt file, locate the Include row
[[email protected] test] # grep include Test.txt
Use of common Linux commands