Tips and Tricks


[Home] [Technology]

This guide contains various tips and tricks.


Make an iso CD/DVD image file (ISO9660) from everything under the folder data

  • 1. Run sudo chown -R root:root data/* to remove owner information from target files.
  • 2. Use sudo chmod to put proper permissions to target files and preserve them in iso.
  • 3. Run sudo mkisofs -J -R -o output.iso data/ to make the iso file with Joliet and Rockridge preservation.
  • 4. Use sudo chown to reclaim ownership of the iso file.


Mount an iso CD/DVD image file (ISO9660)

  • 1. Run sudo mount -t iso9660 -o loop input.iso /mnt to mount the image at /mnt
  • 2. Run sudo umount /mnt to unmount the image at /mnt


Create an iso CD/DVD image file (ISO9660) from a CD/DVD

Note: Using dd if= of= is a bad idea. Look here for why

  • 1. Run isoinfo -d -i /dev/sr0 to print blocksize and blockcount of CD/DVD (in /dev/sr0)
  • 2. Run dd if=/dev/sr0 bs=blocksize count=blockcount of=output.iso to make the iso file from the CD/DVD.

Note: Additionaly you can verify your written image by matching the MD5 hash outputs of following two commands

  • 3. dd if=/dev/sr0 bs=blocksize count=blockcount | md5sum
  • 4. md5sum output.iso


Manage users and groups of a system

  • 1. The user accounts of a system are written in /etc/passwd file in the format username:password:userID:groupID:userIDcomment:homedir:shell
  • 2. The group names of a system are written in /etc/group file in the format groupname:password:groupID:memberlist
  • 3. Run groups username or id username to get information about an user
  • 4. Run groupadd groupname to add a group
  • 5. Run useradd -m -g groupname -G wheel -s /bin/bash username to add an user
  • 6. Run passwd username to change the password of an user

Note: The encrypted password is stored in /etc/shadow and an x is placed in place of password in /etc/passwd


Compiling and installing dwm, a lightweight windows manager for X11

  • 1. Establish proper user account with sudo privilege
  • 2. Enable network connectivity and exclude undesired mirrors
  • 3. Update the system to the latest packages
  • 4. Install xorg-x11-fonts-*, xorg-x11-drivers, xorg-x11-server-Xorg, and xorg-x11-xinit for X11
  • 5. Install gcc C compiler
  • 6. Install libX11{,-devel}, libXinerama{,-devel}, libXft{,-devel}, and freetype{,-devel}
  • 7. Install nano, wget and xterm
  • 8. Download dwm and dmenu from dl.suckless.org using wget
  • 9. Edit config.mk file to point out proper X11 and other header and libs
  • 9. Edit config.h file to point out xterm as termcmd
  • 10. Run make clean && make && sudo make install
  • 11. Create a file ~/.xinitrc and add the line 'exec dwm'
  • 12. Run startx


Format and check FAT16 and FAT32 (MS-DOS) in Linux

  • 1. Identify the device name (e.g. /dev/sdb1)
  • 2. Run sudo umount /dev/sdb1 to unmount it
  • 3. Run sudo mkdosfs -F 16 /dev/sdb1 to format it in FAT16
  • 4. Run sudo mkdosfs -F 32 /dev/sdb1 to format it in FAT32
  • 5. Run dosfsck -a -f -v /dev/sdb1 to check and automatically repair FAT filesystems


Display and dump output of a command

  • 1. Run command 2>&1 | tee log.txt to make the output of command be displayed on the terminal and be recorded in the file log.txt
  • 2. Run command 2>&1 | tee -a log.txt for same as 1 with appending the log.txt rather than overwriting it


Tar and Untar commands

  • 1. To show the contents of the archive run
    tar tvf file.tar
    tar jtvf file.tar.bz2
    tar Jtvf file.tar.xz
    tar ztvf file.tar.gz
    tar Ztvf file.tar.Z
  • 1. To extract the contents of the archive run
    tar xvf file.tar
    tar jxvf file.tar.bz2
    tar Jxvf file.tar.xz
    tar zxvf file.tar.gz
    tar Zxvf file.tar.Z
  • 1. To archive the contents of multiple files or directories run
    tar cvf file.tar file1 file2
    tar jcvf file.tar.bz2 file1 file2
    tar Jcvf file.tar.xz file1 file2
    tar zcvf file.tar.gz file1 file2
    tar Zcvf file.tar.Z file1 file2


Gathered from various sources.