UNIX command

xiaoxiao2021-03-06  76

(1) Basic command command format: Command parameter 1.ls display file name, equivalent to DOS DIR command command format: LS [option] file option: -l Display detail site 1: File Type and File Rights Domain 2: File Connection Digital 3: File Owner Name 4: File User Group Name Field 5: File Length Domain 6-8: Recently Modified Date 9: File Name -a Displays all files, contains hidden files (with. ) -R Display file and all sub-directory -f display files (followed by *) and directory (followed /) -d and L option, display directory name instead of its content

2.CD directory conversion, equivalent to the CD command under DOS, pay attention to the directory separator "/", opposite to the DOS command format: CD DIRNAME 3.PWD Displays the current path 4.cat display file content, equivalent to the TYPE command format under DOS : CAT filename 5.more View file content in paging mode. Command format: more filename 6.rm delete file command format: RM [-r] filename (filename can be file name, or file an abbreviation symbol.) Example: RM File1 Delete the file name of File1. RM file? There are five characters in the delete file, the first four characters are all documents for File. RM f * delete the file, all documents, name f as a word. RM. RM -r DIR1 Deletes Directory DIR1, and all documents and subdirectories. 7.mkdir creates a directory command format: mkdir [-p] Directory-name Exmaple: MKDIR DIR1 creates a new directory DIR1. MKDIR -P DIR / SUBDIR Create Multi-level catalog 8.Rmdir Delete Directory Directory must first be empty command format: RMDir Directory

