Unix operating commands

Source: Internet
Author: User
Tags file copy uncompress ftp hostname
 
  

Unix operating commands

Pan lei, Institute of Theoretical Physics, Chinese Emy of Sciences

Chapter 1 logon and exit

Before you log on, you must first apply for a user registration name from the system administrator. No matter which computer the user logs on to itpnet, the user will access the same file system. 1.1 When a login prompt appears on the screen, you can enter your User Registration Name and press Enter. If you have a password, the system prompts the user to enter the password and press the Enter key. After the password is entered correctly, the user logs on successfully. At this time, some information and command prompts are displayed on the screen. For example, login: Guest [enter] passwd: ****** [enter] sun % note: the user name must be input in lowercase letters, and Unix systems are case-sensitive. 1.2 Exit: when you are about to exit your computer account, enter logout or exit or press [Ctrl-D] in the system prompt. When login appears on the screen, the user can safely leave the computer. For example, Sun % logout [enter] login: 1.3 modify the password to prevent others from using your account. After you log on for the first time, use the passwd command to change the password that only you know, the password is usually composed of 6 to 8 letters and numbers. For example, Sun % passwd [enter] Old passwd: ****** new passwd: ******* retype new passwd: ****** note: when you log out of the system and log on again, you must use a new password.

Chapter 2 Directory operation commands

2.1 display directory command: Pwd (print working directory) Format: Pwd function: displays the full path name of the user's current working directory. For example: % pwd2.2 create directory command: mkdir (make directory) Format: mkdir directory_name function: Create a new directory for example: % mkdir directory2.3 Change directory command: Cd (Change directory) format: CD directory_name function: change the current working directory. Note: The directory name options include: (1) directory name, and go to the subdirectory under the current directory. (2) .. indicates to go to the parent directory of the current directory. (3)/indicates to go to the root directory. (4) If there is no option, go to the user's home directory. For example: % Cd directory2.4 Delete directory command: rmdir (remove directory) Format: rmdir directory_name function: delete sub-directory names that do not exist. Note: (1) When deleting a sub-directory, the deleted directory must not contain any files or sub-directories; otherwise, the sub-directories cannot be deleted. (2) If the deleted directory contains files or subdirectories, see the command Rm-r directory_name. Example: % rmdir directory

Chapter 3 file operation commands

3.1 run the "ls (list)" command to list file directories. Format: ls [Option] directory_name: Used to list file names and subdirectory names in a specified directory. If no sub-directory name exists, list the file names and sub-directory names in the current directory. Option:-A lists all files, including hidden files starting with a vertex. -L list file names in long format, including file type identifiers, permissions, number of links, file Master name, file group name, number of bytes, and date. -R lists all files in sub-directories.-G indicates the user group ID in the long format. -T sort the generation Date of the security file. For example: % ls-La 3.2 command for displaying file content: CAT (catenae) Format: CAT filename function: displays the file content. Note: When the file content is displayed on the screen, press Ctrl + S to pause the screen and press Ctrl + Q to continue display. For example: % cat filename 3.3 command to display file content on screen: More format: More filename function: display file content on screen by screen option: Comment: the function key is displayed on the screen. The Space key continues the output of the next screen; the Enter key looks at the output of the next line; the Q key jumps out of the more state;/the string returns to the previous screen where the string is located; and The a key returns to the previous screen. For example: % more filename3.4 file content display by PAGE command: PG (PAGE) Format: PG [Option] filename function: Display by page the content of the specified file. When a page of files is displayed, the last line displays the waiting user input command. You can enter the following commands. Option: H displays the help commands that can be used in the PG command. Q: exit the PG command. [Return] displays the next page. 1. display the next [space] Page of the text. d/[Ctrl-D]: Scroll the screen to the half screen. N displays the next file described in PG command line. P displays the previous file described in PG command line. % Display the first page of the current page of the body. /Pattern searches forward for the specified character pattern in the file.? Pattern searches for the specified character pattern in the file. Note: When the PG command is displayed at the end of the file, an end of file (EOF file) is displayed ). For example: % PG filename3.5 command for reading files: view format: View filename function: only file content can be read. Note: This command cannot write the read source file. If you modify the original file, run the ": W newfilename" command to write the modified file to the new file. For example: % view filename3.6 display file header command: Head format: head [Option] filename function: display file header option: by default, the first 10 lines of the file are displayed. -I: displays the start line of the file. For example: % head filename3.7 command for displaying the end of a file: tail format: tail [Option] filename function: display the end of a file option: the last 10 lines of the file are displayed by default. -I: displays the last line of the file. + I is displayed from row I of the file. For example: % tail filename3.8: display formatted file content command: Pr (print) Format: Pr filename function: display formatted file content on the screen, that is, 66 lines of text files are printed on each page, including the header of five lines and the end of five lines. The page header contains two blank lines, one line containing the time, file name, and page number of the file, and the other two blank lines. There are five blank lines at the end of the page. For example: % PR filename3.9 file copy command: CP (copy) Format: CP [Option] filename1 filename2 CP [Option] filename... directory CP-r directory1 directon2 function: Copy all the content of a file to another file, or copy one or more files to another directory. Option:-I copy the file as prompted. -P: copy the original file. -R copies all files in the subdirectory. Note: When filename1 is copied to filename2, if filename2 already exists, the content of filename2 will be overwritten by filename1. For example: % CP filename1 filename23.10 command for moving a file or renaming a file: MV (MOVE) Format: MV filename1 filename2 MV filename... direction MV dire1 1 direction2 function: Change the name of a file or directory, or move some files to another directory. Note: When filename1 is renamed to filename2, if filename2 already exists, the content of filename2 will be overwritten by filename1, for example, % MV filename1 filename23.11. The file deletion command is in RM (remove) format: rm filename Rm-r ction: delete a specified file or a file in a directory. Note: When the-r option is used, the files used in the specified directory, including the directory name, will be deleted. For example: % RM filename3.12 link file command: ln (Link) Format: ln [Option] filename linkname ln [Option] directory pathname function: Creates a chain for a file or directory. Filename and directory are the source file name and source directory name. linkname and pathname indicate the files or directories linked to the source file or source directory name respectively. Option:-s creates a symbolic link for a file or directory. Note: The purpose of the link is to assign more than two names to a file or directory so that they can appear in different directories, which can share files or directories, it can also save disk space. Example: % ln-s filename linkname3.13 command for changing file read permission: chmod (Change Mode) format: chmod {u | G | o | A} {+ |-| =}{ R | w | x} filename chmod [who] [op] [mode] Directory function: change the read/write and execution permissions of a file. The signed method and the octal digit method. Option: (1) Symbolic method: U (User) indicates the user himself. G (Group) indicates the same group of users. O (oher) indicates other users. A (all) indicates all users. + Permission granted to a specified user. -Cancels the permission granted to a specified user. = Grant the permitted permissions to the file. R (read) indicates that the content of the file or directory can be copied. W (write) Write Permission indicates that the content of the file or directory can be modified. X (execute) indicates that you can execute the file or enter the directory. (2) octal digit method: This method uses three octal digits as the option. Each digit indicates the permissions of the user himself, the user in the same group, and other users, 4 (100) indicates readable. 2 (010) indicates writable. 1 (001) indicates executable. Note: For example, % chmod A + RX filename allows all users to read and execute file filename. % Chmod go-Rx filename cancels the read and execute file filename permissions for the same group and other users. % Chmod 741 filename allows you to read and write files, read files from the same group of users, and execute files from other users. 3.14 command for changing File Ownership: chown (change owner) Format: chown username filename chown-r username directory function: Change the ownership of a file or directory. Option:-r changes the owner of all files and directories in the directory. Note: Only the file owner and superuser can change the ownership of the file. For example: % chown username filename3.15 file search command: Find format: Find pathname [Option] Expression Function: Find a file that matches the expression under the given path. Option:-name indicates the file name-User username. Select the file-group name to which the user belongs, select files belonging to this user group-mtime n select files modified in N days-newer fn select file notes modified later than the file name FN: for example: % find. -name '* ABC *'-print3.16: Match character command in search file: grep format: grep [Option] pattern filenames function: searches the specified file or standard input row by row, and each line in the matching mode is displayed. Option:-V find out the row with Mode Mismatch-C count the number of matched rows-n show the comment for each row of the matching mode: for example: % PS-Aux | grep r3.17 compare different commands in the file: diff (difference) Format: Diff filename1 filename2 function: display the differences between the two files. Option: annotation: for example: % Diff file1 file23.18 comparison file command: CMP (compare) Format: CMP [-L] [-S] filename1 filename2 function: option for displaying and comparing different information of two files:-l the number of bytes of the two files-S does not show the different parts of the two files, and the comparison result comment is given: for example: % CMP file1 file23.19 command for comparing files in common: comm (common) Format: comm [-123] filename1 filename2 function: select or reject the common line option for comparing two files: -1: No 1st columns-2: No 2nd columns-3: No 3rd column comments: output three columns. The first column indicates the rows that appear in file1, the second column indicates the row that appears in file2, and the third column indicates the row that appears together in file1 and file2. For example: % comm file1 file23.20 sorting FILE command: Sort format: Sort [Option] filename function: sort the specified file as required option: -R sort by letter in reverse order-N sort by number value in reverse order from smile to big-r sort by current sort rule in reverse order-F sort by case-insensitive-D sort by typical order comment: the options are sorted in ASCII order, for example, % sort-Nr file3.21. The compressed file command: compress format: compress [Option] filename function: compressed files. Option:-F force compression-V compression display compression percentage Note: For example: % comproess files3.22 uncompress FILE command: uncompress zcat format: compress [Option] filename zcat filename function: expand or display the compressed file. Option:-C does not change the file to the standard output. Note: The zcat command is equivalent to uncompress-C for example: % uncomproess files. z3.23 command for displaying file types: File Format: file filename... function: determines the file type based on the file content, such as text, ASCII, C, executable, and core. Option: Comment: for example, % file * 3.24 command for creating an archive: Tar (tape archive) Format: Tar [Option] tarfile filename function: Create an archive or read an archive file. Option:-C create a new archive file-x read the file from the archive file-V displays the information for processing the file-F specifies the archive file name, note: % tar CVF tarfile. % tar xvf tarfile % tar tvf tarfile3.25 tape copy command: dd format: dd [option = value] function: use a tape drive to convert or copy files. Option: If = Name: Specify the input file name of = Name. Specify the output file name IBS = n. specify the size of the input file block to n Bytes (default: 512 bytes) obs = n specifies that the size of the output file block is n Bytes (default: 512 bytes). Note: For example: % dd If = filename of =/dev/RMT/0% dd If =/dev/RMT/0 of = filename IBS = 10243.26 Modify file date command: Touch format: Touch filenae function: change the file date. do not modify the file content. If the file does not exist, create a new file. Option: Comment: for example, % Touch file3.27 word count command: WC (word characters) Format: WC [Option] filename function: count the number of lines, words, and characters in the file. Option:-l number of rows in the statistics file-W number of words in the statistics file-C number of characters in the statistics file note: if the default file name is used, the standard input is % WC file3.28. Check the spelling command: spell (spelling) Format: Spell [Option] filename... function: check spelling errors in files option:-B spell by UK check-V show words literally not in the spell dictionary-x show every possible reasonable root comment: for example: % spell File

