Posts Tagged: Terminal

Figuring out the size of folders in your Terminal

Ever wonder how big those folders are getting on your server? Your wp-uploads folders can get huge over time, and it’s hard to figure out just how huge.

Using ls -la tells you about the files, but not the folders:

terminal-ls-la

Luckily we’ve got something better. Give du -hsc * a try. It will return this pile of useful information:
terminal-du-hsc

I can now see the size of each file and folder in my current directory and I get a total at the end. Cool! The odds of you actually remembering that command in two weeks time though is probably zero, so let’s setup an alias with a better name:

  1. Log in to your server
  2. Type nano ~/.bash_profile
  3. Nano is a basic text editor. In that window add a new line: alias whatsize="du -hsc *"
  4. Save and close that file (ctrl+x)
  5. When Nano closes and you get back to the $ prompt, you’ll need to tell your shell about the new alias you just created. Do that with: source ~/.bash_profile.
  6. Last, go to a folder you want to inspect and simply type whatsize!

Simple new way to download WordPress: a shell alias

By accident or not I’m not sure, but WordPress conveniently links to the newest version using the same link: latest.tar.gz. Instead of having to go to WordPress.org to grab the link every time, just make an alias to it and put in your .bash_profile:
  1. Open a Terminal window and type:  edit ~/.bash_profile
  2. Add the following code on two blank lines:
#download latest WordPress
alias wplatest='wget http://wordpress.org/latest.tar.gz'

Then close the file, open a new Terminal window, and browse to the directory you want to install WordPress in. When you get there, just type ‘wplatest’ to download the magic.