9.CP Document Replication Command Format: CP [-r] Source Destination Example: CP file1 file2 copies the document file1 into File2 CP file1 Dir1 Copy the document file1 to the directory DIR1, the file name is still file1. CP / TMP / file1. Copy the document File1 under the directory / TMP to the current directory, the file is still file1. CP / TMP / file1 file2 Sets the document File1 under the directory / TMP File1, filed to file2 cp -r Dir1 Dir2 (Recursive Copy Copy the entire directory. If the directory DIR2 does not exist, copy the directory DIR1, all the documents and subdirectories, and copy it to the directory DIR2. If the directory DIR2 does not exist, Dir1, and all the documents and subsets Directory, copy is directorized DIR2.

10.MV file mobile command format: MV Source Destination example: mv file1 file2 will change the document file1, change the file name File2. MV file1 Dir1 Move the document file1, move down to the directory DIR1, the file name is still file1. MV Dir1 Dir2 If the directory Dir2 does not exist, move the directory DIR1, and all the files and subdirectories, moved to the directory DIR2, the new directory name is DIR1. If the directory DIR2 does not exist, the DIR1, all the documents and subdirectories are changed to the directory DIR2. 11. DU Viewing the DC Capacity Command Format: DU [-SK] Directory example: DU DIR1 Displays the total capacity of the directory DIR1 and its number of capacity DU -SK DIR1 Displays the total capacity of the directory DIR1, with K bytes as metering 12.Find file lookup command format: Find Dir -Name FileName Command Example: Find. -Name Hello -Print Looking for the current directory and all sub-directory called Hello's document. Find. -Ctime 7 -print identifying no seven days Dividing Document Find. -Size 2000m -print Document Finding Document Find / TMP -User B1234567 -Print belongs to the document Find. -Name '* .c' -EXEC RM {of B1234567 under / TMP } Delete all .c file Find. -Name test / * -print Display the current directory and its subdirectories file name before 4 digits TEST file name

13.vi Editor Command Status: J, K, H, L: Up and down left and right 0: Line 1 $: Row I, I: Insert Command, I Insert the i-line head inserted in the current cursor, A: Add command, A After the current cursor, A add o, o: Open the command, o opens a line in the current line, o Insert a row R, R: replace command, R replace the current cursor, R: R: R: Rode, R Replace the current cursor character, R from the cursor Start replacement number S: Replace the specified quantity character x: Delete the cursor Character DD: Delete the current row D0: Delete the cursor half row D $: Delete the cursor half a line Ctrl f: Turn pages Ctrl B: front page G : File tail number g: Digitally specified line / string lookup string n Continue to find N reverse continuation Find% Look Correspondence U Cancel The EX Command Status: SET NUMBER Display Brand: SET SMD Display Status: 0 file First: 1, 5 COPY 7 copies: 1, 5 DEL block delete: 1, 5 Move 7 mobile: 1, $ s / string1 / string2 / g full file lookup string1 and replace String2: WQ! Deployment

(2) Enhanced Command 1. LN Document Connection Command Format: ln -s OldName NewName (HARD LINK) The same document can have more than one name, you can make a number of documents. Example: ln -s file1 file2 will name File2 Connect to the document file1. 2.GREP Search String Command Format: GREP STRING FileName

Looking for a string, there are many ways. For example, I want to find all the best in M. This must introduce Pattern's concept. Here are some simple □ examples, and description:

^ M starts in m, ^ indicates that the mean of M is M $ is ended in M, and the meaning of the end is the end of the meaning ^ [0-9] starts with the number, [] can list the letter ^ [124Ab] to 1 , 2, 4, a, or b starting line ^ B.503 Status represents either letter * asterisk indicates that more than 0 letters (no) plus sign indicates more than one letter /. The slash can remove special Significance CAT passwd | grep ^ B lists the university department has an application account number list cat passwd | grep ^ S lists the exchange student application account number list Cat Passwd | Grep '^ B.503' Lists the motor system. .. grep '^ /.' myfile.txt lists all rows that start at the beginning 3.FGREP Search String Command Format: FGRep String File 4.File Display File Type Command Format: File FileAl File Type Shell Script, ELF 32bit Different content command formats of ASCII TEXT, DATA or TAR FILE 5.DIFF Compare Documents or Directory: DIFF [-r] Name1 Name2 (Name1 Name2 can be mataly named, or directory name.) Example:% Diff file1 file2 comparison document File1 and file2, each line is different.% DIFF -R DIR1 DIR2 comparison directory DIR1 and DIR2, the different places of documents. 6.cmp comparative document The same partial command format: CMP file1 file2

7.FTP Remote File Transfer Command Format: FTP [Hostname | IP Address] After entering the ftp, if it is connected to the Remote Host, it will ask you UserName and password, if you enter a pair, you can start document transmission. Note : If the user has no password, it cannot be registered (1) FTP command ASCII Set the transfer mode to ASCII mode. Usually used to transfer text files. Binary set the transfer mode to binary mode, usually used to transfer the execution unit, compressive file and video file Wait. CD Remote-Directory changes the working directory on the remote host. LCD [Directory] Changes the working directory of the local host. LS [Remote-Directory] [local-file] lists the documentation on the remote host. Get Remote-file [ Local-file] MGET Remote-Files You can use a general-purpose character to get multiple documents at a time. Put local-file [remote-file] Send the document of the local host to the remote host. MPUT LOCAL-FILES can use universal The character places multiple documents on the remote host. Help [Command] Online Auxiliary Directive. Mkdir Directory-Name creates a directory at the remote host. Prompt changes the conversation mode, if ON is in MPUT and MGET When the transfer of documents will ask. Quit / Bye leaving FTP. (2) Operation FTP 1. First, put the instructions used in the process in order in order, as follows:% cat ftp_command! Mkdir test LCD Test CD Test Prompt Binary mget *. * BYE 2. Second, build a .NETRC file, attribute is 400, let FTP automatically read UserName and Password, the host, the host, the host, as follows:% Cat .Netrc Machine Remote login Anonymous Password Guest 3. Finally, execute the following instructions.% NOHUP FTP Remote Message & 8.Telnet Remote Terminal Access Command Format: Telnet [Hostname | IP Address]

9. IO Re-directed UNIX All program execution, all require information input and output information. In general, the information is input from the keyboard, and the data is output to the screen, which is called standard input and standard output, and we You can change the standard output. A. Change standard input - Add "" in the command, you can enter information from . B. Change the standard output - add "in the command"> < FileName> ", you can guide the data output to the . C. Change the standard output - add" >> "in the command, the function is similar, but this will Data is added behind the document. D. Pipe - add '|' in the middle of the two commands, you can use the output of the front instruction as a rear instruction

D. Pipe - Add '|' in the middle of the two commands, the output of the front instruction can be used as the input of the rear instruction.

转载请注明原文地址:https://www.9cbs.com/read-94244.html

New Post(0)