linux ubuntu

Ubuntu show desktop on corner hover (mac os x style)

Open gconf-editor



apps → compiz → general→ allscreens → options → show_desktop_edge

If the show_desktop_edge key is not there, create it as string and then add the value BottomLeft and save.


Nautilus Script – print all documents in folder

I had to print a lot of files lately and it became clear that opening each of them, then hitting ctrl + p takes too long, so i decided instead to look for a nautilus script that allows me to right click inside the folder and hit Print All. Since i didn’t find anything (probably didn’t look enough…) i built one myself.

Save the script bellow as “Print All Documents” then place it in ~/.gnome2/nautilus-scripts


## By Romeo - Adrian Cioaba
## [email protected]
## If you modify it, Please let me know.
## released under GPLv3


for eachFile in $filenames
    case $eachFile in
        *.pdf) lpr "$eachFile"
        *.doc) libreoffice -p "$eachFile"
        *.docx) libreoffice -p  "$eachFile"
        *.txt) lpr "$eachFile"
        *.jpg) lpr "$eachFile"

exit 0

Make it executable

chmod +x ~/.gnome2/nautilus-scripts/Print\ All\ Documents

and you are good to go. When you go inside a folder, right click and under the Scripts entry you will have the option “Print All Documents”

This script can be of course tweaked to print more file types.


Fullscreen any window in Gnome

If you are running any distro that has a recent Gnome, chances are that your window manager is either Metacity or Compiz. I’ve found that while working, having my IDE fullscreen helps as that way i can keep away the “noise” and really concentrate on the work i’m doing.

Here’s how to fullscreen any window in Gnome:

1. Metacity
– Run gconf-editor.
– Go to /apps/metacity/window_keybindings.
– Change toggle_fullscreen from disabled to F11.

2. Compiz
– apt-get install compizconfig-settings-manager compiz-fusion-plugins-extra
Then open System -> Preferences -> CompizConfig Settings Mangager. The “Extra WM Actions” plugin should now be available under “Window Management”. Check it and click “Close”.

Restart your X-server by logging out and back in again. The “Toggle fullscreen” keyboard shortcut should now work with whatever you set in the main Gnome keyboard shortcuts settings.


Print a text file to PDF from CLI on Linux

It is nice how modern text editors have that feature to “print” a file to PDF. I wanted to do the same from CLI and after a bit of looking around i’ve found this solution:

sudo apt-get install enscript
enscript lorem.txt -o - | ps2pdf - lorem.pdf

There is also the unoconv, which converts between any document format that OpenOffice understands. It uses OpenOffice’s UNO bindings for non-interactive conversion of documents.
Supported document formats include Open Document Format (.odt), MS Word (.doc), MS Office Open/MS OOXML (.xml), Portable Document Format (.pdf), HTML, XHTML, RTF, Docbook (.xml), and more.


Converts between different document formats that OpenOffice understands
OpenOffice can export to about 100 different document formats
Can be used for batch processing
Combines with asciidoc and docbook2odf/xhtml2odt to create PDF or Word (.doc) files
Can apply custom style templates during conversion (to enforce corporate identity)
Autostarts OpenOffice for processing if necessary
Can be used in a client/server environment to process documents centrally
Can influence OpenOffice filters during import and export
Supports OpenOffice on Linux, Windows and MacOSX


How to: Replace with LibreOffice on Ubuntu

Here are a few easy steps to replace with libreoffice on ubuntu:

CLI instructions (these will take care of removing and installing LibreOffice):

Add the PPA and install LibreOffice:

sudo add-apt-repository ppa:libreoffice/ppa
sudo apt-get update
sudo apt-get install libreoffice 

For GNOME integration (for people running default Ubuntu):

sudo apt-get install libreoffice-gnome

or for KDE Integration (for people running Kubuntu):

sudo apt-get install libreoffice-kde

As of Ubuntu 11.04, LibreOffice will replace by default OpenOffice.

linux ubuntu

Fix gitk ugly fonts in Ubuntu

I’ve recently started playing around with git and found out the power of gitk. Gitk is a small tool built using tcl/tk that helps the user visualize the changes he’s done in a graphical, easy to follow manner. By default Ubuntu 10.10 ships with tk8.4 installed by default and that makes gitk look really ugly, as tk8.4 doesn’t support antialiased fonts. To fix this problem simply install tk8.5 and make it default on your machine:

sudo apt-get install tk8.5
sudo update-alternatives --config wish
# a list will show up and you need to type in the number that corresponds to tk8.5 (in my case was 3) then hit enter.

That’s it. You can now reopen gitk and see the difference.

linux ubuntu

Find string in files and show line number with grep

Handy snippet to find some string inside the files in a directory:

grep -r --line-number "string_you_search" path/where/to/look

Note the -r tells grep also to look into all subfolders recursively.


Setup VPN server and client using OpenVPN

The good thing during the last years is that net access is almost everywhere, and is pretty cheap or even free. A lot of bars, hotels, restaurants offer a free wifi connection, but most of the times that connection is not secured. The biggest security risk with unencrypted connections is the man-in-the-middle type of attack. You are sitting on a bar, checking email, browsing and all your traffic is not encrypted. That means that an attacker can tap into your connection and “listen”, intercept everything you are typing. Like that the attacker can get sensitive data (accounts, passwords, credit card numbers etc.)

