Unix common instructions

xiaoxiao2021-03-06  57

LS

This is the most basic archive instruction. The meaning of LS is "List", which is to put a directory or

The content of a certain file is displayed. If you are not followed by any file behind the LS command, it will show all the files in the current directory. You can also add the name of the directory name or file to be viewed behind LS, such as

% LS / ETC

Ls have some special parameters, you can give users more information, as follows:

-a: If a directory or file name is "in Unix". ", use LS.

Will not show the name of this file, we call this file as a hidden file. Such as TCSH's initial settings .tcshrc; if we want to see such files, you must add parameters -a.

-l: This parameter represents long (long) format using LS, you can display more information, such as file access, file owner (Owner), file size, file last update date, even Symbolic Link files is LINK That file, etc. as follows

% ls -l

2. CP

The meaning of the CP is to replicate ("copy"), that is, copy one or more files into another file or copy it to another directory.

-i: This parameter is when the file has been named F2, if you use the CP, you will use the CP.

The content covers the past, so you must ask the user before you have to cover it. Asser

The answer is Y (YES) to perform the actions of the copy.

-r: This parameter is used to make a replication, you can copy a whole tree to another.

Directory.

3. MV

The meaning of MV is Move, mainly to change the file to another directory. As with CP, it also

Three formats:

There are two, -f and -i parameters, -f and -i, where the meaning of -i is the same as the CP, all Interactive

Inquiry. And -f is forced (forced), no matter whether there is a file with the same name, I just want it anyway.

Move it, all other parameters encounter -f will fail.

4. RM

The meaning of RM is remove, which is used to kill an instruction of a file. In Unix

The file killed is unless the system has just made backups, otherwise it is unable to save it like DOS.

Come. So when doing RM actions, users should be particularly careful.

-f: The system will make any warning messages when the system is deleted.

-i: You will ask if you want to remove it before removing the file.

-r: Removal deletion.

5. mkdir

MKDir is a directive that allows users to create a directory. You can use it under a directory

MIDIR builds a subdirectory, don't say more, use it!

6. ChDIR (CD)

This is to let the user used to transfer the work catalog.

Chdir Dirname

So you can transfer the current directory to DIRNAME. Or use "chdir .." to transfer to the previous layer directory.

7. RMDir

RMDIR is used to kill an "empty" directory relative to MKDIR. If there is no file below a directory, you can remove it with the RMDIR instruction. The RMDir's usage is as follows:

Rmdir dirname1 [dirname2 ....]]

If there are other files under a directory, RMDIR will not be able to kill this directory unless the RM directive is using the -R option.

8. PWD

PWD will display the path (PATH) of the current directory, for example:

9. Cat / more / less

The above three instructions are instructions to view the contents of the file. Cat's meaning is cat .... No, CONCATENATE, in the Dictionary meaning "link, smashed" (language electronic dictionary cdict), is actually displaying the contents of the file meaning. Cat has a lot of strange parameters, which is often used by the -n parameters, which is to add the displayed content. The use of CAT is as follows: CAT [-n]: Self-standard input reading, you can use PIPE to turn other programs

Give CAT.

