Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use Linux Command Line to manage Network

2025-03-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

Editor to share with you how to use the Linux command line to manage the network, I believe that most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!

Whether you want to download files, diagnose network problems, manage network interfaces, or view network statistics, there are terminal commands that can be done. This article is a collection of time-tested commands, as well as several relatively new ones.

Most commands can be executed on the graphical desktop, and even Linux users with little terminal experience will often execute commands to use ping or other network diagnostic tools.

Curl & wget

Using the curl or wget command, you can download files without leaving the terminal. If you use curl, type curl-O followed by a file path. Wget does not require any options. The downloaded file is in the current directory.

Curl-O website.com/file wget website.com/file

Ping

Ping sends ECHO_REQUEST packets to the address you specify. In this way, you can easily confirm whether your computer is connected to Internet or a specified IP address. Using the-c switch, you can specify the number of ECHO_REQUEST packets to send.

Ping-c 4 google.com

Tracepath & traceroute

The tracepath command is similar to the traceroute command, but does not require root permissions. And Ubuntu pre-installed this command, traceroute command is not pre-installed. Tracepath tracks the network path to the specified destination address and gives each hop (hop) on the path. If your network has a problem or is slow, tracepath can find out where the network is down or slow.

Tracepath example.com

Mtr

The mtr command combines the ping command with the tracepath command. Mtr will continue to send packets and show how long it takes to ping each hop. Any problems in the process will also be displayed, and in the example below, you can see that more than 20% of the packets were lost at No. 6.

Mtr howtogeek.com

Type Q or CTRL + C to exit the command.

Host

The host command is used to do DNS queries. If the command parameter is a domain name, the command outputs the associated IP;. If the command parameter is IP, the command outputs the associated domain name.

Host howtogeek.com host 208.43.115.82

Whois

The whois command outputs the whois record of the specified site, and you can see more information such as who registers and owns the site.

Whois example.com

Ifplugstatus

The ifplugstatus command can tell you whether a network cable is plugged into the network interface. This command, Ubuntu, is not preinstalled, and is installed by the following command:

Sudo apt-get install ifplugd

This command can view the status of all network interfaces, or specify the status of network interfaces:

Ifplugstatus ifplugstatus eth0

The command output "Link beat detected" (connection heartbeat detected) indicates that there is a network cable plugged in, and if not, it will output "unplugged" (not plugged in).

Ifconfig

Ifconfig is used to output various options for network interface configuration, tuning, and debug. You can quickly view information about IP addresses and other network interfaces. Type ifconfig to view the status of all enabled network interfaces, including their names. You can specify the name of the network interface to display information about only this one interface.

Ifconfig ifconfig eth0

Ifdown & ifup

The ifdown and ifup commands have the same function as running ifconfig up,ifconfig down. Given the name of a network interface, only this interface can be disabled or enabled. Root permission is required, so you need to use sudo to run it on Ubuntu.

Sudo ifdown eth0 sudo ifup eth0

Running these two commands on a Linux desktop system is likely to output an error message. The Linux desktop manages your network interface by using the Network Manager (NetworkManager). However, these two commands are still available on the server version where the network manager is not installed.

If you do configure the network manager on the command line, use the nmcli command.

Dhclient

The dhclient command releases your computer's IP address and gets a new one from the DHCP server. Root permission is required, so sudo is required on Ubuntu. There is no option to run the command to get the new IP, or specify the-r switch to release the current IP address.

Sudo dhclient-r sudo dhclient

Netstat

The netstat command displays many statistics about network interfaces, including open socket and routing tables. There is no option to run the command to display the open socket.

This command has many functions. For example, the netstat-p command can display the program corresponding to the open socket.

Netstat-s displays detailed statistics for all ports.

The above is all the contents of the article "how to use the Linux command line to manage the network". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report