Linux command shell 1. pwd: view the current directory. 2. cd: used to open a directory. Cd/: Open the root directory. Cd/bin: Open the bin directory under the root directory. Cd ..: Return to the upper-level directory. Cd.../: returns the last two levels of directories. Cd usr/local/bin: Open the bin directory under the local directory under the usr directory. Cd ~: Open the user's directory. 3. ls: view the directory command. Ls-a: displays all files and directories, including hidden files. Ls-l: displays the detailed list of files, including the file name, file form, permission, and file size. Ls-r: displays files in descending order of letters. Ls-t: displays the files in sequence based on the Creation Time. Ls-A: it is the same as a but does not display the. Directory and. directory. Ls-F: Add a symbol after the listed file name. Indicates whether it is a file or a directory. Ls-R: list the files in the directory in sequence. 4. touch: Create an empty file. 5. mkdir rmdir: Create and delete directories. The parameter p can be used to create a multi-level directory. It can also be used to delete multi-level directories when the directory is empty. 6. cp: file copy command. Cp [parameter] source file or directory target file or directory-a: usually used when copying a directory. It retains links, file attributes, and copies all contents in the directory. The function is equivalent to the dpR parameter combination. -D: the link is retained during copy. The link mentioned here is equivalent to the shortcut in windows. -F: overwrite the existing target file without prompting. -I: opposite to f, a prompt is displayed. -P: In addition to copying the file content, it also copies the modification time and access permissions to the new file. -R: if the source file is a directory file, all subdirectories and files under the directory will be copied. -L: Generate links instead of copying files. 7. mv: file movement and renaming command mv. -B: If the file is overwritten, back up the file before overwriting. -F: if the target file or directory has the same name as the existing file or directory, the existing file or directory will be overwritten. -I: cover the money and ask the user first. -S: used together with the-B parameter. You can specify the end of the word to be appended to the backup file. -U: when moving or renaming a file, if the target file already exists and its date is newer than the source file, the target file is not overwritten. -V: detailed information is displayed during execution. -V: used with-B to develop backup methods. 8. rm: delete the file "love you" and "directory" command. -D: Delete the hard link data of the deleted directory. -F: Force delete a file or directory. -I: Ask the user before deleting a file or directory. -R: recursive processing. All files and subdirectories in the specified directory are deleted. -V: displays the command execution process. 9. ln: create a link command. -B: overwrite the backup before the target file. -D: Create a hard link for the target. -F: forcibly create a link to a file or target. -I: Ask the user before overwriting an existing file. -N: the object of the symbolic link is considered as a normal file. -S: Creates a symbolic link instead of a hard link to the source file. -S: Use the-B parameter to back up the target file. 10. wc: Command for viewing file information. -L: displays the number of lines of text in the file. -W: the number of words in the file. -C: the number of characters in the file. 11. cat: File Viewing command. -N: Numbers of all output rows starting from 1. -B: similar to-n, but not a blank row. -S: When there are two or more consecutive blank rows, It is rotated into one row. 12. head tail: Command for viewing the file view. Head-n5 001.c: view the first five rows of the file. Head 400b 001.c: view the first 400 bytes of the file. Head 4 k 001.c: view the file content in 4KB. Head 3 m 001.c: view the content of the first 3 MB file. In contrast, tail starts from the end of the file. 13. chmod: File Permission setting command. File Level 3 permissions: u: Owner. G: group. O: Users except owners and users in the same group. Permission character: r: The table is readable. W: indicates that data can be written. X: indicates the execution. Common command parameters:-c: if the file permission has been changed, the change action is displayed. -F: if the file permission cannot be changed, no error message is displayed. -V: displays detailed information about file changes. -R: set the same permissions for all files and subdirectories in the directory. 14. find: find the file command. Find directory file name 15. man: System Help Command. Man [command] 16. info: Another help document in the system. Man is the standard help manual for linux systems, and info is the help manual for free software. The content is richer than man. 17. environment variables. View All: export view A: export $ [environment variable name] Set variable: [variable name] = [value] 18. Define the environment variable in the system configuration file. The system configuration file for environment variables is/etc/profile. 19. shell operator. The operators in shell can assign values, calculate, test, and compare variables. In ubuntu, you can use echo $ [expression] to output the value of an expression. 20. shell input and output. Echo $ str outputs the result to the terminal. Echo $ str> file: Save the result to the file. If no file exists, a new file is created. If a file already exists, the previous file will be overwritten.> Indicates you can view the end of an existing file. Echo output content, which can contain the following format control characters. \ C: Add at the end, indicating that the line does not wrap after the output is complete. \ T: Output a hop, equivalent to pressing the "TAB" button. \ N: Output A line feed. Note that if you want to output special characters, you must add the-e option. Otherwise, the output results will directly output characters. Adding the-n option will disable line breaks after echo output. 21. read command to read information. If a variable is read-only, all input information on the keyboard is assigned to the variable. Press Enter to end the input. If multiple variables are input, use the space key to separate the input variables. If the number of input variables is greater than the number of variables to be read, the remaining variables are assigned to the last variable. Add <filename after the read statement to read data from the file and assign the value to the variable. 22. File redirection. Command> filename redirects the standard output to a file. Command> filename redirects the standard output to an object in append mode. Command 1> filename redirects the standard output to a file. Command> filename 2> & 1 redirects the standard output and standard error to a file. Command 2> filename redirects standard output errors to a file. Command 2> filename redirects the standard output to an object in append mode. Command> filename 2> & 1: append the standard output and standard error to a file. Command <filename> filename2 uses the command as the standard input in the filename file and filename2 as the standard output. Command <filename: The command is input using the filename file as the standard. 23. Use of quotation marks. Double quotation marks indicate that a string is referenced. Special characters such as $, quotation marks, double quotation marks, backslash, and quotation marks cannot be used in strings. The reverse quotation marks are used to execute the system command in the quotation marks and then return the result of that command. The returned result can be assigned to a variable. Backlash is used to escape special characters. 24. Test statement file test statement: A test of the file status determines the permissions, attributes, and types of the file. Different from other languages, if the test command returns 0, the test is successful. If 1 is returned, the test fails. Numerical test: The numerical test compares the two values in an equal or equal relationship with the comparison operators in C. There are two forms of numerical testing in the shell program. The first operand value of test compares the second operand and replaces the test command with brackets. [First operator numeric comparator second operand] numerical comparison Symbol:-eq: whether two numbers are equal. -Le: whether the first number is greater than the second number. -Gt: whether the first number is greater than the second number. -Ne: whether two numbers are not equal. -Ge: whether the first number is smaller than the second number. -Lt: whether the first number is smaller than the second number.