Basic Linux Part 1: Command-line CD Fu

Alex and I are going to start a series on basic Linux shell commands and all the neat things you can do from the terminal. In my opinion there is a shortage of these type of articles on the internet. We are going to try to cover most every basic task and show how it can be done in the shell with no GUI or Desktop at all.  I am going to start out with this article on cd recording, but we will cover such topics as watching movies in the framebuffer, connecting to wireless via the shell, shell based irc chat clients, mysql commands and many more things. I have no idea how many articles there will be in the series but if anyone has a specific request or question you can always post in our engage question and answer section for a more personalized response.

How to mount a ISO image read only in Linux (You should be root or use sudo to do this stuff).

First off we need to create a mount point. This is a directory in our file system where we can mount the image so that we can browse the files.

infected r00t # mkdir /mnt/isoimage

Next we need to mount our .iso to the new mount point:

infected r00t # mount -t iso9660 -o loop bt4-mod-haha.iso /mnt/isoimage

Now we can browse our files:

infected r00t # cd /mnt/isoimage/

infected isoimage # ls -l
total 7
dr-xr-xr-x 3 root root 2048 May 30  2009 boot
-r–r–r– 1 root root 2048 Sep 29 21:48 boot.catalog
dr-xr-xr-x 2 root root 2048 Sep 29 21:33 casper
-r–r–r– 1 root root  782 Sep 29 21:48 md5sum.txt

Once we are done we can unmount the image like this:

infected ~ # umount /mnt/isoimage

(Make sure you get out of the directory before you try to un mount it)

Ok, So that was pretty simple but what if we want to make a .iso? We can do that to from the shell no problem.

First off, make a temp file in which to place your iso files: (Make sure they are arranged the way that you want them to appear on the .iso)

infected r00t # mkdir /tmp/iso

Next copy your files over:

infected r00t # cp /home/r00t/my_iso/* /tmp/iso/

And finaly make the iso:

infected r00t # mkisofs -f -R -r -l -J -V 001  -A BT4  -o my_new.iso  /tmp/iso

You will see a lot of output and in the end you should see something like this:

99.33% done, estimate finish Thu Dec 24 10:20:19 2009
Total translation table size: 0
Total rockridge attributes bytes: 2192
Total directory bytes: 6144
Path table size(bytes): 48
Max brk space used 0
729889 extents written (1425 MB)

There are literally hundreds of options for the mkisofs tool. I have simply used a set of defaults which should work in almost any situation. For a complete listing of the flags you can check out the man page here

So now you are saying that was OK but I rarely make a iso image. Well did you know you can just burn a .iso from the shell?

infected r00t # cdrecord -v -pad speed=1 dev=0,0,0 my_new.iso

That’s all you need to do to burn your newly made .iso to a disk. There is of course also a man page for cdrecord with lots of fancy options.

Burning audio CDs using cdrecord is easy  too:

Create your audio tracks and store them as uncompressed, 16-bit stereo .wav files.

Name the audio files in a manner that will cause them to be listed in the desired track order when listed alphabetically, such as 01.wav, 02.wav, 03.wav, etc.

Change into the directory containing the wave files and make sure there are not any wave files you do not want included in the CD.

With a blank CD in your burner, issue the following command:

infected r00t # cdrecord -v -pad speed=1 dev=0,0,0 -dao -audio -swab *.wav

Well that’s it for for number one in our Basic Linux Series. I hope someone will find this stuff helpful and we will continue to write these as often as I have time.

List Price: $49.99 USD
New From: $18.57 USD In Stock
Used from: $16.23 USD In Stock