Common Linux Network commands

Source: Internet
Author: User

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:
$ Content $ nbsp; ftp host name/IP


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: $ Content $ nbsp; ftp> at this time, enter the open command and add the host name or IP address after the ftp> prompt, and 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 on the user machine. 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 file name. You can also give a local file name, which is the name of the file to be obtained when it is created 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, Linux creates a directory named new_dir in the user's local directory.


A typical dialog process for downloading binary data files from grunthos on a remote machine is as follows:
$ Content $ nbsp; 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. The logon process using the telnet command is as follows: $ Content $ nbsp; telnet host name/IP 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:
$ Content $ nbsp; 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 :~ $ Content $ nbsp; server :~ $ Content $ nbsp; 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 the two files, the user executes the r-Series

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.