Why I use Linux

This is a re-post of a blog post I wrote for my department blog couple years ago. I just read it again and I found it still relevant.
For those of you who have been to my office or have taken my classes will know that I am a big Linux fan. I started to use a little bit of Linux since early 2000. But I was “converted” completely around 2007 or 2008. Since then, Linux is my main OS. But first things first, I want to emphasize that I am not an MS hater. I used most of the MS OSes before, from MSDOS, Win3.x, Win95, Win98, WinME (yes,it is a horrible one), Win2000, WinXP, Vista, and Win 7. (Sorry, Win 8. I don’t see that I may own any more new Windows device soon in the future. And Mac, yeah, I know you are cool. But everything I need is offered by Linux already. I am not sure I want to pay the premium for you.)
Even though I only started using Linux as the main OS of my computers for the last several years, I have been exposed to the Unix-like system quite a bit earlier. Back in the days of early 90’s (yeah, I am old, at least quite a bit older than many of you reading this) when I was an undergrad student, workstations were popular and we had to telnet to some mainframe computers to do programming assignments. And interestingly, the Unix commands I learned then are almost identical to the Linux commands I use now.
I guess you see why I am writing all this… because while I see some of you are Linux experts, it just came to me that many of the students I met here have little exposure of Unix-like systems. Of course, I myself am more or less a user only rather than a realexpert. But I think that some experience to Unixlike system is essential to any electrical/computer/tel ecom engineers. I can think of many reasons for that. Just name a few,
1). Linux is ubiquitous. It is used by different devices, from very small embedded systems, to enormous mainframes and super computers.
2). Linux is free. And so do many tools on its platform aswell. Need to typeset your paper? Use Latex/Kile. Need to edit your photo? Use GIMP. Need to dosome math? Use Octave. Of course, some of this software is available on Windows as well. But it is often way easier to install them on Linux than Windows because most of them were developed on theformer natively.
3). Linux is reallyfree. Not to mention that the commonly used application software is free on Linux. Some very sophisticate or specialized software is free there also. Just name a few, ns-2/3 for network simulation, zoneminder for security system, and musescore for music composition and notation. And you can even setup a professional (and completely free) web server at home with Linux in an hour or so.
4). Your future boss wants you to know it. Because of the above, there is a good chance that your future bosses would like someone to at least familiar withthe OS. So being acquaint with Linux will allow you to access to many more possible positions in the job market.
If the above reason is not sufficient for you to start playing with Linux, here is another one: using Linux/Unix-like system makes one more productive. Okay. It sounds a bit subjective and I am not sure if anyone does any statistical study for that. But there are indeed quite a few productivity features that Unix-like system has offered for decades while one is still waiting for MS to catch up. The most noticeable one is virtual desktop. I just can’t understand whyMS still doesn’t implement that one. Another very useful productive feature is packaging systemsfor software installation. Okay, MS finally got this one eventually and we have “apps for windows”… But when I say Linux can make one more productive. The first thing came to my mind are not the above. What is more important to me is that Linux comes with lots of useful built-in command line tools. Yes. I mean old fashion command line tools. I know everyone likes GUI and command line stuffs seem scary and difficult to use. But GUI tools tend to become obsolete much faster than command line tools. As I mentioned earlier, I am still using the commands such as sed/grep/cut/find/tr that I learned 20 years ago. And those commands were introduced like 40 years ago. So your time learning those things won’t be wasted soon in the future. In contrast, every Office version looks a bit different and it takes time to adapt a new one!
To be fair, Windows provide some batch commands also. But they are less powerful and more importantly, far less portable outside the windows world.In contrast, you can run those Linux commands with little modification on a Mac right away. Besides, one can use these tools on Windows too if they really want to. For example, by installing a Linux layer, such as Cygwin, on top of windows. But honestly, it just makes life complicated.
Actually, not just command line tools are available on Linux, everything needs to be done can be done with them alone. By design, GUI tools on Linux are really just wrappers for these “primitive” commands. Therefore, one can always fall back to these commands and get things done especially when resources are really limited. For example, at this right moment, I am connecting to my office desktop using ssh even though I am in a time zone 13 hours away from Tulsa. If I had a windows box, the remote connection would definitely be unusable as the GUI stuffs would have sucked up so much resources that the poor connection here just couldn’t afford it.
 1  Okay, Cygwin may seem like a godsend for Windows veteranswho want to start playing with Linux. But frankly, I would not recommend Cygwin to anyone Linux newbies. Cygwin is far less user friendly than modern Linux distros like Ubuntu. One canencounter way more problems installing and running any software on Cygwin than on distro like Ubuntu.
