The Linux command line can be a bit intimidating at first, but it gets much easier once you learn a few basic building blocks. The power of the command line lies in combining many basic commands in interesting ways.
Open up a Linux terminal (or, if you want to follow along on Windows, Cygwin). The darkness of the abyss stares at you, but it’s really not as unfriendly as all that.
First things first. Where am I? Type “pwd” without quotes and hit enter:
You should see something like “/home/leonsp”. That’s your home directory, similar to your Documents folder on Windows. “pwd” stands for “print working directory”, and is a handy way to find out your current location.
Let’s try going somewhere else. Enter “cd ..”, followed by “pwd”.
Two dots means one directory up. You just changed the directory to one directory up from /home/leonsp, which is /home.
Let’s get back to your home directory. There’s a few ways to do this. The following commands will all do the same thing:
$ cd /home/leonsp
$ cd ~
~ is convenient shorthand that refers to the home directory of the current user — you.
What’s in all these directories? Let’s list the contents using the “ls” command:
Not much will show up, as your home directory starts out with few files in it. It will, however, have a bunch of hidden files. Let’s list all of these:
$ ls -a
.Â ..Â .bash_historyÂ .bash_profileÂ .bashrcÂ .inputrcÂ .lesshstÂ .sshÂ .subversion
By convention, Linux treats all filenames starting with a dot as hidden. They will only show in the listing when you ask to see them.
.bash_history, .bash_profile, and .bashrc are configuration files for my shell, Bash. Which shell you have mostly affects scripting (or automation), which is a more advanced topic. Bash, ksh, and sh are similar, while csh and tcsh are a bit different.
. and .. will show up everywhere. Single dot “.” refers to the current directory, and two dots “..” refer to the parent directory.
It’s possible to get a long, more detailed listing:
$ ls -la
drwxr-xr-x+ 1 leonsp NoneÂ Â Â Â 0 Feb 22 15:30 .
drwxrwxrwt+ 1 leonsp rootÂ Â Â Â 0 Jan 28Â 2010 ..
-rw-------Â 1 leonsp None 17431 AprÂ 5 00:16 .bash_history
-rwxr-xr-xÂ 1 leonsp NoneÂ 1150 Jan 28Â 2010 .bash_profile
-rwxr-xr-xÂ 1 leonsp NoneÂ 3754 Jan 28Â 2010 .bashrc
-rwxr-xr-xÂ 1 leonsp NoneÂ 1461 Jan 28Â 2010 .inputrc
-rw-------Â 1 leonsp NoneÂ Â Â 35 Jan 10 16:48 .lesshst
drwx------+ 1 leonsp NoneÂ Â Â Â 0 Mar 30 13:05 .ssh
drwxr-xr-x+ 1 leonsp NoneÂ Â Â Â 0 Feb 22 15:30 .subversion
-rw-r--r--Â 1 leonsp NoneÂ Â Â Â 0 Aug 26Â 2010 blah
We’ll get into what these columns mean later.