Every Linux user will tell you the same thing: know your computer. Mine always works not because there are no bugs, but because I know enough to identify their sources every time and correct them. And one of the best ways to monitor your system is through the command line. There are some great GUI for this, but the command line has the advantage of working on every computer, and it can easily be put into a script.
I propose to you five great commands for:
- Knowing your kernel
- Finding hidden processes
- Listing running modules
- Checking disk usage
- Locating binaries and configuration files
1. Knowing your kernel
The kernel is the core of your Linux system. It is frequently updated, and knowing its version may be important for compatibility reasons. Certain programs may require a certain version in order to work properly. It may also be important for some peripherals and modules. As an example, my Ubuntu is based on the official kernel 3.0.0. So far, the latest version is 3.2.5.
To know exactly what kernel you are using, its version, and your computer architecture, use the command:
With this example, we can clearly see that I am using the official kernel, version 3.0.0. The i686stands for my computer architecture. Here it means that I am using a 32-bit computer. On the other hand, x86_64 would have indicated a 64-bit architecture.
2. Finding hidden processes
To know what processes are currently running on your machine, most people would recommend the command “
top“. Joshua wrote a very good article about it last year at
Linux Running Too Slow? Here’s How to Find the Cause. Personally, I find this command very useful, and as Joshua explains, it can even be used to monitor the RAM usage.
However, I am sometimes too lazy to search in the list provided by “top“, and if I already know the name of the program running, I recommend the combination:
ps aux | grep [name of the program]
This will have the effect of listing all the current processes, even the smallest ones that will not be picked up immediately by “top“, and then filtering them according to your keywords.
This method will instantly give you the name of the user responsible for this process, the PID number, the CPU usage percentage, the memory usage, the name of the process, etc.
As a side note, if you don’t know how to kill a running process:
OR
killall [name of the process]
3. Listing running modules
Modules appeared in version 2.0 of the Linux kernel. They are very useful, and you can consider them as drivers that you can load and remove from the memory. As an example, if you are using a laptop, you probably have a WiFi card. The corresponding modules for that card are probably loaded automatically at start up. If you want to save some battery, you may want to stop the card when you are not using the Internet. Removing the corresponding driver from the memory will then give you a little bit more memory (and you will also be sure that your card is disabled).
But first you need to know which modules are currently running. The command for that is
This command is simply the combination of “ls” for listing files in a directory and “mod ” for module (I know, what a surprise).
As a complement to your knowledge, you can add modules with the command
modprobe [name of the module]
and remove them via
rmmod [name of the module]
These two commands have to be launched by a super-user.
4. Checking disk usage
Keeping an eye on your system’s volumes can save you a lot of trouble. You may want to be sure that there is always enough room in /root, and remember to periodically clean your /tmp. For that purpose, there are two great commands:
and
lsblk displays a tree representation of the partitions of your computer. It also gives you some useful information about the size of these partitions, their type, and their mountpoint.
However, even if lsblk is more visual, I still prefer to use df -h. The latter gives you more information about the remaining space, the size of the partitions, and the percentage of memory in use.
You may have noticed that the command df alone will give you the size in bytes, which might be very hard to interpret. The option -h stands for human readable and gives you the amount of data in gigabytes, megabytes, or whatever is the easiest for a human to understand.
5. Locating binaries and configuration files
One of the first things that confused me when I left Windows a few years ago was that the file system was completely different on Linux. There is no such thing as Program Files, or a single directory for all the configuration files. But it may be very useful to know where these binaries are. For that purpose, the command:
is among the best. Similarly to
which gives you the name of the current user, or
which explains a command quickly, whereis can locate binaries, manual entries, and various configuration files. Its syntax is also very simple:
In the example above, I asked where Firefox was, and the command returned the location for its binary and various directories, as well as the manual page.
But one of the greatest strengths of whereis is its ability to locate standalone configuration files. Here is another example, where I was searching for rc configuration files:
Such options can become very useful, especially if you are not using Ubuntu but another distribution like Archlinux which requires a serious amount of time to edit these files.
Conclusion
With these commands in your pocket, you will be able to see a little more of what is going on in your system. If you still prefer to have a GUI for that, I would still recommend things like Baobab for the files and Gnome System Monitor in general.
Are you using other commands? Other GUIs? Let us know in the comments.