Cat [-n] filename: Read the contents of the filename, displayed on the standard output. The problem is that CAT is not stopped, so it is not easy to use (if a screen is twenty-four lines, and a file is 400 lines, Cat will come out, it will be rolled up, the user is very It is difficult to get the information they need. So someone wrote more more.

More, you can display the observed files to the form of the terminal of the terminal, and then change the page or row according to the user's request. If the user wants to search for a specific string in a certain file, press / and then follow the words to be searched to search. More can also be found. The usage method is as follows:

More filename

If you feel that some part you want, you can use 'Q' to leave more. Press 'V' in use or you can use the editor to edit the viewed file. The usage of Less is similar to more. It was originally designed to make up for more than the shortcomings of the pages. The usage is as follows:

Less filename

It is different from more that it can be rolled up by Y, and can you use "?" To search for the words you have to find.

10. chmod

CHMOD is the change mode. This instruction is used to change the access mode of the file. On a file of UNIX (R), writable (W) can be performed (X), respectively, with the owner of the file, the group member (you can ls -lg Watch the group of a certain file, and others. A file If you change to an executable mode, the system will treat it as an executable file, and a directory executable represents the user's right to enter the directory. Chmod is used to change the model of some files, which is as follows:

Chmod [-fr] mode filename ...

The significance of its parameters is as follows:

-f force. Chmod will not pay the failure.

-R Recurive. All subdirectories and files under all subtrands will be changed to the mode you have to change.

MODE can be a three or four-digit eight-in number to represent the access to certain objects. For details, please refer to the explanation of Absolute Modes in the Manual Page of CHMOD (1). Or use a string to indicate, please refer to CHMOD (1).

b. About Process processing instructions:

PS

PS is used to display the status of your Process or System Processes.

The following list is listed below:

The options are described below:

-A lists the process situation including other users.

-u Displays the User - Oriented Process situation.

-x Display includes a process situation without Terminal control.

-W Use a wide display mode to display the process situation.

We can achieve the status of the current processes, such as PID, Running State, etc. via PS.

2. Kill

The use of the Kill Directive is to send a signal to a certain process. Because most of them are sent

Used to kill Process Sigkill or Sighup, it is called Kill. Kill's usage is:

Kill [-signal] PID ...

Kill -l

Signal is a Singal number, from 0 to 31, where 9 is Sigkill, that is, one

It is used to kill some signals that cannot be normal Terminate. The use of its 讯 号 s s s ec (2)

Description of Signal in Signal.

You can also look at the number of words that can replace the Signal number with Kill -L. Detailed situation of Kill

See Man Kill.

c. Quality of string processing:

Echo

Echo is used to display a string on the terminal. □ Echo -n is the action that does not have a jump after it is displayed.

2. GREP / FGREP

GREP is a filter, which can be filtered out of one or more files, or a row with a string, or

Filtering a row with a string is filtered from standard input.

FGREP can put a group of strings that want to filter in a certain file, then use the FGRep will contain

Rows that belong to this group of strings are filtered out.

The usage of GREP and FGREP is as follows:

GREP [-nv] match_pattern file1 file2 ....

FGREP [-nv] -f pattern_file file1 file2 ....

-n lists the rows found before the line is listed.

-V puts the row that does not contain match_pattern

Match_pattern to search the string to search

-f in Pattern_File stores the string to search for

d. Instructions for query status on the network:

MAN

MAN is the meaning of manual. UNIX provides the function of On-line Help,

MAN is used to let users query instructions, system calls, standard program libraries, various tables

The use of the grid is used. The use of Man is as follows:

MAN [-M path] [section] title] .....

MAN [-M Path] -k keyword ...

The path to the Manual Database required by the -M path Man.

We can also replace the -m option with the way to set the environment variable MANPATH.

Title This is the goal to query.

Section represents the classification of Manual for a number, usually 1 represents executable instructions,

2 Representative System Call, 3 represents standard functions, and so on.

If we want to refer to EQNCHAR (7), we enter man 7 eqnchar,

You can get the auxiliary message we want.

-k Keyword

It is used to list Title containing this keyword.

MAN is a very important instruction on UNIX. We use the usage only one of this lecture only one of the more common usage and a simple description, and the truly detailed usage and instructions should be required to use Man to get.

2. WHO

The WHO directive is used to query those people now.

3. w

The W command is used to query the people currently online, and the current work is displayed.

4. Ku

Ku can be used to search for User on the entire network, unlike WHO just for Local Host queries. And KU provides the user to establish a list of search-specific users. You can build a file information-file to store your friend's information, and then build a file hosts-file to specify the machine name of the search. The ku's instruction format can be obtained from Ku -h.

E. Network Directive:

Unix provides a connection to the network, making you do some special things on each of the machines, such as you can do graphics on the Iris graphics workstation in the line, read news on the Sun, even to school The meter is going to find a classmate Talk. These work can utilize UNIX's network instructions to connect to each different machine on your position. In this way, even if you are in the bedroom, you can work easily oriented in the system, you don't have to bubble in cold ice. The instructions of these networks are as follows:

Rlogin and RSH

The meaning of Rlogin is Remote Login, which is to go to another machine Login via the Internet.

Rlogin's format is:

Rlogin Host [-l username]

Options -l username is the option you must enter when you are different from the username and local host on the remote machine, otherwise Rlogin will assume that you are the same as localhost over there, and then inevitably in the first login An error will occur.

RSH is to perform some instructions on the remote machine, and turn the result back the result. RSH format

as follows:

RSH host [-l username] [Command]

Like the parameters of rlogin - L Username, RSH - L Username also specifies the UserName of Remote Host. COMMAND is the instruction to be executed on the Remote Host. If there is no Command specified, RSH will execute rlogin, just in direct Rlogin.

However, RSH will not ask you Password like a normal login program while executing, but if you don't set Trust Table, Remote Host will not accept your request.

RSH is required to set a file on each machine that may be used as Remote Host, called .rhosts. Each line of this file is divided into two parts, the first is to allow Login's hostname, and the second part is to allow login's UserName. For example, in ccsun7.csie.nctu.edu.tw, your username is Qiangge, and your home is below. Rhost has the following line:

CCSUN6.cc.nctu.edu.tw u8217529

The User U8217529 on the ccsun6.cc.nctu.edu.tw machine can perform the RSH program with the following method:

% rsh ccsun7.csie.nctu.edu.tw -l ysjuang cat mbox

The Mbox file content on ccsun7.csie.nctu.edu.tw is displayed on the local host ccsun6.cc.nctu.edu.tw.

And if .rhost has such a line, USER U8217529 on ccsun6.cc.nctu.edu.tw

Will be able to directly via RSH or RLogin login without entering password

CCSUN7.CSIE.NCTU.EDU.TW.

note:

.rhost is a table that sets the people who can trust, so if the setting is improper, it will make the idos ones have the opportunity to take the system. If you read Man 5 rhosts, you will find that you can use to replace any hostname in the first column, and use to replace any username in the second column.

For example, user likes to use " username" to replace the column long strings Hostname, but this will make the User running Unix, you can get your Trust to invade your system. . This is easily dangerous in system security. So this department wrote your .rhost file in the way in this way, if discovered to stop until the center of the staff will correct it. Similarly, if your second field is , such as "Hostname ", you are allowed to enter your account with "all" users allowed to enter the password, it is more Dangerous behavior. So please be careful.

2. Telnet

Telnet is a User connected to Remote Host.

The format of Telnet is as follows:

Telnet [Hostname | ip-address] [port]

Hostname is a Name Address like ccsun1 or ccsun1.cc.nctu.edu.tw, IP-Address is an IP address consisting of four less than 255 numbers, such as ccsun1 IP-Address is 140.113.17.173, ccsun1 .cc.nctu.edu.tw 's IP-AddRess is 140.113.4.11. You can connect to CCSUN1 using Telnet CCSUN1 or Telnet 140.113.17.173.

Port for some special programs to give the outside world, such as the MUD of the system, providing some port to the MUT of the MUT by these ports. See Telnet (1) for details.

3. FTP

The meaning of ftp is File Transfer Program, which is a very common application of online file transmission.

Program. The FTP format is as follows:

FTP [Hostname | ip-address]

Where Hostname | IP-Address is the same as Telnet.

After entering the FTP, if it is connected to the Remote Host, it will ask you UserName and password. If the input is correct, you can start file transfer.

There are many commands in FTP. For details, please refer to FTP (1), here only listed more common CD, LCD, MKDir, PUT, MPUT, GET, MGET, BINARY, ASCII, PROMPT, HELP and Quit Use way.

ASCII sets the transmission mode to ASCII mode. Usually used to transfer text files.

Binary sets the transmission mode to a binary mode, usually used to transfer the execution file, the compressed file, and the image form.

CD Remote-Directory changes the work directory on the Remote Host.

LCD [Directory] Changes the working directory of Local Host.

LS [Remote-Directory] [local-file] lists the files on the Remote Host.

Get Remote-file [local-file] achieves a distant file.

MGET Remote-Files can use a general-purpose character to get multiple files at a time.

Put local-file [remote-file] Sending the file of Local Host to Remote Host.

MPUT LOCAL-FILES You can use a general-purpose character to put multiple files on Remote Host once.

Help [Command] Online Auxiliary Directive.

MKDir Directory-name creates a directory in Remote Host.

PROMPT changes the conversation mode. If ON is in the MPUT and MGET, each time a file is transmitted. Quit / Bye leaves FTP.

With FTP, we can transfer the required information on different machines. Some special machines store large amounts of information for users to capture, and the more famous FTP Server has Nctuccca and the department. Ftp.csie.nctu.edu.tw. These FTP Server have a User called Anonymous, and a general "foreign guest" can take this username to acquire public information of the Server. However, Anonymous is asking for the use of Anonymous to enter its email address. In the past, many Taiwan users did not enter their Email Address according to the requirements of the FTP Server in foreign countries, but only casually play some words. Strings, causing dissatisfaction with many internet users and managers, becomes very bad for Taiwan's users, so it is also a considerable thing to follow the rules of FTP Server.

f. Directive for communication:

WRITE

This instruction is to provide the user transfer message to another user, how to use:

Write username [TTY]

2. Talk / YTALK / CYTALK / CTALK

Unix dedicated conversation program. The screen is separated from the area of ​​your area and the object of the object, and can also talk to the user of different machines. Use mode:

Talk username [@Host] [TTY]

3. MESG

Choose whether to accept the Messege of others, if the Messege No, the Messege of others will not be able to send it, and he can't interfere with your work. Instructions:

MESG [-N | -y]

4. Mail / ELM

The email program on the Internet can give the letter mail to others via this program. Use mode:

Mail [username]

Mail -f mailboxfile

If you have a letter, type mail directly to read your mail.

ELM provides more convenient interfaces than Mail, and can do line alias. You can enter ELM

Use the upper and lower left to select the read letters and you can press H to get the HELP file on the line.

Use mode:

ELM [usernmae]

ELM -F Mailboxfile

g. Compiler:

The use of Compiler is to translate the program you wrote into an executable file. The programmatic language commonly used in the system is C, Pascal, Fortran, etc. You can write a C or PASCAL or FORTRAN's original program, and then use these Compiler to turn it into an executable file. You can use this method to make your own special instructions.

1. CC / GCC (C Compiler)

/ usr / bin / cc

/ usr / local / bin / gcc

Syntax: cc [-o execfile] SOURCE

GCC [-o execfile] SOURCE

Execfile is the name of the executive file you want, and if the executable that is not added to the -O option, it is a file name as a.out. Source is a C program that is ended with .c. See the description of CC (1).

2. PC (Pascal Compiler)

/ usr / local / bin / pc

Syntax: PC [-o execfile] SOURCE

Execfile is the name of the executive file you want, and if the executable that is not added to the -O option, it is a file name as a.out. Source is a Pascal program ended with .p. See / Net / Home5 / Lang / MAN Instructions for PC (1). 3. F77 (FORTRAN Compiler)

/ NET / Home5 / Lang / F77

Syntax: F77 [-o execfile] Source

Execfile is the name of the executive file you want, and if the executable that is not added to the -O option, it is a file name as a.out. Source is a Fortran program ending with .p.

h. Instructions for the print:

The following is the instructions used in the printing table, and there is LP1, LP2 (point matrix printers) in this labeling machine.

LW, SP, PS, Compaq (Lei Printers) for users.

1. LPR

LPR is an instruction used to print a file to the listing machine.

usage:

Lpr -P [Printer] file1 file2 file3 ....

or

LPR -P [Printer]

example:

LPR-PLP1 H * llo.c H * llo.lst h * llo.map

LPR-PLP1

The former is input by parameter input, the latter prints the standard input file (STANDARD INPUT), because the H * llo.c is turned to standard input, so the file content of H * llo.c is printed.

2. LPQ

LPQ is used to observe JOBS on Printer Queue.

usage:

LPQ -P [Printer]

3. lprm

LPRM is an instruction used to cancel the print request. Usually we sometimes refrain, or misuse non-text files to Printer, and you must use the LPRM to cancel the print request to avoid waste of resources.

usage:

lprm -p [printer] [jobs id | username]

LPRM is used to clear the JOBS in the Printer Queue. If you use the Job ID as a parameter, it clears this job from Printer Queue. If you use username as a parameter, it will use all Owner in this queue for this UserName's JOBS clearance.

I. Change your personal usage information:

Passwd

Passwd is used to change your password, usage is:

Passwd [username]

When using Passwd, it will ask your old password first, then ask twice to change the password to determine if it is correct, then change your password.

2. Chsh

Chsh is a directive that provides users replacing Login Sh * LL, which can be replaced with SH * LL you use.

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

New Post(0)