How-To: Use SSH to Investigate Folder Sizes

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.

loading

Comments have been disabled for this post