Tag Archives: linux

How To: Delete ALL older kernels

If you are using Ubuntu, there is a good chance you get kernel upgrades once in a while. There is no reason, after you’ve booted the new kernel and verified that everything is working properly, why you should not delete all older kernels. This will free up a bit of that root partition. If you are like me and mount / on a small SSD partition, every MB counts. For me the modules for each kernel version are around 160MB.

Here is a CLI one-liner to delete all order kernels, leaving only the latest on the system:

sudo apt-get remove --purge $(dpkg -l 'linux-*' | sed '/^ii/!d;/'"$(uname -r | sed "s/\(.*\)-\([^0-9]\+\)/\1/")"'/d;s/^[^ ]* [^ ]* \([^ ]*\).*/\1/;/[0-9]/!d')

Install native 64bit Flash Player 11 on Linux

Update 3 [30 10 2011]: The script was updated to install of Flash Player 11.2 Beta
Update 2 [7 09 2011]: The script was updated to install rc1 of Flash Player 11
Update 1 [13 08 2011]: The script was updated to install b2 of Flash Player 11

Abobe released yesterday the first beta of Flash Player 11 for Linux 64 bit.

I’ve put together a small script that takes care of installing it on Ubuntu:

#!/bin/bash
# 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 11"
cd ~
wget 'http://download.macromedia.com/pub/labs/flashplatformruntimes/flashplayer11-2/flashplayer11-2_p1_install_lin_64_102611.tar.gz'
tar zxvf flashplayer11-2_p1_install_lin_64_102611.tar.gz
sudo cp libflashplayer.so /usr/lib/mozilla/plugins/ 
sudo cp -r usr/ /usr

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

# now doing some cleaning up:
sudo rm -rf libflashplayer.so 
sudo rm -rf usr/
sudo rm -rf flashplayer11-2_p1_install_lin_64_102611.tar.gz

A very interesting application that comes bundled in this release is the “flash-player-properties” app which allows us to finally be able to set permissions to mic/camera on websites.

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.

Features:

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 OpenOffice.org with LibreOffice on Ubuntu

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

CLI instructions (these will take care of removing OpenOffice.org 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.

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.

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
./clean-all
./build-dh
./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
server 10.10.0.0 255.255.255.0

persist-key
persist-tun

client-to-client

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

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 10.10.0.0/24 -o eth0 -j MASQUERADE

7. Start the server

/etc/rc.local
/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