Work commonly used linux command Daquan

Article Content Reference: https: //www.cnblogs.com/yjd_hycf_space/p/7730690.html thanks for sharing Gangster

 

system message 

date Display System Date

cal + year display the calendar year

date 041217002007.00 set date and time - in seconds, month, day, hour 
clock -w will save time to modify the BIOS 

 

Files and Directories 

cd back to the root directory

cd .. back to the parent directory

cd ../ .. back to the two directories

 

The current working directory pwd

 

ls view files in the directory

ls -l show details of files and directories

ls -a show hidden files

ls * [0-9] * Displays the file and directory names that contain numbers

 

displaying a tree structure of files and directories tree starting from the root directory
lstree displays a tree structure of files and directories starting from the root of

 

mkdir dir1 create one called 'dir1' directory ' 
mkdir dir1 dir2 create two directories simultaneously 
mkdir -p / tmp / dir1 / dir2 create a directory tree 

 

rm -f file1 delete called 'file1' file ' 
dir1' directory 'rmdir dir1 delete called' 
RM -rf dir1 delete a 'dir1' directory is called and delete its contents 
rm -rf dir1 dir2 remove two simultaneously directories and their contents 

 

Music Videos dir1 new_dir rename / move a directory does not exist if new_dir rename dir1 if present, will be placed under the directory dir1 new_dir

 

cp file1 file2 copying a file 
cp dir / *. Copy all files in a directory to the current working directory 
cp -a / tmp / dir1. copy a directory within the current work directory 
cp -a dir1 dir2 copy a directory 

 

ln -s file1 lnk1 create a link to the file or directory soft link 
ln file1 lnk1 create a physical link to the file or directory 

 

touch -t 0712250000 file1 modify timestamp of a file or directory - (YYMMDDhhmm) 

 

iconv -l lists known encoding

 

File search 
find / -name file1 from '/' began to enter the root file system search for files and directories 
find / -user user1 search belongs to the user 'user1' files and directories 
find / home / user1 -name \ * . Bin in the directory '/ file home / user1 'searches with' .bin 'end of the 
find / usr / bin -type f -atime +100 searched in the past 100 days has not been used to perform a file 
find / usr / bin -type f -mtime - 10 searches created or modified file in 10 days 
. find / -name \ * rpm -exec chmod 755 '{}' \; search files ending in '.rpm' and define permissions 
find / -xdev -name \ * .rpm search files ending in '.rpm', ignoring the CDROM, pen-drive and other removable devices 
locate \ * ps find files with '.ps' ending - first run 'updatedb' command 
whereis halt show a binary file, location of the source or man 
which halt show full path to a binary file or executable file 

 

Disk Space 
df -h display has been mounted partition list 
ls -lSr | more aligned to the size of the files and directories 
du -sh dir1 estimate disk space directory 'dir1' has been used

 

File permissions - using the "+" to set permissions, use the "-" is used to cancel 
ls -lh permission to display the 
ls / tmp | pr -T5 -W $ COLUMNS divide terminal into 5 columns will show 
chmod ugo + rwx directory1 set all directory people (u), group (g) and others (o) to read (r), write (w) and execute permissions (x), 
chmod go-rwx directory1 delete a group (g) and others (o) perform read and write access to a directory 
chown user1 file1 change owner of a file's properties 
chown -R user1 directory1 change all of the properties of a directory and also change the attributes of all files in the directory to change 
the group chgrp group1 file1 change file 
chown user1: group1 file1 change a file and group ownership of the 
find / -perm -u + s list of all uses a file system control SUID 
chmod u + s / bin / file1 set SUID bit on a binary file - run the file the user is also given the same permissions and owner 
chmod us / bin / file1 disable SUID bit on a binary file 
chmod g + s / home / public set SGID bit on a directory - similar to SUID, but this is for directory 
chmod gs / home / public disable SGID bit on a directory 
chmod o + t / home / public set a STIKY bit files - delete files allow only legitimate owners 
chmod ot / home / public disable a catalog of STIKY bit 

 

Special attributes files - using the "+" to set permissions, "-" is used to cancel 
chattr + a file1 append mode allows only read or write files 
chattr + c file1 allows that a file is automatically compressed kernel / decompression 
chattr + d file1 in when a file system backup, the dump program ignores file 
chattr + i file1 an immutable file can not be deleted, modify, rename, or linked 
chattr + s file1 allows a file to be safely deleted 
chattr + S file1 upon application programs have been written on this file, the system immediately modify the results written to disk 
chattr + u file1 If the file is deleted, the system will allow you to recover the contents of a file is deleted 
lsattr show special properties 

 

