Common Linux commands (version 2) and common linux commands
System switch command
Note: The server will not be shut down frequently, restarted, and will not be shut down if there is no fault. Therefore, these commands are not very common.
1. shutdown/usr/sbin/shutdown
E.g.
Shutdown-h 0 # shut down immediately, but you 'd better not use this command on the server.
2. reboot/usr/sbin/reboot
E.g.
Reboot system restart
For more information, see:
Man shutdown
Man reboot
Common linux Commands include
Common linux commands (BASICS)
1. man provides help explanations for familiar or unfamiliar commands
For example: man ls, you can view the ls-related usage.
Note: Press q or ctrl + c to exit. in linux, you can use ctrl + c to terminate the current program.
2. ls view the directory or file owner * and list the files under any directory
Eg: ls/usr/man
Ls-l
A. d indicates directory. If it is a "-", it indicates a file. If it is l, it indicates a connection file (link)
B. Permission for file or directory permission. Read (r), write (w), and run (x) respectively ).
3. Copy files using cp
Eg: cp filename1 filename2 // copy filename1 to filename2
Cp 1.c netseek/2.c // copy 1.c to the netseek directory and name it 2.c.
4. rm delete files and directories
Eg: rm 1.c // Delete the. c file.
5. Remove the directory or change the file name.
Eg: mv filename1 filename2 // rename filename1 to filename2
Mv qib. tgz ../qib. tgz // move to the upper-level directory
6. Change the current directory pwd on cd to view the complete path of the current directory
Eg: pwd // view the current directory path
Cd netseek // enter the netseek directory
Cd // exit the current directory
7. cat, more command
Displays the content of a file. The two commands are different: cat prints the file content all the time, and more is displayed on the split screen.
For example; cat> 1.c // You can paste the code into the. c file and press ctrl + d to save the code.
Cat 1.c or more 1.c // you can view the content in it.
Gcc-o 1 1.c // compile 1.c into the. exe file. We can compile the Code with this command.
8. Modify the chmod command permission usage: chmod one-digit octal number filename.
Eg: chmod u + x filenmame // you only want to run the command for yourself.
// U indicates the file owner. g indicates the group of the file. O indicates others; r table readable; w table writable; x table can run
Chmod g + x filename // the same group of people to execute
9. clear, date command
Clear: clear screen, equivalent to cls in DOS; date: displays the current time.
10. mount a hardware device
Usage: mount [parameter] device load point to be loaded
Eg: mount/dev/cdrom
Cd/mnt/cdrom // enter the cd directory
11. su switches to another person's identity without logging out.
Usage: su-l user name (if the user name defaults, the user name is switched to the root state)
Eg: su-l netseek (switch to the netseek user and the user will be prompted to enter the password)
12. whoami, whereis, which, id
// Whoami: confirm your identity
// Whereis: queries the directory where the command is located and the directory where the help document is located
// Which: query the directory where the command is located (similar to whereis)
... The remaining full text>
Examples of common linux commands
There are a lot of commands, and I will forget what I learned at once. I can only accumulate them slowly. Many of them are generally not used. 1. File Viewing and connection commands
Connect the file together, use the ">" operation to combine several files into a new file, or use ">" to append the file to the end of the saved file.
Syntax:
Cat [parameter] filelist
-N or -- number: numbers the number of all output rows starting from 1
-B or -- number-nonblank: similar to n, but not numbered for empty rows
-S: two blank lines are displayed. replace them with one blank line.
-V: displays unprintable characters.
Filelist: an optional list used to combine files. 2. split-screen display command
Similar to cat, But it displays a page each time, displays the next page by space, exits by pressing the <q> key, and provides help information by pressing the Syntax
More [Options] <file>...
-Num: specifies the number of lines displayed per screen.
-D: a message is displayed below the screen.
-L: by default, more will suspend if it encounters a paper delivery character ^ L. You can use this option to cancel this function.
-F: calculate the actual number of rows.
-P: Not to display every page in a scroll mode, but to display the page first.
-S: two blank lines are displayed. replace them with one blank line.
-U: No underline is displayed.
+/<String>: Search for string in the file and display the content on the page where the string is located.
+/<Num>: displays data starting from row num.
File: the file to be displayed.
3. Display files by page. Similar to more, but can be moved before and after the file.
Syntax:
Less [parameter] File Name
-I: Case sensitivity is ignored during query.
-Num: specifies the number of lines displayed per page.
-P <string>: Search for the string in the file and display it from the first matching position.
-S: when the content of a column exceeds the width of the display screen, the excess part is directly truncated. By default, the excess part is folded back to display the commands for copying, deleting, and moving.
1. Copy an object.
Syntax:
Cp [Option] <source> <dest>
Cp [Option] <source>... <directory>
-R recursive copy directory
-F delete an existing target file and copy it again
-A tries its best to retain the structure and attributes of the source file in the backup.
2. Delete
Rm [Option] <name> ....
This command is used to delete specified files or directories one by one. By default, <name> is the file name. The rm command does not delete the directory. The directory can be deleted only when the-d option is specified.
Syntax:
-F force Delete, including read-only files, without prompting the user
-I prompt the user when deleting each file
-R recursively deletes contents in a directory to move or rename files and directories.
Syntax:
Target file of the mv [parameter] source file
-F forcibly overwrite existing files.
-I prompt the user before overwriting existing files.
-U does not overwrite the target file when the target file is earlier than the original file.
-V outputs relevant information when moving files. Create and delete directory commands
1. Create a directory command
Mkdir [parameter] Directory Name
-P if the parent directory does not exist, create all parent directories. 2. Delete the empty directory.
Syntax:
Rmdir [parameter] Directory List
-P indicates that after a specified directory is deleted, if the parent directory of the directory is empty, the switch working directory and display directory commands will be deleted.
1. Change the current working directory.
Syntax:
Cd directory name
If the directory name is not followed, the root directory of the user is returned. In addition, the user must have the permission to enter the directory. In addition, cd ~ Switch to your home directory. You can switch cd... to the upper directory 2 in front of the ticket to display the working or current directory name.
Pwd [parameter] 3. List contents in the directory.
Syntax:
Ls [parameter] [Directory]
-A shows all files, including hidden files... the remaining full text>