Linux Network Operation Command Encyclopedia

  

The common network operation commands for Linux systems include netstat, nslookup, host finger, and ping.

The function of the netstat command is to display network connection, routing table and network interface information, which allows users to know which network connections are currently running. The function of the nslookup command is to query the IP address of a machine and its corresponding domain name. It usually requires a domain name server to provide the domain name service. If the user has already set up the domain name server, you can use this command to view the domain name corresponding to the IP address of different hosts. The host command can query the host's IP address based on the host name or query the host name based on the host IP address. The function of the finger command is to query the user's information. The user name, home directory, dead time, and login time of a user in the system are usually displayed. , login shell and other information. The ping command is used to see if the host on the network is working.
netstat

The syntax of the netstat command is:

netstat [options]

The common parameters for netstat are as follows:

-a Show all sockets Including

-c listening is repeated every 1 second until the user interrupts it

-i The information format of all network interfaces is the same as “ifconfig –e”

-n shows the network connection situation by the network IP address instead of the name

-r The core routing table format is the same as “route –e”

-t shows the TCP protocol connection Situation

-u Displaying the connection status of the UDP protocol

-v Displaying the work in progress

Example:

1) Using the netstat command on this machine , the output is as follows

Active Internet connections (w/o servers)

Proto Recv-Q Send-Q Local Address Foreign Address State

tcp 0 256 10.153.89.66 :ssh 10.153.21.168:1054 ESTABLISHED

tcp 0 0 10.153.89.66:ssh 10.153.21.166:1222 ESTABLISHED

tcp 0 0 10.153.89.66:1521 10.153.21.166:2625 ESTABLISHED

tcp 0 0 10.153.89.66:1521 10.153.21.166:2623 EST ABLISHED

……Active UNIX domain sockets (w/o servers)

Proto RefCnt Flags Type State I-Node Path

unix 9 [ ] DGRAM 919 /dev /log

unix 2 [ ] STREAM CONNECTED 50246124

unix 3 [ ] STREAM CONNECTED 3914245

/tmp/.ICE-unix/dcop18694-1074144356

unix 3 [ ] STREAM CONNECTED 3914244

unix 3 [ ] STREAM CONNECTED 3914127 /tmp/.X11-unix/X0…..
nslookup

The function of the nslookup command is to query one The IP address of the machine and its corresponding domain name. It usually requires a domain name server to provide a domain name service. If the user has already set up a domain name server, you can use this command to view the domain name corresponding to the IP address of different hosts. The syntax of the command is:

nslookup [IP address/domain name]

Example:

Executing the nslookup command locally

Default Server: name.tlc .com.cn

Address: 192.168.1.99

> Enter the IP address or domain name you want to query after the symbol >>” and press Enter. If you want to exit the command, type exit and press Enter.
host Command

The function of the host command is basically the same as nslookup. The syntax of the same command is:

host [option] [IP address/domain name/hostname]

The common parameters of host are as follows:

-a Display the domain name being checked or Information about the IP address, domain name, or host name.

Example:

[root]# host huawei-3com.com

huawei-3com.com has address 172.19.1.228
finger

The function of the finger command is to query the user's information. It usually displays the user name, home directory, dead time, login time, login shell, etc. of a user in the system. If you want to query the user information on the remote machine, you need to select the format of [username@hostname] after the username, but the network host to be queried needs to run the finger daemon. The general format of the command is:

finger [options] [users] [user@host]

The common parameters of finger are as follows:

-s Display user registration Name, actual name, terminal name, write status, dead time, login time, etc.

-l In addition to the information displayed with the -s option, it also displays information such as the user's home directory, login shell, mail status, and the contents of the .plan, project, and .forward files in the user's home directory. >

-p is the same as the -l option except that the .plan file and the .project file are not displayed.

Example:

1 ) Displaying information about user orcale

finger Oracle

The result is

Login: oracle Name: (null)

Directory: /home/oracle Shell: /bin/bash

On Since Fri Feb 6 16:26 (CST) on pts/1 from 10.153.21.166 33 seconds idle

On since Wed Feb 4 20:10 (CST) on pts/2 from 10.153.21.166 1 second idle< Br>

No mail.

No Plan.
Ping Command

The ping command is used to check if the host on the network is working. It sends the ICMPECHO_REQUEST packet to the host. Sometimes we want to download files from a host on the network, but if we don't know if the host is on, we need to use the ping command to view it. The general format of the command is:

ping [options] [hostname/IP address]

The common parameters for ping are as follows:

-c The number is sent in the specified number Stop after package

-d Set options for SO_DEBUG

-f Send large and fast network packets to a machine to see its response

-I seconds Set a network packet to a machine for a few seconds. The default value is one second.

-l The number of times to send the packet data to the specified machine in the fastest way within the specified number of times (only superuser can use This option)

-q does not display any information about the transport packet. It only shows the final result.

-r Sending packets directly to a machine without going through the gateway is usually a view of the network interface of the machine. Is there a problem?

-s The number of bytes specifies the number of bytes of data to be sent. The default value is 56, plus an 8-byte ICMP header, which is a total of 64 ICMP data bytes.

Copyright © Windows knowledge All Rights Reserved