Debian is 1 of the oldest free Linux distribution that still exist today. It was first released by Ian Murdock in 1993. It is known to be very stable. As a result, people tend to use it when they are building production servers.

Source.lst generator:

Add source lists

Add Debian CD-ROM or DVD in the source.list

apt-cdrom add

Add Debian ISOs

# Assumed all ISOs are in /debian/iso/ directory
mkdir /debian/debian-7.4.0-i386-DVD-1
echo "/debian/iso/debian-7.4.0-i386-DVD-1.iso /debian/debian-7.4.0-i386-DVD-1 udf,iso9660 loop 0 0" >>/etc/fstab
mkdir /debian/debian-7.4.0-i386-DVD-2
echo "/debian/iso/debian-7.4.0-i386-DVD-2.iso /debian/debian-7.4.0-i386-DVD-2 udf,iso9660 loop 0 0" >>/etc/fstab
mkdir /debian/debian-7.4.0-i386-DVD-3
echo "/debian/iso/debian-7.4.0-i386-DVD-3.iso /debian/debian-7.4.0-i386-DVD-3 udf,iso9660 loop 0 0" >>/etc/fstab
mount -a
apt-cdrom -d=/debian/debian-7.4.0-i386-DVD-1 add
apt-cdrom -d=/debian/debian-7.4.0-i386-DVD-2 add
apt-cdrom -d=/debian/debian-7.4.0-i386-DVD-3 add

Adobe Flash Player

Install Flash Player for Firefox

  1. Download the linux version of Flash from
  2. Decompress the file downloaded
    tar -xvzf install_flash_player_9_linux.tar.gz
  3. Copy to /usr/lib/mozilla-firefox/plugins/ folder.
    cp /usr/lib/mozilla-firefox/plugins/
  4. Restart Firefox.

Install Flash Player for Opera

  1. Download the linux version of Flash from
  2. Decompress the file downloaded
    tar -xvzf install_flash_player_9_linux.tar.gz
  3. Copy to /usr/lib/opera/plugins/ folder.
    cp /usr/lib/opera/plugins/
  4. Restart Opera.

BASH Prompt Customization

Customization of the the Bash terminal line

Add the following codes in ~/.bashrc. Every time you open a Bash terminal, the first line will show HH:MM:SS@hostname:workingDirectory # .

export PS1="\t@\H:\w # "
export PS1="\n--=[\$(date +%Y-%m-%d)\t@\u]=--\n\w>"
# Add yellow color
export PS1="\e[0;33m--=[\$(date +%Y-%m-%d) \t@\u]=--\e[m\n\w>"


Bash eternal history

Add the following codes in ~/.bashrc. It will save whatever you type in the command line forever in ~/.bash_eternal_history file.

               "$(history 1)" >> ~/.bash_eternal_history'


# log every command typed and when
if [ -n "${BASH_VERSION}" ]; then
    trap "caller >/dev/null || \
printf '%s\\n' \"\$(date '+%Y-%m-%dT%H:%M:%S%z')\
 \$(tty) \${BASH_COMMAND}\" 2>/dev/null >>~/.command_log" DEBUG



# ~/.bashrc: executed by bash(1) for non-login shells.
# Note: PS1 and umask are already set in /etc/profile. You should not
# need this unless you want different defaults for root.
# PS1='${debian_chroot:+($debian_chroot)}\h:\w\$ '
# umask 022
# You may uncomment the following lines if you want `ls' to be colorized:
export LS_OPTIONS='--color=auto'
eval "`dircolors`"
alias ls='ls $LS_OPTIONS'
alias ll='ls $LS_OPTIONS -l'
alias l='ls $LS_OPTIONS -lA'
# Some more alias to avoid making mistakes:
alias rm='rm -i'
alias cp='cp -i'
alias mv='mv -i'
# Define what to display on the command line.
export PS1="\t@\H:\w # "
# Keep track of all your command lines in ~/.bash_eternal_history file forever.
               "$(history 1)" >> ~/.bash_eternal_history'
