Linux Troubleshooting Commands
1. hostname - hostname command in Linux is used to obtain the DNS(Domain Name
System) name and set the system’s hostname or NIS(Network Information System) domain
name. A hostname is a name which is given to a computer and it attached to the network. Its
main purpose is to uniquely identify over a network.
Syntax :
hostname -[option] [file]
Options:-
a) -a : used to get alias name of the host system(if any). It will return an empty line if no alias
name is set.
b)-A : used to get all FQDNs(Fully Qualified Domain Name) of the host system.
c) -b : Used to always set a hostname. Default name is used if none specified.
d) -d : used to get the Domain if local domains are set. It will not return anything(not even a
blank line) if no local domain is set.
2. host- Displays domain name for given IP address or vice-versa. It also
performs DNS lookups related to the DNS query. The host command's default
behavior displays a summary of its command-line arguments and supported
options.
Syntax:
The host command supports various command-line arguments and options.
The basic syntax for the host command is as follows:
host <name>
Options:-
-4: It is used for Ipv4 address only for the query.
-6: It is used for IPv6 address only for the query.
-a: The '-a' option stands for "All." It is equivalent to '-v', '-r', 's', any
option. But, it influences the behavior of the '-l ' option.
3. ping - PING (Packet Internet Groper) command is used to check the network
connectivity between host and server/host. This command takes as input the IP address
or the URL and sends a data packet to the specified address with the message “PING” and
get a response from the server/host this time is recorded which is called latency.
Syntax-
ping <ip address of destination source>/<url link>
sudo ping -V to check the ping version installed on your system
ping www.youtube.com
To stop pinging we should use ctrl+c otherwise it will keep on sending packets.
4. ifconfig - ifconfig(interface configuration) command is used to configure the
kernel-resident network interfaces. It is used at the boot time to set up the interfaces
as necessary.
Syntax:
ifconfig [...OPTIONS] [INTERFACE]
options:-
-a : This option is used to display all the interfaces available, even if
they are down.
Syntax:
ifconfig -a
-s : Display a short list, instead of details.
Syntax: ifconfig -s
5. route - route command in Linux is used when you want to work with
the IP/kernel routing table. It is mainly used to set up static routes to
specific hosts or networks via an interface. It is used for showing or
update the IP/kernel routing table.
Many Linux distributions do not have route command pre-installed. To
install it use the following commands as per your Linux distribution.
In case of Debian/Ubuntu
$sudo apt-get install net-tools
In case of CentOS/RedHat
$sudo yum install net-tools
In case of Fedora OS
$sudo dnf install net-tools
6. ip- used to show or manipulate routing, devices, and tunnels. It is similar to
ifconfig command but it is much more powerful with more functions and facilities
attached to it.
Syntax:
ip [ OPTIONS ] OBJECT { COMMAND | help }
-link: It is used to display link layer information, it will fetch characteristics of
the link layer devices currently available.
This link option when used with -s option is used to show the statistics of the
various network interfaces.
ip -s link