As a programmer, you have to understand some Linux commands. These are some of my favorite commands.
- Tail -f -n Is often used to view logs. It can print out the newly added content of the log in real time. -n displays the last N lines of the file.
- Find file
- Df -h Displays system allocation, used, and available information
- Du -sh Displays the size of each folder
- Vi Create or modify a file
- Wq: save and exit. Wq! Forced exit. q! Exit without saving.
- Chmod Modifies file/folder permissions
chmod [-cfvR] [--help] [--version] mode file... File three levels: Owner, Group, and Other Users.Copy the code
- U is the owner of the file, G is someone who belongs to the same group as the owner of the file, O is someone else, and A is all three.
-
- – indicates that the permission is added, – indicates that the permission is cancelled, and = indicates that the permission is uniquely set.
- R means readable, W means writable, x means executable, and x means executable only if the file is a subdirectory or has been set to be executable.
- Grep is a powerful text search tool that uses regular expressions to search text and print out matching lines. Often used with | (pipe).
- Ps is used to list the processes currently running in the system. Often and ps – ef | grep * * to use.
- More less View files
The difference between:
-
More can’t go back, can’t go forward, can only go back. Less can use up and down arrows
-
Less does not need to read the entire file and loads the file faster than more.
-
Less exits and the shell does not leave what was just displayed, while more exits and the shell leaves what was just displayed.