# #########
# Some shortcuts for different directory listings
alias ls='ls -hFA --color=tty'                 # classify files in colour
alias dir='ls -A --color=auto --format=vertical'
alias vdir='ls -A --color=auto --format=long'
alias ll='ls -lA'                              # long list
alias la='ls -A'                              # all but . and ..
alias l='ls -CFA'                              #
alias grep='grep --color'                     # show differences in colour
# Default to human readable figures
alias df='df -h'
alias du='du -h'
alias du1='du --max-depth=1'
# Some more alias to avoid making mistakes:
alias rm='rm -i'
alias cp='cp -i'
alias mv='mv -i'
# Define what to display on the command line: e.g. --=[2015-05-26 14:00:32 @root]=--
red=$(tput setaf 1)
green=$(tput setaf 2)
reset=$(tput sgr0)
export PS1="\[$green\]--=[$(date +%Y-%m-%d) \t @\[$reset\]\[$red\]\u\[$reset\]\[$green\]]=--\[$reset\]\n\w>"
# Keep track of all your command lines in ~/.bash_eternal_history file forever.
               "$(history 1)" >> ~/.bash_eternal_history'

Restarting the Shell Environment After Changes

source .bashrc


Plain text icon bashrc_root.txt1.83 KB

Burning CD/DVD

