Amazon offers very competitive pricing in its bid to lead in the cloud services market, and if you’re really interested in getting the best savings on AWS EC2 (Elastic Compute Cloud), Linux users get an even better deal. Just last month, Amazon slashed prices again on virtual servers running Linux/Unix. In order to take advantage of the potential savings, however, you may need to brush up your command line skills. Have you run up a free Amazon EC2 machine, got as far as the blinking cursor at the command line, then thought, “I’ve really got a lot of cleaning to do. I’ll get back to this later”?

Here are some tips. These are reserved for the new people. If you have hours of experience piloting the command line, you might want to go elsewhere.


If you want to take advantage of the AWS free machine offer, you must get to grips with the CLI (Command Line Interface) – probably the least intuitive control panel made by man. There’s nothing there. A command line is pretty much the opposite of an aircraft cockpit. There are no lights or dials to read and no knobs or switches to fiddle with. There are just a few random characters like [ec2-user@ip-10-2-3-4 ~]$ and a flashing cursor. You have to remember what to do next.

I love the command line. I also love the web UI. I don’t love fat clients, and I don’t love heavy AJAX that makes a web UI look like a fat client. I’m like a polygamist with standards.

If you want to learn to love the command line, spend time with the simple commands and get to know them. Many have been around a long time and have skills that can help you.

Amazon’s t1.micro virtual machine is a small, simple AWS machine. It’s cheap, and Amazon let you have it free for your first year. They even throw in their own operating system, Amazon Linux. This is actually a variation on an OS provided by Red Hat, the billion dollar Linux company.

The first question you may want answering after firing up your new virtual machine is, “Where am I?” You can use the commands uname, ls and pwd to illuminate this new territory.

Where am I?

You really are in virtual reality now, generated by a Linux kernel. This is user-space and you are in a directory. The make and model of the kernel that is manufacturing this reality are Linux and 3.2.38-5.48.amzn1.x86_64.


That’s what the first command uname tells you.

[ec2-user@ip-10-226-114-5 ~]$ uname
[ec2-user@ip-10-226-114-5 ~]$ uname -r
[ec2-user@ip-10-226-114-5 ~]$

There are many makes of kernel. If you do this on a Mac you will see a make and model along the lines of Darwin and 12.2.0.


Everyone is familiar with the concept of sticking files in folders. There is a hierarchy of folders within folders going on here. Use pwd (Print Working Directory) to see. The top-level home folder contains the nick folder.

By the way, people get a little precious about the way things are described. For instance, GUI people say folder and CLI people say directory. Which will you choose?

[ec2-user@ip-10-226-114-5 ~]$ pwd
[ec2-user@ip-10-226-114-5 ~]$


The ls command (list files) has been around since before the dawn of Linux. If you list files on a brand new Amazon Linux machine, you will see nothing.

[ec2-user@ip-10-226-114-5 ~]$ ls
[ec2-user@ip-10-226-114-5 ~]$ 

After some use, you may build up some content.

[ec2-user@ip-10-226-114-5 ~]$ ls
downloads  music  myfile
[ec2-user@ip-10-226-114-5 ~]$

Everything in Linux is treated as a file. Folders, obscure device drivers, and shortcuts are all treated as files.

You can’t tell by looking at this list above, but one of these is a file and the others are directories. These are usually displayed in different colors to help you tell them apart but sometimes – like here – the display is in oldskool two-tone. This is where an optional extra comes in handy. List files and classify them by sticking the -F option after the ls command. This adds a symbol on the end (/ for a directory, @ for a shortcut, nothing for a file).

[ec2-user@ip-10-226-114-5 ~]$ ls -F
downloads/  music/  myfile
[ec2-user@ip-10-226-114-5 ~]$   

Over the years the ls command has gained more options than a restaurant menu. Files and directories that you don’t usually need to bother with are hidden. This is done in Linux land by making the first character of the name a period (.). Applications like git, bash and gnome put hidden configuration files in your home folder.

This is one of the more annoying design decisions if, like me, you forget to check for them. I know an .htaccess file affects the behaviour of the Apache web server, but when I am troubleshooting a problem I will be banging my head on the desk before remembering to look for .htaccess files. List all the files, not just the un-hidden ones.

[ec2-user@ip-10-226-114-5 ~]$ ls -a
.   .bash_logout   .bashrc    music   .ssh
..  .bash_profile  downloads  myfile
[ec2-user@ip-10-226-114-5 ~]$

ls options go on and on

The longer you use Linux, the more ls options you need. You can list lots of details about a file, including its permissions with ls -l. You can list files with one name per line (-1), with inodes (-i), without sorting them in alphabetic order (-f), in reverse order (-r) and so on.