|
aka Cameron Kerr |
Where I spew forth whatever little thing could be useful to people, that have generally tripped me up, or I felt were just worth sharing. I've tried to put some kind of order into it, so its no so random.
People using a dialup ISP account, who don't have a valid top-level-domain (most netizens, including DSL users), will want the uncomment and change a line in /etc/tin/tin.defaults
disable_sender=ON
It's not enough just to uncomment it, as its set to OFF by default.
If your local machine has a hostname orloc.localdomain, then without this, you would get an error message something like
Invalid From: <cameron@orloc.localdomain>
You can then set your email address in either ~/.tin/tinrc, or by typing `M' (note capital) in rtin.
Mail address: Cameron Kerr <cameron.kerr@paradise.net.nz>
Do you:
If you answered yes to all of the above, then you need to read the Sendmail-Address-Rewrite-HOWTO. You'll likely find it installed in /usr/doc/Linux-mini-HOWTOs/. It's likely this be one of the most important HOWTOs for a Slackware user.
On a NFS client, if you don't want to be running a portmapper, support the mount option nolock. That way, you won't get that nasty wait when you try to mount a NFS filesystem without having rpc.portmap running.
If you've ever wondered how to find out what exports are offered by an NFS server, much like you can in MS Windows Network Neighbourhood, then have a look at the showmount program.
showmount is a standard Linux program, that is little known by practically everyone, including a some security experts I've asked.
showmount will query the mountd process running on the server. The requests can ask such things as retrieving the export list, who has currently mounted what exports, and others.
Before you rush off to create an NFS network browser, you should note that mountd will log this action in the syslog.
Using the Samba suite of programs, you can list the shares a host is offering using this command
smbclient -L \\\\servername\\
But how can you find out what hosts are on a network? If you have a Master Browser on your network, you can use the following command
nmblookup -T "*"
I'm a big fan of OpenSSH, it can be used for lots and lots of things, its sooo much more than just telnet, any Unix vet will know what I'm talking about.
Here are some the various slightly unusual ways I've used ssh lately.
The sound playback on my laptop didn't quite come up to spec when hitting some of the higher notes on my Herbs CD the other day, so I decided to play it on my desktop machine which has a better sound system.
Rather than copy all my ogg vorbis files (who needs mp3 anymore?) I decided to use the ogg vorbis player and ssh to play it over the network. You can do the same thing with rsh, but who's crazy enough to still use that?
ogg123 -d wav -f - myfile.ogg | ssh talion play -t wav -
I was curious to know what the bandwidth used was like, so I used bwm to monitor the bandwidth going through my ethernet card. It turned up at about 1Mbps (these were CD quality .oggs, too).
At the place where I work, I have two networks that I administer, only one of which can be seen from the internet. I do a lot of work on the internal network, however, a significant amount is done with me sitting at home. To work on the internal network, I have to ssh to the external network, and from there ssh to the internal network. I call this multihopping, as I can't ssh to internal directly. It would be great to be able to copy files to and from my home computer and the internal host without first copying them to external first. This is also useful for printing.
Actually, in my environment, I generally have to ssh three times, first to external, then to internal, and then, since internal is actually a gateway into a private network, so to do useful work, I have to ssh thirdly into private.
Lets say that I want to print a file from one of the private machines. We cannot use scp, since that only supports single-hop operation. Instead, I'll use plain ssh, optionally in conjunction with tar. The reader should be aware that ssh allows the user to run commands on another system using the the following syntax. The reader should set up ssh keys and use ssh-agent so they don't have to enter a password or passphrase.
ssh external ls
Well that's all and good, but what if we need to run two programs on external, perhaps in a pipeline? The trick is to escape the shell punctuation. So if I wanted to run the command cd work; make, I would run ssh as follows.
ssh external cd work ";" make "&&" psnup -2 report.ps | lpr
Let's analyse this a little. If you follow the quoting, the command that will be run on external is
cd work; make && psnup -2 report.ps
As you can see, what this does is to change into the work directory in my home directory, runs make, and if that succeeds, will output a postscript file in 2-up format on stdout. Since this is the only thing that is written to stdout, the output from ssh (the report) will be sent to lpr (which is running locally).
Now that that's out of the way, lets add a hop to our journey. To do this, we must first use ssh agent forwarding, so use the -A switch to ssh, and make sure that agent-forwarding is turned on at the server, and that your local public key is installed into all target accounts.
As you may have already figured out, all we need to do is use the ssh command as the command to run on our first hop. Here's the command. Note the extra escaping of shell punctuation, this scales poorly, so some frontend would be useful here.
ssh -A external ssh -A internal cd work \\\; cat report.ps | lpr
Okay, so that's two hops, what about the three that I need to get through to do useful work (I do a lot of work with LaTeX, and internal doesn't have all the programs I need, such as fig2dev.) It's quite simple, just add ssh -A internal and add another layer of escaping for any shell punctuation ("cooking" the command).
ssh -A external ssh -A internal ssh -A private cd work \\\\\\\; make \\\\\\\&\\\\\\\& cat report.ps | lpr
If you plan on using this method frequently, you would be well advised to put this into a wrapper script. I'll include one in my Software section soon.
Have Fun!
sudo is a wonderful little program for running the odd command as root, and provides superior auditing, should you need it. But its major drawback is that it does not alter the environment significantly, so when you sudo to root, the PATH remains the same as the user using sudo.
This can break program that need PATH to include the /sbin and /usr/sbin locations, which are generally only in root's PATH. To load the root users environment using sudo, use this command
sudo bash --login -e upgradepkg zlib.tgz
If this command were to be run, without the bash --login -e part, you would get messages complaining that the programs removepkg and installpkg could not be found. Note that environment entries such as your current working directory are preserved.
If you find that your mouse is exhibiting strange behaivour, and its not related to having the wrong protocol selected, or gpm conflicting with X, insert the software cursor option (SWCursor) in the Devices section of your XF86Config .
To use about 25% of the paper, and about 70% toner, print documents two-up and double-sided. While you're there, you may as well print it in a format so you can fold it in half, staple three times, and then you can read it as a book! To do this, you'll need Angus Duggan's PSUtils package, and a grunty stapler (or nail, string and hammer, if its a big job). You'll also want a laser printer, for speed.
Breaking it down into steps, this is what we do:
Relocate the odd pages to the right by about 1-2cm, and those on the even pages 1-2cm. This creates a gutter for the spine of our book.
To do this, we can use pstops. You'll refine the offsets later, when we make it 2-up.
Now, so we can print it in book order, we need to reorder the pages. Make the signature size 16. This means that no more than 4 pages will be folded in half at a time. Too many pages, and you'll need to guilotine the front, to get rid of the ripples. The ripples make it harder to turn the page.
You'll do this using the psbook program.
Make the pages two-up. Use psnup for this.
Join these commands together, and send the output to a temporary file. Run gv on this file and make sure that the pages are in the right order and the pages are reasonably centered on the page, and that there is a sufficient guttering.
cat file.ps | pstops '2:0(0cm,0cm)1(0cm,0cm)' |
psbook -s16 | psnup -2 > tmp.ps
gv tmp.ps &
You can leave gv open, and it will reload the document when it changes.
When you're happy with the result, you need to output the even pages, in reverse order, to the printer.
Then you take the output from the printer, open the manual feed, and without turning the stack of paper, put it into the tray that you've opened out. Note that most manual feeds on laser printers have extension bits for supporting the paper, use them.
Then you print the odd pages.
cat file.ps | psselect -e -r | lpr
# Put output paper stack into foldout paper tray
cat file.ps | psselect -o | lpr
Now fold each set of four pages, collate and staple. Pretty simple when you've done it, but do make sure that you preview it, and check the ordering, as it can seem to change from what you might expect.
Thanks to Nathan Roundtree for teaching me this trick