Here are practical command lines for burning CD/DVD.

  • Create ISO from CD/DVD.
    dd if=/dev/cdrom of=/your/new/iso/image.iso
  • Create ISO from local files.
    mkisofs -Jrv -V "32 chars volume name" -o image.iso /path/to/your/files/
    # -J uses Joliet naming records, for Windows compatibility
    # -r uses Rock Ridge naming conventions for UNIX/Linux compatibility, and makes all files publicly readable
    # -v sets verbose mode, for a running commentary as the image is created
    # -V provides a volume ID up to 32 characters; this is the disk name that shows up in Windows Explorer
    # -o names the new .iso image file (image.iso)
  • Create audio CDs.
    cdrecord -v speed=8 -pad -audio -dao /your/audio/files/*.wav
    # Note: Your *.wav files should be uncompressed and 16-bit stereo.

    Change console resolution

    Add the following lines in /etc/default/grub:


    Then, run:


    Confusing architecture naming convention

    I just bought a new laptop. It has a 64-bit 2 GHz Intel dual-core processor. I want to install a 64-bit Debian on that laptop. Therefore, I headed to this download page. It showed the following available architectures: alpha, amd64, arm, armel, hppa, i386, ia64, mips, mipsel, powerpc, sparc, s390, source and multi-arch. I'm stocked and confused as I don't know which architecture to download. By deduction, I only have 3 choices: amd64, i386 and ia64. I wasted an hour reading the how-to of the 3 architectures to no avail. I spent another hour searching on the internet and finally stumbled on the Debian wikipedia page that shows the meaning of each architecture. Here is the important part:

    x86 architecture designed for Intel/AMD 32-bit PCs. Also compatible but not recommended on Intel/AMD 64-bit single/multi core PCs
    x86-64 architecture designed for Intel/AMD 64-bit single/multi core PCs
    Intel Itanium (IA-64) architecture

    Why in hell they are calling x86-64 architecture amd64? The "amd" part is freaking confusing. Obviously, if you have an Intel processor, you wouldn't want to install something that has "amd" in it. You are wondering: Is this "amd64" reserved exclusively to AMD processor only?

    To the Debian maintainer, please change amd64 to something generic or at least put the description on the download page so people know what they mean.


    1. Check if cron service is running:
      ps -el | grep cron
      # It should return a line with cron. Otherwise, Cron service is not running.
      # or
      #ls -lut /etc/init.d/cron
      # It shows the last time /etc/init.d/cron was executed or read.
    2. If Cron service is not running on Debian, you have to run the following command:
      /etc/init.d/cron start
    3. To make sure that the Cron service is still running after the reboot, run the following command:
      update-rc.d cron defaults
    4. Test to see if cron is running:
      echo "* * * * * echo 'test'>> /test_cron.txt " > cron_list.txt
      crontab cron_list.txt
      It should append 'test' to /test_cron.txt every minutes.
    5. To remove the cron test, run:
      crontab -r

    Display the total memory (RAM) on the Linux system

    #cat /proc/meminfo
    MemTotal:      2076452 kB
    MemFree:         87404 kB
    Buffers:          7844 kB
    Cached:        1899844 kB
    SwapCached:          0 kB
    Active:         102824 kB
    Inactive:      1864888 kB
    HighTotal:     1179584 kB
    HighFree:        36952 kB
    LowTotal:       896868 kB
    LowFree:         50452 kB
    SwapTotal:     5245180 kB
    SwapFree:      5245060 kB
    Dirty:             224 kB
    Writeback:           0 kB
    AnonPages:       60024 kB
    Mapped:          37012 kB
    Slab:            11408 kB
    SReclaimable:     7776 kB
    SUnreclaim:       3632 kB
    PageTables:       1076 kB
    NFS_Unstable:        0 kB
    Bounce:            132 kB
    WritebackTmp:        0 kB
    CommitLimit:   6283404 kB
    Committed_AS:   148140 kB
    VmallocTotal:   114680 kB
    VmallocUsed:      5156 kB
    VmallocChunk:   109340 kB
    HugePages_Total:     0
    HugePages_Free:      0
    HugePages_Rsvd:      0
    HugePages_Surp:      0
    Hugepagesize:     4096 kB


    #List supported video and audio codecs
    ffmpeg -codecs
    #Get the info of video
    ffmpeg -i input.avi
    #Convert wav file to mp3 file.
    ffmpeg -i filename.wav filename.mp3
    # Preserve audio and video quality but use a different container(i.e from MOV to MKV)
    ffmpeg -i -vcodec copy -acodec copy output.mkv


    WinFF, GUI for FFmpeg. You can see the parameters of FFmpeg.

    PDF icon Tutorial_FFMPEG.pdf1.19 MB

    Files / Directories listings

    List files by sizes

    ls -Srsh *.txt
    # -S Sort by size
    # -r  Reverse order while sorting
    # -s Show size
    # -h Show sizes in human readable format

    List directories only

    ls -d */
    # or
    ls -l | grep '^d'
    # or
    ls -p |grep "/"

    Show size of all directories under the current directory

    du -c | sed -n '/^.*\.\/.*\/.*/!p'
    # or
    du -h -d 1
    # or with du from GNU
    du -h --max-depth=1

    How to increase command line history size?

    1. To see how many commands does it remember in the command history, run
        echo $HISTSIZE
    2. To change that value, open ~/.bashrc and then change the value of HISTSIZE or add the following if it doesn't exist.
        export HISTSIZE=999
    3. Run the following for the change to take effect
        source ~/.bashrc
    4. Run the following to see the change
        echo $HISTSIZE

    Info about your CPU

    cat /proc/cpuinfo

    Install JDK

    1. Add non-free in your /etc/apt/source.lst.
      deb lenny contrib non-free
    2. Update the packages list.
      aptitude update
    3. Install Sun's Java JDK.
      aptitude -y install sun-java6-jdk

    Linux run levels

    Linux run levels

    0 – halt (shutdown pc)
    1 – Single user mode
    2 – Multiuser
    3 – Full multiuser mode
    4 – unused
    5 – X11 (Graphical)
    6 – reboot


    To check the current run level

    who -r

    To change the run level

    init 1

    To view run level config file

    cat /etct/inittab

    List all disks and partitions

    /proc/partitions will list all the block devices and partitions that the system recognizes:

    cat /proc/partitions

    Then use file to determine what kind of filesystem is present on the partition, if any:

    file -s <device(e.g /dev/sda1)>

    Mount Hot-pluggable devices(SD cards, USB)

    1. In the shell, run fdisk -l and note all the devices listed.
    2. Plug in your device and then re-run fdisk -l. You should see your newly added device appear in the list.
    3. Create a directory for your device.
      mkdir nameOfDirectory
    4. Mount the device to the directory.
      mount /dev/path/listed/by/fdisk  nameOfDirectory   

    Mount ISO image

    1. mkdir -p /your/desired/mount/path
    2. mount /path/to/your/iso/debian-7.2.0-i386-CD-1.iso /your/desired/mount/path -o loop

    Mount partitions

    Show all partitions

    fdisk -l

    Edit /etc/fstab

    # /etc/fstab: static file system information.
    # <file system> <mount point>   <type>  <options>       <dump>  <pass>
    proc            /proc           proc    defaults        0       0
    /dev/sda12      /               ext3    defaults,errors=remount-ro 0       1
    /dev/sda11      /boot           ext3    defaults        0       2
    /dev/sda7       none            swap    sw              0       0
    /dev/scd0       /media/cdrom0   udf,iso9660 user,noauto     0       0
    /dev/sda6   /fatb       vfat    defaults        0       0
    /dev/sda8   /app        ext3    defaults        0       0
    /dev/sda9   /img        ext3    defaults        0       0
    /dev/sda10  /storage    ext3    defaults        0       0

    Make sure that there is an empty newline at the end of /etc/fstab.

    Mount NTFS partition

    1. Add the following line in /etc/apt/sources.list:
      deb etch-backports main contrib non-free
    2. Update package list by running
      aptitude update
    3. Search for linux-image available and select the 1 according to the architecture of your CPU:
      aptitude -t etch-backports search linux-image-2.6
    4. In my case, I install linux-image-2.6.22-2-486 and ntfs-3g by running:
      aptitude -t etch-backports install linux-image-2.6.22-2-486 ntfs-3g
    5. To mount NTFS partition by running:
      mount /dev/hda1 -t ntfs-3g /mnt/win


    Move files with x size

    There are multiple ways to move files with x size. In my case, I use the find and mv commands. The example below will move all files that are less than 32 kilobytes into /to/my/folder/.

    find -type f -size -32k -exec mv {} /to/my/folder/ \;
    -type -f
    Find files only. Otherwise, find will consider . and .. .
    -size -32k
    The size that you want. The hyphen(-) in front of the number means less than. If you put + in front of the number, then it means more than. If nothing is put in front of the number, then it means equal.
    The filename that matches your criteria defined.

    Network Configuration

    Manually configure network in Debian

    If you are manually setting a static IP address in Debian, you have to edit /etc/network/interfaces. For example, if you want to change your eth0 interface to use a static IP address instead of dynamic IP address , change the following settings accordingly.

    #iface eth0 inet dhcp #Comment this line out with the pound(#) key. It was your dhcp setting(dynamic IP address).
    # Add the following lines below in /etc/network/interfaces.
    # Add the 'auto' line below. Otherwise, at reboot eth0 interface will not be up. You have to manually run ifup eth0.
    auto eth0
    # Set eth0 interface to use static IP address
    iface eth0 inet static
        # Enter your static IP address for eth0 interface.
        # Enter the IP address of your gateway(router).

    Make sure that the nameserver in /etc/resolv.conf as follows:


    Then, run the following for the changes to take effects:

    /etc/init.d/networking restart
    ifdown eth0
    ifup eth0


    Debian's network configuration manual

    /etc/resolv.conf - your name servers go in there /etc/hostname - hostname for your box /etc/hosts

    ifconfig eth0 netmask up #computer
    route add -net netmask eth0 #network
    route add default gw eth0 #router/gateway 


    All packages used.

    VNC Server

    1. Install VNC Server.
        aptitude -y install vnc4server
    2. You must run VNC Server at least once to setup the password.
    3. To connect to the VNC Server from another computer, you have to install VNC Viewer.


    Raid sync status

    cat /proc/mdstat

    Details info RAID drive

    mdadm -D /dev/md1

    Run some script at startup

    1. Copy your script(e.g into the directory /etc/init.d/.
    2. Run
          update-rc.d defaults
    3. That is it! Everytime Debian started, it will run


    What is SciTE?

    SciTE is a lightweight code editor. I mainly used to:

    • Do search and replace text with regular expression.
    • Write simple and small scripts.
    • Open huge file.

    Customs properties I use

    # Added customs properties in file (/usr/share/scite/
    # LinuxMint: /etc/scite/
    # -----------------------------
    # Turn every characters to monospace.
    # Line numbering
    # Foldable for block of code?(e.g. loops, functions, etc)
    # Indentation
    # Status bar
    # Highlight background color
    # Find/Search highlight background color
    # File Encoding

    I add the $(all.files)\ right after open.filter so that I can see all the files when I open the file dialog:



    Show directory structure and all files in text format

    1. Run the following to install.
      aptitude -y install tree
    2. Here is an example of what it will show for /root/.java directory:
      # tree /root/.java/
      `-- deployment
          |-- cache
          |   |-- javapi
          |   |   `-- v1.0
          |   |       |-- ext
          |   |       |-- file
          |   |       |   |-- ADT_homepage4.gif-1731c063-7adea2e8.idx
          |   |       |   |-- LiveCounter.class-10be6239-7b0308a3.class
          |   |       |   |-- LiveCounter.class-10be6239-7b0308a3.idx
          |   |       |   |-- RotatingPicture.class-b6f03b0-1332bc45.class
          |   |       |   |-- map1.gif-5bd14354-33c04e0a.gif
          |   |       |   |-- site0.gif-15518bd4-551cfce3.gif
          |   |       |   |-- site0.gif-15518bd4-551cfce3.idx
          |   |       |   |-- theCicero.class-474ef599-29a40ad6.class
          |   |       |   |-- theCicero.class-474ef599-29a40ad6.idx
          |   |       |   |-- up.gif-495c0cfe-369c9ad6.gif
          |   |       |   |-- up.gif-495c0cfe-369c9ad6.idx
          |   |       |   |-- util2.gif-7ab0e6fb-10bad922.gif
          |   |       |   `-- util2.gif-7ab0e6fb-10bad922.idx
          |   |       |-- jar
          |   |       |   |-- Ticker.jar-5dfbca87-51bf510b.hst
          |   |       |   |-- Ticker.jar-5dfbca87-51bf510b.idx
          |   |       |   |-- txtscroll.jar-64d28141-7ae6c7fe.idx
          |   |       |   `--
          |   |       `-- tmp
          |   `-- tmp
          |-- ext
          |-- host
          |   |-- 167dc6a3.hst
          |   |-- 7ff51e9b.hst
          |   `-- b145321.hst
          |-- log
          |   `-- plugin150_14.trace
          `-- security

    Softwares used

    aptitude -y install x-window-system wmaker mplayer iceweasel gkrellm scite gftp gqview k3b epiphany-browser sun-java6-jdk sun-java6-jre tree dia tidy gawk lxsplit unzip ntp vnc4server imagemagick openssh-server
    aptitude -y install xfonts-intl-chinese xfonts-intl-chinese-big ttf-arphic-bkai00mp ttf-arphic-bsmi00lp ttf-arphic-gbsn00lp ttf-arphic-gkai00mp ttf-arphic-ukai ttf-arphic-uming
    aptitude -y install avidemux


    # Compress using gzip compression.
    tar -zcvf archive_name.tar.gz directory_to_compress
    # Decompress gzip compression.
    tar -xzvf archive_name.tar.gz
    # Compress using bzip2 compression.
    tar -jcvf archive_name.tar.bz2 directory_to_compress
    # Decompress bzip2 compression.
    tar -xjvf archive_name.tar.bz2
    # Compress hidden files starting with a dot(i.e .bashrc, .htaccess, etc)
    tar -zcvf archive_name.tar.gz .
    # Multiple volumes:
    #  Tar does support multi-volume but not in conjunction with gzip nor with bzip2.
    #  So, use the "split" command to create multiple volumes.
    # Split the compressed archive into 100 MB files.
    split -d -b100m archive_name.tar.gz archive_name.tar.gz.
    # Join the splitted files.
    cat archive_name.tar.gz.* archive_name.tar.gz

    Pros and Cons of different compression algorithm

    decompression speed (fast > slow): gzip, zip > 7z > rar > bzip2
    compression speed (fast > slow): gzip, zip > bzip2 > 7z > rar
    compression ratio (better > worse): 7z > rar, bzip2 > gzip > zip
    availability (unix): gzip > bzip2 > zip > 7z > rar
    availability (windows): zip > rar > 7z > gzip, bzip2


    Time Zone

    Time zone is stored in /etc/timezone file. Running /usr/bin/tzselect will help you find your time zone but doesn't update your system.

    Setting Time Zone on system wide

    run tzconfig


    Once you've set your timezone you might wish to change the UTC setting, upon Debian machines you can find that in the /etc/default/rcS file. Although changing this will require a reboot. I think, hwclock --systohc --utc command (in case UTC=yes) could be used instead of reboot.


    #!/bin/bash /usr/sbin/ntpdate -s /sbin/hwclock --adjust /sbin/hwclock --systohc
    1. apt-get -y install ntpdate
    2. echo "ntpdate -b" >
      chmod +x

    Video/audio encoding using mencoder and ffmpeg

    mencoder originalfile.mkv -oac mp3lame -lameopts abr:br=128 -ovc xvid -xvidencopts bitrate=1000:pass=2 -vf pp=de,scale=480:-2 -o "newfile.avi"

    mencoder input_file.rm -ovc frameno -oac mp3lame -of rawaudio -lameopts cbr:br=128 -o output_file.mp3

    Convert video to different standards: vcd, svcd, dvd, dv, pal-vcd, ntsc-svcd, ntsc-vcd, ntsc-dvd, etc... ffmpeg -i myfile.avi -target vcd /tmp/vcd.mpg

    Video to mp3 ffmpeg -i video.mpg -f mp3 audio_track.mp3 ffmpeg -i video.flv -ab 64k -ar 22050 videosound.mp3 -i is to specified input file, -ab audio bitrate, -ar audio sampling frequency mplayer -dumpaudio -dumpfile audio_file.mp3 video.flv

    Dump audio as wav mplayer -vc null -vo null -ao pcm -benchmark video.flv

    REM mencoder %1 -vf scale=320:240 -oac lavc -ovc lavc -lavcopts acodec=aac:abitrate=48:vcodec=mpeg4:vbitrate=600:mbd=2:cmp=2:subcmp=2:trell=yes:v4mv=yes:aic=2:vglobal=1:aglobal=1 -ffourcc mp4v -of lavf -lavfopts format=mp4:i_certify_that_my_video_stream_does_not_use_b_frames -o %2
    REM mencoder %1 -vf scale=320:240 -oac lavc -ovc lavc -lavcopts acodec=aac:abitrate=48:vcodec=mpeg4:vbitrate=600:mbd=2:cmp=2:subcmp=2:trell=yes:v4mv=yes:aic=2:vglobal=1:aglobal=1 -ffourcc mp4v -of lavf -lavfopts -o %2
    REM ffmpeg -i source_video.avi input -acodec aac -ab 128kb -vcodec mpeg4 -b 1200kb -mbd 2 -flags +4mv+trell -aic 2 -cmp 2 -subcmp 2 -s 320x180 -title X final_video.mp4
    REM ffmpeg -i %1 -acodec aac -ab 128kb -vcodec mpeg4 -mbd 2 -flags +4mv+trell -cmp 2 -subcmp 2 -s 320x180 %1.mp4
    REM ffmpeg -i %1 -vcodec libx264 -bt 50k -acodec libfaac -ab 56k -ac 2 -s 480x320 %1.mp4
    REM ffmpeg -i %1 -vcodec libx264 -crf 25 -acodec libfaac %1.mp4
    REM ffmpeg -i %1 -f mp4 -vcodec mpeg4 -maxrate 2000 -b 1500 -qmin 3 -qmax 5 -bufsize 4096 -g 300 -acodec aac -ar 44100 -ab 128 -s 320x240 -aspect 4:3 %1.mp4
    REM mencoder %1 -oac mp3lame -lameopts abr:br=48 -ovc xvid -xvidencopts bitrate=500:pass=2 -vf pp=de,scale=480:-2 -o %1.mp4
    REM mencoder %1 -oac mp3lame -lameopts abr:br=48 -ovc x264 -x264encopts bitrate=500:pass=2 -vf pp=de,scale=480:-2 -o %1.x264.mp4
    REM mencoder %1 -oac mp3lame -lameopts abr:br=48 -ovc x264 -x264encopts bitrate=500 pass=2 nr=2000 -o %1.x264.480..mp4
    REM ffmpeg -i %1 -vcodec libx264 -acodec aac -b:5M -ab:41k %1.mp4
    REM ffmpeg -y -i %1 -acodec libfaac -ar 44100 -ab 96k -coder ac -me full -me_range 16 -subq 5 -sc_threshold 40 -vcodec libx264 -s 1280x544" -b 1600k -cmp +chroma -partitions +parti4x4+partp8x8+partb8x8 -i_qfactor 0.71 -keyint_min 25 -b_strategy 1 -g 250 -r 20 %1.mp4;
    REM ffmpeg -i %1 -vcodec libx264 -b 500 -g 3 -bf 3 -b_strategy 1 -coder 1 -qmin 10 -qmax 51 -sc_threshold 40 -flags +loop -cmp +chroma -me_range 16 -me_method hex -subq 5 -i_qfactor 0.71 -qcomp 0.6 -qdiff 4 -directpred 1 -flags2 +fastpskip -dts_delta_threshold 1 -acodec libfaac -ab 41 %1.mp4 
    REM ffmpeg -i %1 %1.mp4
    REM ffmpeg -i %1 -f ipod -vcodec libx264 -s 320x240 -ab 96k %1.mp4
    REM ffmpeg -y -i %1 -vcodec libx264 -r 25 -b 516k -bt 516k -crf 22  %1.mp4
    mencoder %1 -oac mp3lame -lameopts abr:br=48 -ovc x264 -x264encopts bitrate=500 pass=2 nr=2000 -o %1.mp4



    #Playing ISO DVD with mplayer
    mplayer -dvd-device movie.iso dvd://1
    #Play DVD on the G: drive
    mplayer -fs dvd:// -dvd-device G:
    # At runtime, press # to change language
    #Play mediafile in loop
    mplayer -loop 0 mediafile
    #Play at a specific interval of a video
    mplayer -ss 1:33:28 -endpos 1:50:15 -loop 0 <file>

    Install Codecs

    1. Download Windows x86 xxxx from
    2. Create a codecs folder
      mkdir /usr/lib/codecs
    3. Decompress the download archive and copy all files to /usr/lib/codecs
      cd windows-essential-20071007
      cp * /usr/lib/codecs

    Example of config file

    If you use gmplayer, you can do it the preferences dialog, if not you should edit ~/.mplayer/config.
    The settings for the config file are: subfont-autoscale and subfont-text-scale. Check the man pages ( for the values they can take.
    As an example here's the part about subtitles in my config file:
    # Subtitles
    # VobSubs
    # Align VobSubs (-1: as they want to align themselves)
    # Anti-alias VobSubs (4: best and slowest)
    # Default VobSub language to select
    # Text-based subtitles
    # Find subtitle files (1: load all subs containing movie name)
    # Font
    # Font encoding
    # Subtitle file encoding
    # Resample the font alphamap (10: bold black outline)
    # Subtitle position (100: as low as possible)
    # Subtitle alignment at its position (2: bottom)
    # Font size (2: proportional to movie width)
    # Font blur radius (default: 2)
    # font outline thickness (default: 2)
    # Autoscale coefficient of the subtitle (default: 5)
    # OSD
    # Autoscale coefficient of the OSD elements (default: 6)

    To check: /usr/bin/mplayer -noquiet -nofs -sub-fuzziness 1 -identify -slave -vo xv -ao alsa -zoom -nokeepaspect -input conf=/usr/share/smplayer/input.conf -stop-xscreensaver -wid 83886090 -monitorpixelaspect 1 -subfont-autoscale 1 -subfont-text-scale 5 -subcp ISO-8859-1 -aid 1 -subpos 100 -contrast 0 -brightness 0 -hue 0 -saturation 0 -nocache -ss 1275 -osdlevel 0 -vf-add screenshot -vf-add eq2,hue -channels 2 -af scaletempo -softvol -softvol-max 110 /media/some_videos_dvd/funny_video.avi

    echo "deb squeeze main non-free" >>/etc/apt/sources.list
    aptitude update
    aptitude -y install w32codecs libdvdcss2 mplayer

    Automatically take 8 screenshots of a video using mplayer

    # Description: Automatically take 8 screenshots of a video using mplayer
    #              Screenshots are saved in 01.png, 02.png, ..., 08.png
    # Author: Xuan Ngo
    # Usage: ./ VideoFilename
    # Requirements: mplayer, grep, sed
    # For some unknown reason, the last screenshot is not generated by mplayer.
    # Therefore, always add 1 more to the total number of screenshots that you want.
    # Get the total length of the video in seconds.
    #  Use mplayer to display the info of the video and then get the value of ID_LENGTH, the total number of seconds of the video.
    total_length=$(mplayer -identify -frames 0 -vc null -vo null -ao null ${filename} | grep ID_LENGTH | sed 's/ID_LENGTH=//' | sed 's/\..*//')
    # Remove 4 seconds from the video so that it doesn't take screenshot at the ends.
    let total_length-=4
    # time_slice: At which time interval should mplayer take screenshots.
    let time_slice=${total_length}/${NUM_OF_SCREENSHOTS}
    # time_at: When should mplayer take screenshots.
    # Looping to take screenshots.
    for ((i=1; i <= NUM_OF_SCREENSHOTS ; i++))
      # Create unique filename.
      padding=$(printf %03d ${i})
      # Take the screenshot.
      mplayer -nosound -ss ${time_at} -vf screenshot -frames 1 -vo png:z=9 ${filename}
      # Increment to the next time slice.
      let time_at+=${time_slice}
      # Move the screenshot 00000001.png to 0X.png
      mv 00000001.png ${padding}.png