1. Files and directories 1.1, File/folder permissions
Usage:
(1) chgrp group_name Dir_name/file_name,
(2) Chown User_name:group_name dir_name/file_name
(3) chmod 777 Dir_name/file_name,-R can be recursive
Note: "1" in 4 is r,2 to w,1 X, the end of the +_ number is whether there is an ACL link
Files starting with. Default to hidden files
1.2, directory and file View/operation
Cd, pwd, mkdir, RmDir, RM, CP, MV, LS, umask, touch, chattr/lsattr, file, which, Groupadd, Useradd/usermod, Su, passwd
./For the current directory,.. /For Upper Directory
"1" CD (Changedirectroy): Enter/switch to a directory
Basic usage: Cd/home/test into the test folder
(1) CD-: Returns the directory before the operation
(2) CD ~: Return to the home directory of the login account
"2" PWD: View the absolute path of the current directory
Basic usage: PWD, viewing the current directory absolute path
(1) Pwd[-p]: Returns the real file name (in case of soft and hard links)
"3" mkdir: Creating a Directory
Basic usage: mkdir folder, creating folders in the current working directory
(1) Mkdir–m 711 Path: Create a new path directory and grant 711 permissions
(2) Mkdir–p Folder1/folder2/folder3: If the folder1 does not exist, recursively set up the directory
"4" rmdir: Delete Empty directory
Basic usage: rmdir Null_ folder Delete empty directory Null_folder
(1) rmdir–p Folder1/folder2/folder3: If the Folder1 is an empty directory, remove the directory recursively
"5" RM: Delete File/Add-R to delete folder
Basic usage: RM file_name Delete files with file name file_name under current working directory
(1) Rm–f file deletion of files does not prompt
(2) rm–i file to delete file and prompt for confirmation to delete
(3) Rm–r folder delete all files and folders
"6" CP: Copying files
Basic usage: CP source file target path/target file
(1)-a/-p the rights, attributes, users and other information of the file.
(2)-I confirm reminder to prevent the generated target file from overwriting the existing file with the same name
(3)-R recursive replication
"7" MV: Moving Files
Basic usage: MV Source file destination path/destination file
With CP, with-R,-I
"8" LS: View current directory
Basic usage: LS View non-hidden files in the current directory
(1)-a displays all files (both hidden and non-hidden)
(2)-L Show details of non-hidden files (including permissions, attribution, etc.)
"9"umask: View preset permissions for the current working directory
Basic usage:
(1) Umask, will return a string of words such as 0022 (2) umask 002 Change permissions.
Analysis:
(1) in 4 digits, the 1th digit represents the command permission, does not have the tube, the latter 3 represents Owner,group,other respectively, and this number expresses the meaning is does not have the permission, for example this 022, then change the permission is Rwxr-xr-x, This means that group and other are missing W (for numbers, 2).
(2) Change the authority to 002, that is, to become rwxrwxr-x, that is, only a few other W permissions
"Permission 0022 1th is representative of special permissions such as 1.3, 4 for suid,2 on behalf of sgid,1 representative Sbit"
(3) Umask–s can show the default permissions of the current work in the form of rwx
"10" touch: Create an empty file, modify the time basic usage: touch file_name
"11" Chattr/lsattr hidden properties
Basic usage chattr +i/+a folder/file, lsattr folder/file
Analysis:
(1) chattr +i/+a Folder/file,
"+i" causes documents to be deleted, renamed, soft-connected, written, modified
"+a" will make the document unavailable for deletion and modification, only for append operations
Once the Chattr +i property is set, the I property can be canceled with the Chattr-i file name, and the undo is restored.
(2) Lsattr
Show hidden properties of a document
"12" File Folder/file: View Files Properties
"13" which command (e.g. LS): see which of the commands
"14" Groupadd Newgroupnmae: Create a new group
"15" Useradd/usermod: New user/user attribute changed
(1) Useradd-g Primary Group-G sub-group (comma distinguished) user name
For example, Useradd-g oinstall-g Dba,oper Oracle is the creation of Oracle users. The primary group is the Oinstall sub-group for DBAs and Oper
(2) usermod-g groupname username
Add the existing user name to an existing group
(3) Modify user name:
usermod-l New user name old user name-d/home/ new username - m old user name
"16" ID Username: viewing user properties
Example: ID Guochaoqun
uid=500 (Guochaoqun) gid=500 (Guochaoqun) groups=500 (Guochaoqun), 501 (test)
"17" su-username: Switch User
"18" passwd Username: Modify the user password (note that only the current user's password can be modified only if the other user is currently root)
1.3, File special permission Suid,sgid,sbit
4 represents suid,2 on behalf of sgid,1 representative Sbit "
SUID: When the file is executed, the permission to have the file own (in the 777 permission is represented by S in own)
SGID: Same as suid, except that own becomes group (represented in group s in 777 permissions)
Sbit: If a in a directory with the group and other W permissions, which means that "a directory of anyone to create files and directories to delete/move/rename the operation", if the A directory with the Sbit permission entries, a can only set up their own files W operation, You cannot perform W operations on files and directories created by others. (in 777 permissions, represented by T in the oher position),
Permission setting: Chmode 4755
s S T in uppercase
Appendix
Basic: CD,MORE,LESS,CAT,VI,MKDIR,RMDIR,RM,CP,MV,GREP,LS,HEAD,TAIL,SORT,UNIQ,DIFF,FILE,FIND,BZIP2,BZCAT/BUNZIP2, TAR-CVF file 1 file 2, tar-xvf file. Tar,
Go to Directory: CD destination folder
Return to upper directory: CD. /
Sibling directory: CD./
Display content: Cat file name/more filename/less file name
Create and edit files: VI
Create a Delete directory: Mkdir/rmdir destination folder
Delete Files: RM target file/-I delete before ask/F Direct delete/-R delete directory and all files in directory
Copy: CP source file destination location new file name
Move: MV Source file destination location new file name
File content Blur match: grep ' match character ' file name/cat filename |grep ' match character '
View catalog: LS
Show file header: Head file name (default 10 rows) head-x file name (first x row displayed)
Display end of File: Tail filename (default 10 lines tail-x file name (displayed after X line)
Sort by character: Sort file name/sort-u file name (remove duplicate line display)
Remove adjacent duplicate rows within a file: Uniq file name,
View two file differences: diff file 1 file 2/U merge query, unsigned for common,-No. 1 exclusive, + number for file 2
View file status information: filename (view file encoding/size information)/file file 1 file 2 File 3
Find directory: Find after lookup directory,-name specifies the name of the file that needs to be looked up, the name can use * to represent all.
Find/home-name "*.txt"; Find all files or directories that end with. txt in the/home directory.
System: Who,w,finger,write,mesg,date,echo,pwd,acl
Show current connection user information: who/w
Send message to connected User: Write user enter input send message return press CTRL + C to end.
Turn off message send receive: MESG y/n
Show Current log: Date
Copy your own parameters and display them on the screen: Echo data
View current directory location: pwd
ACLS are used:
[Email protected] data]# setfacl-m u:zyq:rwx test.sh
[Email protected] data]# getfacl-c test.sh
Ctrl+w: Remove the current single phrase
Ctrl+u: Row Delete
Ctrl+h: Single word deletion
Linux File system commands