dd seems slow when I use command like # dd if=/dev/sda2 of=./sda2.bak How to make it faster? You can make dd faster by specifying a good bs like # dd if=/dev/sda2 of=./sda2.bak bs=8192 8192 is a magic number. There are may be other good sizes for bs for different systems. But 8192 works pretty well
Read more
Author: Q A
How to un-trust a computer that I have trusted with iOS 7 device?
Posted onHow to un-trust a computer that I have trusted with iOS 7 device, such as iPhone? You can delete the Lockdown folder to reset the trust/un-trust status of iPhones. Apple provides tutorials for Max OS X and Windows at: http://support.apple.com/kb/TS5335 (archived) . If you are using Linux, the Lockdown folder is: /var/lib/lockdown Answered by Lucy.
How to get the git commit tree?
Posted onHow to get a tree-like view of the git commit history? My favorite command line: git log –graph –oneline It will prints a text based graph like (with colors): * b5dc8b9 Merge branch ‘master’ of https://github.com/layerzero/libi0 | | * 7514ef1 revised the README.md a little bit | * 6692428 align size to page for both
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 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
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.
Import Evolution mail directory to Thunderbird/imap account
Posted onI have some old emails left in the Evolution local directory (unfortunately not in the mail server’s imap directory). So how to import the Evolution directory which contains some files for the emails to Thunderbird so that I can copy them to the imap directory if needed? You can do this in two steps: First,
Read more
utop key bindings / key shortcuts
Posted onutop is an improved toplevel for OCaml supporting line edition, history, real-time and context sensitive completion, colors and etc. utop is convenient to use. However, the key bindings are a little bit different from the ones with GNU readline. What are all the key bindings? The #utop_bindings command will print all the key bindings. Here
Read more
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’
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
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
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
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
Auto indenting for OCaml code in Vim
Posted onHow to set up auto indenting for OCaml code in Vim? The built-in indenting in Vim for OCaml seems not very good. Please check the post at https://www.systutorials.com/5212/auto-indenting-for-ocaml-code-in-vim-with-ocp-indent/
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 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 padding a integer with 0s in bash?
Posted onHow to convert an integer into a string of many characters padded with 0s in bash. To do this in C: sprintf(buffer, “%08d”, n); which convert integer n to a 8-character string padded with leading 0s. How to padding a integer with 0s in bash? In bash, you can also use printf For the previous
Read more