scripting language on Linux I'll choose Python, so I don't know much about bash.
In this part of the school to learn some very basic command and knowledge points
1. The beginning of any script file should be #! To declare what type of file you are.
For example: if it's bash, then #! /bin/bash; If it's python, then #! /usr/bin/python;
#! This is followed by the location of the Python interpreter, and if you are not sure where it is, you can use which Python to find it, and it is not recommended to use locate.
In Linux (STD is the abbreviation for standard)
Standard input: i.e. keyboard input stdin
Standard output: Directly to the screen stdout "1"
Standard error output: Also lost to the screen, stderr "2"
If you want your results to be entered in a file, not on the screen
For example, ls > Ls_result, which is the result of LS, is redirected to the Ls_result file.
LS >>ls_result;
The difference between > and >> is that the former will overwrite the contents of the rewrite, which is appended
In Linux, 1 is used to represent stdout,2 for stderr;
Example: If you want to put the wrong result in a certain location, how to write it?
(insert: Explain the use of a Find command using Find path-opt-action)
Find/home-name lost 2>err-result
(insert: Explains a command to change permissions chmod who-opt-mod file name
Who u file owner, G same group, o other, a All
-opt the meaning of the operation; + Add,-delete; = Give
-mod R W X
chmod g+rwx myfile
If you use numbers to represent simpler
chmod 755 myfile
)
Echo This command is to display a piece of text on the display
Echo $path
If you want to add a directory path to the path, how do you do it?
Path=path:/home/myname/mybin
Find generally have four commands
Whereis, which, locate, find
Linux environment variables and file lookups