Basic Networking Command Tools in Linux

# w
  Shows who all are currently logged in and where they are logged in from. It also shows the load average of the server.

# who
  It also shows who is logged in.

# netstat
  Shows all current network connections.

# netstat -an
  Shows all connections to the server, the source and destination ips and ports.

# netstat -ntul
  Shows all the listening sockets.

# route -n
  Shows routing table for all ips bound to the server.

# top
  Shows live system processes in a formatted table, memory information, uptime and other useful info.

# top -u root
  Show processes running by user root only.

# nslookup  <domain_name>
  Query your default domain name server (DNS) for an Internet name (or IP number).

# traceroute <IP or domain_name>
  Displays each host that a packet travels through as it tries to reach its destination. This command is only run by root user.

# tracepath <IP or domain_name>
  To trace the route of a packet to the <IP or domain_name>. This command can run by any user. When compare to traceroute, tracepath has only limited options.

# ifconfig -a
  Display info of all the network interfaces on the server.

# ifconfig eth0 down
  This will take eth0 (assuming the device exists) down, it won’t be able to receive or send anything until you put the device back “up” again.

# ifconfig eth0 up
  This would take eth0 up and available to receive or send packets.

# ping <IP or domain_name>
  ping sends an ICMP ECHO_REQUEST packet to the specified host. It provides a very quick way to see if a machine is up and connected to the network.

# hostname
  Show the system's host name

# findsmb
  Used to list info about machines that respond to SMB name queries. findsmb with noargument would find all machines possible. You can also specify a particular subnet to localize search.

# host <domain_name>
  Performs a simple lookup of an internet address using DNS.

# dig <domain_name>
  The “domain information groper” is a DNS look up tool. This looks up information about <domain_name> in the DNS.

# dig -x <IP>
  Looks up the address and returns the associated domain name.

# dig -t MX <domain_name>
  TO show MX records of <domain_name>

# dig -t ANY <domain_name>
  To view all the record types (A, MX, NS, etc.).

# dig @<dnsserver_name>  <domain_name>
  By default dig uses the DNS servers defined in your /etc/resolv.conf file. We can use a different DNS server to perform the query, specify it in the command line.

# whois <domain_name>
  Used to look up the contact information from the “whois” databases. Also reports IP address and name server of domain as well as creation and expiration dates.

# ftp <IP>  [port]
  File transfer protocol. Transfers files to another host (insecure).

# telnet <hostname>
  Allows to remotely login to a computer. telnet does not encrypt the information it sends. Everything is sent in plain text, even passwords.

# telnet <hostname> [port]
  To connect to a host on a certain port. We can easily check wheter a specifc port on a server is listening or not, using telnet command.

# ssh <user_name>@<IP or domain_name> -p [port]
  Allows to remotely connect to <IP or domain_name> via [port]. Unlike telnet, all the information in this session are encrypted.

# scp -r <user_name>@<IP or domain_name>:<source_file_path> <local_file_path>
  With the scp (secure copy) command you can easily copy from and to a remote computer or between remote computers.

This entry was posted by Unknown. Bookmark the permalink.