using the terminal

June 2, 2013

One of the things that scares a lot of people about using Linux, and one of the things that makes it such a flexible and powerful set of operating systems, is the command-line interface or terminal.  As I mentioned in a previous post, I’ve never been scared of a monochrome blinking cursor, and I loved using DOS when all I knew was how to type “cd”, “dir”, and the few programs I ever used in the 80s (ah Wordperfect 4.1).  That’s a good thing, because you absolutely have to use the terminal if you’re going to use Ubuntu or any other Linux distribution as your primary operating systems.  Things will go wrong, you’ll have to compile from source code, you’ll accidentally set recursive file properties on your system files, and even if you don’t want to, you’ll have to use the terminal.  So I thought I would give a brief description of the last 3 commands I’ve used in my terminal on Ubuntu.

First things first: in most version of Ubuntu (and several other distributions), you can open the terminal with the keyboard shortcut Ctrl+Alt+t.  You can also access it by clicking on the Dash (if you’re using Unity as I am) and typing in any portion of “terminal”.  When you open it you’ll see something of the form <user>@<machine>.  For instance, if your username is cthulu and your computer’s hostname is rlyeh, you’ll see cthulu@rlyeh.  The default default location (not a typo — I mean the system default for the default folder you’re in when you open the terminal) is your home folder, so after a colon you’ll see ~, which is shorthand for your home directory.

We don’t want to be limited to our home directory, so I’ll introduce the first basic command, which easily enough is the same as for Windows: “cd”, which stands for “change directory”.  For instance, if I want to change into my Downloads directory, which resides in my home folder, I could type “cd Downloads” (remember: commands and folder names are case-sensitive).  If I want to get back to my home folder from anywhere, I can just type “cd”.  Okay, now I want to actually see what’s in my Downloads directory.  This command is different from Windows: “ls”, because we’re listing the contents of the directory.  By default ls only lists non-hidden files and folders, so if you want to see everything you’ll have to do “ls -a”.  This shows all files and folders.

Okay, now I’m bored and want to actually do something instead of just listing files.  The utility I use probably more than anything (including cd and ls) is ping, which sends ICMP packets to a target IP address and logs how many of them were returned and how long it took them to get back.  ping is used to test network connectivity.  For instance, if your computer won’t connect to the internet, and you want to know if your computer is properly connected to the router, you could ping the router.  If you’re connected, you should get all or most of the packets back, and the times should generally be 5-10ms if you’re using wireless and are some distance from the router.  Less than this is great, much more typically indicates radio interference or network congestion.  If you’re on a home network, the router IP address is probably, though it may also be  In my case it’s the latter, so if I want to test my connectivity I type in “ping” in the terminal, and I start getting responses like “64 bytes from icmp_req=1 ttl=255 time=1.43ms”.  The most relevant part of that for our purposes is the last bit: “time=1.43ms”. This means the time it took my computer to send an ICMP packet to the router and get a response back was a little over a thousandth of a second: great!  The default for Linux systems is to continuously ping, so if you enter the above command, it’ll just keep going forever and ever.  To stop this (or any other running process in the terminal), you can hit Ctrl+c — which, incidentally, is why you can’t use keyboard shortcuts for copying and pasting in the terminal.  If you want a specific number of pings, for instance the Windows default of 4, you can use “ping -c 4”, where 4 is the number of ICMP packets that will be sent.

Okay, we’re done!  Now I type “exit” and the terminal closes itself.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: