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.
#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: (2) Example 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< ;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/imghwm/default1.png" data-src="https://img.php.cn/upload/article/000/000/024/a0630bda4c67c0c43cf5996ca6b309e3-2.png?x-oss-process=image/resize,p_40" 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/imghwm/default1.png" data-src="https://img.php.cn/upload/article/000/000/024/aeafb415bfec575962a1c11f68141be7-3.png?x-oss-process=image/resize,p_40" 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< ;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端口
Compared with the picture above, you can see that only the TCP ports in the listening state are displayed
##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
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) ExampleDisplays the current route. From the figure, you can see the change with option -n
Delete and add settings for the default gateway
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 addressesUsage(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
##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 -p:Set 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 -w:Set 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
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 -c:Specify 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 -t :Specify 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
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)
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
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
The five core components of the Linux operating system are: 1. Kernel, 2. System libraries, 3. System tools, 4. System services, 5. File system. These components work together to ensure the stable and efficient operation of the system, and together form a powerful and flexible operating system.
The five core elements of Linux are: 1. Kernel, 2. Command line interface, 3. File system, 4. Package management, 5. Community and open source. Together, these elements define the nature and functionality of Linux.
Linux user management and security can be achieved through the following steps: 1. Create users and groups, using commands such as sudouseradd-m-gdevelopers-s/bin/bashjohn. 2. Bulkly create users and set password policies, using the for loop and chpasswd commands. 3. Check and fix common errors, home directory and shell settings. 4. Implement best practices such as strong cryptographic policies, regular audits and the principle of minimum authority. 5. Optimize performance, use sudo and adjust PAM module configuration. Through these methods, users can be effectively managed and system security can be improved.
The core operations of Linux file system and process management include file system management and process control. 1) File system operations include creating, deleting, copying and moving files or directories, using commands such as mkdir, rmdir, cp and mv. 2) Process management involves starting, monitoring and killing processes, using commands such as ./my_script.sh&, top and kill.
Shell scripts are powerful tools for automated execution of commands in Linux systems. 1) The shell script executes commands line by line through the interpreter to process variable substitution and conditional judgment. 2) The basic usage includes backup operations, such as using the tar command to back up the directory. 3) Advanced usage involves the use of functions and case statements to manage services. 4) Debugging skills include using set-x to enable debugging mode and set-e to exit when the command fails. 5) Performance optimization is recommended to avoid subshells, use arrays and optimization loops.
Linux is a Unix-based multi-user, multi-tasking operating system that emphasizes simplicity, modularity and openness. Its core functions include: file system: organized in a tree structure, supports multiple file systems such as ext4, XFS, Btrfs, and use df-T to view file system types. Process management: View the process through the ps command, manage the process using PID, involving priority settings and signal processing. Network configuration: Flexible setting of IP addresses and managing network services, and use sudoipaddradd to configure IP. These features are applied in real-life operations through basic commands and advanced script automation, improving efficiency and reducing errors.
The methods to enter Linux maintenance mode include: 1. Edit the GRUB configuration file, add "single" or "1" parameters and update the GRUB configuration; 2. Edit the startup parameters in the GRUB menu, add "single" or "1". Exit maintenance mode only requires restarting the system. With these steps, you can quickly enter maintenance mode when needed and exit safely, ensuring system stability and security.
The core components of Linux include kernel, shell, file system, process management and memory management. 1) Kernel management system resources, 2) shell provides user interaction interface, 3) file system supports multiple formats, 4) Process management is implemented through system calls such as fork, and 5) memory management uses virtual memory technology.
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software