10 Useful Linux Terminal Commands

Gnome Terminal

1. $ whoami#

Okay, I hear you, this might not be that useful, but shh! I enjoy it nonetheless. This command basically just prints out the name of the current user. After a long programming session I occasionally like being told my own name.

2. $ arch#

This is a surprisingly useful terminal command if you spend your time installing many different Linux distributions and changing between 32-bit and 64-bit. This command will simply and quickly tell you if whether you are using x86_64 or x86_32.

3. $ xset -dpms#

If you have recently upgraded to using gnome3 you may have found it has very little in the way of customizing it’s power settings. This means your monitor might turn off half way through watching a video. The xset -dpms command basically just turns off power management in X.

4. $ hostname#

The command hostname on its own will print the current hostname of your computer, which is great if you don’t already know it, but if you were to type: ‘hostname newHostname’ it would set newHostname as your newHostname. Note: This will be lost on restart and needs to be set in /etc/hosts as well.

5. $ netstat -tulpn | less#

This is a quick way to list which ports are open in your systems firewall. Great for checking if a recent change is active. If you want to open a port in your firewall use the ‘sudo gedit /etc/sysconfig/iptables’ command to edit the iptables file.

6. $ sensors#

The package ‘lm_sensors’ is required for this to work. Once setup correctly this command will print out the temperatures and voltages of your CPU and mainboard. This is a great way to check your computer/sever is running correctly over an ssh connection. If you use Ubuntu this page might help.

7. $ ping -i 5 -a #

The ping command, as I’m sure you’re aware, basically checks to see if there is a response from an IP address but this command specifically checks for the IP every 5 seconds and then beeps once it gets a response. Great for checking when your internet connection comes back online.

8. $ sudo shutdown -h 60#

I love watching films in bed but commonly fall asleep to them, with this command I can tell the computer to shutdown by itself in an hours time. The time is calculated in minutes by default but you can specify an exact time, such as 8:00.

9. $ ps aux | sort -nrk 4 | head#

List the top 10 resource intensive applications currently running on your computer, which can be an efficient way to find out which applications are causing your system to grind to a halt. Once you have found the application in question you can shut it down with the kill command.

10. $ ssh username@hostname#

I have, admittedly, only just got into ssh but I find it amazingly useful being able to run commands on different computers. For the future I would like to look into more X Forwarding over ssh.