
Looking deceptively arcane at first glance, Unix Power Tools is a gold mine of useful information, and practical techniques, "tricks" and methods for getting things done in Unix-like OSs, and understanding what's happening in the machine. Well written, and easy to understand, don't let the first glance intimidate you.
|
( Updated: Mon 18 Mar 2007 )
feedback: havoc@harrisdev.com
Linux news and information
- Linux Weekly News - best Linux news and commentary site
- Linux HOWTOs - extensive documentation on how to do things in Linux.
- Linux Google - Google has a side that's all Linux all the time. If you can't find your answers in the HOWTOs, this is the best place to start your research or digging for answers
Bash QuickRefs
My Linux distribution of choice is
SuSE. I think they put out a fine product, and I'm willing to say so.
If you're going to run SuSE, and you're not going to be satisfied with some of the programs that don't release SuSE RPMs, you need to bookmark this url:
http://www.usr-local-bin.org/. I just finished installing the latest GAIM in only a few seconds after fighting with it on my own for two months.
Another resource for SuSE RPMs is
Packman.
The following items are a mixed bag of tips and tricks for everyone from the experienced Linux user to the first time newbie. I hope you find them helpful, and occassionally amusing.
Looking for something?
I had used Linux for a long time before I discovered apropos. Ask apropose a "question," and it will give you back a list of documents related to it.
Usage: apropose <word>
Example: apropose web
On my notebook, it results in 18 lines that start with:
w3m (1) - a text based Web browser and pager
QNPWidget (3qt) - QWidget that is a Web-browser plugin window
indexmaker (1) - Creates index files for mrtg web sites (mrtg-2.9.17)
Weblint::Messages (3pm) - perl module encapsulating weblint output messages
LWP::RobotUA (3pm) - A class for Web Robots
Pretty code printing, 2-cols/page, 2-sided, with line numbers:
a2ps -T 2 --line-numbers=1 -l 100 -o - | psmandup | lpr
-T 2 - convert tabs to 2 spaces
--line-numbers=1 - print line number on each line (-C = --line-numbers=5 = print line number every 5th line)
-l 100 - print 100 cols wide
you may need to use -M letter or -M a4 (or whatever) to set the "medium" to the paper you are printing on.
You can set most a2ps options in /etc/a2ps-site.cfg
psmandup will set up manual duplexing for you.
Printing 2-column/2-sides from Mozilla:
insert "psnum -pletter -2 | psmandup | " before the lpr string in the printer properties "Print Command" line. Make sure that Mozilla is set to print to "letter" sized paper. The full printer command should look something like this:
psnup -pletter -2 | psmandup | lpr ${MOZ_PRINTER_NAME:+'-P'}${MOZ_PRINTER_NAME}
If you want to get more on a piece of paper, here's a little trick I finally figured out how to do: Set Mozilla to print to A4 paper (8.3x11.7inch), then change the psnup settings to "-pletter -2 -Pa4". This will put two A4 size pages side-by-side on the letter page. Less wasted space in the margins, and even less paper used. The full printer command ends up being:
psnup -Pa4 -pletter -2 | psmandup | lpr ${MOZ_PRINTER_NAME:+'-P'}${MOZ_PRINTER_NAME}
(font size is very slightly reduced over printing 'letter' sized pages side-by-side, paper savings aproaches 13%.)
For some reason, Mozilla resets this parameter at start up every time, and there is no way (yet) to set this configuration permanently. UPDATE: I put Mozilla 1.2.1 on my machine a few days ago, and it does retain your printer configuration from one session to the next. It's a good thing!
If you don't want manual duplexing, just use: "psnup -pletter -2 | ..." in the print command field.
Dealing with spam
I think everyone agrees that spam is a bad thing. If you're receiving it, you're wasting time and bandwidth to make it go away. If you're sending it, you're an idiot. Stop sending spam. Spam breed resentment, not sales. Get over it.
If you're lucky enough to be running Linux, have an ISP that's running Linux, or willing to install and learn linux, go to SpamAssassin.org, read up and learn how to use it. There are enough different ways to deploy it based on differences in your system that I won't go into it. I'll just leave it with, "Use the Force, Luke."
Can't print more than one copy?
I've been puzzeled by the fact that when I ask for 2 copies of something to be printed, I only get one -- and sometimes, none. Finally, I was using my scanner to make a photo copy a few nights ago, and SANE just out and out failed when I asked it to make multiple copies.
What the...?
I scanned the image to a file, then tried lpr -#10 img.ps, and got back Fatal error - Maximum of 1 copies allowed. Okay. I just su'd into root and opened /etc/lpd.conf with vim and.... well... I didn't see it. So, I just ran lpr img.ps several times and went on to bed.
Yesterday, I finally had a chance to look on the net and find the documentation for LPRng. Turns out, all I had to do was add mc=20 to the lpd.conf file, and Maximum Copies (mc) was set to 20.
Cool.
Pick and editor, learn to use it:
Two two most popular text editors for Unix/Linux are Vim and Emacs. I, personally, use Vim. I've never tried Emacs, so I can't comment on it other than to say, "pick one, use it, learn it."
These editors are very, very powerful, and have the tools built in to save you litterally hours of time -- but only if you know how to use them.
Vim has online documentation, but I've also found that Vi IMProved-- Vim by Steve Oualline is an excellent resource. I'm sure there are equally good resources for Emacs.
There's also vim.org, which is a great resource.
The most important thing to remember is that these editors are not Notepad, or DOS Edit. They are real power tools. The more you know about them, the more work you can get done in less time.
To run the vim tutorial, type vimtutor at the shell prompt (this should work in Windows as well if all is install correctly). It's well worth your time to learn a few things, at least.
Burn a CD:
cdrecord -eject -v speed=8 dev=1,1,0 -data filename.iso
Getting a simple "failsafe" Xsession for a user:
make a copy of the .xinitrc.template to .xinitrc in the user's home directory
edit the .xinitrc file -> change the last command from exec $WINDOWMANAGER to exec $failsafe
[this is great when you're planning on using a low-end machine as a thin client. You can then set up your keys and your .bashrcs to have the user automatically logged into a more powerful machine and have the actual X desktop started up from there.]
do something until some time
Set up a while loop that tests the time (with date), and repeat until test fails.
Example:
I want to play an internet stream, restarting automatically if the stream gets interrupted, until 2:00 pm.
while (( `date +%H` < 14 )); do mplayer "http://www.url.com/path/to/stream"; done
`date +%H` executes a shell, returning the current hour only.
< 14 will compare the returned number to '14'
while ... do ...; done is your loop structure.
parse a set of MP3 index pages and download the MP3s
feedback:
havoc@harrisdev.com