Author: Joe Barr
whereis
, whatis
, df
, kernelversion
, ifconfig
, route
, and last
— that can quickly answer questions about your system or configuration. Wipe that GUI mess out of your eyes and meet me at the CLI. Where is that darn command?
You know the command is on your system, because you’ve used it before. But now you can’t remember where it lives. Is it in /sbin? Or /usr/bin? Somewhere else? The whereis
command is designed to answer that very question. In fact, whereis
will tell you not only where to find the executable command, but the source code — if it’s present — and man pages as well. All you need to do is ask, by providing the name of the command you’re looking for:
warthawg@linux:~> whereis whatis whatis: /usr/bin/whatis /usr/share/man/man1/whatis.1.gz
What is that command for?
Maybe you’ve heard people mention a command, but aren’t sure what it does. All you have to is ask. Here’s a metaphysical example to consider:
warthawg@linux:~> whatis time time (1) - time a simple command or give resource usage time (2) - get time in seconds time (n) - Time the execution of a script time (1p) - time a simple command time (3p) - get time
How much disk space do I have left?
An excellent question to ask from time to time, and especially before a critical drive fills up completely. To get the answer, type df
on the command line. This handy little utility shows you how much space you’ve used and how much is left in every mounted file system. Like this:
warthawg@linux:~> df Filesystem 1K-blocks Used Available Use% Mounted on /dev/hdc1 19550436 3493984 16056452 18% tmpfs 517572 0 517572 0% /dev/shm /dev/hda2 7847500 32840 7814660 1% /downloads /dev/hdd1 115380192 39944740 69574416 37% /home
I’m running the 2.4 kernel, what about you?
If you hang around Linux people very long, whether it’s a LUG meeting or online chat, someone is going to ask what version of the kernel you’re running. There’s a command to tell, just in case you forget:
warthawg@linux:~> /sbin/kernelversion 2.6
What’s my IP address?
Sometimes you just have to know your IP address. Entering ifconfig
without any arguments is one way to find out, and learn a lot more as well:
warthawg@linux:~> /sbin/ifconfig eth0 Link encap:Ethernet HWaddr 00:50:8D:4E:9D:D0 inet addr:192.168.0.101 Bcast:192.168.0.255 Mask:255.255.255.0 inet6 addr: fe80::250:8dff:fe4e:9dd0/64 Scope:Link UP BROADCAST NOTRAILERS RUNNING MULTICAST MTU:1500 Metric:1 RX packets:74969 errors:0 dropped:0 overruns:0 frame:0 TX packets:76379 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:54194289 (51.6 Mb) TX bytes:12136154 (11.5 Mb) Interrupt:11 Base address:0xe800
How do I get to the Internet from here?
OK, you found out what your IP address is — even if it is private, like the one above — but how do you talk to the Internet? The route
command can give you the answer. No arguments required:
warthawg@linux:~> /sbin/route Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use Iface 192.168.0.0 * 255.255.255.0 U 0 0 0 eth0 link-local * 255.255.0.0 U 0 0 0 eth0 loopback * 255.0.0.0 U 0 0 0 lo default 192.168.0.1 0.0.0.0 UG 0 0 0 eth0
As you can see, my default gateway has an IP address of 192.168.0.1. In my case, that’s my router, which talks to the LAN on one side and to the cable modem/Internet on the other.
At last
Last we have last
. Enter it without any arguments and it will show you the last system signons to your system, going as far back as the log files allow it to go. The output looks like this:
warthawg pts/0 :0.0 Mon Jul 18 16:43 still logged in warthawg pts/0 :0.0 Mon Jul 18 16:42 - 16:42 (00:00) warthawg pts/0 :0.0 Mon Jul 18 16:40 - 16:40 (00:00) warthawg pts/3 :0.0 Mon Jul 18 15:35 - 15:39 (00:04) warthawg pts/2 :0.0 Mon Jul 18 14:47 still logged in warthawg pts/0 :0.0 Mon Jul 18 14:36 - 16:34 (01:58) warthawg pts/0 :0.0 Mon Jul 18 14:23 - 14:36 (00:13) warthawg pts/0 :0.0 Mon Jul 18 14:20 - 14:23 (00:02) warthawg pts/2 :0.0 Mon Jul 18 14:07 - 14:18 (00:11) warthawg pts/2 :0.0 Mon Jul 18 13:44 - 13:45 (00:01) warthawg pts/0 :0.0 Mon Jul 18 11:52 - 14:07 (02:15)
There you have it. A tease on seven different commands you can use to get information about your system. Many of them allow arguments that you can use to tune and modify the output. If any of these have caught your fancy, do the man thing.