LinuxCooking.com RSS Feed

LinuxCooking.com

whip up a batch of Linux

Finding Disk Space

recipe June 21st, 2008

Introduction

How many times have you had your web server stop serving web pages because it was out of disk space? Well, it seems to happen to me quite often. That is why I thought I would put this post together to help find the culprit that’s eating up my disk space.

Determining where you need space

The first thing you need to know is “where do I need space?” To find out where (which partition/disk) needs the space use the following command:

df -h

The “-h” gives you a human readable format. So you see results like 29M for 29 megabytes versus stuff like 30234524. It is much easier to read the results with the “-h”.

Now take a look at the given results from the ‘df’ command to see which partition needs space. Here is a sample output:

Filesystem Size Used Avail Use% Mounted on
/dev/sda3 31G 23G 5.6G 81% /
varrun 697M 256K 696M 1% /var/run
varlock 697M 0 697M 0% /var/lock
udev 697M 88K 696M 1% /dev
devshm 697M 12K 697M 1% /dev/shm
/dev/sda6 24G 16G 7.4G 68% /home

As you can see my root partition (“/”) is 81% used. If I was having disk space troubles, this figure could be as much as 100%.

Finding the Big Files

With the information about where we are running low on disk space from the section above, change directories to the start of that partition using the ‘cd’ command as follows:

cd /

If my root partition was low on disk space that is the partition I would go to.

Now, I am ready to determine which files are taking up the majority of my disk space. Use something like the following command to accomplish this:

find . -size +20M -exec du -h \{\} \;

This command will first find file of size 20MB or larger. Next it passes that file over to the ‘du’ (disk usage) command to show us in human readable format (-h) the size of the file.

That is quite a handy little command.

Removing Large Numbers of Files

Sometimes you may find that you have a directory with a large number of files that you wish to get rid of. However, the normal method of using the “rm” (remove) command comes back and complains that the list is too long. What do you do now? Well, don’t despair use the following command to solve this dilemma:

find /tmp -type f -exec rm -f \{\} \;

Be very careful using a command like this. This one if JUST an example. Read the man page on ‘find’ to see just how useful this command really is. This particular commandline will find all files (-type f) in the /tmp directory and pass the filenames to the “-exec” command. In this case the “”exec” command is the remove command (rm). The “-f” forces deletion quietly. The curly braces are replaced by the find command with the filename being passed in. The semicolon (with the backslash in front) is the required end of command marker.

Luckily the find command is pretty quick and VERY useful!

Tags:

Upgrading Your Ubuntu Distribution

recipe June 20th, 2008

Introduction

I am writing this post because the first time I attempted to upgrade a major distribution change, I did it without researching the right way to do it. Needless to say, it did not go well. So, I am putting this together to help those of you willing to “read the instructions”.

First thing to know is that there are different types of distribution upgrades. If you are upgrading within a major distribution (like say ‘Hardy’), then you use the “Minor” release method. However, if you are upgrading from one “Long Term Support” version to another (like ‘Dapper’ to ‘Hardy’), then use the “Major” release method below.

Determining which Release you are running

There are multiple ways to determine which release you are currently running. Here are a few of them (choice one):

  1. lsb_release -a
  2. more /etc/lsb-release
  3. uname -a

NOTE: The last method will not give you the current release name (like ‘Gutsy’) but only the release number (like ’2.6.24-19-server’).

Minor Release Upgrade Method

Use the following steps as a guide to upgrade from one minor release to another:

  1. apt-get update
  2. apt-get upgrade
  3. apt-get dist-upgrade

NOTE: if you are not running as root you will have to use ‘sudo’ (without quotes) before each of the above commands.

Major Release Upgrade Method

Here are some guidelines for upgrading from one major release to another:

  1. apt-get update
  2. apt-get upgrade
  3. apt-get install update-manager-core
  4. do-release-upgrade

NOTE: if you are not running as root you will have to use ‘sudo’ (without quotes) before each of the above commands.

Tags: , ,

infobyte: dangerous shell commands

infobyte January 3rd, 2008

Recently, there was an announcement on www.ubuntuforums.org warning users against malicious shell commands that might be run accidently by unsuspecting or inexperienced users. I wanted to spread the warning by posting it here.

For the education of Linux users everywhere, here are some common examples of dangerous commands that should raise a bright red flag. Again, these are extremely dangerous and should not be attempted on a computer that has any physical connection to valuable data — many of them will even cause damage from a LiveCD environment.

Read the rest of this entry »

Incoming search terms:

  • most dangerous shell tricks linux

Tags: ,

recipe: enable the universe and multiverse ...

recipe December 31st, 2007

Ubuntu is a popular free Linux distribution that promotes “Linux for human beings”. If you read through many Ubuntu tutorials, you may notice that one of the steps is often to enable the “universe” and “multiverse” repositories. This “recipe” tells you how to enable the universe and multiverse repositories.

The universe and multiverse repositories are official Ubuntu repositories, with safe, well-tested programs. The only difference between them and the repositories enabled by default is that the universe and multiverse repositories are maintained by the Ubuntu community rather than by paid Ubuntu developers. This means that Canonical (the company that backs Ubuntu and provides paid support) does not officially support packages from these repositories. Also, be aware that some of the packages in the universe and multiverse repositories make use of patented technology (such as multimedia codecs) and may be illegal to use in your country. It is your responsibility to find more information about any patent issues that affect you. That being said, the universe and multiverse repositories bring a vast number of useful, high-quality programs to Ubuntu users everywhere.

Read the rest of this entry »

Incoming search terms:

  • ubuntu 8 04 repositories
  • ubuntu enable multiverse command line
  • ubuntu hardy enable multiverse repository
  • ubuntu repositories

Tags: ,

Powered by Yahoo! Answers