4 Comments

Summary:

Users can let their Home folder get out of hand and slowly kill any remaining hard drive space. I use Apple Remote Desktop if I need to find out who’s using up too much space with their Home folder and SSH works perfectly for this.

terminal_thumb

Sometimes users can let their Home folder get out of hand and slowly kill any remaining hard drive space. I like to use Apple Remote Desktop if I need to find out who’s using up too much space with their Home folder. I don’t want to just remote in if someone’s working on the machine so SSH works perfectly for this.

Enable SSH

If SSH isn’t enabled on your target machine, send this command through Apple Remote Desktop as root.

/sbin/service ssh start

This will enable SSH until the machine is rebooted.

Start an SSH session

Open up Terminal and make a connection to the target machine using its IP address.

ssh 10.0.0.1

If you’re in an Active Directory environment like me, enter the password that matches your current username you’re logged in with. Otherwise your SSH command will need to pass along a username that exists on the target computer. Something similar to the following.

ssh 10.0.0.1 -l admin

Explore the hard drive

Once you’ve successfully made your connection, check out the disk space with the following command.

df

For our situation, the disk0s2 is what we’re looking at. The HDD is getting pretty full.

In my situation, I know that the most space is probably being wasted in the Users directories so lets head there and get an idea of what’s going on.

cd /Users/

Now let’s run the DU command and see what users have the biggest folder.

sudo du -sh *

You will be prompted for your password, and it may seem to go slowly, but you will get a nice list showing you the size of everyone’s Home folder.

Looks like we’ve found some Home folders that need to be purged. This is also easy to do using Finder but sometimes you can’t disturb the machine and Terminal is perfect for that.

You're subscribed! If you like, you can update your settings

  1. Another good du usage is to pipe it into sort so you can easily see the biggest offenders. You can’t sort using -h since 4.0g would look smaller than 400m, so you need to give it a set unit. -m for megabyte and -g for gigabyte (added in Snow Leopard).

    du -ms | sort -n

    Also, if you want ssh to stay on after reboots, instead of the /sbin/service ssh command, use:

    /bin/launchctl load -w /System/Library/LaunchDaemons/ssh.plist

    Share
  2. Alan Fischer Tuesday, May 4, 2010

    Sounds a bit snoopy to me.

    Share
  3. Huh? First of all you should have SSH turned on anyways to be able to encrypt data going from your computer to the client, second you could then put in your command right into “send unix command” window anyway! Why are you advertising ARD if you´re using your Terminal for that? ;-)
    I also strongly agree with Andy that using -m is better (for being able to sort) and I would also advise using -d x (where x is a number) instead of -s, so you can easily tell “du” how deep to traverse into your folder structure!
    Finally you should definitely consider a) talking to your users about disk space usage or b) using quota or mcx policies if that happens regularly.
    Cheers, Asmus

    Share
  4. I’m with Andy – I use a variation of this command on a linux box I have to babysit, and it works great for the macs too.

    du -cms *| sort -nr

    Gives you your disk usage of every file in the folder (in megabytes) sorted largest on top for easy finding of offenders! :)

    you can leave off the ‘c’ … it outputs a total. I happen to find that useful as well.

    Thanks for the post!

    Share

Comments have been disabled for this post