Getting started with Linux Admin – Part 2

This is the second part of my occasional blog dumps of stuff from my two FastTrack Intro to Linux Admin. Part 1 outlined the approach and what we needed to get started. This can be boiled down to get a PC and a LiveCD – we’ll be using theUbuntu LiveCD.

Getting started with the command line

As Linux sysadmins we do the majority of our work at the command line, or shell. There are a wide variey of shells, BASH,tcshKornShellZsh, are some of the common examples. On most Linux systems the default shell is BASH. BASH stands for Bourne Again SHell – one in the long line of witty word jokes in a Unix system – one of the original shells for Unix was written by Stephen Bourne and called the Bourne Shell. BASH is more than just a shell, it also has a built in scripting language (which is boxy but useful).

Aside: One of the things you have to get used to within the world of Linux and open-source software is that there is almost never just one example for any class or type of software. We need a shell to do our work, so of course there’s never just one type of shell. Later on we’ll need an editor, and the number of open-source editors is approaching inifinity. This theme will come back again and again.

Once our machines has booted the LiveCD we’ll have a graphical desktop like the picture below (I’ve rather presumtiously assumed you’ll have opened a browser to this page).


Within the GUI environment the type of program we need to run to get a command line is called a terminal – and of course there are loads of terminals. Thankfully on the Ubuntu LiveCD there is only one, which we can find in Applications->Accessories->Terminal (as shown on the picture above).


Now we have the terminal we can get going. The first command we’re going to use is echo which is the simplest command going: it simply repeats back to us what ever we give it.

ubuntu@ubuntu:~$ echo "Hello there I'm the echo command"
Hello there I'm the echo command

Once you’ve had a play with that the next command is ls which lists the files in the current directory.

ubuntu@ubuntu:~$ ls

Aside: Those of you with exprience in DOS might be expecting to type dir to get a list of files in the current directory. Go ahead and try it. On Ubuntu it works, but is just a copy of ls with a different name, on other Linux systems it might be an alias (we’ll cover those later) that gives an error message or even just not there.

There aren’t any files to look at – we’ll fix that in the next section – the next thing we might want to do is change directories. This time it is the same command as DOS.

ubuntu@ubuntu:~$ cd Desktop
ubuntu@ubuntu:~/Desktop$ ls
ubuntu@ubuntu:~/Desktop$ cd ..

That last line introduces one of two hidden directories in every directory. The double dot represents the parent directory of the current directory, a single dot represents the current directory. So you might be wondering why we haven’t seen these directories in either of the previous examples of ls? Well, there is a convention of hiding files that start with a full stop (aka dot, making those files dotfiles). There is an argument to ls to turn this convention off and show all files.

ubuntu@ubuntu:~$ ls -a
.              Desktop    .gnome2_private    .mozilla          .xsession-errors
..             .esd_auth  .gstreamer-0.8     .nautilus
.bash_history  .gconf     .gtkrc-1.2-gnome2  .Trash
.bash_profile  .gconfd    .ICEauthority      .update-notifier
.bashrc        .gnome2    .metacity          .Xauthority

There’s a whole heap of hidden files and directories in the user’s home directory, most of them storing configuration and metadata. There is a whole load of other arguments we can give to ls to output info we may be interested in. To find out more about ls we can type

ubuntu@ubuntu:~$ man ls

when we hit enter the teminal is taken over by the manual viewing application


You can now page through the manual with the space bar or move up and down a line at a time with the cursor keys. When you’re done type q to quit the manual. All commands in the system (should) have a manual page, even if it’s very terse and assumes that you know how to use it in the first place.

That’ll do for this blog entry. Next time (if there is a next time) we’ll look at input and output redirection and shell variables. If you want to get ahead then all of this and more is covered in ‘The Command Line’ chapter in the free LPI Manuals that starts on page 52 (in my copy).

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 )

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