Miscellaneous Command Line Goodies

Connect to Antoher Host Via SSH

ssh user@host.name

Force Reconfiguration of a package via DPKG

dpkg-reconfigure package-name

Purge a Package

This will delete all related files, including configuration:

dpkg --purge package-name

Base64 Encode a File. This might be useful, for example, to embed images and other files in to a multi-part MIME format email. Install the uuencode and uudecode tools, which on Debian are found in the sharutils package:

# apt-get install sharutils

Then simply call uuencode with the -m parameter to specify base64 encoding, the source filename and a MIME name to go at the top of the base64 encoded file. In the example below we pipe the output to a file called base64.txt:

$ uuencode -m sourceimage.gif name > base64.txt

Before I could sucesfully embed an image in to an email, it was necessary to remove the header containing the MIME name we specified from the top of the file, and also the === at the footer of the file.

Compile Some C Code

gcc somefile.c

Make an ISO file from a CD:

# dd if=/dev/cdrom of=~/cd.iso

Backup the WWW root to a TAR archive:

tar -vcf archive.tar /var/www

Use DD to clone a disk partition to file:

dd if=/dev/hda1 bs=1k conv=sync,noerror | gzip -c | ssh -c blowfish user@hostname "dd of=filename.gz bs=1k"

Use DD to restore the cloned parition from file:

gunzip -c < filename.gz | ssh -c blowfish root@deadhost "dd of=/dev/hda1 bs=1k conv=sync,noerror"

Backup the MBR:

dd if=/dev/hda of=backup-of-hda-mbr count=1 bs=512

Restore the MBR and partition table:

dd if=backup-of-hda-mbr of=/dev/hda

Restore just the MBR:

if=backup-of-hda-mbr bs=448 count=1.

Add a user:

adduser

Discussion

Enter your comment:

Subscribe to the RSS feed for Andy's Debian HOWTOs

Article from Andy's Debian HOWTOs (http://www.besy.co.uk/debian/debian)

 
debian/command_line_goodies.txt · Last modified: 2008/08/01 22:56 (external edit) · [Old revisions]
Recent changes RSS feed Powered by Debian Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki