Table of Contents
Common network commands under Linux
Usage
Home Operation and Maintenance Linux Operation and Maintenance What are the network commands in linux

What are the network commands in linux

May 12, 2022 pm 05:08 PM
linux

Linux has a variety of built-in network commands: 1. ping, used to test whether the TCP/IP network is smooth or test the network connection speed; 2. telnet, used to log in to the remote host and manage the remote host; 3. netstat, used to print status information of network systems in Linux; 4. ifconfig, etc.

What are the network commands in linux

#The operating environment of this tutorial: linux5.9.8 system, Dell G3 computer.

There are many kinds of network commands under Linux. Let me share with you some common network commands.

Common network commands under Linux

1. ping

The ping command is used to test whether the TCP/IP network is smooth or to test the network connection speed. It is very useful for determining whether the network is connected correctly and the status of the network connection. it works. Simply put, ping is a test program. If ping runs correctly, it can generally eliminate faults in the network access layer, network card, Modem input and output lines, cables and routers, thereby narrowing the scope of the problem.
The principle of the ping command is based on the unique IP address of the computer. When the user sends a data packet to the destination address, the other party will return a data packet of the same size. Based on the returned data packet, the user can determine the existence of the destination host. , and initially determine the operating system of the destination host.

Usage

(1)Command format

  • ping (option) destination address

destination address Refers to the IP address, host name or domain name of the computer under test. The ping command contains 12 parameters, all parameters can be viewed by executing ping. As shown below:
What are the network commands in linux
(2) Example
What are the network commands in linux
Note: The ping command under Linux is different from the ping command under Windows. Ctrl C is required to terminate
(Linux The difference from the ping command under Windows)

(3) Option

-d: Use the SO_DEBUG function of Socket;
-c: Set the number of times to complete the request response;
-f: Limit detection;
-i:Specify the interval between sending and receiving information;
-L:Use the specified network interface to send data packets;
-l

: </preload></strong>Set the data packet to be sent before sending the request information; <br><strong>-n: </strong>Only output the numerical value; <br><strong>-p&lt ;Template style>: </strong> Set the template style for filling the data packet; <br><strong>-q: </strong>Do not display the instruction execution process, except for the relevant information at the beginning and end; <br><strong> -r: </strong> Ignore the ordinary Routing Table and send the data packet directly to the remote host; <br><strong>-R: </strong>Record the routing process; <br><strong>-s<data packet size>:</data></strong>Set the size of the data packet; <br><strong>-v:</strong>Display the execution process of the instruction in detail. <br><strong>-t<survival value>: Set the size of the survival value TTL</survival></strong></p></blockquote> <p> Let’s talk about <strong>-c</strong> and <strong>-i</strong>Parameters<br> Among them -c count times, which is the number of pings; -i interval interval, the time space between each ping<br><img src="/static/imghw/default1.png" data-src="https://img.php.cn/upload/article/000/000/024/a0630bda4c67c0c43cf5996ca6b309e3-2.png" class="lazy" title="" alt="What are the network commands in linux"></p> <hr> <p><strong><span style="font-size: 18px;">2. telnet</span></strong></p> <p>The telnet command is used to log in to the remote host and manage the remote host. Because telnet uses clear text to transmit messages, its security is not good. Many Linux servers do not open the telnet service and use the more secure ssh method instead. </p> <h5 id="Usage">Usage</h5> <p>(1)Command format:</p> <ul><li><strong>telnet (option) (parameter) </strong></li></ul> <p> (2) Example </p> <p><img src="/static/imghw/default1.png" data-src="https://img.php.cn/upload/article/000/000/024/aeafb415bfec575962a1c11f68141be7-3.png" class="lazy" title="" alt="What are the network commands in linux"></p> <p> (3) Parameter </p> <ul> <li> <strong>Remote host: </strong>Specify the remote host to log in for management</li> <li> <strong>Port: </strong>Specify the port number used by the TELNET protocol </li> </ul> <p> (4) Option</p> <blockquote><p><strong>-8:</strong>Allows the use of 8-bit character data, including input and output; <br><strong>-a:</strong>Try to automatically log in to the remote system; <br><strong>-b<host alias>: </host></strong>Use an alias to specify the remote host name; <br><strong>-c: </strong>Do not read the .telnetrc file in the user-specific directory; <br><strong>-d: </strong>Start debugging mode; <br><strong>-e<escape character>:</escape></strong>Set the escape character; <br><strong>-E:</strong>Filter out the escape character; <br><strong>-f: </strong>The effect of this parameter is the same as specifying the "-F" parameter; <br><strong>-F: </strong>When using Kerberos V5 authentication, adding this parameter can The host's authentication data is uploaded to the remote host; <br><strong>-k<domain name>:</domain></strong>When using Kerberos authentication, add this parameter to let the remote host use the specified domain name instead of the host's Domain name; <br><strong>-K:</strong>Do not automatically log in to the remote host; <br><strong>-l<user name>:</user></strong>Specify the user name to log in to the remote host; <br><strong>-L:</strong>Allow output of 8-bit character data; <br><strong>-n<record file>:</record></strong>Specify the file to record relevant information; <br><strong>-r:</strong>Use a user interface similar to the rlogin command; <br><strong>-S<service type>: </service></strong>Set the ip TOS information required for the telnet connection; <br><strong>-x:</strong> Assume that the host has the function of supporting data encryption, use it; <br><strong>-X<authentication mode>:</authentication></strong>Close the specified authentication mode. </p></blockquote> <hr> <p><strong><span style="font-size: 18px;">3. netstat</span></strong></p> <p> The netstat command is used to print the status information of the network system in Linux, which allows you to Know the network situation of the entire Linux system</p> <h5 id="Usage">Usage</h5> <p> (1) Command format</p> <ul><li><strong>netstat (option)</strong></li></ul> <p> (2) Options </p> <blockquote><p><span style="color:red"><strong>-a or –all: </strong>Display all sockets in the connection; </span> <br><strong>-A&lt ;Network type> or –<network type>: </network></strong> List the relevant addresses in the connection of this network type; <br><span style="color:red"><strong>-c or –continuous: </strong>Continuous listing Network status; </span> <br><strong>-C or –cache: </strong>Display cache information of router configuration; <br><strong>-e or –extend: </strong>Display other network-related information; <br><strong>-F or –fib: </strong>Display FIB; <br><strong>-g or –groups: </strong>Display the multicast function group member list; <br><strong>- h or –help: </strong>Online help; <br><strong>-i or –interfaces:</strong>Display network interface information form; <br><span style="color:red"><strong>-l or –listening:</strong> Display the Socket of the server being monitored; </span> <br><strong>-M or –masquerade: </strong>Display the disguised network connection; <br><span style="color:red"><strong>-n or –numeric: </strong>Use the IP address directly instead of passing the domain name server; </span> <br><strong>-N or –netlink or –symbolic: </strong>Display the symbolic link name of the network hardware peripheral device; <br><strong>- o or –timers: </strong>Display timers; <br><span style="color:red"><strong>-p or –programs: </strong>Display the program identification code and program name that is using Socket; </span> <br><strong>-r or –route: </strong>Display Routing Table; <br><strong>-s or –statistice: </strong>Display network work information statistics table; <br><span style="color:red"><strong>-t or –tcp : </strong> Display the connection status of the TCP transmission protocol; </span> <br><span style="color:red"><strong>-u or –udp: </strong> Display the connection status of the UDP transmission protocol; </span> <br><strong>-v or –verbose: </strong> Display the instruction execution process; <br><strong>-V or –version: </strong>Display version information; <br><strong>-w or –raw: </strong> Display the connection status of RAW transmission protocol; <br><strong>-x or –unix: </strong>The effect of this parameter is the same as specifying the "-A unix" parameter; <br><strong>-ip or –inet: </strong>The effect of this parameter is the same as specifying the "-A inet" parameter</p></blockquote> <p>(3) Example</p><pre class='brush:php;toolbar:false;'>netstat -a //列出所有端口 netstat -at //列出所有tcp端口 netstat -au //列出所有udp端口
Copy after login

Display all TCP ports here

What are the network commands in linux

netstat -l        //只显示监听端口
netstat -lt       //只列出所有监听 tcp 端口
netstat -lu       //只列出所有监听 udp 端口
Copy after login

Compared with the picture above, you can see that only the TCP ports in the listening state are displayed
What are the network commands in linux


##4 , ifconfig

The ifconfig command is used to configure and display the network parameters of the network interface in the Linux kernel. The network card information configured with the ifconfig command will no longer exist after the network card is restarted and the machine is restarted. If you want to store the above configuration information in your computer forever, you need to modify the configuration file of the network card.

Usage
(1)Command format

  • ifconfig (parameter)

(2) Example
What are the network commands in linux

eth0 represents the first network card, you can see Information about this network card

  • HWaddr represents the physical address of the network card, which is the MAC address. You can see that the current MAC address of this network card is: 00:0C:29:A7:C0:6C
  • inet addr is used to represent the IP address of the network card. The IP address of this network card is: 192.168.1.106
  • Broadcast address Bcast: 192.168.1.255
  • Mask address Mask: 255.255.255.0

lo represents the loopback address of the host. This is generally used to test a network program, but does not want users on the LAN or external network to view it. It can only be run and viewed on this host. network interface.

(3) Parameters

##add

: Set the IP address of the network device IPv6
del
: Delete the IP address of the network device IPv6
down:Close the specified network device
io_addr:Set the I/O of the network device O address
irq: Set the IRQ of the network device;
media: Set the media type of the network device;
mem_start:Set the starting address occupied by the network device in the main memory;
metric:Specify the number of times the data packet is transmitted when, the number to be added;
mtu:Set the MTU of the network device;
netmask:Set the network The subnet mask of the device;
tunnel
:Establish the tunnel communication address between IPv4 and IPv6;
up:Start the specified network device;
-broadcast
: Treat the data packet sent to the specified address as a broadcast packet;
-pointopoint
: with the specified address Establish a direct connection with the network device. This mode has a confidentiality function;
-promisc:Close or enable the promiscuous mode of the specified network device;
IP address:Specify the network The IP address of the device;
Network device: Specify the name of the network device.

5. route

# The route command is used to display and set the network routing table in the Linux kernel. The route command The routes set are mainly static routes.

It should be noted that executing the route command directly on the command line to add a route will not be saved permanently. When the network card is restarted or the machine is restarted, the route will become invalid; it can be added in
*/etc/rc. Add the route command to local to ensure that the routing settings are permanently valid.

Usage
(1) Command format

  • route (option) (parameter)
( 2) Option

-A: Set the address type;
-C: Print the Linux core routing cache;
-v:Detailed information mode;
-n:Does not perform DNS reverse lookup and directly displays the IP address in numerical form;
-e: Netstat format displays the routing table;
-net: The routing table to a network;
-host: The routing table to a host.

(3) Parameters

Add:Add the specified route record
Del:Delete the specified route Record
Target:Destination network or destination host
gw:Set the default gateway
mss:Set the maximum block length of TCP ( MSS), in MB
window:Specifies the TCP window size for TCP connections through the routing table
dev:The network interface represented by the routing record

(4) Example

Displays the current route. From the figure, you can see the change with option -n


What are the network commands in linux

Delete and add settings for the default gateway


What are the network commands in linux


6. The arp

#arp command is used to operate the host arp buffer and can display the arp buffer. All entries in the area, delete specified entries or add the correspondence between static IP addresses and MAC addresses

Usage
(1)Command format

  • arp (Option) (Parameter)
(2) Option

-a:Display all entries of the arp buffer
-H

:
Specify the address type used by the arp instruction
-d:Removes the arp entry for the specified host from the arp buffer
-D:Uses the hardware address of the specified interface
-e: Display the entries in the arp buffer in Linux display style
-i: Specify the network interface to operate the arp buffer
-s: Sets a static mapping of the IP address and MAC address of the specified host
-n: Displays entries in the arp buffer numerically
-v:Display detailed arp buffer entries, including statistics of buffer entries
-f:Set the host's IP address and MAC Static mapping of addresses

(3) Parameters

  • Host: Query the arp entry of the specified host in the arp buffer.

(4) Example
What are the network commands in linux


##7、traceroute

The traceroute command is used to trace the entire path of data packets when they are transmitted on the network. The default size of the data packets sent is 40 bytes.

Through traceroute, we can know how the information goes from your computer to the host at the other end of the Internet. What path. Of course, the path a data packet takes from the same starting point (source) to the same destination (destination) may be different every time, but basically the route taken is the same most of the time.
Traceroute measures how long it takes by sending small packets to the destination device until it returns. Each device on a path is traceroute tested three times. The output results include the time (ms) of each test and the name of the device (if any) and its IP address

Usage
(1) Command format

  • traceroute (option) (parameter)
(2) option

-d: Use Socket level Troubleshooting function
-f:Set the survival value TTL size of the first detected packet
-F:Set not to disconnect Bit
-g:Set the source routing gateway, up to 8 can be set
-i:Use the specified network interface to send Packet
-l:Use ICMP response instead of UDP data information
-m:Set the maximum survival value TTL size of the detection packet
-n:Use the IP address directly instead of the host name
-pSet the communication port of the UDP transmission protocol
- r:Ignore the ordinary Routing Table and send the data packet directly to the remote host
-s:Set the TOS value of the data packet sent by the local host
-v:Display the execution process of the command in detail
-wSet the time to wait for the remote host to report back
-x: Turn on or off the correctness check of data packets

(3) Parameters

  • Host: Specify the destination host IP address or host name
(4) Example


What are the network commands in linux It can be seen from the figure that the records start from 1 according to the sequence number. Each record is a hop, and each hop represents a gateway. We You see that each line has three times, the unit is ms, which is actually the default parameter of -q. After the detection packet sends three packets to each gateway, the time it takes for the gateway to respond;
In the later part we will see that some lines are represented by asterisks. When this happens, it may be that the firewall blocks the ICMP return information, so we cannot get any relevant packet return data.


8. The host

host command is a commonly used analysis domain name query tool, which can detect whether the domain name system is working properly

Usage
(1)Command format

  • host(option)(parameter)
(2)Option

-a:Display detailed DNS information
-cSpecify the query type, the default value is "IN"
-C:Query the complete SOA record of the specified host
-r:Do not use recursive query when querying the domain name
-tSpecify the query domain name information type
-v:Display detailed information about command execution
-a:Display detailed DNS information;
-w:If the domain name server does not give a response message, wait until the domain name server gives a response
-WSpecify the maximum time for domain name query, if within the specified time If the domain name server does not give a response message, exit the command
-4: Use IPv4
-6: Use IPv6

(3 ) Parameter

  • Host: Host information to be queried

(4) Example
What are the network commands in linux


9. tcpdump

The tcpdump command is a tool for capturing data packets. It can print the header information of all data packets passing through the network interface. You can use the -w option to save the packets to a file for later analysis.

Usage

(1)Command format

  • ##tcpdump(option)
(2)Option

-a:Attempt to convert network and broadcast addresses into names;
-c:Received the specified After the number of data packets is reached, stop the dumping operation;
-d: Convert the compiled data packet encoding into a readable format and dump it to the standard output;
- dd: Convert the compiled data packet encoding into C language format and dump it to the standard output;
-ddd: Convert the compiled data packet encoding into decimal number format , and dump to standard output;
-e: Display the connection-level file header on each column of dumped data;
-f: Display the Internet address in numbers ;
-F:Specify the file containing the expression;
-i:Use the specified network section to send data Package;
-l: Use the buffer of the standard output column;
-n: Do not convert the host’s network address into a name;
-N: Do not list domain names;
-O: Do not optimize packet encoding;
-p: Do not let the network interface enter the promiscuous Mode;
-q: Quick output, only lists a few transmission protocol information;
-r:Read from the specified file Packet data;
-s:Set the size of each packet;
-S:List with absolute rather than relative values Number of TCP associations;
-t:Display timestamps on each column of dumped data;
-tt:Display unformatted on each column of dumped data timestamp;
-T:Force the data packet specified by the expression to be translated into the set packet type;
-v:Display the instruction execution process in detail;
-vv:Display the instruction execution process in more detail;
-x:List the data packets in hexadecimal characters Information;
-w: Write packet data to the specified file.

