VM 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.
Category: QA
Questions and answers.
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
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
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/
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 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
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 hard reset an Amazon Kindle
Posted onHow to hard reset an Amazon Kindle 5? First, press and hold the power button for 30 seconds. Second, release the power button and wait for the kindle to restart. After a while, the progress bar appear and kindle is rebooting.
How to convert a latex file to a single page html
Posted onHow to convert a latex file to a single page html? htlatex is a good choice. On Fedora, install it by yum install texlive-tex4ht. To generate the HTML page from a latex file doc.tex: htlatex doc You can use the latex2html (can be installed on Fedora by yum install latex2html). $ latex2html -split +0 -info
Read more
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
How to use ibus for inputting Chinese in Cinnamon on Fedora
Posted onHow to use ibus for inputting Chinese in Cinnamon on Fedora 19? By default, ibus is not started. If I manually start it by run $ ibus-daemon The ibus daemon is started and an icon appears in the tray area. However, no Chinese is inputted to the programs even it is turned on in the
Read more
How to convert seconds since the epoch to a date in Linux?
Posted onHow to convert seconds since the epoch (1970-01-01 UTC) to a date in Linux? For example, Convert the time stamp 1349361711.169942 to Thu Oct 4 22:41:51 HKT 2012 You can use the date command on Linux to convert the time formats. For converting the time stamp 1349361711.169942 to the normal data format: $ date -d
Read more
How to replace gdm with lightdm on Fedora
Posted onCinnamon does not work well with gdm. And there is no meaning to use gdm when using Cinnamon. On Fedora, the default one id gdm. How to replace gdm with lightdm on Fedora? First, install lightdm if it is not installed yet: # yum install lightdm lightdm-gtk Then, disable gdm service and make the lightdm
Read more
GUI tool to crop PDF file margins on Linux
Posted onAny GUI tools to crop PDF file margins on Linux? I use krop: http://arminstraub.com/computer/krop krop is a simple graphical tool to crop the pages of PDF files. To install krop on Fedora: # yum install krop
How to tell whether the shell is run in screen
Posted onHow to tell whether the shell is run in screen? For example, I run screen and it starts a bash environment. How to tell in the bash, whether it is run by screen or it is a normal bash environment? It can be identified by checking the TERM environment variable: In a bash in screen:
Read more
How to install Cinnamon on Fedora
Posted onHow to install the Cinnamon desktop environment on Fedora 19? On Fedora 19: # yum groupinstall ‘Cinnamon Desktop’ to install the packages needed for the Cinnamon desktop environment. Then, in the login screen, select ‘Cinnamon’ in the “Session” menu and you will start the Cinnamon desktop environment.
HTML form generation from the database and store value into the database
Posted onI have a “t_form” table and a “t_attribute” table. It looks a little bit like below. Form table form_id | form_name | description ———————————– 1 | Laptop | Possible attributes are Model, Screen Size, OS, Cd Player 2 | Mobile | Possible attributes are Model, OS 3 | Tablet | Possible attributes are Model, Screen
Read more
How to count the number of page view
Posted onI have seen the question Better way to count total page views? I think, the better way is.. We can save the number of page views in the database. It is acceptable. But, it is not fulfilling my requirement, if many different users can appear to have the same IP Address (e.g, if they are
Read more
How to set the geometry for Gnome 3 under a VNC Server
Posted onWith Gnome 3, I try to start a vncserver with $ vncserver -geometry 1024×768 to start a vnc server with geometry 1024×768, which works well with Gnome 2 before. This also works for twm. However, after I connect to the vnc server, the resolution is not 1024×768. I change the geometry to other resolution and
Read more