The Terminal also known as Command Line Interface (CLI) can be a scary place if you dont know what you are doing. Once you get used to it, it starts to be logical and will become second nature.
Below is the LXTerminal from the Raspbian Distribution
When you first start the Terminal you are presented with the following:
[email protected] ~ $
The first part pi
is your username you are logged on with. The second part rpi-two
(in my case) is the name of the computer
First Steps
To ease you in gently, lets find something about ourselves
who am i
As the command suggests, it queries what user you are logged in as:
[email protected] ~ $ who am i pi pts/2 2014-09-13 21:44 (192.168.1.8)
This displays various information such as Username pi
, Connection Type pts/2
(0 is locally logged on, I am using ssh to connect remotely), Date/Time 2014-09-13 21:44
and IP Address (192.168.1.8)
.
Directory Navigation
Whether you call them Folders of Directories they are the same thing:- basically a box that contains stuff. So lets figure how to navigate around.
Where Am I ?
To find out where you are, type the following:
pwd
pwd stands for Print Working Directory. It will tell you which directory you are currently in
[email protected] ~ $ pwd /home/pi
By default when you log in, you log into the root of your user. In this case /home/pi
Listing Directories
Great, now we know where we are, but is there any content inside of this directory ? To do this we will use theList Directory Contents command ls
. In the Terminal type the following:
ls
This will list you the contents of your current directory
[email protected] ~ $ ls Desktop Downloads npm-debug.log python Scratch Documents indiecity ocr_pi.png python_games wwwroot
(I have a couple of extra directories, so dont worry if yours doesnt match exactly)
The ls
command has some options which changes the way the content is displayed:
[email protected] ~ $ ls -l total 44 drwxr-xr-x 2 pi pi 4096 Sep 3 22:09 Desktop drwxr-xr-x 3 pi pi 4096 Aug 1 19:48 Documents drwx------ 2 pi pi 4096 Sep 6 20:01 Downloads drwxr-xr-x 3 pi pi 4096 Aug 9 19:50 indiecity -rw-r--r-- 1 pi pi 2153 Jun 29 09:41 npm-debug.log -rw-r--r-- 1 pi pi 5781 Feb 3 2013 ocr_pi.png drwxr-xr-x 2 pi pi 4096 Aug 9 08:41 python drwxrwxr-x 2 pi pi 4096 Jan 1 1970 python_games drwxr-xr-x 2 pi pi 4096 Aug 1 19:48 Scratch drwxr-xr-x 3 pi pi 4096 Jun 28 15:41 wwwroot
The -l
switch, displays the content in a long list. Don’t worry about the information displayed, we will discuss that later
Using the -t
switch, puts them in Date order, latest Date at the top
[email protected] ~ $ ls -t Downloads indiecity Documents npm-debug.log ocr_pi.png Desktop python Scratch wwwroot python_games
So, if we combine both l
& t
, we get a long list in date order !
[email protected] ~ $ ls -lt total 44 drwx------ 2 pi pi 4096 Sep 6 20:01 Downloads drwxr-xr-x 2 pi pi 4096 Sep 3 22:09 Desktop drwxr-xr-x 3 pi pi 4096 Aug 9 19:50 indiecity drwxr-xr-x 2 pi pi 4096 Aug 9 08:41 python drwxr-xr-x 3 pi pi 4096 Aug 1 19:48 Documents drwxr-xr-x 2 pi pi 4096 Aug 1 19:48 Scratch -rw-r--r-- 1 pi pi 2153 Jun 29 09:41 npm-debug.log drwxr-xr-x 3 pi pi 4096 Jun 28 15:41 wwwroot -rw-r--r-- 1 pi pi 5781 Feb 3 2013 ocr_pi.png drwxrwxr-x 2 pi pi 4096 Jan 1 1970 python_games
There are many more options, if you want to have a look, here are some websites: