(1), Linux file permissions and directory configuration
Linux files are divided into three identities: owner, group, others. Three permissions read, write, execute
#ls-al
Drwxr-xr-x 1 root root 4230 2012-09-12 17:21 jdk-7u7
Corresponding file permissions connection number user group user file size last Modified Date file name
Where [d] is represented as a directory
[-] represented as file
File types and permissions three for a group, a total of three groups, where the first group is the file owner permissions, the second group is the user group permissions, the third group is other user rights, each group has [RWX] three parameter combinations. [r] Represents read, [W] represents write, [x] represents executable if no permission is [-], can also be used with the number table three R:4 w:2 x:1
Changing file properties and Permissions
CHGRP: Change the user group to which the file belongs Chgrp [-r] Users Install.log [-r] means recursion, including all files under subdirectories and directories
Chown: Change file owner Chown [-R] Oracle:oracle Install.log
chmod: Changing the identity and permissions of file permission files needs to accumulate, for example [-rwxrwx---],
corresponding owner = rwx = 4+2+1 = 7
Group = RWX = 4+2+1 = 7
others =---= 0+0+0 = 0
So the permission number is 770.
chmod [-R] 770 files and directories
Increase and removal of permissions
For example, to add an executable permission
chmod a+x files and directories, add executable permissions to all users, chmod a-x Remove executable permissions for all users
Available options [A,o,g,u]
(2), File and directory creation, deletion, find, copy, paste,
#ls |wc-l Statistics File and directory number
#pwd-P. Displays the current directory (path), [P] Displays the correct file, not the path to the connection file (shortcut inside Windows)
#mkdir-M 777 test1. Create a new directory and give this directory 777 permissions.
#mkdir-P Test1/test2 directory is created by default only one layer at a level, plus the [P] system automatically creates TEST1,TEST1/TEST2
#rmdir-P Test1/test2. By default, you can delete a directory only one layer at a time, and the directory must be empty, and [P] The system will delete multiple layers at once. If the deleted directory is not empty, you need to use the following command.
#rm-R test2. Delete everything in the directory.
#rm-RF test2. Remove all items under the directory including the Test2 directory.
#rm-RF! (Rbeijing.mid | RBEIJING.MIF) These two commands combine to delete files other than Rbeijing.mid and RBEIJING.MIF.
#ls | Xargs-n rm-fr ls Delete a lot of trivial files
#cp-a/var/test1/var/test2 copy files test1 to test2. [A] the source and target data are copied, and the permissions and identity times are identical to the current user. [R] is a directory that can be copied. [i] ask the user if a copy of the file already exists is overwritten
#scp Remote File copy
For example, to copy the current file to a remote other host, you can command the following.
#scp/home/daisy/full.tar.gz [Email protected]:/home/root
It is also easy to copy files from the remote host to the current system if you want to do this in reverse.
#scp [email protected]/full.tar.gz 172.19.2.75:/home/root/full.tar.gz home/daisy/full.tar.gz
#cat-N test to view the contents of the file, [n] Displays the line number.
#find-name test.pdf Find test.pdf file
#find/trs-name Protect Find all protect directories under the TRS directory
-type finding a file of a certain type
B-block device files.
D-Directory.
C-character device file.
P-Pipeline file.
L-Symbolic link file.
F-Normal file.
# Find-type D Find Directory
#mv move files/or rename commands
MV 1.txt desfile move 1.txt files to the Desfile directory, similar to the cut
MV 1.txt 2.txt name 1.txt file 2.txt
#dd if=1.txt of=2.txt copies 1.txt content into 2.txt text files and supports block copies
#grep find text in text
-C: Outputs only the count of matching rows.
-N: Displays matching lines and line numbers.
-V: Find rows that do not contain matches
Like what:
$ grep ' test ' d* #显示所有以d开头的文件中包含 Test line.
$ GREP-VN "Data.doc" #输出所有不包含48的行
$ grep-i "AB" Data.doc #输出所有含有ab或Ab的字符串的行
$ grep–e "ABC|EFG" file name//Find a string containing ABC or EFG from the file contents
$grep "17071" 20120406.txt | grep "2012-04-06 06:28:08" | grep "Word2"//Find rows that meet 17071,2012-04-06 06:28:08, word2 three strings
#more
-N Rows specify the number of rows to display per screen
+ line number is displayed starting with the specified line number
#tail
1. To display the last ten lines of the notes file, enter:
Tail notes
2. To specify the number of rows to start reading from the end of the Notes file, enter:
Tail-n notes
#wc-L Directory Statistics file count
-C Count bytes.
-L COUNT the number of rows.
-W counts the number of words.
Package compression of archives and file systems
(3), archive and file system packaging compression
A, compression instructions
Under Linux, the compressed file has an extension of *.tar, *.tar.gz,*.gz
*.gz gzip program compressed files;
*.tar the TAR program to package the data, and has not been compressed;
*.tar.gz the TAR program to pack the files and do the compression;
*.tgz Tar packed compressed archives.
B, Packaging instructions
#tar-CVF File.tar File//packaging
#tar-cvzf file.tar.gz File//package and compress
TAR-CVFZ 05.tgz/mnt/ctb/data/traffic/backup/2014/05//packaging and compression
#tar-XVF eclipse-jee-juno-linux-gtk.tar.gz//Unpacking Package
Optional parameters [C] Create a new archive
[v] verbosely list files processed, output related information during processing
[F] Use archive file or device archive, compressed file name
[z]--gzip,--gunzip,--ungzip filter the archive through GZIP, compressed format
[x] Extract files from an archive, extracting the file from the archive file
Linux common Commands (3)-File and directory management