http://htop.sourceforge.net/
This is htop, an interactive process viewer for Linux. It is a text-mode application (for console or X terminals) and requires ncurses. Tested with Linux 2.4 and 2.6.

Problem:
VirtualBox kernel driver not installed. The vboxdrv kernel module was either not loaded or /dev/vboxdrv was not created for some reason. Re-setup the kernel module by executing '/etc/init.d/vboxdrv setup' as root.
VBox status code: -1908 (VERR_VM_DRIVER_NOT_INSTALLED).
Solution:
sudo apt-get install linux-headers-$(uname -r)
sudo /etc/init.d/vboxdrv setup
Like most people I have multiple backups of the same files, stored in an ad-hoc structure. I went hunting fir a good utility to remove duplicates, and replace them with hard links.
It surprised me that there is a tool for doing this on NTFS volumes under windows. Update: and another free one!
I found a perl script called trimtrees.pl You can find it in CPAN, it's describes itself such:
Traverse all directories named on the command line, compute MD5
checksums and find files with identical MD5. IF they are equal, do a
real comparison if they are really equal, replace the second of two
files with a hard link to the first one.
Special care is taken to cope with C error conditions.
The inode that is overbooked in such a way, is taken out of the pool
and replaced with the another one such that the minimum of files
needed is kept on disk.
The C< --maxlinks> option can be used to reduce the linkcount on all
files within a tree, thus preparing the tree for a subsequent call to
C. This operation can be thought of the reverse of the normal
trimtrees operation (--maxlinks=1 produces a tree without hard links).
I'll turn this into a script and update the post, but for now:
rsync -avrxP --delete $FILESYSTEMS backup-server:backups/$HOSTNAME
-a, --archive archive mode; same as -rlptgoD (no -H, -A)
-v, --verbose increase verbosity
-r, --recursive recurse into directories
-x, --one-file-system don't cross file system boundaries
-P same as --partial --progress
--progress show progress during transfer
--partial keep partially transfered file in case of interuption,
should make a subsequent transfer of the rest of the file much faster.
Some caveats if you want to fully automate this...
- remove -vP (verbose w/ progress)
- --delete is NECESSARY to make sure deleted files get deleted from the
backup
- FILESYSTEMS should be any local filesystems you want backed up (-x
won't cross filesystems, makes backing up in NFS environment easier)
- obviously this doesn't preclude a bad guy checking out
backup-server:backups/otherhostname (use ssh keys, and invoke cmd="cd
backups/hostname; rsync with whatever daemon options" will limit that)
- on backup-server, rotate the backup every 12 hours or whatever.
- rsync -ar --delete store/hostname.2 store/hostname.3
- rsync -ar --delete store/hostname.1 store/hostname.2
- rsync -ar --delete backups/hostname store/hostname.1
# that could be better optimized, but you get the idea
I've used this rsync system to successfully maintain up to date backups w/
great ease, AND restore very quickly... use a LinuxCare Bootable Business
Card to get the target fdisked and ready, then mount the filesystems as
you desire, and rsync -avrP backup-server:backups/hostname /target. I got
a 700mb server back online in under 20 minutes from powerup to server
serving requests (the rsync itself is 3 to 5 minutes). Making sure you
do (cd /target; lilo -r . -C etc/lilo.conf)) is the only tricky part.
care of ted@psy_spam_ber.com
I've just upgraded my home media server, and had to set up LVM again, and as i do it so infrequently, i completely forgot what i was doing... so i thought I'd make some notes:
We are going to set up a LVM across two drives, identical 750GB sata disks (sda & sdb), then format it with the jfs file system, which is arguably the best for large (>1GB) files. xfs is also a suitable file system, but ext3 is really slow. in fact I'm surprised anyone uses it at all any more, as reiser is much better for a system partition. Justin Piszcz has the figures to prove it.
First we need to install LVM and JFS suppport:
apt-get install jfsutils lvm2 lvm-common
Initialise the drives with cfdisk (fdisk is buggy and shouldn't be used. If you need bsd support or stuff cfdisk can't do then use sfdisk which is the best in terms of compatibility, but cfdisk is good at what it supports and the interface is nicer).
Create a single partition filling the whole disk. I chose the standard type for linux, 82, & it seemed to work OK, but I did notice that there is a specific type for LVM's (8E), That may be a better choice. I'll look into it and let you know.
now initialise the disks to LVM. this can be done to a partition instead of the whole disk, just use /dev/sda# instead of /dev/sda
pvcreate /dev/sda
pvcreate /dev/dsb
if you get errors you can wipe the disk with
*CAUTION*
dd if=/dev/zero of=/dev/sd# bs=1k count=1
Now create the VolGroup
vgcreate VG_Data /dev/sda /dev/sdb
you can add to an existing volgroup with
vgextend VG_Data /dev/sdc
now initialise the volgroup
vgchange -a y VG_Data
use vgdisplay to see your shiny new volgroup, and note how many extents it has (Total PE):
vgdisplay
Create a logical volume on the volgroup:
lvcreate -l[number of extents] -i[PV's to strip over] -I[stripe size, 32/64/128] -n[name] [VolGroup]
in my case
lvcreate -l357702 -i2 -I128 -ndata VG_Data
check to see the utilisation with vgdisplay, you can extend the logical vol with lvextend:
lvextend -L+2.4G /dev/VG_Data/data
now format the new volume:
mkfs.jfs /dev/VG_Data/data
And that's it, mount and play:
mkdir /mnt/data
mount -tjfs /dev/VG_Data/data /mnt/data
You finally got your Linux environment to crash. Ctrl+Alt+Backspace does nothing, nor do the F-keys. You know you shouldn’t have installed that bad driver, but you did it anyway.
So you reach for the power button.
Stop.
Mashing in the power button to reboot could cause a problem if your
hard drive is still being written to, and usually causes more problems
than it solves. The Linux kernel includes a secret method of restarting
your PC should it ever stop doing its job.
- Hold down the Alt and SysRq (Print Screen) keys.
- While holding those down, type the following in order. Nothing will appear to happen until the last letter is pressed: REISUB
- Watch your computer reboot magically.
What the individual keys do in that sequence are not as important as
what it does as a whole: stops all programs, unmounts all drives, and
reboots. A lot safer than just cutting the power.
Here it is again: REISUB. Remember that, as it will
save you a lot of time when you are configuring a system and something
gets messed up. Need a mnemonic? Try Raising Elephants Is So Utterly Boring.
As an aside, don’t try this if you just want to reboot. A normal
reboot, if it can be done, should always be used instead of the REISUB keys.
R-E-I-S-U-B.
iptables is the packet filtering technology that's built
into the 2.4 Linux kernel. It's what allows one to do firewalling,
nating, and other cool stuff to packets from within Linux. Actually,
that's not quite right -- iptables is just the command used to control netfilter,
which is the real underlying technology. We'll just call it iptables
though, since that's how the whole system is usually referred to.
A nice refresher...
Shamelessly ripped from here My personal favorite, the netcat web server:
while true; do nc -l -p 80 -q 1 < error.html; done
I always say that small, simple and self contained tools can often be more useful, and more feature rich than huge bloated frameworks. For example lets take legendary “Swiss Army Knife of Networking? - netcat. It is a single binary, which takes up about 60KB of space on your disk (give or take a few KB depending on where and how you compile it). What can it do?
I guess a good question is what can’t it do?
Port Scanner
Netcat can be a port scanner. It does not have as many features as say nmap, but if you just want to see what ports are open on a given machine, you can simply do:
nc -v -w 1 localhost -z 1-3000
The command above will scan all the ports in the range 1-3000 on localhost.
File Transfer
Let’s say you want to transfer a big zip file from machine A to machine B but neither one has FTP, and using email or IM is out of the question due to file size, or other restrictions. What do you do? You can use netcat as a makeshift file transfer software.
On machine B do the following, where 1337 is some unused port on which you want to send the file:
Assuming that the IP of machine B is 10.48.2.40 go to machine A and do:
nc -w 1 10.48.2.40 1337 < file.zip
That’s it. The file will be magically transfered over the network socket.
Chat Server
Have you even needed an improvised one-on-one chat? Netcat can do that too. You simply start listening to connections on some port like this:
Then on another machine simply connect to that port:
Now start typing on either machine. When you press enter, the line will immediately show up on the other machine.
Telnet Server
Nectat can also be used to set up a telnet server in a matter of seconds. You can specify the shell (or for that matter any executable) you want netcat to run at a successful connection with the -e parameter:
On windows you can use:
Then on a client machine simply connect to port 1337 and you will get full access to the shell, with the permissions of the user who ran nc on the server.
Spoofing HTTP Headers
You can use netcat to connect to a server using completely spoofed headers. You can actually type out your user agent, referrer and etc. It’s useful when you want to generate bunch of hits that can be easily found in the logs or something like that:
nc google.com 80GET / HTTP/1.1Host: google.comUser-Agent: NOT-YOUR-BUSINESSReferrer: YOUR-MOM.COM
Note that your request won’t be sent until you generate a blank line. So hit return twice when your are done typing. You will get a response of headers and HTML streaming down your screen:
HTTP/1.1 200 OKCache-Control: privateContent-Type: text/html; charset=ISO-8859-1Set-Cookie: PREF=ID=79f8f28c854d90ec:TM=1186369443:LM=1186369443:S=UIiTvi68MtmbcmGl; expires=Sun, 1-Jan-2038 19:14:07 GMT; path=/; domain=.google.comServer: GWS/2.1Transfer-Encoding: chunkedDate: Mon, 06 Aug 2007 03:04:03 GMT 738
I deleted the HTML that followed the response - but you get the idea. It is also a good way of looking at headers. Some sites have nice surprises there (like slashdot’s X-Bender and X-Fry headers). Seriously, check them out!
Web Server
I think this is my favorite trick. Did you ever need to set up simple makeshift webserver that would serve a single page? I know I did. In the past when my web server at work melted down, I set up laptop with this simple script:
while true; do nc -l -p 80 -q 1 < error.html; done
The error.html page was just a very simple error message notifying our users about the outage, and giving them an estimate of when it would be fixed. It took me 3 minutes to set up, and probably saved us many angry support calls.
Cloning Hard Drive Partitions Over the Network
This trick was submitted by Craig in the comments. On a system you want to clone do:
dd if=/dev/sda | nc 192.168.0.1 9000
Where 9000 is some random port. On the receiving side di:
nc -l -p 9000 | dd of=/dev/sda
Of course you need to have the cloned partitions unmounted on both systems. So if you are cloning / you will have to boot from a live distro like Knoppix. Note that you can use this technique to clone NTFS partitions as well - just need to use a live Linux distro on both sides.
Summary
Despite being able to do all that netcat still conforms to the Unix philosophy of doing one thing, and doing it well. Netcat was designed for a single purpose - to read and write data packets over network sockets. And because of it’s singular purpose it can be used in such a myriad of ways.
It is ironic, but it is of ten the case that the more features you add to your application, the more specialized it gets. And of course, GUI is the ultimate functionality killer. If netcat had a GUI I doubt it would be half as useful as it is right now.
I’ve been told that socat is a more powerful netcat fork which has even more functionality. Personally, I haven’t played with it at all. It does seem to have a different syntax, and it is not as mature or well known, and popular as it’s predecessor.
OK, there are basically two or three (reccomended) ways to do this:
- using Samba and winbind
- using squid LDAP authentication (i'm not convinced that this is sso compatible)
- use squidNT the entire process seems much more simple. The disadvantage is obviously that you have to have another windoze server in your DMZ.
I think i'm gonig to have a go with the samba/winbind option. I have found a runthrough that looks helpful. It's quite datad now though, as Samba 2.2.X reached its End-Of-Life on October 1, 2004. This one looks a little more up to date
Microsoft Active Directory is an LDAP v3 compliant directory and
therefore can be used as a mechanism to authenticate users. Squid
supports LDAP v3 and an authentication method. You can achieve similar
results by using Samba and Winbind, however that process is much more
involved and requires the Squid server machine to become a member of
the domain.
Although this refers to FreeBSD, and is actually a request for help, it lists a lot of what needs to be done in a very fluff free way. (and he's got nearly everything right, with the exception of /var/db/samba/winbindd_privileged permissions, as Henrick points out in his reply.