(3) Example

tcpdump: Monitor all data packets flowing on the first network interface (with the -i option, monitor the specified network interface)

What are the network commands in linux

Related recommendations: "

Linux Video Tutorial"

The above is the detailed content of What are the network commands in linux. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Hot Topics

Java Tutorial
1655
14
PHP Tutorial
1252
29
C# Tutorial
1226
24
Linux Architecture: Unveiling the 5 Basic Components Linux Architecture: Unveiling the 5 Basic Components Apr 20, 2025 am 12:04 AM

The five basic components of the Linux system are: 1. Kernel, 2. System library, 3. System utilities, 4. Graphical user interface, 5. Applications. The kernel manages hardware resources, the system library provides precompiled functions, system utilities are used for system management, the GUI provides visual interaction, and applications use these components to implement functions.

vscode terminal usage tutorial vscode terminal usage tutorial Apr 15, 2025 pm 10:09 PM

vscode built-in terminal is a development tool that allows running commands and scripts within the editor to simplify the development process. How to use vscode terminal: Open the terminal with the shortcut key (Ctrl/Cmd). Enter a command or run the script. Use hotkeys (such as Ctrl L to clear the terminal). Change the working directory (such as the cd command). Advanced features include debug mode, automatic code snippet completion, and interactive command history.

How to check the warehouse address of git How to check the warehouse address of git Apr 17, 2025 pm 01:54 PM

To view the Git repository address, perform the following steps: 1. Open the command line and navigate to the repository directory; 2. Run the "git remote -v" command; 3. View the repository name in the output and its corresponding address.

Where to write code in vscode Where to write code in vscode Apr 15, 2025 pm 09:54 PM

Writing code in Visual Studio Code (VSCode) is simple and easy to use. Just install VSCode, create a project, select a language, create a file, write code, save and run it. The advantages of VSCode include cross-platform, free and open source, powerful features, rich extensions, and lightweight and fast.

How to run java code in notepad How to run java code in notepad Apr 16, 2025 pm 07:39 PM

Although Notepad cannot run Java code directly, it can be achieved by using other tools: using the command line compiler (javac) to generate a bytecode file (filename.class). Use the Java interpreter (java) to interpret bytecode, execute the code, and output the result.

What is the main purpose of Linux? What is the main purpose of Linux? Apr 16, 2025 am 12:19 AM

The main uses of Linux include: 1. Server operating system, 2. Embedded system, 3. Desktop operating system, 4. Development and testing environment. Linux excels in these areas, providing stability, security and efficient development tools.

vscode Previous Next Shortcut Key vscode Previous Next Shortcut Key Apr 15, 2025 pm 10:51 PM

VS Code One-step/Next step shortcut key usage: One-step (backward): Windows/Linux: Ctrl ←; macOS: Cmd ←Next step (forward): Windows/Linux: Ctrl →; macOS: Cmd →

vscode terminal command cannot be used vscode terminal command cannot be used Apr 15, 2025 pm 10:03 PM

Causes and solutions for the VS Code terminal commands not available: The necessary tools are not installed (Windows: WSL; macOS: Xcode command line tools) Path configuration is wrong (add executable files to PATH environment variables) Permission issues (run VS Code as administrator) Firewall or proxy restrictions (check settings, unrestrictions) Terminal settings are incorrect (enable use of external terminals) VS Code installation is corrupt (reinstall or update) Terminal configuration is incompatible (try different terminal types or commands) Specific environment variables are missing (set necessary environment variables)

See all articles