Tuesday, January 30, 2007

Commands I need to remember

This will be a bit of a work-in-progress post. The idea is that I sometimes find neat commands I really should know because, let's be quite honest, they can save a lot of time and aggravation. I am going to make this a series of articles -- one specifically for linux, another for OSX, another for Solaris, another for Windows, one for generic unix stuff, and whatever else I can think of -- to keep things organized in my demented mind. So, let's start with linux:

Boot> linux dd

This is entered when you boot the machine up, whether by a CD or its own hard drive or whatever. You know, when the machine asks you if you want to change the boot options. I used that during a centos install and booting a (once again) centos liveCD distro. What it does is ask you during the boot process to insert a disk/cd/floppy/whatever with extra drivers it needs to know about. Made setting up a certain supermicro's onboard SATA raid controller possible right at boot time, because centos 4.4 was not aware of that raid controller.

Finding OS Version

I do not know about you but every so often I need to find out which version of OS I am running. Originally I thought all Linuces were the same, but I was wrong. In fact, that is the reason I started writing that down. Then, I decided to expand for the different unices and other operating systems I mess with. So, we have.

  • Redhat (RHES4 box in this example):

    $ cat /etc/redhat-release
    Red Hat Enterprise Linux ES release 4 (Nahant)

  • ubuntu

    raub@keg:~$ ls /etc/issue*
    /etc/issue  /etc/issue.net
    raub@keg:~$ cat /etc/issue
    Ubuntu 7.04 \n \l
    raub@keg:~$ cat /etc/issue.net 
    Ubuntu 7.04
    raub@keg:~$ cat /etc/issue.net 
    Ubuntu 7.04
    raub@keg:~$ lsb_release -a
    No LSB modules are available.
    Distributor ID: Ubuntu
    Description:    Ubuntu 7.04
    Release:        7.04
    Codename:       feisty
    raub@keg:~$ cat /etc/lsb-release
  • AIX

    $ oslevel
    $ oslevel -r
  • Solaris

boot {disk, cdrom, net} {-r}

open boot command to start the boot process. Normally you have the machine configured such that when it turns on it knows where to boot from, but if you are doing things to the machine and want to specify which device to boot from, you would use this command. I am not going to go over all its details but it suffice to say if you type disk it would boot off its default disk. The same goes for cdrom. Now, the -r option is used to tell it to scan for new hardware devices, which is important if you added/removed devices and drives and little cards from the machine.

Where does the scripts to strt files during the startup hide?
  • Redhat

  • BSD, Debian


pkgadd is one of the most common ways to install packages in a Solaris box. It is similar in certain ways to rpm in Linux. Incidentally, if you want something more on the lines of apt-get, you want to look into pkg-get, which I shall talk about later on. But, for now, we spend a bit of time with pkgadd.

Let's say, for the sake of argument, that you decided to get a sunpci 2 pro card for your trusty Solaris box. So, after you install the card and reboot the machine (we will talk about the entire process in another blog entry), you go to the sun website and get the file SUNWspci2.3.2.tar.Z.


Then you untar/uncompress the file:

raub@nassau-26>zcat SUNWspci2.3.2.tar.Z | tar xf -
SUNWspci2  SUNWspci2.3.2.tar.Z

As you can see, you ended up with a new directory, SUNWspci2. Now the next step is to run pkgadd itself:

root@nassau-19>pkgadd -d .

The following packages are available:
 1  SUNWspci2     SunPCi II
                  (sparc) 2.3.2

Select package(s) you wish to process (or 'all' to process
all packages). (default: all) [?,??,q]:

You will notice that I entered a dot (.) as the name of the package. What that means is every package in the current directory. I could specify which package but I am lazy. Also, I am given the option of which packages to install anyway. As you probably guesses, -i stands for install package.

After careful consideration, I decided not to include AIX in this entry; since it is so different from the other Unix flavours, I've decided to make its own entry. Keep an eye for it!