How to make fdisk -l display partition sizes by bytes instead of sectors? fdisk does not have such options as far as I know. However, good news is that you can use parted: # parted -l It will print partition info like # parted -l Model: Linux device-mapper (linear) (dm) Disk /dev/mapper/fedora_vm235-swap: 2164MB Sector size
Read more
Author: Eric Ma
Eric is a systems guy. Eric is interested in building high-performance and scalable distributed systems and related technologies. The views or opinions expressed here are solely Eric's own and do not necessarily represent those of any third parties.Which are sequence points in C?
Posted onWhat are sequence points in C? The comp.lang.c FAQ explains this quite well. A sequence point is a point in time at which the dust has settled and all side effects which have been seen so far are guaranteed to be complete. The sequence points listed in the C standard are: at the end of
Read more
How to disable auto mounting on Linux Mint Cinnamon?
Posted onI prefer Linux Mint (I am using Cinnamon) not automatically mounting a portable storage such as USB disk or iPhone for me and I would like do the mounting manually if I need it. The default behavior of Linux Mint is to automatically mount the disks. How to disable this? The auto mounting on Linux
Read more
How to change the commit message of a commit in the history (not HEAD)?
Posted onA commit is not the HEAD now. and git commit –amend will not work for it. How to change its commit message? You can use git rebase together with git commit –amend as follows. Assume your commit to be edited is 2b8ed. $ git rebase -i 2b8ed^ Change the pick to edit in the line
Read more
How to dynamically attach a disk to running DomU in Xen?
Posted onI want to attach a disk to a DomU. The Xen DomU is running and should not be rebooted. Hence, changing its configuration file is not an option. How to dynamically attach a disk to running DomU in Xen? To attach phy:vg_xen/vm-228-large to vm-228 as xvdb, run this on Dom0: # xl block-attach vm-228 phy:vg_xen/vm-228-large
Read more
What is database schema?
Posted onAs is known, database schema is a collection of database rules like data type and data relationship. However, this is still a little abstract. So what is database schema in one sentence everyone could understand it clearly. The wikipedia page on Database schema is quite good for understanding the concept. A database schema of a
Read more
How to remove AdSense ads for mobile devices while keep them for desktops?
Posted onI want to add adsense ads to be shown to visitors on desktop only. How to remove AdSense ads for mobile devices? You can achieve this through using “Responsive ad unit” of AdSense. The support article Create a responsive ad unit from AdSense discusses this and gives an example. Check the “Hiding an ad unit”
Read more
How to make taglist recognize specific files with certain extensions as C source files?
Posted onHow to make taglist recognize specific files with certain extensions as C source files? You may try adding this line to your ~/.vimrc: autocmd BufRead,BufNewFile *.c0 set filetype=c Reference: https://stackoverflow.com/questions/9013263/vim-tagslist-plugin-not-detecting-custom-language-racket
How to make ctags recognize specific files with certain extensions as C source files?
Posted onHow to make ctags recognize specific files with certain extensions such as .c0 or .puc as C source files? You may add this line to your ~/.ctags: –langmap=c:+.c0,c:+.puc
How to kick off a user on a Linux box?
Posted onI want to kick off a user such as “bob” on a Linux box which I managed remotely. How to do this? bob may log on the Linux box by various ways: Log on the screen on the Linux box (locally) with a X server. Log on remotely by a ssh shell. Log on by
Read more
Simple and Basic Image Editor in Linux
Posted onWhich simple and basic image editors are good on Linux like the paint program on Windows? GIMP is great but too high weighted for normal usage like resizing, cropping, image annotation with text. Pinta is a free and open source drawing/editing program that is easy to edit images. It is available on many Linux distros.
Read more
How to force iPhone to reboot/restart/reset?
Posted onHow can I force iPhone to reboot/restart/reset when it locks up completely and does not response? To force an iPhone to restart: Press and hold the iPhone’s power key and home button together. Holding the two keys for around 10~15 seconds until the screen is turned off. Release the buttons once the screen lights up
Read more
How to resize a batch of images on Linux?
Posted onResizing images on Linux with gThumb is easy. However, I have a batch of images inside a folder. Manually resizing them will consume too much time. How to automatically resize them on Linux with a script? You can use convert from ImageMagick together with bash script to resize images inside a directory. mkdir resize; IFS=$(echo
Read more
How to add a new HDFS NameNode metadata directory to an existing cluster?
Posted onWe have a running HDFS cluster. Currently, the NameNode metadata data directory has only one directory configured in hdfs-site.xml: <property> <name>dfs.namenode.name.dir</name> <value>file:///home/hadoop/hdfs/</value> <description>NameNode directory for namespace and transaction logs storage.</description> </property> We would like to add a new directory for dfs.namenode.name.dir to make replicas of the metadata on a separated disk for higher data reliability.
Read more
How to suppress “Entering/Leaving…” messages when invoking make recursively?
Posted onThe “Entering/Leaving…” messages when invoking another make by a make is kind of annoying. Is it possible to suppress these messages and how to suppress them? For GNU make, it is controlled by options: -w, –print-directory Print a message containing the working directory before and after other processing. This may be useful for tracking down
Read more
How to detect whether an image is almost blank on Linux?
Posted onHow to detect whether a .jpg image is almost blank/black on Linux? Here is a bash function that I used to detect whether an image is black on Linux: function isBlank () { mean=`convert $1 -format “%[mean]” info:` echo “$mean” } It uses ImageMagic to generate formatted image characteristics (the mean). If the mean is
Read more
How to add a “status bar” to screen on Linux?
Posted onI noticed that some guys’ screen console has a status bar with tab numbers. That will be very useful for 1) know you are using screen rather than a normal terminal. 2) which tab you are working in. Below is my ~/.screenrc: hardstatus alwayslastline hardstatus string ‘%{= kG}[ %{G}%H %{g}][%= %{=kw}%?%-Lw%?%{r}(%{W}%n*%f%t%?(%u)%?%{r})%{w}%?%+Lw%?%?%= %{g}][%{B}%Y-%m-%d %{W}%c %{g}]’ It
Read more
Fixing “Remote Host Identification Has Changed” Error When SSH to a Server
Posted onIf you encounter an error message like the one below when attempting to SSH to a server: @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @ WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED! @ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY! Someone could be eavesdropping on you right now (man-in-the-middle attack)! It is also possible that a host key has
Read more
How to merge multiple jpg images to a pdf on Linux?
Posted onI have multiple jpg images as files like 001.jpg, 002.jpg … How to merge multiple jpg images to a pdf on Linux? convert is your good friend: convert *.jpg output.pdf
List Files from a .deb Package in Ubuntu Linux
Posted onHow to list all files from a .deb package like rpm -ql on RPM based systems? Use this command dpkg -L pkg_name -L lists files: -L, –listfiles package-name… List files installed to your system from package-name. More on the dpkg command, check dpkg manual.