Chapter 4 State Information commands

4.1 Display the currently registered user command: W format: W [Option] [username] function: displays the user name, registration time, and command currently being executed by the system. Option:-H does not show start line-s display in short format-l display in long format (default setting) Note: For example: % w4.2 shows who logged on to the machine command: who format: Who function: Display All usernames in the system currently, using the terminal device number, registration time. For example, % who4.3 shows the user name command on the current terminal: whoami format: whoami function: displays the user on the current terminal. For example: % whoami4.4 determine the command location command: whereis format: whereis command function: determine the location of a command's binary line code, source code, and online manual. Option: Note: for example, % whereis ls4.5 command for querying Non-Standard Commands: which format: Which command function: Find Non-Standard Commands, that is, using aliases or commands other than standard command sets in the system. Option: Note: For example: % which ls4.6 display date command: Date Format: Date function: display or set date and time. Option: Note: Only the super user has the right to set the date. For example: % date4.7 "display Calendar" command: Cal (calendar AR) Format: Cal [month] year function: display the calendar option specified in a year: Note: Example: % Cal 19984.8 calculation command execution time command: Time Format: time [command] function: time used by a computing program or command during execution. Option: Note: The calculated time is: real is the total time for the command to reside in the system, user is the CPU time consumed by the command, and sys is the time consumed by the command I/O. For example: % time myprog4.9 account query command: acseek (Account seek) Format: acseek [-d n] [-M usersname] function: Query user accounts for this month. Option:-d n-M username Note: If no option is available, the current month's bill is displayed. For example: % acseek4.10 command for displaying user IDs: Id format: Id [Option] [user] function: Display user IDs and all groups to which users belong. Option:-A: displays the user name, user ID, and all Group notes of the user. For example, % ID username4.11: displays the host identity. Command: hostid format: hostid function: displays the unique identity of the host, is used to limit the permission to use the software and cannot be changed. Option: Note: For example: % hostid4.12 show host name command: Hostname format: Hostname function: show or set host name. Option: Note: Only the Super User can set the host name. For example: % hostname4.13 display process command: PS format: PS [Option] function: Display process information in the system. Including process ID, control process terminal, execution time, and command. Option:-A lists information about all processes in the current system-l displays a long list-e displays information about each running process-F displays a complete list comment: for example: % PS-ef4.14: Display Disk Space Command: DF (Disk Free) Format: DF [Option] function: Display disk space usage, including the directory name, block device name, Total Bytes, used bytes, and percentage of remaining bytes installed on the file system. Option:-I display used and unused bytes-K display disk space usage information note: for example: % DF-k4.15 display file Disk Space Command: Du (disk usage) format: du [Option] [filename] function: display the disk space occupied by a directory or file option:-A displays the size of all files-s displays the disk size occupied by a specified directory. Note: For example: % du4.16 display disk space limit command: Quota format: Quota-V [username] function: displays the user's disk space limit and usage. The quota and number of used disk space, the number of nodes allowed to be created and the number of nodes used. Option:-V view the disk space in the system. Note: Only the Super User can display the usage of any user. You can use the edquota command to modify the disk space. For example: % quota-v4.17 Display Terminal Option command: stty format: stty [Option] function: display or set any terminal options. Option:-A display all settings-G display current settings Note: For example: % stty-a4.18 display terminal name command: tty format: tty function: Display Terminal name option: Note: example: % tty4.19 recall command: History format: history function: Help the user recall the executed command. Option: Note: for example, % history4.20 online help manual command: Man (manual) Format: Man command_name function: displays the reference manual and provides online help information. Option: Comment:-K query related commands by keyword, for example, % man tar4.21 alias creation command: alias format: alias newname function: you can rename frequently-used commands with the names you prefer. Option: Note: for example, % alias dir 'LS-F'

