DæmonNews: News and views for the BSD community

Daemon News Ezine BSD News BSD Mall BSD Support Forum BSD Advocacy BSD Updates

Gathering System Information

By Chris Coleman chrisc@vmunix.com

If you manage multiple BSD computers, you have noticed that one command line looks very much like any other command line. It is easy to get turned around and think you are working on one computer, when you are really working on another. This is especially true if you use the same or similar passwords on multiple systems.

I know several BSD admins that have rebooted the wrong computer because they forgot which computer they were logged into. They all look the same when you are logged in remotely.

BSD provides several utilities to display information about the computer you are working on. hostname will display the name of the computer you are logged into.

myname# hostname
myname.my.domain

This helps if all you need to know is the name of the computer to verify that you are working on the right one. However, this isn't always enough. The next level of information about your system can be gathered from the uname utility. According to the man page:

The uname command writes the name of the operating system implementation to standard output. When options are specified, strings representing one or more system characteristics are written to standard output.

If you just type uname it will tell you which operating system it is.

To get any really useful information from uname, we need to use the -a option. I have listed below the uname -a output from FreeBSD, OpenBSD, and NetBSD. I tried to grab one from different architectures as well as different BSDs. I don't actually have all these machines, so I grabbed these off the mailing list archives.

myname# uname -a
FreeBSD myname.my.domain 3.3-STABLE FreeBSD 3.3-STABLE #8: Fri Dec 17 20:43:04 GMT 1999 root@myname.my.domain:/usr/src/sys/compile/grumpy i386

# uname -a
OpenBSD bigturd 2.5 GENERIC#172 sparc

pc164# uname -a
NetBSD pc164 1.4P NetBSD 1.4P (PC164.v6-intl) #5: Sat Nov 27 18:31:37 CET 1999 root@pc164:/usr/src/sys/arch/alpha/compile/PC164.v6-intl alpha

Each one of them starts out by printing the operating system type, followed by the computer name. Then it gives the OS version. The # following the OS version is the number of times the running kernel has been recompiled without modification to the kernel configuration file. Basically, the system was upgraded or changed and they used the same kernel config file.

The architecture of the computer is also listed, along with the name of the Kernel config file that was used.

When you are asking other people for help, especially on a mailing list, they will want to know the output of uname -a. Yet, there will often be times when this is still not enough information about your system. dmesg is a utility that will display the information that appeared during boot up. This includes the processor speed, amount of RAM memory, and all the device drivers that loaded.

OpenBSD 2.1 (TWP) #3: Sat Jul 19 18:37:43 CDT 1997
    twp@twp.tezcat.com:/usr/src/sys/arch/i386/compile/TWP
CPU: Pentium (GenuineIntel 586-class CPU) 133 MHz
BIOS mem  = 654336 conventional, 32505856 extended
real mem  = 33157120
avail mem = 29097984
using 430 buffers containing 1761280 bytes of memory
mainbus0 (root)
isa0 at mainbus0
com0 at isa0 port 0x3f8-0x3ff irq 4: ns16550a, working fifo
com1 at isa0 port 0x2f8-0x2ff irq 3: ns16550a, working fifo
lpt0 at isa0 port 0x378-0x37f irq 7
isadma0 at isa0
aic0 at isa0 port 0x340-0x35f irq 11
scsibus0 at aic0: 8 targets
probe(aic0:3:0): sync, offset 8, period 100nsec
sd0 at scsibus0 targ 3 lun 0:  SCSI2 0/direct fixed
sd0: 2063MB, 6703 cyl, 5 head, 126 sec, 512 bytes/sec
cd0 at scsibus0 targ 4 lun 0:  SCSI2 5/cdrom removable
wdc0 at isa0 port 0x1f0-0x1f7 irq 14
wd0 at wdc0 drive 0: 
wd0: 2067MB, 4200 cyl, 16 head, 63 sec, 512 bytes/sec (96KB cache)
wd0: using 16-sector 16-bit pio transfers, lba addressing
npx0 at isa0 port 0xf0-0xff: using exception 16
vt0 at isa0 port 0x60-0x6f irq 1: s3 765 (Trio64 V+), 80 col, color, 8 scr, mf2-kbd, [R3.32]
spkr0 at vt0 port 0x61
fdc0 at isa0 port 0x3f0-0x3f7 irq 6 drq 2
fd0 at fdc0 drive 0: 1.44MB 80 cyl, 2 head, 18 sec
pci0 at mainbus0 bus 0: configuration mode 1
vendor 0x8086 product 0x7030 (class bridge, subclass host, revision 0x02) at pci0 dev 0 function 0 not configured
vendor 0x8086 product 0x7000 (class bridge, subclass ISA, revision 0x01) at pci0 dev 7 function 0 not configured
vendor 0x5333 product 0x8811 (class display, subclass VGA, revision 0x54) at pci0 dev 9 function 0 not configured
biomask 4840 netmask 4840 ttymask 48da
root on wd0a

This dmesg output provides a lot of very helpful information. The downside to this is that is isn't apparent to the new user what it all means. The first section of it describes the operating system, CPU type and physical RAM memory. Try to get Windows to tell you that with out rebooting. :-)

The rest of the dmesg output is a list of devices drivers and how they loaded. I'll list a few of the basic devices:

    aic0 is the SCSI controller.
    sd0 is the first SCSI disk drive.
    wd0 is the first IDE disk drive.
    cd0 is a SCSI CD Drive.
    wdc0 is an IDE controller.
    fdc0 is the floppy disk controller.
    spkr0 is the internal speaker.
    fd0 is the floppy disk drive.

These will differ a bit on each BSD and they tend to change a little over time. This is an older dmesg, but it does the job.

There is still some information that we might need. The filesystem has not been addressed yet. We still need to be able to tell how much disk space we have available and how our filesystem is arranged. The command df displays the filesystem layout and how much of it is used. According to the man page:

Df displays statistics about the amount of free disk space on the speci- fied filesystem or on the filesystem of which file is a part.

chris# df
Filesystem  1K-blocks     Used    Avail Capacity  Mounted on
/dev/wd0s1a     31743    27686     1518    95%    /
/dev/wd0s1f   1359855  1078917   172150    86%    /usr
/dev/wd0s1e     31743     5779    23425    20%    /var
procfs              4        4        0   100%    /proc

Each disk or partition on disk is listed. The "Mounted on" listing shows which directory device is attached to. For example we have 172 Meg available in the /usr/ directory and only 23 Meg available in the /var/ directory.

This should be enough information to keep you informed about your computer. For further information read the man pages for dmesg, df, and uname.

Google
Web daemonnews.org

More Articles
  • Interview with Jan Schaumann
  • Interview with Theo de Raadt
  • Book Review: Virtualization with VMware ESX Server
  • Editorial: Not Quite Dead Yet
  • The Design of OpenBGPd
  • Interview with der Mouse
  • Letter to Steve Jobs
  • Interview with Manuel Bouyer on Xen
  • Apple and Open Source
  • BSDCan 2006
  • BSD Certification Survey Results
  • Lab in a Box
  • Ike Notes on BSDCan 2005
  • BSDCan 2005 Photos
  • FreeBSD Developer Summit Pictures

  • Advertisements




    Author maintains all copyrights on this article.
    Images and layout Copyright © 1998-2006 Dæmon News. All Rights Reserved.