For those who are still not convinced, let me illustrate the power of Linux with an example task that I do occasionally. From time to time, my collaborator generates many figures in eps format but we actually need them in pdf format instead. And often we have the files scattered in several subfolders (say, under the current folder) and I have to convert all the files. Imagine that if someone were using Windows, first he or she would need to figure out how to convert eps file to pdf format as there is no built-in tools for that. Maybe someone eventually found some software (most likely not free) but then he would still need to find a way to convert all of them efficiently. If he was very lucky, maybe there was a batch conversion function offered by the software. But at many times, he would have ended up wasting an hour more converting the files one by one manually even after paying like $20 for the software.
On a contrary, if you use Linux and are knowledgeable with some Linux commands, you are really lucky in such situation. All the hassle can be done ina single line:
find . -name “*.eps” -print | sed ‘s/\(.*\)\.eps/ps2pdf “\1.eps”“\1.pdf/”’ | sh
The command seems complicated but is actually very easy to understand. It is really just a cascade of three commands linked by the pipe character “|”. The firstcommand, find . -name “*.eps” -print, simply search for all eps files under the current folder including all the subfolders. The second command, sed ‘s/\(.*\)\.eps/ps2pdf “\1.eps” “\1.pdf/”’, tries to replace each eps file, say with a name ‘XXX.eps’, by a command string ‘ps2pdf “XXX.eps” “XXX.pdf” ‘. And the third command, sh, simply executes the command string created in the previous step.
Okay, this definitely is getting too long and I probably should stop here. And this finishes my advice (rant) of why all engineering students should know (and use) Linux. Actually, I also believe all graduate engineering students should use Latex (instead of Words) for their papers. But maybe I will write about it some other time.

February 4, 2017 at 6:50 pm Leave a comment

Playing StarCraft on Ubuntu 14.04 and X230

I recently got a used X230 tablet and tried to have some fun on it. StarCraft runs well with wine but cannot run on full screen. One possible solution is to open another X server following this post. But I need some tweaks for 14.04 and for touch and stylus to work.

First, one needs to add

Section "ServerLayout"
    Identifier     "SCLayout"
    Screen      0  "StarCraft Screen"
    InputDevice    "Keyboard0" "CoreKeyboard"
    InputDevice    "Mouse0" "CorePointer"

Section "Screen"
	Identifier     "StarCraft Screen"
	Device         "Device0"
    Monitor        "StarCraft Monitor"
    DefaultDepth    24
    SubSection     "Display"
        Virtual     640 480
        Depth       24
        Modes      "640x480@60" "1280x800@50"

Section "Monitor"
    Identifier     "StarCraft Monitor"
    VendorName     "Plug 'n' Play"
    ModelName      "Plug 'n' Play"
    Gamma           1
    ModeLine       "640x480@60" 25.2 640 656 752 800 480 490 492 525  -hsync -vsync

to /etc/X11/xorg.conf. However, xorg.conf is no longer there by default. One can generate one following this.

One would also need to modify the line


in /etc/X11/Xwrapper.config to


For audio to work, one need to add current user to the audio group. Run

sudo usermod -a -G audio $USER

Some posts mentioned that one needs to reboot. But I am not certain it is a must.

Finally, create the following script and run it.

X :1 -layout SCLayout -ac &
sleep 2
xbindkeys --display :1 -f $HOME/.scbind
#pax11publish -D :1 -e
DISPLAY=:1 xsetwacom --set 10 area "3454 -41 24103 15420"
DISPLAY=:1 xsetwacom --set 11 area "348 0 2432 1569"
DISPLAY=:1 xsetwacom --set 15 area "3454 -41 24103 15420"
DISPLAY=:1 xsetwacom --set 10 TabletPCButton "off"
DISPLAY=:1 wine $HOME/tmp/StarCraft/StarCraft.exe -- /usr/bin/X :1 -layout SCLayout 
sleep 1
kill $XPID

I assume StarCraft folder is under $HOME/tmp. Modify it accordingly.

The xsetwacom lines attempt to “calibrate” the touch screen and stylus accordingly. These numbers should work well for X230. For other tablet, You may obtain this number by first changing the resolution to 800×600. Then run “Wacom Tablet”->”Calibrate…” and extract the number by typing

xsetwacom --get 10 area

Note that device “11” is the “finger touch” and ubuntu’s calibration function will only work for the stylus. But one can get the number easily by scaling the number obtained above. For example, dividing each number for devices 10 and 15 by 10 probably will work well for 11 (finger touch). But I didn’t try any other tablet pc other than X230.

June 5, 2016 at 9:25 am Leave a comment

Protected: Some thoughts on proposal writing

This content is password protected. To view it please enter your password below:

September 23, 2014 at 5:08 am Enter your password to view comments.

Goagent experience

I am in Shanghai a couple days and it is quite inconvenient with many websites blocked. I heard about “breaking” the wall but I didn’t realize it is quite fast and easy. All one needs is a software called goagent. It takes advantage of the google app engine. Here, I will assume that ones already have created a google app engine application before. If not, it is easy to do and there are many guides for that.

I am using it on my linux box LTS 12.04. The goagent team has created a very good guide on its site. I have encountered few problems following it. It appears that one can’t install gevent automatically for 12.04 and have to use the manual route. And I didn’t try to start the proxy automatically. I just run it in a terminal using