Chapter 5 network commands

5.1 network address display command: ARP format: ARP hostname function: displays the remote host name, IP address, and hardware address currently accessed by the system. Option:-A Comment: for example: % ARP-A5.2 Display User Information command: Finger format: Finger username function: display online user machine usage, this includes the User Logon Time and the last registration record. Option: Comment: for example: % finger username5.3 online dialog command: talk format: Talk username function: chat with another user online. Option: Note: During a dialog, the system divides the terminal into the upper and lower parts. The upper half displays the information you typed, and the lower half displays the information you typed. Type delete or Ctrl + C to end the dialog. For example: % talk username5.4 allow or reject the message command: mesg (Message) Format: mesg [N/y] function: Allow or deny other users to send information to their terminals. Option: N deny other users to write information to their terminals y allow other users to write information to their terminals (default value) Note: For example: % mesg n5.5 write information to other users. Command: Write format: Write username [ttyname] function: write information to terminals of other users. Option: Note: if the recipient does not refuse, the dual-user can talk. Type EOF or Ctrl + C to end the conversation. For example: Write username5.6 test network command: Ping format: Ping hostname function: Send ICMP echo request packet to the host on the network to check whether the network is smooth. Option: Note: available IP addresses of the tested host names. When the packet loss rate is (100% packet loss), the current network is disconnected. Example: % Ping hostsname5.7 remote shell command: RSH (Remote Shell) Format: RSH hostsname command function: execute remote host shell command on a local machine. Option: Note: For example: % RSH hostname who5.8 remote Beibei FILE command: RCP (Remote copy) Format: RCP [-R] File newfile function: Copy files on the remote host. Option:-r copy directory comment: for example: % RCP hostname:/tmp/file. 5.9 Remote Registration command: rlogin (remote login) Format: rlogin hostname [-l username] function: register on the remote host. Option:-l username register to another user Note: You must have a user password to register. Example: % rlogin hostname5.10 remote logon command: Telnet format: Telnet hostname function: remote login to other hosts on the Internet. Option: Note: different operating systems are supported. For example: % telnet bbs.tsinghua.edu. cn5.11 file transfer command: FTP (file transfer program) Format: ftp hostname function: Network File Transfer and remote operations. Option: FTP command :? /Help FTP online help open hostname open developed remote machine CD [dirname] Enter remote machine directory LCD [dirname] set local machine directory DIR/ls display remote directory file binary transmit get/mget in binary mode to get one or more files from the remote machine put/mput to send one or more files to the remote machine prompt interaction when opening or disabling multiple file transfers prompt close to close the connection to the remote machine quit to exit ftp. Note: for example: % FTP hostname5.12 shows the route command to the network host: Traceroute format: Traceroute hostname function: displays the route and time when the local machine arrived at a network host. Option: Comment: for example, % traceroute hostname

