Category: System Administration

Backup and Play DVD with Linux

If your linux does not play DVD correctly, try this:
sudo apt-get install libdvdread4
sudo /usr/share/doc/libdvdread4/

Backup DVD as ISO file:
ddrescue -d /dev/dvd ~/dvd_backup.iso ~/dvd_backup.log
This is just an example. Please replace the arguments with those of your specific backup task.

According to the following post:
Pack­ages needed:
Gnu ddres­cue

The process:
ddres­cue –n –b 2048 /dev/dvd output.iso
dvd­backup –M –i output.iso –o dvd_structure
mkisofs –dvd-video –o clean_dvd.iso dvd_structure

Step 1 copys the DVD to disk block by block but any bad sec­tors found zero data is filled in. At this point you are left with a DVD iso that has the copy pro­tec­tion removed but the encryp­tion is still intact. Step 2 extract the con­tents to a direc­tory. This sec­ond step leaves you with the struc­ture of a dvd with­out the encryp­tion. I want to pre­serve every­thing about the orig­i­nal DVD (except the copy pro­tec­tion and encryp­tion) so I used the mir­ror option. This leaves me with all the fea­tures and orig­i­nal menus. Step 3 take the DVD struc­ture and pack it up into a nice ISO.

Enable/Disable Touch Screen with Ubuntu

1. Identity Touch Screen
xinput –list
It will output a list of your input devices. For example:
⎡ Virtual core pointer id=2 [master pointer (3)]
⎜ ↳ Virtual core XTEST pointer id=4 [slave pointer (2)]
⎜ ↳ SynPS/2 Synaptics TouchPad id=10 [slave pointer (2)]
⎜ ↳ ELAN Touchscreen id=12 [slave pointer (2)]
⎜ ↳ Microsoft Microsoft® 2.4GHz Transceiver v5.0 id=13 [slave pointer (2)]
⎣ Virtual core keyboard id=3 [master keyboard (2)]
↳ Virtual core XTEST keyboard id=5 [slave keyboard (3)]
↳ Power Button id=6 [slave keyboard (3)]
↳ Video Bus id=7 [slave keyboard (3)]
↳ Power Button id=8 [slave keyboard (3)]
↳ AT Translated Set 2 keyboard id=9 [slave keyboard (3)]
↳ Lenovo EasyCamera id=11 [slave keyboard (3)]
My touch screen is “ELAN Touchscreen”

2. Enable/Disable Touch Screen
xinput –enable “Name Of Your Touch Screen”
xinput –disable “Name Of Your Touch Screen”

For example:
xinput –disable “ELAN Touchscreen”

Set Default File Association in Ubuntu Unity for Applications Not Listed in “Open With”


One can use “mimeopen -d file” to invoke an application to open a file in the command line. Afterwards the used application will be the default application associated with the file type, even from the Nautilus.

Example: Set nano as the default program to open *.txt files:

$ mimeopen -d file.txt

Please choose a default application for files of type text/plain

1) notepad (wine-extension-txt)
2) gedit (gedit)
3) GNU Emacs 23 (emacs23)
4) Other…

use application # 4

use command: nano

Opening “useful.txt” with nano (text/plain)

Install Ubuntu on Ideapad Yoga 2 Pro

Before Buying Yoga 2 Pro:
If you have bought a Yoga 2 Pro, then skip this section and jump directly to the next section. This computer has the following problems, known widely among its users, yet not acknowledged or properly addressed by Lenovo.
1. Inaccurate Rendering of the Yellow Color. This is widely and notoriously known. Lenovo’s BIOS update until today (June 6, 2014) does not solve it. Lenovo regards it as solved and dismisses it, but many users do not agree at all.
2. Poor Micro HDMI Compatiblity. The Micro HDMI port, the only video export of the computer, is hidden too deep to make a stable contact with a standard Micro HDMI cable. Some DIY users have to manually file the bud of their Micro HDMI cable for 1mm~2mm to fit with this port. You may need to try a few cables to find a working one.
3. Unintended Mute Speaker Caused by Inconsistence Audio Jack Detection. Sometimes, the speaker mute because the computer falsely detects audio jack as plugged in, though actually not at all. Unfortunately, plugging-and-unplugging does not always solve the problem. It depends on luck.
4. Frequent WiFi Signal Dropping. To my experience, my 8-year old T60 has much better WiFi performance than my Yoga 2 Pro. By the way, this computer can only receive 2.4G Hz signals, not 5G Hz signals.

Install Ubuntu on Ideapad Yoga 2 Pro

Hardware: IdeaPad Yoga 2 Pro, Intel Haswell i5 CPU, 256 SSD, 8G RAM
Software: Ubuntu 13.10, 64bit

1. Enable booting from USB
Power down the computer. Push the “novo” button, then the computer enter BIOS configuration. Disable “Security Boot”, and Disable “Lenovo Fast Boot”.

2. Prepare Ubuntu Installation USB
Create a Ubuntu Installation USB following the instruction by Ubuntu. After this, find file /boot/grub/grub.cfg and modify it by adding “acpi_backlight=vendor” before “quiet splash”. You shall have something like this in the boot options: “acpi_backlight=vendor quiet splash”. You may need the root permission to edit this file, so use “su” or “sudo” to get the root permission when editing, for example, sudo vi /boot/grub/grub.cfg
This is important. Otherwise, Ubuntu installation runs but the screen does not turn on.

3. Install Ubuntu
Insert the USB disk and power on the computer with the “novo” button. Select USB boot from the Boot Menu. Then the Ubuntu installation process starts. You many need to use “gparted” to shrink the Windows partition and create one partition for Grub boot loader and another partition for Ubuntu. It is wise to avoid overwriting partitions with factory settings and factory boot loaders. For example, the Windows 8 is on partition /dev/sda5. /dev/sda1 ~ /dev/sda4 has software installed by Lenovo, then I shrink /dev/sda5, and created /dev/sda8 for boot loader and /dev/sda9 for Ubuntu. I try to avoid overwriting /dev/sda1 ~ /dev/sda5.

4. Screen Problem
Now, your Ubuntu can boot, but you still have only a black screen.The
Restart computer, and choose “advanced Ubuntu” in grub and choose recovery mode, and choose “root console“. In this way, you can enter the command line mode to solve the screen problem.
Modify /etc/default/grub by modify with GRUB_CMDLINE_LINUX_DEFAULT=”acpi_backlight=vendor quiet splash”
Run update-grub2, then this “acpi_backlight=vendor” option will be pushed to your /boot/grub/grub.cfg. Now the screen problem shall be solved.
Make sure you make this change for all the Ubuntu boot entries of your grub, otherwise some entries will not work.

5. Wifi and Screen Brightness Problem
There may be other solutions, but this simple solution works perfect for me.
In /etc/modprobe.d/ I created a file “blacklist-ideapad_laptop.conf”, and in it, I put “blacklist ideapad_laptop”, in this way, both the wifi and brightness problems are solved. Very simple. You do not need wicd to solve this problem.

6. Tweak for SSD (Optional).
Edit /etc/fstab to add options mount “noatime,nodiratime,discard” to your ubuntu partition.
Edit /etc/fstab to use tmpfs for /tmp and /var/tmp

Useful Links: (Thanks to rubo77)

Scan WIFI Channels around You

Sometimes there are too many wifi routers around you so that their channels conflicts with yours. In this case, you may need to manually choose a channel for your router, to minimize confliction. In this case, you need to scan and see the channels being used around you.

Solution for Linux:
In console, use the following command:
sudo iwlist wlan0 scanning | grep -iA3 Channel

Use PDF-XChange Viewer in 64bit Ubuntu with 32bit Wine

To run “PDF-XChange Viewer” in Linux, we need 32-bit Wine. The 64-bit version is incompatible.

GUI Solution:
(1) Install “PlayOnLinux”
(2) Launch “PlayOnLinux”
(3) In “Tools”->”Manage Wine versions”, install an x86 version Wine. Please make sure that you choose from “Wine Versions (x86)”.