Since you don’t have any control over the connection, what one can do to protect himself is to use a VPN. With a VPN, you are creating a secure (encrypted) point-to-point connection between your PC and the VPN server. Translated, that means that all the Internet traffic you are doing, is going through that secure channel, which can’t be hacked that easily.

Here us how to setup a vpn server using openVPN

The server

1. Install openvpn and openssl

sudo apt-get install openvpn libssl-dev openssl

2. Configurations

cd /etc/openvpn/
cp -r /usr/share/doc/openvpn/examples/easy-rsa/2.0/* /etc/openvpn/easy-rsa/

3. Create server certificates

cd /etc/openvpn/easy-rsa/
source vars
./pkitool --initca
./pkitool --server server
cd keys
openvpn --genkey --secret ta.key
cp server.crt server.key ca.crt dh1024.pem ta.key /etc/openvpn/

4. Create client certificates

cd /etc/openvpn/easy-rsa/
source vars
./pkitool hostname

For each new client that connects to the VPN you’ll need to create new client certificates using step 4

5. Create server configuration file:

cp /usr/share/doc/openvpn/examples/sample-config-files/server.conf.gz /etc/openvpn/
gzip -d /etc/openvpn/server.conf.gz

After editing your file should look like this:

dev tun
proto tcp
port 1194

ca ca.crt
cert server.crt
key server.key
dh dh1024.pem

user nobody
group nogroup



push "redirect-gateway def1"
push "dhcp-option DNS"
push "dhcp-option DNS"

6. Enable routing and MASQUERADE for your VPN by placing the following in your /etc/rc.local

echo 1 > /proc/sys/net/ipv4/ip_forward
iptables -t nat -A POSTROUTING -s -o eth0 -j MASQUERADE

7. Start the server

/etc/init.d/openvpn restart

The Client

1. Ubuntu (all modern linux?)
I’m using an Ubuntu machine as a client. To use openvpn in Ubuntu just install the openvpn plugin for NetworkManager:

sudo apt-get install network-manager-openvpn

A reboot is recommended.

You can now go and add your connection in Network Manager

2. Windows – to come
3. Mac OS X – to come

linux ubuntu

CD Emulation in Linux

In Linux, most of the time you don’t need any special tool to mount an image. You can just mount an .iso file using the mount tool:

sudo mount -oloop Image.iso /mnt

Unfortunately if you want to play a game that needs the CD inside the drive, mounting using the mount tool won’t make the CD available for the game (unless it didn’t worked for me). So i looked around and found that CDEmu can do the job. To install on Ubuntu add the repos from ppa:cdemu/ppa them install:

sudo add-apt-repository ppa:cdemu/ppa
sudo apt-get update
sudo apt-get install gcdemu

This will install and applet which you can use with your Gnome panel, and all the other libs that it needs. In order for the applet to work you need to start the cdemud daemon, which depends on the vhba kernel module. To start those run:

sudo modprobe vhba; cdemud &

Now you can mount images using your CDEmu applet 🙂

linux ubuntu

Install Adobe® Flash® Player “Square” on Linux

Adobe® Flash® Player “Square” is a preview release that enables native 64-bit support on Linux, Mac OS, and Windows operating systems, as well as enhanced support for Microsoft Internet Explorer 9 beta.

I’m glad to see Adobe has is finally embracing the way it should the 64 bit Platform. This release is a milestone as far as i know, as is the first one that’s released in the same time for win, mac and linux. I’ve put together a small tutorial on
how to install adobe flash player square on linux:

# Script  created by
# Romeo-Adrian Cioaba [email protected]

echo "Stopping any Firefox that might be running"
sudo killall -9 firefox

echo "Removing any other flash plugin previously installed:"
sudo apt-get remove -y --purge flashplugin-nonfree gnash gnash-common mozilla-plugin-gnash swfdec-mozilla libflashsupport nspluginwrapper
sudo rm -f /usr/lib/mozilla/plugins/*flash*
sudo rm -f ~/.mozilla/plugins/*flash*
sudo rm -f /usr/lib/firefox/plugins/*flash*
sudo rm -f /usr/lib/firefox-addons/plugins/*flash*
sudo rm -rfd /usr/lib/nspluginwrapper

echo "Installing Flash Player Square"
cd ~
# 64 bit
tar zxvf flashplayer_square_p1_64bit_linux_091510.tar.gz
# 32 bit
# wget
# tar zxvf flashplayer_square_p1_32bit_linux_091510.tar.gz
sudo cp /usr/lib/mozilla/plugins/

echo "Linking the libraries so Firefox and apps depending on XULRunner (vuze, liferea, rsswol) can find it."
sudo ln -sf /usr/lib/mozilla/plugins/ /usr/lib/firefox-addons/plugins/
sudo ln -sf /usr/lib/mozilla/plugins/  /usr/lib/xulrunner-addons/plugins/

# now doing some cleaning up:
sudo rm -rf
sudo rm -rf flashplayer_square_p1_64bit_linux_091510.tar.gz

To check if the install did it’s job, you need to check about:plugins in your address bar. It should show you this for flash player:

Shockwave Flash

Shockwave Flash 10.2 d161
MIME Type Description Suffixes Enabled
application/x-shockwave-flash Shockwave Flash swf Yes
application/futuresplash FutureSplash Player spl Yes

As usual, I’ve wrapped everything mentioned before into a script to easily install flash player square on Linux

If this version doesn’t work out that well for you, you can still check my other tutorial on how to install native 64bit flash player on Linux
Happy browsing!