Packaged and compressed files 
file1.bz2 decompression called bunzip2 'file1.bz2' file 
compression called bzip2 file1 'file1' files 
gunzip file1.gz decompression called 'file1.gz' file 
gzip file1 compress called 'file1' file 
gzip -9 file1 maximize compression 
rar a file1.rar test_file created called 'file1.rar' package 
rar a file1.rar file1 file2 dir1 while compressing 'file1', 'file2' and the directory 'dir1' 
RAR the X-file1 packet decompression .rar rar 
unrar x file1.rar packet extracting rar 
tar -cvf archive.tar file1 create a non-compressed the tarball 
tar -cvf archive.tar file1 file2 dir1 created containing a 'file1', 'file2' and 'dir1' archive 
tar -tf archive.tar display the contents of a package 
tar -xvf archive.tar release a package 
tar -xvf archive.tar -C / tmp to release the compressed packet / tmp catalog 
tar -cvfj archive.tar. bz2 dir1 create a bzip2 compressed format
tar -jxvf archive.tar.bz2 extracting archive a bzip2 format of 
tar -cvfz archive.tar.gz dir1 create a compressed gzip format of 
tar -zxvf archive.tar.gz decompress a gzip format compressed 
zip file1.zip file1 create a zip format compressed 
zip -r file1.zip file1 file2 dir1 several files and directories simultaneously compressed into a zip archive format 
unzip file1.zip extracting a zip format archive 

 

Look at the file 
cat file1 view the contents of the file forward from the first byte 
tac file1 in reverse, starting from the last row view the contents of a file of 
more file1 view the contents of a long file of 
less file1 similar to 'more' command, but it file and allow the same operation as the forward reverse operation of 
the first two rows of the head to view a file file1 -2 
tail -2 file1 view last two lines of a file 
tail -f / var / log / messages in real time a file is added to the view contents 

 

Text Processing 
CAT file1 file2 ... | the Command <> file1_in.txt_or_file1_out.txt General Manipulation text syntax for a using PIPE, STDIN and STDOUT 
CAT file1 | the Command (sed, grep, awk, grep, etc ...)> result.txt a detailed description of the combined text file and write a new introduction file 
cat file1 | command (sed, grep , awk, grep, etc ...) >> result.txt merger described in detail a text file, and About write an existing file 
grep Aug / var / log / messages in the file '/ var / log / messages' in the keyword to find "Aug" 
grep ^ Aug / var / log / messages in the file' / var / log / messages' to find "Aug" words beginning 
grep [0-9] / var / log / messages select '/ var / log / messages' file numbers of all lines contained 
grep Aug -R / var / log / * in the directory '/ var / log' and subsequent directory search string "-Aug" 
Sed 'S / stringa1 / stringa2 / G' example.txt in example.txt the "string1" replace "string2" 
sed '/ ^ $ / d' example.txt remove all blank lines from a file example.txt 
sed '/ * # / d; / ^ $ / d' example.txt example.txt deleted from the document, all comments and blank lines 
echo 'esempio' | tr '[ : lower:]' '[: upper:]' merger vertical cell contents 
sed -e '1d' result.txt excluded from the first line of the file example.txt 
sed -n '/ stringa1 / p' contains only See Glossary "string1" row 
sed -e 's / * $ / / 'example.txt delete each line of the last blank character 
sed -e' s / stringa1 // g 'example.txt only delete words "string1" from the document and retain all remaining 
sed -n' 1,5p; 5q 'example See .txt from the first row to the fifth row of content 
'5p; 5q' sed -n example.txt view line 5 
Sed -e 'S / 00 * / 0 / G' by replacing a plurality of individual zero zero example.txt 
cat -n file1 number of lines marked files 
cat example.txt | all even rows awk 'NR% 2 == 1' delete example.txt file 
echo abc | awk '{print $ 1}' view the first column of a line 
echo abc | awk '{print $ 1,  $ 3}'See the third row and the first column
paste file1 file2 merging two files or the contents of two columns 
paste -d '+' file1 file2 merging contents of two files or two columns, with the intermediate "+" to distinguish 
sort file1 file2 sort contents of two files 
sort file1 file2 | uniq of two files and set (only one copy of duplicate rows) 
sort file1 file2 | uniq -u files by viewing only unique line 
sort file1 file2 | uniq -d taken intersection of the two documents (leaving only two files exist in the file) 
content comm -1 file1 file2 compare two files to delete only content 'file1' contained 
comm -2 file1 file2 compare two the contents of a file only removes what 'file2' contained 
comm -3 file1 file2 compare contents of two files by deleting only partially common to both files 

 

ifconfig to view ip address

 

Guess you like

Origin www.cnblogs.com/Roc-Atlantis/p/11647213.html