Chapter 6 mail commands

6.1 send or receive email command: Mail/mail/mailx format: Mail username (send) Mail [Option] (accept) function: send or receive emails to online users. Option:-r mails are sorted in the FIFO order. By default, the mail is sorted in the FIFO order. After Q is interrupted, the Mail content is not changed.-P indicates that each mail is displayed, and the prompt message is not displayed.-F reads the mail comment from the mail format file: MAIL command :? Show mail HELP command H mail Title List P show current mail n show next mail R [uers] to the sender or user reply s Save the mail to the file, save the title information W. Write the email to the file. Do not save the title information d [N] Delete the current email or the nth mail Q. Save the undeleted email to the mbox file, and exit mail X. Do not modify all emails. Exit mail such as % mail-s "subjet... "username <messages6.2: display the Message Queue command: mailq format: mailq function: view the queue status of sending or receiving emails. Option: Note: This command is generally used when the system or network is different. For example: % mailq6.3 mail operation command: pine format: pine function: a program that operates on your own mail. Option: Note: this operation is performed under the menu prompt. Example: % pine

Chapter 7 run program commands

7.1 Execute Command by Time: AT/batch format: At [Option] [time] [data] function: Execute Command or command file at specified time. Option:-r cancels a job submitted with the AT command.-l displays the status and number of all jobs submitted with the AT command. Note: For example: at 0030 Jan 20 myfile7.2 Parameters Back to the standard output command: Echo format: Echo [-N] [arguments] function: the parameter is the string to the standard output is the display option: -N do not send line breaks to the standard output. Note: For example: Echo * 7.3 copy to file command: Tee format: Tee [Option] filename function: Copy to file at the same time as the standard output option: -A is appended to the file when output-I ignore the interrupt Note: For example: % Who | tee file7.4 give the program priority command: Nice format: Nice [-N] command function: run programs or commands with a low priority. Option:-N priority 0-20 from high to low note: for example: Nice-5 progame7.5 stop process command: Kill format: Kill [Option] PID function: sends a signal to the specified process or terminates the process. Option:-9 Force Process Termination-17 process suspension-19 process suspension activation Note: PID indicates the process number, which can be obtained by the ps command. For example: % kill-9 pid7.6 process sleep command: Sleep format: Sleep time function: Make the currently executing process sleep within the specified time. Option: Note: Time indicates the time in seconds that the process will sleep. Example: % Sleep time7.7 display job status command: Jobs format: jobs [-L] function: display the status of the current job option:-l long list display job status, including the owner, job number, terminal, and status. Note: When the job status is +, it indicates the recently stopped job,-indicates the previous job, Exit 1 indicates the exited job, and job # done indicates the completed job. For example, % jobs7.8 foreground job command: FG format: FG job # function: transfers a job with a specified job number to the foreground for running. Job # indicates the job number. Option: Note: For example: % FG job #7.9 background job command: BG/& format: BG job # command & function: Push the job or command with the specified job number to the background for running. Option: Note: For example: % BG job #7.10 pending job command: Stop format: Stop job # function: suspends the background job with the specified job number. option: Comment: for example: % stop job #

