Part 1: Basic operations of Linux 1. Executers ./program_name
2. Termination error programs 4.1 Display process PS - Print Status EG PS -AXU | More Lists all processes running (option a) including those running (option X) that are running (option X) that are running (option x) The username (option U) belonging to the process may exceed one screen because the displayed content may be used with "more", there is a stop between the "more".
4.2 Kill PID enforces a process to terminate. First, use the PS to determine the process identification number (PID) of the termination process. EG KILL 123 4.3 KILLALL Termination of the program EG KILLALL NETSCAPE Submission Netscape 3. Find 2.1 Find file name EG FIND / -NAME "Netscape" From the root of the root "/" Start Find EG FIND $ HOME - Name core -exec rm -f {} /; from $ home directory looking for file "core". For each file being found, "RM -F" (forced delete file) is executed. {} represents the discovered files, "/" Terminates the list of commands.
E.G look for all CPP or H files in the current directory
Find. -name "* .cpp" -o -name "* .h"
E.G Find all files not CPP in the current directory
Find.! --Name "* .cpp"
E.G Find all content in the current directory contains ABC's CPP file
Find. -Name "* .cpp" | Xargs Grep ABC 2.2 Quick Find E.G Locate Netscape Because Locate is based on database (usually reconstructed at night), you can't find files that have just been sent to the file system.
2.3 Display execution file full path EG which executable_name 2.4 grep / rgrep EG RGREP -R 'CELESTE'. | More Eg Grep -r 'Celeste'. | More in the current directory and all subdirectories Search all files with string "Celeste" (Option "-r" represents recursive). The display file name and the row in the file contain the string looking.
4. Modify file access E.G chmod a x my_file to turn "my_file" into everyone can do
"A" means that all users (AL) "U" represents the user (user) "G" represents the user group ("O" means other users (other users) plus " " add permission minus "-" delete permission "=" Set permissions
4.1 Character Permissions (X R W) 4.2 Digital Permissions EXECUTE = 1 Write = 2 = 4
User Level: File owner User Group Other User Permissions Set Example RWX RW- R - ROP RW- R - ROP 111 110 100 Permissions Octa Representation 1 6 4 5. File ownership file has a owner and a user group EG - RWX ------ 1 Gaagaa AP1 27 APR 24 14:12 JUNK JUNK file belongs to the owner gaagaa and user group AP1 6. Permissions 6.1 File three access properties: x (execution) RW 6.2 three user level: File Owner (U) File Group (G) System Other User (O) 6.3 File Type "-" Represents Normal File "D" indicates that the "L" representation of the link file "C" indicates that the character device "B" means block The device "P" indicates a nomenclature such as a FIFO file (First in first, advanced first out) "f" indicates that stack files such as LIFO files (Last In First Out, first out out) EG -RWXR-XRWX first character "- "Displays the type of file, refer to 6.3. The first three character group after the first character indicates that the second three-character group indicating that the file user group is the third three-character group of the file user group to represent the system other users. Permissions to this document. If there is no permission, "-" characters are generally displayed. 7. Background execution command EG Eclipse & eg fg Eclipse Restores the background process to the front run EG BG Eclipse Sends the front desk process to the background Run 8. SHELL scripts Writing 1. File head #! / Bin / bash tells the shell which one should be used The program explains my script, "#!" Is a must. 2. Parameter parameters $ 0, $ 1, $ 2 ... is the parameter passing to the script. EG MYScript Abcdefg $ 0 is Myscript, $ 1 is A, $ 2 is B, $ 3 is C ... 3. Execute ./script_name eg #! / bin / bash echo untaarring the file $ 1 # this calls tar with options -Xvzf (extract) , Verbose, Filter Through Gzip, Input FileName, Tar -Xvzf $ 1
9. Input Output Redirection 9.1 Redirection Standard Output E.G Dir My_Dir> FileListing.txt 9.2 Redirects Standard Error E.G Dir My_DIR 2> ErrorListing.txt
9.3 Redirection addition DIR my_dir >> fileListing.txt dir my_dir 2 >> ERRORLISTING.TXT 9.4 "TEE" command writes the standard output to file and screen E.G Dir | Tee fileLiSting.txt
10. Transaction character * = Character sequence used to match any length is greater than equal to zero. Except for the file name starting with. (Point). ? = Used to match any single character [ABC1] = any single character for matching enumerations. In the proportion, the collection consists of 'A', 'B', C ',' 1 '. [AZ] = Used to match any small word letter [AF] = used to match any existed letters [0-9] = for matching any bit number [A-ZA-Z0-9] = for matching any letter (size Write) or numbers. / (Reverse slope) Shielding a special meaning (translit) of special letters, making this character only take the literal meaning representing the symbols. E.G
LS [ABA-Z] * Lists all file names in the current directory to start with A, B or any business writing letters
11. Text copy paste the text to be copied in the mouse, switch to the copyable destination address. Click on the mouse button to perform the paste operation. (If you only have two buttons, press two keys at the same time) 12. File Copy CP Source Destination -R (Recursive) Copy the content of the entire directory tree
13. Document rename, mobile MV Source Destination
14. Establish a link 14.1 Hard link LN Source Destination 14.2 Soft Dip (Link) LN-Source Destination
15. Delete 15.1 Delete file RM Files "-f" (force), force delete 15.2 Delete Directory RM -R Files Delete files, directories, and all their subdirectory
16. Document Manager MC Activates "Midnight Commander" file manager 17. Unplementing and compressed packaging and compression packaging refers to a total file or directory what to become a total file. Compression is to turn a large file into a small file through some compression algorithms. Many compressed programs in Linux can only compress one file, so when you want to compress a lot of files, you have to first take this big pile of files to a package first, then The original compression program performs compressed packaged program - TAR compression program - Gzip, Gunzip; Bzip2, Bunzip2; Compress, Uncompress; zip, unzip tar eg tar -cf all.tar * .jpg Put all .jpg files into one name ALL.TAR package. -F specified package file name -c indicates that a new package -R add file -U means that the update file -T list-t-x-解-文件
TAR can call other compressed programs while packaging or unpacking, such as calling Gzip (* .gz) -z calls bzip2 (*. bz2) -z call compress (*. z) 16.1 Tar Eg tar -cvf filename.tar filename compressed Eg tar -xvf filename.tar extract 16.2 tar.gz / tgz eg tar -zcvf filename.tar.gz filename compressed Eg tar -zxvf filename.tar.gz decompressed 16.3 gz / z EG EG Gunzip filename.gz decompressed 16.4 zip eg zip all.zip * .jpg Compression EG unzip filename.zip decompression
18. Alias
I don't like Linux, it is not used for the people. It is very powerful for the orders, but it also determines its difficult operability. What's more, my memory is very bad, so I can only use aliases. Defining the syntax of the alias is: alias shringcut = 'command'
Definition in ~ / .bashrc, remember to definitely execute it.
. ~ / .bashrc
Note that you can use single quotation marks or double quotes.
The difference is that single quotes will deprive all of these characters, and the '$' (parameter replacement) and '`' (command replacement) in the dual quotation are exception. It is recommended to use double quotes.
18.1 Alias without commands or parameters
Define decompression alias
E.G alias tarx = "tar -zxvf"
#> TARX A.TAR.GZ
18.2 Functions with parameters
Define in all files in all files in all files to find 'endif' alias, $ 1 is location parameters
E.G function DGREP () {grep -r $ 1.;
#> DGREP 'ENDIF'
Alias is said to support a parameter, but I have not tried success. ()
19. View the space of the disk
DF -K
20. Shield the error output
E.G GREP -R CPP. 2> / dev / null
21. VI use
21.1 GG / 1G moved to the first line of the article
21.2g Move to the last line of the article
21.3 NYY (Copy N row) NDD (cut N row) P (paste in the next line of the cursor) P (pasted in the top line of the cursor)
21.4 R FileName (read the file named filename in the current cursor)
21.5 Replacement
N1, N2S / OLD / NEW / G (look up from N1 to N2 replacement into new)
1, $ S / OLD / NEW / G (from the first line to the last line to find OLD to replace NEW)
21.6 U (cancel operation) Ctrl R (recovery operation)
21.7 Set Nu Set Nonu (not displayed)
21.8 Ng (to NP)
21.9 n (Top Check) N (Top Check)
21.10 / Word Find Word below? Word (looking upward from the current location)
22. xargs
Xargs read data from standard inputs and segmented each parameter with blank and restrooms (the blank in quotation is not split). Then execute the specified command (and attach the decomposed parameter to the back).
Reference http://campus.nbc.net.cn/nbcdn/data/1/60.html http://people.linux.net.cn/xgwu/cmuo/basics/cbshell6.html