If you’re a Windows system administrator with a need to log into a Linux server and troubleshoot it, this article is for you.
Log into Linux
Logging into a Linux server can be done via any of the following:
- Login with to a remote Linux server using SSH.
- Login at the console using a monitor, keyboard and mouse while sitting in-front of the Linux system.
- Login using the virtualization console such as via VMWare or Hyper-v.
The method that you use is up to you and difficult for me to advise on here. Just know that the safest way is via the console because any interruption to the network won’t stop you from doing your work.
Check Who Else Is On The Server
You’ll want to know who else is on the server before you start working. You can find out who else is on with the “who” command:
who
Once you know who’s on the server, you can call them, message them or write on their wall. Seriously, try is with the “wall” command:
wall "Hey, i'm working on this server... Andrew G"
The above will send a message to all other logged in users. They can reply in the same way.
Check The Type Of Linux Server
Broadly speaking there are two types of Linux; Redhat and Debian. You can see which type you are using by issuing the following commands. One will work and one will fail. The first one below will work on a Redhat based system (such as Redhat, Fedora and CentOS) while the second will work on Debian based systems (such as Debain, Ubutnu and Mint).
cat /etc/redhat-release
or
cat /etc/debian_version
Check Disk Space
The “df” command will give you a summary of the disk space. The command “df -h” will present the numbers in a nicer format. Finally the “df -i” will show the same information but in relation to the inodes rather than actual disk usage.
df -h
See where the disk space is being used with the “du” command. You can use “du -h” for a nicer output. You can use the “–max-depth=1” to show “1” level of directories. Finally you specify the starting point such as “/” (the entire filesystem) or “/home” for the users home directories. Putting it all together it looks like this:
du -h --max-depth=1 /home
Network Details
On Windows you have the “ipconfig” command. On Linux you have three commands; “ifconfig”, “route” and “cat /etc/resolv.conf”. Actually there is another command if you specifically want wireless network details “iwconfig”.
To show the IP address, netmask, mac address and network statistics (including errors):
ifconfig
To show the routes where “-n” prevents resolving names:
route -n
To show the DNS servers being used for name resolution. The following command simply displays the contents of the “/etc/resolv.conf” file which is where Linux looks to find out what DNS servers it should be using.
cat /etc/resolv.conf
Testing the Network
The usual commands such as “ping”, “netstat” and “tracert / traceroute” are available in Linux but work a little differently.
Ping a remote system. Unless you specify how many times to send a ping (with -c X) the ping tool will never end.
ping -c 4 10.1.2.3
Show netstat details. The following will not resolve namess (-n) and it will list whatever is listening on listed ports and interfaces.
netstat -nlp
List the route IP packets take between the source and destination. You can use either “tracepath” or “traceroute” if both are installed.
tracepath 8.8.8.8
Get the Time and Date
Everything needs the correct time so it’s important and simple to find the time and date of a Linux server.
date
Reboot or Shutdown the Server
You can reboot a server using the following command. The “-r” means “reboot”:
shutdown -r now
You can shutdown a server using the following command. The “-h” means “halt”:
shutdown -h now
Show Performance Information
You can show high-level performance information with the “top” command.
top
Show Firewall Details
You can see the firewall with the “iptables” command. The “-L” command is needed to list the rules. Use “-n” to prevent host and port name resolution:
iptables -L
I will list more commands and tips as i think of them.
ifconfig has deprecated on newer distributions – probably best to mention ‘ip a’ as a replacement.