Chapter 8 program compilation and execution commands

8.1 C program compilation command: CC format: CC [Option] filename function: compile or link a specified C file. Option:-O specifies the output file name. The default value is. out-C is only compiled and generated. o's target file-G generates the execution file for the symbolic test-LM to connect to the CC Math Library-O for general code optimization-O2 secondary optimization note: C compiler Reference Manual available command man CC view. For example: % CC-O test. c8.2 C ++ program compilation command: CC format: CC [Option] filename function: compile or link the specified C ++ file. Option: Same as C compilation option. Note: The C ++ compiler reference manual can be viewed by man CC. Example: % CC-O2 test. cc8.3 FORTRAN77 program compilation command: f77 format: f77 [Option] filename function: compile or link the specified Fortran file option:-O specifies the output file name. The default value is. out-C is only compiled and generated. o's target file-G generates the execution file for the symbol test-O0 does not perform code optimization-O1 as soon as possible code optimization-O2 level 2 Optimization-O3 level 3 optimization notes: FORTRAN77 compiler Reference Manual available command man f77 View Example: % f77-C test. f8.4 FORTRAN90 program compilation command: f90 format: f90 [Option] filename function: compile or link the specified FORTRAN90 file option: Same as FORTRAN77 compilation option note: FORTRAN90 compiler Reference Manual available command man f90 View Example: % f90-o test. f8.5 GNU Program Command for sequential Compilation: GCC (gnu c) g ++/C ++ (gnu c ++) G77 (GNU FORTRAN77) format: GCC [Option] filename g ++ [Option] filename G77 [Option] filename function: compile or link the specified compilation file. Option:-O specifies the output file name. The default value is. out-C is only compiled and generated. O target file-O General Optimization of Code-O2 secondary optimization note: the GNU Compiler reference manual can be viewed under the info menu in Emacs. Example: % gcc-O test. c8.6 run file format: A. Out filename function: the source program is compiled to generate the target code file, put it in the. out file or specify the output file name.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.