GNU/Linux is bursting with information about the system on which it runs. The system's hardware and memory, its Internet link and current processes, the latest activity of each user -- all this information and more is available. And, despite such desktop tools as the KDE Control Center or GNOME's System Monitor, the easiest place to get all the system information available is still the command line.
In many cases, you can view system information via specific commands. Some of these commands are written specifically to give information, while other commands that are mainly intended to alter the system in some way just happen to include parameters for viewing the current state of the system.
In other cases, you can view system information through log or configuration files or the /proc virtual filesystem. Many such files are written in plain text, so all that you need to view them are basic commands that output a file's content to the command line, such as cat, less, or more.
Commands for reading system information
One of the simplest commands for reading system information is arch, which gives back the architecture of your computer, listing Pentiums as i586 and a Pentium II or greater or i686. However, a more complete analysis of your system is available using
uname -a, which lists in a single line the operating system, local host, kernel release and build information, and the processor type. You can flesh out this information further by using
fdisk -l to list partitions, and
swapon -s for information about any swap partitions that you are running. For information about current system usage, including which users are currently logged on and what processes they are running, a simple
w suffices. To learn which kernel modules are loaded, run
Several commands report on memory. For RAM, the basic command is
free -m, which tells you the total amount of RAM and swap space on your system, as well as how much of each is used and how much is free. For hard drive space, you can use the df command to report on the entire system, or specify the device block of a particular filesystem. An especially useful version of the command is
df -hiT, which lists the size of each filesystem, how much space is used and available on it, and its inodes and its mount points. If you need to know the size of a specific file or directory, use
du path or
ls -s du path.
If you are interested in your Internet connection, then
nslookup host-server will give you the domain name and address. The
dnsdomainname command displays the domain name, and so will
hostname -d, while
hostname -i returns your IP address.
Another set of commands gives you information about the processes on the system. One of the most commonly used process commands is
top, which gives you a continuously updated display of the processing using the most memory on the system until you close it by pressing Ctrl-C. For a complete list of running processes, enter
ps auS (note the lack of a hyphen in front of the parameters). Another view of current processes comes from pstree, which displays parent and child processes -- that is, which processes are started by other processes. Alternatively, you can use
fuser -c process to check whether a process is using the contents of the current directory.
Still another set of commands allows you to gather information about users and what they are doing. The command
group user tells you what groups the designated user belongs to, while
id user gives the same information, in addition to the user and group IDs. The command
finger user will give you more information, including the last time the user logged on to the system and whether the use has mail waiting in /var/mail. And, should you really get stuck, perhaps because you have been logging in and out of system accounts, you can use the whoami command to orient yourself.
Other information sources
Besides specific commands, you also have several other sources of system information. One is the collection of logs in /var/log, which contain the latest information about what is happening on your system. For instance, as you can tell from the names, kern.log records kernel activity, while user.log tells you who is logged on to the system and what they have been doing recently. If you are troubleshooting, you can keep a log open and constantly updated with the command
tail -f logfile.
Most logs can be read using standard the standard reading commands, but, depending on your distribution, some may be in a specialized format that requires a special command to read. For example, on Debian, the /var/log directory includes such files as dmesg, which records the most recent system boot, and faillog, which records the last time users tried to log in, and lastlog, which lists users and the last time they logged in, all of which are viewed using commands with the same name as the log.
Another prime source of information is the /proc directory, the virtual filesystem that contains current information about everything from the hardware and the kernel through to the processes now running on the system. Some of the information is stored a directory level or two down, such as the list of sound cards in /proc/asound/cards or the list of SCSI devices in /proc/scsi/device_info. Just be sure that all you do is read the contents of /proc; deleting, moving, or editing any of the files could cause a system crash.
Configuration files such as /etc/fstab, which lists the available filesystems, are also a useful source of information. In fact, most of /etc is worth knowing your way around, especially when you are troubleshooting specific programs.
The advantage that all these sources have is that, instead of needing to remember specific commands to get the information you want, all you need to do is display the information. Most, if not all, the information you can get from specific commands is also available from these sources. For instance, the command
swapon -s gives you the same information as
Whatever source of information you use, a GNU/Linux system is full of information about itself, all of which is available from the command line. All you need to supply is a willingness to dig for it.