You can't remember
Simply write down:
Start:
The main advantage of computer networks is the ability to share resources and information, and users can remotely access information. Linux provides a set of powerful network commands to serve users. These tools can help users log on to a remote computer, transfer files, and execute remote commands. This chapter describes the following common network operation commands:
FTP File Transfer
Telnet logon to a remote computer
R-use various remote commands
Netstat
NSLookup
Finger queries information of a user
Ping to check whether a machine is working
Use FTP commands for remote file transmission
The FTP command is the user interface of the standard file transfer protocol. FTP is a simple and effective method for transferring files between computers on TCP/IP networks. It allows users to transmit ASCII and binary files. During an FTP session, you can use an FTP client program to connect to another computer. From then on, you can move up and down the directory, list the contents of the Directory, copy files from the remote machine to the local machine, and transmit files from the local machine to the remote system.
Note that if you do not have the permission to access the file, you cannot obtain the file from the remote system or transmit the file to the remote system. To use ftp to transfer files, you must know the valid user name and password on the remote computer. This user name/password combination is used to confirm the FTP session and determine the user's access to the file to be transferred. In addition, you obviously need to know the name or IP address of the computer on which the FTP session is performed.
The FTP command transfers files between a local machine and a remote machine. The general format of this command is as follows:
$ FTP host name/IP Address
The "host name/IP Address" is the host name or IP address of the remote machine to be connected. In the command line, the host name is an option. If the host name is specified, FTP tries to connect to the FTP service program of the remote machine. If the host name is not specified, FTP will give a prompt, wait for the user to enter the command: $ FTP ftp> at this time, enter the open command and add the host name or IP address after the ftp> prompt to try to connect to the specified host. No matter which method is used, if the connection is successful, You need to log on to the remote machine. If you have an account on a remote machine, you can use this account through FTP and provide a password.
The read and write permissions of the user account on the remote machine determine what files the user can download and the directory to which the uploaded files are stored. If you do not have a dedicated Logon account for a remote machine, many FTP sites have special accounts that can be used. The login name of this account is anonymous (also known as anonymous FTP). When using this account, enter the email address as the password. If the remote system provides the anonymous FTP service, you can use this service to log on to a special directory for public use.
Generally, two directories are provided: pub directory and incoming directory. The pub directory contains all the files on the site for public use. The incoming directory stores the files uploaded to the site. Once the user successfully logs on to the remote site using FTP, the "ftp>" prompt is displayed. Now you can freely use commands provided by FTP. You can use the help command to obtain a list of available commands, or you can specify a specific command name after the HELP command to obtain instructions on this command.
The most common commands are:
Ls to list the current directory of the remote machine
CD changes the working directory on a remote machine
LCD changes the working directory on the local machine
Set the file transmission mode to ASCII in ASCII mode.
Set the file transfer mode to binary.
Close to terminate the current FTP session
Each time the hash data is transmitted in the data buffer, A # number is displayed.
Get (mget) transfers specified files from a remote machine to a Local Machine
Put (mput) transfers the specified file from the local machine to the remote machine
Open connection to remote FTP site
Quit disconnects from the remote machine and exits FTP
? Display local help information
! Go to Shell
Below is a brief introduction to common FTP commands.
The open command for starting an FTP session is used to open a session with a remote host. The general format of this command is: Open host name/IP address. If you want to connect to more than one site during an FTP session, only FTP commands without parameters are used. If you only want to connect to a computer during a session, specify the remote host name or IP address on the command line as the FTP command parameter. The terminate FTP session close, disconnect, quit, and bye commands are used to terminate the session with the remote machine. Close and disronnect commands close the connection to the remote machine, but leave the user in the FTP program of the local computer. Both the quit and bye commands disable the connection between the user and the remote machine, and then exit the ftp
Program. The "CD [Directory]" command is used to change the directory on a remote machine during an FTP session. The LCD command changes the local directory so that you can specify the location for searching or storing local files. The remote directory list LS command lists the contents of the remote directory, just like using the LS command in an interactive shell. The general format of the LS command is: ls [Directory] [local file] If the directory is specified as the parameter, ls will list the contents of this directory. If a local file name is provided, the directory list is put into the file you specified on the local machine. The get and mget commands for obtaining files from the remote system are used to obtain files from the remote machine. The general format of the GET command is: Get
You can also provide a local file name, which is the name of the file you want to obtain when you create it on your local machine. If you do not provide a local file name, use the original name of the remote file. The mget command obtains multiple remote files at a time. The general format of the mget command is: The mget file name list uses a space-separated or list of file names with wildcards to specify the files to be obtained. For each file, you must confirm whether to transfer the files. Send the put and mput commands to the remote system to send files to the remote machine. The general format of the PUT command is: Put file name mput Command sends multiple local files at a time, the general format of the mput command is: the mput file name list uses a space-separated or wildcard file name list to specify the file to be sent. You are required to confirm whether to send each file.
By default, ftp transfers files in ASCII mode. You can also specify other modes. The ASCII and brinary commands are used to set the transmission mode. Transferring files in ASCII mode is very good for plain text, but to avoid damages to binary files, users can transmit files in binary mode. When you check the transmission status to transfer large files, FTP may find it useful to provide feedback on the transmission status. The Hash command enables FTP to print a # character on the screen after data in the data buffer is transmitted every time. This command can be used to send and receive files. Local commands in FTP when you use ftp, the character "!" It is used to send a command to the command shell on the local machine. It is useful if a user is in an FTP session and needs shell to do something. For example, you need to create a directory to save the received files. If you enter! Mkdir
New_dir, then Linux creates a directory named new_dir in the user's current local directory.
A typical dialog process for downloading binary data files from Grunthos on a remote machine is as follows:
$ FTP Grunthos connected to Grunthos 220 Grunthos FTP server name (Grunthos: PC): anonymous 33l Guest Login OK, send your complete e-mail address as password. password: 230 Guest 1 ogin OK, access restrictions apply. remote system type is UNIX. ftp> Cd pub 250
CWD command successful. ftp> ls 200 PORT command successful. l50 opening ASCII mode data connection for/bin/1 s. total ll4 rog1 rog2 226 transfer comp1ete. ftp> binary 200 type set to I. ftp> Hash hash mark printing on (1024 bytes/hash mark ). ftp> get
Rog1 200 PORT command successfu1. 150 opening binary mode data connection for Rogl (l4684 bytes ). ############ 226 transfer complete. 14684 bytes encoded ed in 0.0473 secs (3E + 02 Kbytes/sec) ftp> quit 22L goodbye.
Use Telnet commands to access remote computers
Use the Telnet command to log on remotely. This command allows you to use the Telnet protocol to communicate between remote computers. you can log on to a remote computer over the network, just as you log on to a local machine and execute commands. To log on to the remote computer through telnet, you must know the valid user name and password on the remote computer. Although some systems do provide the logon function for remote users, the Operation permissions of guests must be restricted for security reasons. Therefore, in this case, few functions can be used. When remote users are allowed to log on, the system usually places these users in a restricted shell to prevent the system from being maliciously or accidentally damaged. You can also use Telnet to log on from a remote site to your computer, check emails, edit files, and run programs, just like logging on locally.
However, you can only use the terminal-based environment instead of the X wndows environment. Telnet only provides terminal Simulation for common terminals, but does not support x wndow and other graphical environments. The Telnet command is generally used as follows: Telnet host name/IP, where "host name/IP" is the host name or IP address of the remote machine to be connected. If the command is successfully executed, the login: prompt will be obtained from the remote machine. Use the Telnet command to log on: $ Telnet host name/IP address to start the telnet session. Once telnet is successfully connected to the remote system, the logon information is displayed and the user's username and password are prompted. If the username and password are entered correctly, you can successfully log on and work on the remote system. You can enter many commands at the end of the Telnet prompt to control the telnet session process. These commands are described in detail in the Telnet online help manual.
The following is an example of a telnet session on a Linux computer:
$ Telnet server. Somewhere. com trying 127.0.0.1... Connected to serve. Somewhere. com. Escape Character is \ '?] \ '. "Turbolinux Release 4. 0 (Colgate) kernel 2.0.18 on an imo-login: Bubba password: Last login: Mon Nov L5 20:50:43 for localhost Linux 2. 0.6.
(POSIX). SERVER :~ $ Server :~ $ Logout Connection closed by foreign host $
After the user finishes the remote session, make sure to use the logout command to exit the remote system. Telnet then reports that the remote session is disabled and returns to the shell prompt of the user's local machine. In addition to FTP and telnet, the R-series commands can also be used to access remote computers and exchange files on the network. Pay special attention to using the R-series commands, because serious security vulnerabilities may occur if you are not careful. After the user issues an R-series command, the remote system checks the file named/etc/hosts. equiv to check whether the user's host is listed in this file. If the user's host is not found, check the file named. rhosts in the home directory of the user with the same name on the remote machine to see if the user's host is included. If the user's host is included in either of these two files, the user does not need to provide a password when executing the R-series command.
Although it is very convenient for a user to access a remote machine without entering a password, it may also cause serious security problems. We recommend that you carefully consider the hidden security issues of the R-command before creating the/etc/hosts. equiv and. rhosts files.
Rlogin command
Rlogin is short for "remote login. This command is similar to the Telnet command, allowing users to start interactive command sessions on the remote system. The general format of Rlogin is:
Rlogin [-8 ekldx] [-e char] [-K realm] [-l username] Host
Generally, the most common format is: rlogin host. The meaning of each option in this command is:
-8 this option always allows an 8-bit input data channel. This option allows you to send formatted ANSI characters and other special code. If this option is not used, the parity bit is removed unless the remote termination and start character are not or.
-E stops using any character as an escape character. When used together with the-8 option, it provides a completely transparent connection.
-K to disable all Kerberos validation. This option is used only when it is connected to a host using the Kerberos validation protocol.
-L allows the rlogin session to run in litout mode. For more information, see the TTY online help.
-D open the socket debugging of TCP sockets that communicates with the remote host. For more information, see the setsockopt online help.
-E: Set the escape character for the rlogin session. The default escape character is "~". You can specify a text character or an \ NNN octal number.
-K requests rlogin to obtain the Kerberos permission for the remote host in the specified region, instead of obtaining the Kerberos permission for the remote host in the remote host region determined by krb_realmofhost (3.
-X enables DES encryption for all data transmitted through the rlogin session. This affects response time and CPU utilization, but improves security.
Rsh command
RSH is short for remote shell. This command starts a shell on the specified remote host and executes the command specified by the user in the rsh command line. If the user does not provide the command to be executed, RSH uses the rlogin command to log on to the remote machine.
The general format of the rsh command is:
Rsh [-kdnx] [-K realm] [-l username] host [command]
The common format is:
Rsh host [command]
Command can be any Linux Command from the shell prompt.
The meanings of the options in the rsh command are as follows:
-K to close all of the Maximo validation. This option is used only when it is connected to the host confirmed by using the o.
-D open the socket debugging of TCP sockets that communicates with the remote host. For more information, see the online help of setsockopt.
-K requests rsh to obtain the Kerberos permission for the remote host in the specified region, instead of obtaining the Kerberos permission for the remote host in the remote host region determined by krb_relmofhost (3.
-L by default, the remote user name is the same as the local user name. This option allows you to specify a remote user name. If you specify a remote user name, use Kerberos to confirm, as in the rlogin command.
-N redirects the input from the special device/dev/null.
-X enables DES encryption for all transmitted data. This affects response time and CPU utilization, but improves security. Linux puts the standard input into the rsh command and copies it to the standard input of the command to be remotely executed. It copies the standard output of remote commands to the standard output of RSH. It also copies remote standard errors to the local standard error file. All exit, stop, and interrupt signals are sent to remote commands. When the remote command is terminated, RSH is terminated.
RCP command
RCP stands for "remote file copy" (remote file copy ). This command is used to copy files between computers.
The RCP command has two formats. The first format is used to copy files to files. The second format is used to copy files or directories to another directory.
The general format of the RCP command is:
RCP [-Px] [-K realm] file1 file2 RCP [-Px] [-R] [-K realm] File
Each file or directory parameter in directory can be either a remote file name or a local file name. The remote file name can be in the following format: rname @ rHost: path. rname indicates the remote user name, rHost indicates the remote computer name, and path indicates the path of the file.
The options of the RCP command are as follows:
-R Recursively copies all the content in the source directory to the target directory. To use this option, the object must be a directory.
-P tries to retain the modification time and mode of the source file, ignoring umask.
-K requests RCP to obtain Kerberos permission for the remote host in the specified region, instead of obtaining Kerberos permission for the remote host in the remote host region determined by krb_relmofhost (3.
-X enables DES encryption for all transmitted data. This affects response time and CPU utilization, but improves security. If the path specified in the file name is not the complete path name, the path is interpreted as the Home Directory of the user with the same name on the remote machine. If no remote user name is provided, the current user name is used. If the path on the remote machine contains special shell characters, it must be enclosed by a backslash (\), double quotation marks ("), or single quotation marks, allow remote interpretation of all shell metacharacters. It must be noted that the RCP does not prompt for a password. It uses the rsh command to execute the copy operation.