Screenshot from 2013-11-27 11:16:40

(4) In “PlayOnLinux”, install “PDF-XChange Viewer”. During the installation process, choose “Use another version of Wine” and then choose the x86 version of Wine.

Choose “Install a non-listed program”
Screenshot from 2013-11-27 11:27:16

Choose “Install a program in a new virtual drive”
Screenshot from 2013-11-27 11:29:00

Choose “Use another version of Wine”
Screenshot from 2013-11-27 11:30:27

Choose “32 bits Windows installation”
Screenshot from 2013-11-27 11:31:36

Browse your PDF-XChange Viewer Installation exe
Screenshot from 2013-11-27 11:42:01

(5) Go through the installation procedure.

(6) Tweaks
If you found errors with, you can fix it with
sudo apt-get install liblcms2-2:i386

Command Line Wrap:
To make “PDF-XChange Viewer” interact with other programs, for example JabRef, we need to make a command line script to wrap the launch of the PDF viewer with a PDF file argument.

——– Method 1 (Recommended) script: PDFXCview —————–


# APP="The name PlayOnLinux uses for launch PDF-XChange"
# You can find it by launching PlayOnLinux

RootDrive="Drive Name To Which Your Wine Maps /"
# For example:
# "z:"
# You can find this by opening PDF-XChange from PlayOnLinux and then browsing to the "My Computer" with its "File -> Open" menu.

if [ $# -lt 1 ]
    "$POL" --run "$APP"
    exit $?
    Input="$( readlink -f "$1" )"
    "$POL" --run "$APP" "${RootDrive}/${Input}"
    exit $?

——– Method 2 (Not recommended) script: PDFXCview ————-


Wine="Your 32Bit-Wine Binary"
# For example, if you use the PlayOnLinux wine installation:
# "/home/your_user_name/.PlayOnLinux/wine/linux-x86/1.5.26/bin/wine"

export WINEPREFIX="Your 32-Bit Wine Environment Folder"
# This is the working environment for the wine binary.
# Wine finds its configuration, its virtual drive maps in this folder.
# This is a very important environment variable.
# Make sure it is correct.
# For example, if you use the PlayOneLinux wine installation:
# "/home/your_user_name/.PlayOnLinux/wineprefix/PDFXChange"

RootDrive="Drive Name To Which Your Wine Maps /"
# For example:
# "z:"

Application="Your PDF-XChange Viewer Binary"
# For example:
# "/home/your_user_name/.PlayOnLinux/wineprefix/PDFXChange/drive_c/Program Files/Tracker Software/PDF Viewer/PDFXCview.exe"

if [ $# -lt 1 ]
    "$Wine" "$Application"
    exit $?
    Input="$( readlink -f "$1" )"
    "$Wine" "$Application" "${RootDrive}/${Input}"
    exit $?


Interaction with Other Programs:
To make PDF-XChange Viewer accessible from command-line, the above script should be put in a fold listed in your environmental variable PATH. For example, as a user, you can put it in “/home/YourUserName/bin” with file name “PDFXCview”. Make sure you grant the executable permission to it. Then you should be able to launch it simply with a command “PDFXCview” in a console. After setting up the command-line script, you can configure other programs to interact with PDF-XChange Viewer.

To interact with JabRef (Version 2.5): launch JabRef, go to “Options” -> “Preferences” -> “External programs” -> “Manage external file types”, select “PDF” and click the edit button, in the edit window, fill the “Application” field with the full path of your PDFXCview script, for example, “/home/YourUserName/bin/PDFXCview”.

Backup MBR

Master Boot Record (MBR):
The first 512 bytes of a storage device. The first 446 bytes are the boot loader; the second 64 bytes are the partition table; the last 2 bytes are the sentenal (OxAA55)

Example with /dev/sda
dd  if=/dev/sda  of=TheBackUpFile  bs=512  count=1
# Make sure to use “bs=512 count=1”

cmp /dev/sda TheBackupFile -n 512

dd if=TheBackUpFile of=/dev/sda bs=512 count=1
# Important: Make sure to use “bs=512 count=1”