Computing‎ > ‎Linux‎ > ‎

Debian notes

Debian is an acronym, which stands for Debra and Ian, the first name of his then girlfriend Debra and the first name of Ian Murdockthe creator of the Debian project. Ian Murdock passed away at the end of 2015. 

From the very start, Debian has been a romantic, idealist and living manifestation of the spirit of free software and testimony to the championing of the cause of linux operating system.

  • unpack *.tar.xz archive, use
          $tar -xavf archive.tar.xz
          where "-a" flag means let tar automatically choose extract algorithm based on *.tar.* archive extension.
  • eject kindle: continue reading while charging, use         
          #sudo eject /dev/disk/by-label/Kindle
  • debian multiarch support, to install package, use
          #sudo apt-get install package:i386
  • web browser shortcuts
          Ctrl-w, close current tab
          Alt-D, go to address bar
          Ctrl-PgUp, Ctrl-PgDn, navigate between tabs
  • Gnome 3 network manager disconnects very often
              edit an entry in /etc/network/interfaces from "allow-hotplug <interface>" back to "auto <interface>"
  • transfer files back and forth via ECE 486 course website on Debian
             sftp -p
     where "-p" is used to preserve timestamps of files.
     use get -r ./* to fetch server ALL files and use put ./* to upload local files.
  • compress a directory with .xz
             tar cJf filename.tar.xz folder
     where "J" flag is for .xz compression.
  • fix the system time difference from debian when use dual OS (debian and windows), edit 

             to change UTC to LOCAL.
  • to improve font rendering in Debian
create a file .fonts.conf in home directory and paste the example configuration into it.
  • to estimate power consumption of the linux system, install powertop or powerstat.
  • debian install history by apt-get
less /var/log/apt/history.log
  • change screen brightness
xrandr --output LVDS-1 --brightness 0.92
  • display ls result screen by screen 
ls | less
  • look up memory info (need super user privilege)
sudo dmidecode -t memory
  • look up hard drive info (need super user privilege)
sudo hdparm -I /dev/sda

CrystalDiskMark equivalent (need super user privilege), test cached read and buffered read

sudo hdparm -tT /dev/sda
  • check system temperature
  • check hard drive firmware
sudo smartctl --xall /dev/sda | grep -i firmware
where --xall prints out all SMART and non SMART info; -i option for grep means case 'insensitive' search. Comprehensive use of smartctl, see
  • OpenGL issues after updating mesa graphics driver
libGL error: unable to load driver:
libGL error: driver pointer missing
libGL error: failed to load driver: i965
libGL error: unable to load driver:
libGL error: driver pointer missing
libGL error: failed to load driver: i965
libGL error: unable to load driver:
libGL error: failed to load driver: swrast
Warning: OpenGL appears to be installed incorrectly. 
Fix: rename the file found at $MATLAB_ROOT$/sys/os/glnxa64/ to, restart MATLAB, this forces MATLAB to use the OS library. 
See the link.
Also, use LIBGL_DRI3_DISABLE=1 matlab to start MATLAB if R2016b is used. The value of the environment variable LIBGL_DRI3_DISABLE does not matter. 
Check hardware acceleration using opengl info.
  • Enable trim for SATA SSD and NVMe SSD. Only manual trimming is necessary
sudo emacs -nw /etc/cron.weekly/fstrim
Then enter the code,
fstrim /
fstrim /home
  • Convert a Debian BIOS-boot system to UEFI-boot system (This is a note I wrote for myself. No warranty for anybody else. Always back up data before proceeding. If you don't know what you are doing, please quit playing with bios or uefi.)
    1. UEFI-boot needs GPT rather than MBR, so try to use gdisk to convert
    existing MBR to GPT. (sudo gdisk /dev/nvme0n1p will send us into gdisk
    environment and later we want to issue w command to convert MBR to
    GPT.) I did this under running Linux machine (mounted partitions) rather
    than using a LiveCD to boot into a live session under which I am supposed
    to use gdisk on unmounted partitions.
    2. Then create an ESP partition once the GPT has been created. ESP
    stands for EFI System Partition. The ESP must be in FAT32 and with a rec-
    ommended size no less than 200MB. ESP needs to be flagged as “boot”.
    3. The mistake I made before I realised the correct way to change the BIOS-
    boot to UEFI-boot was I kept using Debian LiveCD to boot into a live ses-
    sion and try to install grub loader using that live session. Debian LiveCD
    does not support UEFI-boot as of now, so the live session with which I worked
    was BIOS-boot only. The fix was, try to get a Ubuntu LiveCD, and disable
    the legacy boot in the motherboard. I chose UEFI only in the motherboard
    setting so it forced the LiveCD to be booted with UEFI mode.
    4. In case the grub-efi (meta package) in Ubuntu’s repository behaves
    differently from the one in Debian, we need to download all Debian *.deb
    packages first. Do sudo apt-get install –reinstall grub-efi or grub-efi-amd64
    before reboot and start new live session with Ubuntu LiveCD.
    5. Mount the original root / to /mnt in the live session. sudo mount
    /dev/nvme0n1p1 /mnt
    . (Check the correct device names by using sudo
    fdisk -l
    ) If there is a separate /boot partition, also mount that separate
    boot partition to /mnt/boot. Also mount other critical virtual file systems:
    for i in /dev /dev/pts /proc /sys /run; do sudo mount -B $i /mnt$i; done
    6. Create a new folder efi in /mnt/boot and mount the ESP partition
    created in step 2 to /mnt/boot/efi. Go to /var/cache/apt/archives and
    install all the *.deb packages that were downloaded for grub-efi or grub-
    . If you don’t mind using the Ubuntu’s grub bootloader, you can
    just sudo apt-get install grub-efi in the live session; that will install grub
    bootloader from Ubuntu’s repository.
    7. Now we are ready to chroot so that the original system root will take
    over. sudo chroot /mnt (now live session treats /mnt as if the original system / partition is the root directory)
    8. Install efi to /mnt (the original system root). grub-install /dev/nvme0n1
    (no sudo is needed since once you chroot, we are with #; this command
    grub-install is only available after we installed grub-efi or grub-efi-amd64
    package; and the device name should be the device, e.g., in this case,
    /dev/nvme0n1 is the name for my NVMe M.2 SSD, and /dev/nvme0n1p1
    is the first partition on the SSD.) Then issue update-grub . After that, press
    Ctrl+D to exit the chroot environment.
    9. One of the few quirks about efi installation in Debian is that the previous
    step created /boot/efi/efi/debian/grubx64.efi but we have to copy it to
    /boot/efi/efi/boot/bootx64.efi Create a folder /boot/efi/efi/boot if it does
    not exist.
    10. Installation is now complete. Reboot and go to BIOS setting, choose
    UEFI first or UEFI only for boot. In my case, NVMe SSD is only available
    now under UEFI boot (originally it was only available under Legacy boot.)
  • Update ThinkPad X40/X41 bios using Linux only (no Windows, no CD/DVD)
1. Grab the bios file from Lenovo's site or IBM systems archive. The history of X40 bios update  can be seen at

To extract the disc image file that we need to boot into, use

cabextract 1uuj22us.exe 

This will generate several files. The file we are looking for is with the same name as *.exe we downloaded but with the extension *.IMG
2. Install grub-imageboot and the default path for custom boot image is /boot/images. (Install syslinux and copy memdisk to /boot if necessary.)
3. Throw for example the bios file, 1UUJ22US.IMG to /boot/images but *.IMG has to be changed to *.img
4. Update grub boot list by sudo update-grub2 We should see /boot/images/1UUJ22US.img found.
5. Reboot and choose "Bootable floppy diskette 1UUJ22US" and follow the bios flash prompt.
  • Pull Intel PRO/Wireless 2915abg from X41 and install it to X40 (because we need the encryption support of the Enterprise WPA2 for IllinoisNet on campus. The wifi card that comes with X40 is an Intel PRO/Wireless 2100 which does not support WPA2 Enterprise.)
There is a wifi whitelist check in X40 bios and the error code is 1802. There are multiple ways to remove the whitelist check. The way mentioned here is to flip the CMOS whitelist check bit. See

Download the floppy disk image and use the method mentioned above of how to update bios to boot into the no1802.img. Once we boot into the no1802.img, we notice that it is a DOS environment and follow the prompt to remove the error 1802. 

NOTE on how to modify ThinkPad serial number in BIOS: (need WinXP) Download i7tmXXus.exe (ThinkPad Hardware Maintemance Diskette) and unpack the file (unpacking the 32bit exe needes WinXP) and run usbfmtpw.exe from the unpacked folder. It will prepare a USB stick rather than a real floppy disk drive. This USB stick will make sure the EEPROM protection is unlocked (by immediately pressing ESC when IBM ThinkPad logo shows up upon powerup).
  • restart LXDE panel
pkill lxpanel
lxpanel --profile LXDE
  • Gnus reference card
  • Gnus + Gmail
1. The set-up generally follows the quickstart section on page But I have my own gnus-settings.el saved in a separate folder as practised by Jess Hamrick. Do use .authinfo.gpg because by default *.gpg will be encrypted by GnuPG. The first time we start gnus within emacs, we will be asked to key in a password;
2. Start gnus by M-x gnus, if there is no new email, we will see blank screen in *Group* buffer (Group is for news reading, hence the name Gnus). Press L (list all groups), we will see all available folders (to which emails are copied according to labels we created in gmail web version). If we have helm-mode enabled, we can search all available key strokes for gnus actions and their descriptions, for example the L above;
3. I disabled Gmail Tabs so all emails come into INBOX folder (all incoming emails are with inbox labels). We can assign new label to an incoming email with B c (copy to, so we can have the email labelled with new tag while it is still in INBOX folder) and remove a label by going to the group/folder under which the email has been stored (once an email has been assigned a label, it will be stored in a separate folder/group), further press B DEL to remove an email from the group, hence removing an label;
4. Fetch new email, press  / N when in Summary buffer (meaning you are reading emails) or g when in Group buffer. Mark emails as read, press d; to copy a link in Gnus, press u; (this will copy the url to kill-ring.)
5. Remove auto save list of gnus reading in case we have messed up with gnus, delete  ~/.newsrc and ~/.newsrc.eld
  • Gnus + Gmail (WinXP, on Thinkpad X40/41)
1. One of the GnuPG ports on windows is gpg4win. For use within emacs, install gpg4win with GnuPG component only is enough. But there is one line difference in gnus-settings.el (my gnus setting file for emacs), we have to explicitly point to the gpg.exe by

(setq epg-gpg-program "/path/to/gpg.exe")

Simply include (setq epg-gpg-program "gpg") is not working, even gpg4win has set correct environment variable PATH.

2. Emacs win32 needs some extra library files (though emacs may work for general editing without them), specifically, gnutls, libxml2, and zlib. We need to grab them from ezwinports. Preserve the original file system structures as in the archives and unpack them to disk. (preferably within the same directory where emacs folder resides.) In order for emacs to see them, either include those binaries in the system PATH or in general-settings.el (my general setting file for emacs), add a few more lines for PATH,

(setenv "PATH" (concat
                    (getenv "PATH") ";"
                    "C:/Program Files/GNU/GnuPG/pub" ";"
                    "C:/path/to/gnutls/bin" ";"
                    "C:/path/to/libxml2/bin" ";"
                    "C:/path/to/zlib/bin" ";"))

3. Change one line in gnus-settings.el for gmail,

;(nnimap-server-port "imaps") ; *nix only
(nnimap-server-port 993) ; windows only

4. w3m is only available with Cygwin but WinXP is too old to install one, so I disabled html rendering with w3m within gnus.
  • Printing with Emacs 
;; for printing
(setq lpr-command "") ; nil value, sent print to local printer
(setq printer-name "DOT4_001") ; port, WinXP on X41 with HP LaserJet 600 M601

;; printing with ghostscript
(setenv "GS_LIB" "C:/Program Files/gs/gs9.05/lib;")
(setq ps-printer-name t)
(setq ps-lpr-command "C:/Program Files/gs/gs9.05/bin/gswin32c.exe")
(setq ps-lpr-switches '("-q" "-dNOPAUSE" "-dBATCH" "-sDEVICE=mswinpr2"))

Print with command M-x ps-print-buffer-* will evoke default print dialogue.  However, C-u M-x
ps-print-buffer-* will prompt a save as dialogue. 
  • How to restore USB key with fdisk

  • A. First we need to delete the old partitions that remain on the USB key.
    Open a terminal and type sudo su
    fdisk -l and note your USB drive letter.
    fdisk /dev/sdx (replacing x with your drive letter)
    d to proceed to delete a partition
    1 to select the 1st partition and press enter
    d to proceed to delete another partition (fdisk should automatically select the second partition)

    B. Next we need to create the new partition.
    n to make a new partition
    p to make this partition primary and press enter
    1 to make this the first partition and then press enter

    enter to accept the default first cylinder
    enter again to accept the default last cylinder
    w to write the new partition information to the USB key
    umount /dev/sdx1 (replacing x with your drive letter)

    C. The last step is to create the fat filesystem. (optional)
    mkfs.vfat -F 32 /dev/sdx1 (replacing x with your USB key drive letter)
  • Unicode Characters in Gnus reading
Install fonts-symbola from debian testing repo, then add the following line to gnus-settings.el

(set-fontset-font t 'unicode "Symbola" nil 'prepend)
  • Convert .mp4 to .mpg for a DVD file
ffmpeg -i input.mp4 -target ntsc-dvd -aspect 16:9 -ac 2 output.mpg