Linux Study Notes - Part 6
(Disclaimer: This note is only for study records and reference)
Command:
chattr: The format is: chattr [+-=][Asaci][file name or directory name]
+: increase -: decrease =: set
A: After adding this attribute, the atime of the file or directory will not be changed
s: After adding this attribute, the data will be written to the disk synchronously
a: After adding this attribute, it means that it can only be added, not deleted, and non-root users cannot set this attribute
c: After adding this attribute, it means that the file is automatically compressed, and it will be automatically decompressed when reading
i: After adding this attribute, it means that the file cannot be deleted, renamed, linked, written or added.
lsattr: special permission for reading files or directories, format: lsattr [-aR][file name/directory name]
-a: similar to -a of ls, that is, list together with hidden files
-R: List with subdirectory data
set uid: This permission is for binary executable files, so that the file has the permissions of the file owner during the execution phase
set gid: changing permissions can be applied to files (binary executable files) or directories. When acting on a file, like set uid, when acting on a directory, any file created by a user in this directory has the same group as the group to which the directory belongs.
sticky bit: It can be understood as an anti-deletion bit.
which: find the absolute path of the executable
whereis: find files related to the given file name through a pre-generated file list library, format: whereis [-bms][file name]
-b: look for binary files only
-m: find only help files
-s: find only source code files
locate: similar to whereis
find: search for files, format: find[path][parameter]
-atime +n/-n: Indicates files whose query or execution time is greater or less than n days
-ctime +n/-n: Indicates that the time to write, change inode attributes (such as changing the owner, permissions or links) is greater or less than n days.
-mtime +n/-n: Indicates that the writing time is greater than or less than n days for files, this parameter is used the most
-size: Find files that match the specified file size
(Note: access time: changes when the file is read or executed; modified time: changes when the file is written and the content of the file changes; change time: when the file is written, the owner, permissions or link settings are changed with the change of the inode content Change)
-name filename: Indicates that the file with the file name is directly searched
-type filetype: means to find files by file type
filetype: f (normal file), b (block device), c (character device), d (directory), l (symbolic link), s (socket)
stat: used to list atime, ctime and mtime of files