Wednesday, July 2nd, 2008 at
6:30 am
If you’ve had the same Ubuntu installation for a while and have just been upgrading to newer releases, you may have noticed that a lot of older kernel versions are piling up in your grub menu and on your system.
How to remove older kernels from Ubuntu
This can be done by using the Synaptic Package Manager, however I will show you how it is done on the command line.
First, find out what kernel you are currently running:
# uname -a
Linux foogazi 2.6.24-19-generic #1 SMP Wed Jun 18 14:43:41 UTC 2008 i686 GNU/Linux
From the output you can see that you are currently using the 2.6.24-19-generic kernel.
Next, let’s take a look at all of the kernel versions you have installed:
# dpkg -l | grep linux-headers-*
linux-headers-2.6.24-16 2.6.24-16.30 Header files related to Linux kernel version
linux-headers-2.6.24-16-generic 2.6.24-16.30 Linux kernel headers for version 2.6.24 on x
linux-headers-2.6.24-19 2.6.24-19.34 Header files related to Linux kernel version
linux-headers-2.6.24-19-generic 2.6.24-19.34 Linux kernel headers for version 2.6.24 on x
linux-headers-generic 2.6.24.19.21 Generic Linux kernel headers
Now all you need to do is remove the old versions with apt-get. Since we’ve noted with uname -a that we are currently running 2.6.24-19-generic we want to make sure we do not remove it. All of the others can be removed.
# sudo apt-get remove linux-headers-2.6.24-16 linux-headers-2.6.24-16-generic
Now the older kernels are gone. Repeat the apt-get remove step to remove any others you may have. Remember to not remove your current kernel.
Important note: It is a good idea to keep at least one old kernel version around in case anything breaks in your current kernel and you are unable to boot into it. An example would be that you boot into your current kernel but recieve a kernel panic. With an old kernel still available you can reboot the computer and select the older kernel version from the Grub menu and still access your system to find out what is going on.
Popularity: 17% [?]
Sunday, June 29th, 2008 at
7:45 am
I don’t know about you but I find the login sound on Ubuntu pretty annoying. Here is a quick, nice and easy way to disable it.
How to disable Ubuntu Login and Logout sounds
Navigate to System > Preferences > Sound then click the Sounds tab.

Set the Log Out and Log In sounds to “No Sound” to disable the login and logout sounds in Ubuntu.
Popularity: 7% [?]
Wednesday, June 25th, 2008 at
10:30 am
If you want to delete your bash history, there are a few options you have. First you must understand that the history of your bash session is stored into RAM and then written to ~/.bash_history when you log out of the bash session. So even if you delete the ~/.bash_history file, your current bash session will still be written to history once you log out.
Delete bash history
To delete the bash history for your current session as well as old sessions, you should do two things:
Delete the .bash_history file:
# rm -rf ~/.bash_history
Clear the current history stored in RAM:
# history -c
Stop writing to .bash_history for good
If you don’t want to log any history for good, you can do one of two things; turn it off for all users, or turn off logging history for a single user.
Turn off bash history for all users:
Append “unset HISTFILE” to /etc/profile:
# echo "unset HISTFILE" >> /etc/profile
Turn off bash history for a specific user:
Append “unset HISTFILE” to /home/USER/.bash_profile:
# echo "unset HISTFILE" >> /home/USER/.bash_profile
That’s it! Now you have successfully deleted the bash history and stopped logging to bash history.
Popularity: 17% [?]
Wednesday, June 25th, 2008 at
7:02 am
Here is a quick tip on how to use sed to replace a line in a text file from the command line, without opening it.
Replace a Line in a File
First, replace the text you want with sed and output it into a temporary file to ensure that it is correct:
# sed -e 's/original-text/new-text/' textFile > newFile
View the newFile and make sure that the line is correctly replaced:
# more newFile
Overwrite the textFile with the newFile:
# mv newFile textFile
Popularity: 3% [?]
Tuesday, June 24th, 2008 at
7:00 am
Here is a quick tip on how to use sed to add a line into the middle of a text file from the command line, without opening it.
To clarify, let’s say you have a text file that has four lines:
Line1Text
Line2Text
Line3Text
Line4Text
Using sed, you can append a line anywhere you want with a simple command without even knowing the line numbers.
Add a Line into the Middle of a Text File
For this example, lets say we want to append a new line under Line3Text:
# sed '/^Line3Text/a NewLineText' textFile > newFile
You’ll notice that we output the results to a newFile so that we can make sure the new line appended correctly before overwriting the original file. If you check the newFile, you should see a correct output, then you can overwrite the original textFile.
# mv newFile textFile
Popularity: 4% [?]
Saturday, June 7th, 2008 at
8:00 am
Here is a quick Linux tip to log your boot messages in Ubuntu. This is great for checking for any errors or failed startups that may be happening during boot.
Edit /etc/default/bootlogd:
# vi /etc/default/bootlogd
You’ll see the following lines:
# Run bootlogd at startup ?
BOOTLOGD_ENABLE=No
Change No to Yes:
# Run bootlogd at startup ?
BOOTLOGD_ENABLE=Yes
Now every time your computer restarts, a /var/log/boot file will be created.
Popularity: 7% [?]
Friday, June 6th, 2008 at
6:23 am
Here is a quick tip on how to find out what host IPs are on your subnet using nmap. This is useful to find out what IPs are being used or just to know how many devices are connected to the subnet.
How to find out what IPs are being used on your subnet
# nmap -v -sP 192.168.1.0/24
You can replace the 192.168.1.0/24 address with whatever your IP and subnet is.
Also, for a cleaner output that removes the lines that tell you an IP is not used, try the following:
# nmap -v -sP 192.168.1.0/24 | grep -v "appears to be down"
Popularity: 4% [?]
Thursday, May 1st, 2008 at
7:00 am
If you’re looking to get rid of the annoying system beep in Ubuntu, here is how to do it from both the command line, and from the Gnome desktop.
Disable the System Beep from the Command Line
#sudo vi /etc/modprobe.d/blacklist
And then add:
#pc speaker beep
blacklist pcspkr
Save and quit the file:
:wq
Now, remove the pcspkr module:
sudo rmmod pcspkr
Disable the System Beep in Ubuntu from the Gnome Desktop
This way is much easier. Simply navigate to System -> Preferences -> Sound then navigate to the System Beep tab. Uncheck the box labeled “Enable the System Beep” and click close.

Popularity: 10% [?]
Wednesday, April 30th, 2008 at
6:05 am
Here is a quick Linux tip to block incoming access to port 80 using iptables.
iptables -A INPUT -j DROP -p tcp --destination-port 80 -i eth0
The code above will drop all tcp packets coming into your Linux computer on device eth0 on port 80. If your Internet connection runs through a device other than eth0, go ahead and make the adjustment.
To remove the iptables rule use the following code:
iptables -D INPUT -j DROP -p tcp --destination-port 80 -i eth0
For more information on using iptables visit the iptables man page.
Popularity: 6% [?]
Saturday, April 19th, 2008 at
7:19 am
Here is a quick tip on how to display the top largest files and directories within my home directory:
# du -hs /home/adam/* | sort -nr | head
Cheers!
Popularity: 6% [?]