First, variable execution file path: $ PATH
1. To open files in general with relative or absolute path, why ls these can be opened in any path without prompting for file not found it?
A: File PATH
2. PATH executable files are placed in
/ usr / local / sbin: / usr / local / bin: / sbin: / bin: / usr / sbin: / root / bin
if there are a plurality of paths at the same command, the first find of this command is executed
Note: executable commands, files must be placed inside the pATH or absolute path, or command can not be executed
, such as: ls command / usr / sbin, if moved to the / root directory the next, and the current working directory is / root
① execute ls, and can not display the file list (because no path in the pATH)
② can perform / root / ls or ./ls by a relative or absolute path
③ To directly with ls, the / root path may be added to the pATH
pATH = "$ {pATH}: / root"
Second, inspection of documents
- cat: the first line displays the file contents -n show line numbers
- tac: The file contents from the last line
- nl: time display also shows the line number
- more: show the file contents page by page
- less: you can flip forward
- head: Look at the first few lines head [-n number] File
- tail: just look at the tail of a few lines of
exercises: Displays the 11th to 20 /etc/man_db.conf, and display line numbers
head -n 20 /etc/man_db.conf | tail -n 10 | nl
Third, modify the file time or New Document touch
1. time
- modification time (mtime): When the contents of the file data changes, changes this time (ls -l time displayed) Note: The command is not this time
- status time (ctime): rights, property
- access time (atime): read time
ls -l --time=atime 目录
2. touch
the document time may be from the future, because of the different time zones, so there is time to modify the necessary
touch [acdmt] file
Third, the default permissions and Privacy permissions of files and directories
umask: user permissions default value when creating a file or directory is
the default directory and file permissions 1. different
files are generally not an executable file, so x is non-essential; x directory permissions are important, there must be. So:
The default maximum file permissions are -rw-rw-rw-
default is the largest directory permissions drwxrwxrwx
2. Examples
Note: umask is the result of reduced rights
documents: (- rw-rw-rw -) - (--- ---- w -) = - rw- rw-r-
directory: (drwxrwxrwx) - (d ------- w -) = drwxrwxr-x
Fourth, the search instruction file
1. Find the script file name
which 命令
(must be in the PATH, this way can be found to)
search 2. File name
-
whereis: Search only a few specific directories mainly / bin / sbin, man page files in / usr / share / man
can see what documents found by whereis -l -
locate: Find an established database / var / lib / mlocate, the default update time is 1 day, so the new document, and will not be found immediately, this time to an administrator finer database, use the command updatedb.
Fifth, the relationship between the authority and instructions
[Image dump the chain fails, the source station may have security chain mechanism, it is recommended to save the picture down uploaded directly (img-gJKobsi5-1582378549406) (https://user-images.githubusercontent.com/56629574/67254340-15943780-f4af -11e9-88ef-f1149ddbce99.png)]