Kindle is good for reading. However, the A4-size technical/academic paper is pain to read on Kindle 5—the fonts are too small. The “email to Kindl” converting tool provided by Amazon usually loses the formats in the technical paper. How to convert A4 paper format to read on Kindle 5? I use k2pdfopt tool (hey, source
Read more
Tag: Linux
How to make eps files using gnuplot
Posted onHow to make gnuplot generate eps files instead of plot the figures on screen? First, save a Gnuplot plot as a PostScript file by this commands: # gnuplot> load ‘saveplot’ # gnuplot> !mv my-plot.ps another-file.ps The saveplot file’s content: set size 1.0, 0.6 set terminal postscript portrait enhanced mono dashed lw 1 “Helvetica” 14 set
Read more
How to convert a .docx .doc MS Word file to pdf in command line on Linux
Posted onHow to convert a MS Word document file such as .docx and .doc to pdf on Linux using command line tools? Use LibreOffice: libreoffice –headless –convert-to pdf –outdir /path/to/out/dir/ /path/to/doc/docx/file While this LibreOffice answer works, the –headless option still needs as display, even though it does not use it. In otherwords, this option won’t work
Read more
Rsync with non-standard ssh ports
Posted onThis problem appears when I try to rsync directories with hosts inside a cluster used NAT for forwarding ports to internal nodes. Hence, the ssh port for internal nodes are not the default 22. So, how to use rsync with the non-standard ssh ports? The -e options of rsync play the trick very well. For
Read more
How to change the window title font family and size in Gnome 3?
Posted onIt was ever possible to set it in gnome-teak-tool. However, in the latest Gnome 3, it disappears. Is there any other way to set it? The configuration is the org.gnome.desktop.wm.preferences titlebar-font under dconf. You can use dconf-editor to find the appropriate key entry and set it. Or use gsettings: $ gsettings set org.gnome.desktop.wm.preferences titlebar-font ‘Sans
Read more
How to revert only one file back to a revision or commit
Posted onI messed up with one file in one repository and want to check out only that file back to a commit. How to achieve this? To check the file with my_file.name at git commit commit_sha1: $ git checkout commit_sha1 my_file.name You can also use the relative commit instead of commit_sha1 such as master~4, HEAD~4, HEAD^,
Read more
How to use different keys for different git servers?
Posted onI have access to different git servers. I have several keys for these servers. How to use different keys for different git servers? Use the .ssh/config file to specify different configuration for different SSH servers used by git: For example: Host git.example.org Port 22111 IdentityFile ~/.ssh/id_rsa.git.example.org Host code.example.org Port 22 IdentityFile ~/.ssh/id_rsa.code.example.org which specifies the
Read more
How to use LVM groups with libvirt
Posted onlibvirt uses files for VM images by default under /var/lib/libvirt/images/. LVM is a convenient tool for managing VM images. How to use LVM groups with libvirt? This post discusses the method to add LVM groups as a storage pool for libvirt: http://ailoo.net/2011/02/use-a-lvm-volume-group-with-libvirt/ For a general introduction of the storage management in libvirt, please check: http://libvirt.org/storage.html
How to find out which function causes Exception “Stack_overflow” in OCaml
Posted onMy OCaml program prints: Fetal error: Exception “Stack_overflow” without any further information. How to find out which function causes this “Stack_overflow” exception? First, recompile your OCaml program with -g. Second, rerun your OCaml program with OCAMLRUNPARAM=b and the backtrace will be printed out after the “Stack_overflow” exception.
How to install sbt for scala on Fedora Linux
Posted onHow to install sbt for scala on Fedora Linux? It is not included in the default Fedora repository although scala is included. The download page of scala-sbt.org provides the RPM package. You can install the sbt rpm package by yum. We only need the URL to the RPM package. Here, let take version 0.13.1 as
Read more
Linux timer sources
Posted onLinux supports different timer sources and a machine can have multiple ones. How to find the available Linux timer source and the current one used? Find the current timer source: $ cat /sys/devices/system/clocksource/clocksource0/current_clocksource Find all available timer sources: $ cat /sys/devices/system/clocksource/clocksource0/available_clocksource
Remove trailing spaces at the end of each line in a file
Posted onHow to remove trailing spaces at the end of each line in a file on Linux? Use this script with sed: cat your_file | sed ‘s/[[:blank:]]+$//g’
Xen HVM DomU configuration file
Posted onAn example of Xen HVM DomU configuration file. An example for install the OS from an ISO: name=”10.0.1.235″ vcpus=2 memory=2048 shadow_memory=8 disk=[‘file:/lhome/xen/vm-10.0.1.235/vmdisk0,xvda,w’, ‘file:/lhome/Linux-x86_64-DVD.iso,xvdc:cdrom,r’] vif=[‘bridge=xenbr0′] kernel=’/usr/lib/xen/boot/hvmloader’ builder=’hvm’ device_model=’/usr/lib64/xen/bin/qemu-dm’ extra=” vnc=1 vnclisten=”0.0.0.0″ vncpasswd=’1234567′ # vncdisplay=1 vncconsole=1 on_reboot=’restart’ on_crash=’restart’ An example for run the VM after installation: name=”10.0.1.235″ vcpus=2 memory=2048 shadow_memory=8 disk=[‘file:/lhome/xen/vm-10.0.1.235/vmdisk0,xvda,w’] vif=[‘bridge=xenbr0′] kernel=’/usr/lib/xen/boot/hvmloader’ builder=’hvm’ device_model=’/usr/lib64/xen/bin/qemu-dm’ extra=” vnc=1
Read more
Quick method to sniff the data left on a Linux VM in the public cloud
Posted onVM disks in public cloud may be shared by customers. This is privacy problem. Is there a quick method to sniff the data left on a Linux VM? One possible method: # dd if=/dev/xvda bs=1M | strings -n 100 > strings.txt Using the dd and strings which are pervasive on Linux systems.
How to delete a disk from a LVM group while keeping the data
Posted onThis is the scenario: I want to remove a old hard disk which is a LVM PV and contains data. There is free space available on other PVs in the VG. It should move the data from the disk to be removed to other PVs and then remove the disk. The process to remove sdb
Read more
top-like tools on Linux for network
Posted onHow to display the network usage by processes like top for CPU/mem on Linux? The nethogs tool is my favorite: nethogs – Net top tool grouping bandwidth per process
How to attach and mount Xen DomU’s disk to Dom0
Posted onHow to attach and mount Xen DomU’s disk to Dom0 To attach phy:vg_xen/vm-10.1.1.228 to xvda on Domain-0: # xm block-attach Domain-0 phy:vg_xen/vm-10.1.1.228 xvda w Mount the new partition /dev/xvda2 to /mnt/xvda2: # mount /dev/xvda2 /mnt/xvda2 After finishing using the partition, umount it and detach it: # umount /mnt/xvda2/ # xm block-detach Domain-0 xvda
How to find the disk space left for a file on Linux
Posted onHow to find the disk space left for a file on Linux? For example, a program may append data to a file: /mnt/logs/app-log.log How to find which partition the app-log.log is on and how much disk space left on that partition? Use this command: $ df -B1 /mnt/logs/app-log.log | tail -1 | cut -d’ ‘
Read more
How to get the output of a system command in C
Posted onHow to get the output of a system command in C? The system function is handy. But how to get the output? popen is a useful function for this purpose: https://www.systutorials.com/docs/linux/man/3p-popen/ You can use normal file operation functions like fgets to read file content from the file opened by popen.
How to convert HTML file to text on Linux
Posted onHow to convert HTML file to a text on Linux? You can use html2text (can be installed on Fedora by yum install html2text): $ html2text ${html_file} ${html_file} is the html file to be converted. The converted text will be printed to the STDOUT. You can redirect it to a file if it is needed. Adding
Read more