Lesser Known GNU

From SquadLimberWiki

Jump to: navigation, search

Using ar:

use tar.

Contents

dd: data definition

Create an ISO image from a CD-ROM:

dd if=/dev/cdrom of=/tmp/image.iso bs=2k

Backup a hard disk:

dd if=/dev/hda1 | gzip > /mnt/hdb1/system_drive_backup.img.gz

Clone an OS over the network:

1. On Target machine you will need to not have the main disk mounted, i.e. boot a CD-ROM.

2. On the target machine run:

nc -l -p 9000 | dd of=/dev/hda

(Writes anything received on port 9000 to /dev/hda.)

3. On source machine, copy the disk over the network:

dd if=/dev/hda | nc 192.168.1.3 9000


You can also clone individual partitions and the MBR independently. To clone the MBR, which sits in the first 446 bytes:

dd if=/dev/hda of=myMBR bs=446 count=1 



ldd: List dynamic dependencies of executable files or shared objects.

ldd /usr/bin/ls


uniq: output unique lines from the input

Sort first! uniq only outputs unique adjacent lines.


Output lines with only one occurence:

uniq -u


Expanded expressions: the ? character

Remove all two-letter filenames in the current-directory:

rm ??

Longer example:

$ ls
bob
bib
bab
dog
$ rm b?b
$ ls
dog


List (Most) Files Separated By A Comma

ls -m


Detecting the particular Linux distribution

Look for the occurence of any of the following files:

Novell SUSE /etc/SuSE-release Red Hat /etc/redhat-release, /etc/redhat_version Fedora /etc/fedora-release Slackware /etc/slackware-release, /etc/slackware-version Debian /etc/debian_release, /etc/debian_version, Mandrake /etc/mandrake-release Yellow dog /etc/yellowdog-release Sun JDS /etc/sun-release Solaris/Sparc /etc/release Gentoo /etc/gentoo-release UnitedLinux /etc/UnitedLinux-release ubuntu /etc/lsb-release

Also make use of:

uname -a

And possibly:

cat /etc/motd


Useful DOS Stuff

F7Bring up command history
start .Open an explorer window in the current directory
typeList contents of a file (similar to cat on unix)
Drag and drop a folder from explorer to a DOS command promptCopies the path of that folder to the command prompt
Personal tools