[unixbigots.org]

Reviews


Unknown Commands by Obnox

UNIX has many commands, as we are all aware. However, there are some that you just learn from experience. Here are some commands that I've rarely seen documented in books that are often plunked on to my command line.

Finding Stuff with which and find
The which command searches for a file that you specify and tells you where it is. This command only searches your path, so if it happens to be hanging out in an odd place it will not find it.

otto@linux:~> which xmms
/usr/bin/xmms
otto@linux:~>

If the file is in and odd place, you can use the powerful find . -name filename. Here's what happened when I searched for the file I am currently writing using both commands:

otto@linux:~> which command
otto@linux:~> find . -name command
./command
otto@linux:~>

If you don't remember the exact file name, then you can always look for part of the name with find |grep.

otto@linux:~> find |grep and
./command
./.wine/fake_windows/Windows/Command
./.wine/fake_windows/Windows/Command/start.exe
./OpenOffice.org/user/basic/Standard
./music/Anonymous - Ireland Unfree.mp3
./.racer/data/tracks/carlswood/stand_track.dof
otto@linux:~>

As you can see, you will get all sorts of things with such a search. Find starts in the directory that you are in and finds everything that matches the criteria in any sub-directory.

Finding Yourself with whoami and pwd

I don't know about you, but a GUI is just an excuse to have as many terminal windows open as I can. After about 4, it's hard to keep tract of who I am logged in as and what directory I'm in. That's were these two come in:

otto@linux:~> whoami
otto
otto@linux:~> pwd
/home/otto
otto@linux:~>

As you can see, whoami tells you who you are logged in as and pwd tells you the present working directory.

Learning new things with man -k and apropos

The commands man -k and apropos allow you to search for a command that does something you specify and then give you the command name and a short summery. You can use them to get a description of a command that you know, or to look for a new command.

These commands are exactly the same, except that man -k is standard on most UNIX boxes you will encounter, whereas apropos is only installed in some versions of UNIX.

otto@linux:~> apropos
apropos what?
otto@linux:~> apropos apropos
apropos (1)          - search the manual page names and descriptions
otto@linux:~> man -k apropos
apropos (1)          - search the manual page names and descriptions
otto@linux:~> apropos chess
crafty (6)           - a chess playing/analysis program
xcrafty (6)          - a chess playing/analysis program
zic2xpm (6)          - Tool to convert ZIICS chess pieces into XBoard (XPM/XIM) pieces.
endgame (1)          - endgame chess screensaver
cmail (6)            - an email chess helper
xboard (6)           - X user interface for GNU Chess, Crafty, the Internet Chess Server
otto@linux:~> man -k chess
crafty (6)           - a chess playing/analysis program
xcrafty (6)          - a chess playing/analysis program
zic2xpm (6)          - Tool to convert ZIICS chess pieces into XBoard (XPM/XIM) pieces.
endgame (1)          - endgame chess screensaver
cmail (6)            - an email chess helper
xboard (6)           - X user interface for GNU Chess, Crafty, the Internet Chess Server

Playing God with su

su is widely used, but I know that some of you out there still log out and log back in when you need to install something. su allows you to log into superuser without having to relogin.

otto@linux:~> su
Password:
linux:/home/otto # whoami
root
linux:/home/otto # exit
exit
otto@linux:~> whoami
otto
otto@linux:~>

This is a quick way to go into root for on the fly configurations. Of course since only a dumbass would log totally into root when they are within sight of a network cable, I use su for anything I need to do which requires root access. As an added bonus, you can use su to go into any account of the computer, assuming you know the password.

otto@linux:~> su kilpatje
Password:
kilpatje@linux:/home/otto> whoami
kilpatje
kilpatje@linux:/home/otto> echo now I am logged in as my husband
now I am logged in as my husband
kilpatje@linux:/home/otto> exit
exit
otto@linux:~>

Let the fun begin!




Home
About
Features
Humour
What Sucks

Contact Us
Stuckness shouldn't be avoided. It's the psychic predecessor of all real understanding. An egoless acceptance of stuckness is a key to an understanding of all Quality, in mechanical work as in other endeavors. -- R. Pirsig, "Zen and the Art of Motorcycle Maintenance"


copyright © 1999, 2000 unixbigots, except where noted. Contact us if you think you have a legitimate bitch