python proxy.py

instead. In any case, I will only be here for a couple days. I don’t really see any inconvenience running it from terminal rather than having it to start up automatically.

In terms of browser setup, I use chromium (chrome should work too) and SwitchySharp. One would want to look for an option file SwitchyOptions.bak and import it directly to SwitchySharp. It can be easily found with a search.

The only issue I had is that it didn’t load facebook and youtube correctly. It appeared that it was due to some certification problems. But it can be fixed easily following this post.

February 24, 2014 at 7:44 am Leave a comment

M/M/1 Simulation with Matlab

A simple simulation of M/M/1 queue with Matlab. The distribution of the number of “packets” in the system is computed and compared with the theoretical result.

delta=0.1; % simulation step in sec
lambda=0.1; % arrival rate in packets per second
mu=0.2; % departure rate in packets per second
M=50*3600/delta; % number of simulation step for 50 hours
a=zeros(M,1); % arrival log
d=zeros(M,1); % departure log
n=zeros(M,1); % number of packets at each simulation time step
n_cur=0; % current number of packets in the system
for i=1:M
 n_cur; % # packets before the process
 n(i)=n_cur; % record the # of packet before the process
 if rand < lambda*delta % probability of an arrival occurred = lambda * delta
 if rand < mu*delta && n_cur > 0 % probability of departure occurred = mu * delta provided that there is a packet in the system
 if mod(i,1000)==0 % show progress for every 1000 simulation steps
plot(nlist, (1-rho)*rho.^(nlist),'r-+');
title('Distribution of number of packets in the system');


Now, let say if we want to find the delay distribution for the packet arrived when there are 2 packets in the system.

ainds=find(a==1); % the indices when we have an arrival
atimes=ainds*delta; % arrival times in seconds
dtimes=find(d==1)*delta; % departure times in second
delays=dtimes-atimes(1:length(dtimes)); % list of delays in second 
inds=find(n(ainds)==2); % find indices of packets arrived when # packets in system is 2
title('Delay distribution for packets arrived when # packets in system is 2');
xlabel('Time in second');


February 13, 2014 at 11:43 pm 3 comments

Simulating Poisson process in Matlab

Below is a simple Matlab code to simulate a Poisson process. The interarrival times were computed and recorded in int_times. The times are then grouped into bins of 10 seconds in width and the counts are stored in count.

lambda=1/60; % arrival rate per second (1 minute per packet)
T=10*3600; % simulation time in second (10 hours)
delta=0.1; % simulation step size in second
N=T/delta; % number of simulation steps
event=zeros(N,1); % array recording at each step if a "packet" arrived. 
 % initialize it to zeros
R=rand(size(event)); % generate a random array (with elements in [0,1]) of the same size as "event"
event(R<lambda*delta)=1; % set each element of event to 1 with probability lambda*delta
inds=find(event==1); % getting indices of arrivial
int_times=diff(inds)*delta; % interarrival times in seconds
edges=0:10:400; % define histogram bin

The histogram of the absolute counts of the interarrivial is then plotted with the commands below.

figure; bar(edges,count,'histc'); % draw histogram of absolute count


Finally, the counts are normalized and compared with the theoretical result (\lambda \exp(-\lambda T)).

figure; bar(edges,count/sum(count)/(edges(2)-edges(1)),'histc'); % draw histogram of normalized counts
hold;plot(edges,lambda*exp(-lambda*edges),'r'); % plot theoretical result


February 6, 2014 at 10:34 pm 1 comment

ibus jyutping

As a cantonese from HK, I didn’t know how to “type from my mouth” as a kid. I learned Cangjie during high school but I have never become really proficient with it. Chinese is not exactly a phonetic language. But when I write IM, email, or just blog in Chinese. I found it much better to type phonetically as I don’t need to switch my thought to letter ideograph. When I write to mandarin friends, pinyin is great. However, when I chat to friends back home in HK, my message will have “accent” when I try to type in pinyin since I try to “speak” my thought in mandarin when I type.

I finally ended up to have the will to learn jyutping last year. One of the romanization system for Cantonese. I won’t say it is a perfect system (I know it is a standard for linguist but I still found it quite weird to use j for y). Both android and windows have decent input method for jyutping. As for Ubuntu…, there is a jyutping for ibus. But saying it to be horrible is actually a compliment. It is essentially unusable as many common words are missing. And the table is sorted in an absolutely ridiculous way with the top of the table starting with words that no native speakers will ever use.

Fortunately, ibus-table does come with a function to allow users create their own tables. After getting character frequency from Chih-Hao Tsai’s site and jyutping phonetic from HanConv, at least I can build a usable table for myself. There is still lots of tweakings to do though as HanConv does not cover the sounds for all the characters from Chih-Hao Tsai. And some of the pronunciations seem incorrect or at least uncommon. I guess I will make another post to share the final table when it becomes more mature.

October 20, 2013 at 1:51 am Leave a comment

Older Posts