Useful Linux Commands

The following is a list of useful commands that I've learned for Linux, but that I use so rarely, I tend to forget until I need them again.

Creating a CD ISO

To rip an entire normal data-cd (ISO filesystem) from a CD-ROM:

dd if=/dev/cdrom of=my_cd_image.iso

Making an ISO from a file system

To create an iso using files in Linux:

mksisofs -o image.iso path/

Burning a CDROM

wodim dev=/dev/cdrw -v -data cd_image.iso
wodim dev=/dev/cdrw -v -audio [wav files...]

Burning a DVD

To burn a DVD from the filesystem:

growisofs -dvd-compat -input-charset=ISO-8859-1 -Z /dev/cdrom -R -J -pad "/path/to/source/dir/structure"

Creating a floppy image

To create a blank floppy disk image:

mkfs.msdos -C image.flp 1440  

Mount a floppy image to the filesystem

To mount a floppy image:

mount -o loop image.flp /media/floppy1/

Transcoding to iPod and iPhone format

To take a video file to a format usable by an iPod or an iPhone:

 ffmpeg -vcodec xvid -b 300 -qmin 3 -qmax 5 -bufsize 4096 -g 300 -acodec aac -ab 96 \
    -i source_file.avi -s 320x240 -aspect 4:3 target_file.mp4

Take target_file.mp4 and import into iTunes, then sync with your device.

Mounting a SMB fileshare

To mount a Windows or Samba SMB fileshare:

mount -t cifs //ntserver/download -o username=user,password=myPassword /mnt/ntserver

Redirecting STDERR to a pipe in Bourne/BASH

Passing *both* stdout and stderr to the pipe.

<command> 2>&1 | <command2>

Passing only stderr to the pipe:

exec 3>&1
<command> 2>&1 >&3 3>&- | <command2> 3>&-
exec 3>&- 

Running remote backups to tape with tar

Use the following command to dump a directory structure to a remote tape drive:

tar cv --rmt-command=/sbin/rmt --rsh-command /usr/bin/ssh -f <remote_host>:/dev/st0 --directory /path/to/source/dir --label "Label for backup" <directory_name>

Use the following command to recover a directory structure from a remote tape drive:

tar xv --rmt-command=/sbin/rmt --rsh-command /usr/bin/ssh -f <remote_host>:/dev/st0

Of course, as always with the tar command, one can specify the files/sub-directories to be recovered if one wishes.

Enabling Routing on Linux

Add the following to /etc/sysctl.conf:

net.ipv4.ip_forward = 1

Run the following command:

# sysctl -p /etc/sysctl.conf

Verify with:

# cat /proc/sys/net/ipv4/ip_forward
1
 
techdocs/linux/commandline.txt · Last modified: 2010/01/11 19:08 by earnoth
 
Recent changes RSS feed Creative Commons License Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki