As you have no doubt discovered, Raspbian has a graphical interface similar to that of Windows or Mac OS X. You can do most of your day-to-day tasks in this interface. There's a file manager, web browser, text editor and many other useful applications.
However, sometimes you need an interface that's a bit more powerful, and this is where the Command Line Interface (CLI) comes in. It's also known as the Terminal or Shell.
This is an entirely text-based interface, where you type in commands and get a response. We won't lie to you: it will seem a bit confusing at first. Don't worry though, once you've had a bit of practice, it will start to make sense, and spending a little time learning it now will pay dividends in the future.
Article continues below
The first thing you need to do is open up a terminal. Click on LXTerminal on the Raspbian desktop. You should now see a line the looks like:
This is the command prompt. Whenever you see this, you know the system is ready to receive input. Type pwd, and press return. You should see:
If you've changed your username, then you'll see a different line. The rather cryptically named pwd command stands for Print Working Directory, and the system simply outputs the directory you're currently in. When you start a terminal, it will go to your home directory (see the Raspbian Storage section for a little more information about what /home/ means).
Now we know where we are, the next logical thing to do is move about through the directories. This is done using the cd (change directory) command. Try entering:
You should find that the system returns /home. This is because we've cd'd to '..', and two dots always points to the parent directory. To move back to your home directory, you can enter cd pi.
There is also another way you can do it. The (pronounced tilda) character always points to your home directory, so wherever you are in the filesystem, you can enter cd and you'll move home.
Now type ls and hit Enter. This will list all the files in the current directory. One of the big advantages of commands is that we can tell them exactly how we want them to behave. This is done using flags, which come after the command and start with a '-'. For example, if we want to list all the files in the current directory (including hidden ones, which start with a '.' on Unix-based systems), we use the flag -a. So, in your terminal, type ls -a.
This time, you should see more files appear. Another flag for ls is -l. This gives us more information about each file. Try it out by typing ls -l . You can even combine flags, such as in ls -al.
Knowing what commands to use
At this point, you're probably wondering how on earth you are supposed to know what commands and what flags you can use for a task. Well, there's good news and bad news. The good news is that it's usually not too hard to find out the flags for a command. Most support the -h or --help flags, which should give some information about what flags a command can take and how to use it. For example, if you run ls --help, you'll see a long list of flags and what they all do, including:
-a, --all do not ignore entries starting with .
-l use a long listing format
The second way of finding information on a command is using man. This is short for manual. It takes a single argument, that is, a word after the command that isn't preceded by a hyphen. It then displays information on the command given as an argument.