Archive for January, 2010

Run Stata 10/11 with GUI under Ubuntu

January 24, 2010 19 comments

Stata 10/11 are available for Linux, which is great but… after installing Stata (dynamically linked) under Ubuntu, starting the GUI version (xstata) usually results in an error message because one or more libraries apparently cannot be found.

By adding the corresponding symbolic links

sudo ln -s /usr/lib/libgtk2.0-0 /usr/lib/libgtk-1.2.0

sudo ln -s /usr/lib/ /usr/lib/

sudo ln -s /usr/lib/ /usr/lib/

Stata can be tricked into using the newer version instead of the old version it is expecting.

As Julian pointed out below, Stata 11 may close unexpectedly when starting the .do file editor. If that happens (I reproduced that bug on a fresh Karmic install), installing libgtksourceview 1.0 may fix the problem:

sudo apt-get install libgtksourceview1.0-0

Natty Narwhal update: After upgrading to 11.04, I got an error message (“error while loading shared libraries: cannot open shared object file: No such file or directory.”) when trying to run Stata. I fixed it by creating another symbolic link:

sudo ln -s /usr/lib/i386-linux-gnu/ /usr/lib/

Oneiric Ocelot update: Thanks to Charles Opondo for pointing out that libgtksourceview1.0 is not in the Oneiric repos.
You can either 1) download and install libgtksourceview from the Natty repos or 2) re-install the statically linked version of Stata.

– Option 1 –
cd ~/Desktop
sudo dpkg --install libgtksourceview-common_1.8.5-2build1_all.deb
sudo dpkg --install libgtksourceview1.0-0_1.8.5-2build1_i386.deb
rm libgtksourceview*.deb

– Option 2 –
Delete your Stata installation in the /usr/local/stata folder and re-install it from the disk. During the installation, Stata asks whether you want to install the 32-/64-bit dynamically/statically linked version. Choose statically linked.

Whichever way you choose, please update Stata 11 after installing it before doing any analyses. There is a serious bug in the original CD version that can completely muck up your results. You have to run Stata as a superuser to do that

sudo /usr/local/stata/xstata

Replace xstata with xstata-se if you are using Stata/SE.
Then, in Stata, type update all and when prompted update swap. When you are done, restart Stata as a normal user. It should now say “Stata 11.2” in the title bar.

Categories: Hacks, Science

File sharing with Python from the command line

January 24, 2010 Leave a comment

Can’t remember where I found this nifty little trick. Running

python -m SimpleHTTPServer 1234

at the command line starts an HTTP server in the current working directory. Other people on the same network can then access the files in this directory by pointing their browser to

1234 is just an arbitrary port number. You may choose (almost) any other port number you like.

Categories: Networking

Turn off the annoying system beep

January 24, 2010 Leave a comment

Sitting in the library or classroom with your laptop and the annoying system beep is causing all heads to turn and people give you dirty looks? Simply unload the pcspkr kernel module:

sudo modprobe -r pcspkr

If you want to remove it for good, add the line

blacklist pcspkr

to /etc/modprobe.d/blacklist.

Categories: Hacks, Sound

Simple backup from the command line

January 24, 2010 Leave a comment

I must say I don’t have much faith in Ubuntu’s sbackup program. Sure, it’s convenient and it’s got a GUI and automatically creates compressed incrementals backup in the background for you. But who knows if I’ll ever be able to actually restore my data from these compressed files? I prefer something where I can actually see what has been backed up, even if it’s a little less convenient.

For my backups, I use this command (that can be used in a cron job) that simply incrementally copies files onto a second hard drive:

cp -dpRuvx /home/yourfolder /media/data/backup 2> ~/Desktop/backup_errors.log

As a safeguard, all error output is redirected into a log file on my desktop. The drawback of this method is that files that you deleted on your source drive remain in the backup. That means that you have to do a clean backup every once in a while otherwise you’ll run out of space on your backup drive.

Categories: Utilities

Merging PDF files from the command line

January 24, 2010 Leave a comment

To merge the pdf files infile1.pdf, infile2.pdf, and infile3.pdf, and output the result into a new file outfile.pdf in the same directory, do:

gs -q -sPAPERSIZE=letter -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile=outfile.pdf infile1.pdf infile2.pdf infile3.pdf

Note: Requires the ghostscript package.

Categories: Graphics, Utilities