You can use Terminal commands to download files, diagnose network problems, manage network interfaces, and view network statistics. This article collects proven and reliable commands and several new ones. Most commands can be executed on the graphic desktop, that is, Linux commands.
You can use Terminal commands to download files, diagnose network problems, manage network interfaces, and view network statistics. This article collects proven and reliable commands and several new ones.
Most commands can be executed on the graphic desktop. Even Linux users who have little experience in using the terminal often execute commands to use ping or other network diagnostic tools.
Curl & wget
Use the curl or wget command to 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 to send the ECHO_REQUEST packet to your specified address. In this way, you can easily check whether your computer and Internet or a specified IP address are accessible. Use the-c switch to specify the number of ECHO_REQUEST packets sent.
- ping -c 4 google.com
Tracepath & traceroute
The tracepath command is similar to the traceroute command, but does not require the root permission. The traceroute command is not pre-installed in Ubuntu. Tracepath traces the network path of the specified destination address and provides each hop on the path ). If your network is faulty or slow, tracepath can find out where the network is broken or slow.
- tracepath example.com
Mtr
The mtr command combines the ping command with the tracepath command. Mtr continuously sends packets and displays the time used for each hop ping. Any problems during the process will also be displayed. in the following example, we can see that more than 6th packets are lost in 20% hops.
- mtr howtogeek.com
Type q or CTRL + C to exit the command.
Host
The host command is used for DNS query. If the command parameter is a domain name, the command outputs the associated IP address. if the command parameter is an IP address, 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 to view more information such as who registered and held the site.
- whois example.com
Ifplugstatus
The ifplugstatus command tells you whether a network cable is inserted on the network interface. This command is not pre-installed in Ubuntu. use the following command to install it:
- 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" (The connection heartbeat is detected) indicates that a network cable is inserted. if not, the command output "unplugged" (not inserted ).
Ifconfig
Ifconfig is used to output various options for network interface configuration, optimization, and debug. You can quickly View 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 a network interface to display only information about this interface.
- ifconfig
- ifconfig eth0
Ifdown & ifup
The ifdown and ifup commands have the same function as running ifconfig up and ifconfig down. You can only disable or enable a specified network interface. Root permission is required, so sudo is required for running on Ubuntu.
- sudo ifdown eth0
- sudo ifup eth0
If you run these two commands on a Linux desktop system, an error message may be output. Linux desktop uses the network manager to manage your network interfaces. However, these two commands are still available on the server version that does not have the network manager installed.
If you want to configure the network manager on the command line, use the nmcli command.
Dhclient
The dhclient command can release the IP address of your computer and obtain a new IP address from the DHCP server. The root permission is required, so sudo is required on Ubuntu. No option to run the command to obtain a new IP address, or specify the-r switch to release the current IP address.
- sudo dhclient -r
- sudo dhclient
Netstat
The netstat command displays a lot of statistics about network interfaces, including opened sockets and route tables. No option to run the command to display the opened socket.
This command also has many functions. For example, the netstat-p command can display the program corresponding to the opened socket.
Netstat-s displays the detailed statistics of all ports.