System commands 101
So, now we've covered the basic commands needed to mess around with files and directories. Finally, it's on to the fun stuff, system commands. Some of these commands require elevated privileges to be executed. In plain words this means that some commands mess with your system and only root can do them.
First, let's meet “
top” the 'graphical' list of the current tasks running on your host. It provides a load of information on what is going on, and what makes a system tick. However, it's not exactly handy to work with.
If you like a more functional interface,
htop is a better implementation of top. “Htop” isn't installed standard on a system, but it's in nearly all
package managers and will be installed in a matter of seconds. On our Debian system
apt-get install htop installs the program for us.
The fun thing about “htop” is the way it shows processes. If you turn on the tree view, you'll see how the process structure is working. Also, if something isn't doing what it is supposed to do, “htop” can alter “
nice”-levels or even “
kill” processes (if htop is started as root).
Now, let's take a look at disk utilities.
For our example, I have added a 100MB IDE harddisk to my Virtual System. After restarting, Linux will show this new drive under '/dev/hda'. For reference, drives are always illustrated in '/dev/', and are listed as:
- hda - IDE 0, Drive 0 (Primary Master),
- hdb - IDE 0, Drive 1 (Primary Slave),
- hdc - IDE 1, Drive 0 (Secondary Master),
- hdd - IDE 1, Drive 1 (Secondary Slave).
SATA drives are lettered sequentially - sda, sdb, etc, and CD Rom drives are listed as just that - CDROM. Though that doesn't sound important, it can be an amazing insight into how the system is built, including the drives and their order on the chain. And, if you're the system builder, it's a guarantee that you know which drive you're accessing.
Now, back to our disk. Since we see this drive as 'hda', we know that VMWare has placed it as the primary master. A completely blank, unformatted disk isn't exactly useful, though, so we need to add a partition to it. Old-school people will use “
fdisk” for this, but “
cfdisk” is much more user-friendly. So, fire it up (this must all be done as root) by doing
cfdisk /dev/hda. “New” creates new partitions, and asks the user for the needed information. Don't forget to “Write” it before you “Quit”!
Next, we need to make a filesystem on the partition (which is not-so-creatively named /dev/hda1, for the first partition on hda). There are a huge number of different filesystems you can use, but
ext3 is a widely adapted filesystem. We 'format' the disk with
mkfs.ext3. So issue
mkfs.ext3 /dev/hda1 and, upon successful completion, you are shown some statistics on the newly created filesystem.
Finally, we need to attach the filesystem to our tree structure. This is called 'mounting' and is done through the “
mount” command. Syntax is as always - “mount <what> <where>”, or in our case,
mount /dev/hda1 /mnt/test. If you issue the
mount command without arguments, you'll get a list of all the mounted filesystems - handy for checking out what someone has set up on another computer.
To check how much space there is left on our mounts, we use “
df”. To make it readable to humans, instead of listing blocks, use
df -h.
Finally, if you want to unmount the device again (like you
must do with USB sticks or USB HDDs), the “
umount” command is the weapon of choice. Issue
umount /mnt/test to remove our recently created hard disk from our filesystem tree.
That's all there is to getting around the filesystem. Though it seems like a lot of information, that's because it is - you are now able to comb through a computer, be it yours or someone else's, and view
everything about the computer's filesystems. You can even explore Windows-based NTFS systems with this, as long as you have a newer distro...just boot up from a LiveCD on your own computer and give it a try!
Want to comment? Please log in.