Simon The Pi Man bookstore
Mmmm Raspberry Pi
Simon the Pi Man
To Infinity (probably) and beyond
(A beginners Resource for the Raspberry Pi computer using the Debian distro)
since June 2012

If you are looking for info on the Raspberry Pi computer stay on this site
however
If you are looking for a good cafe in Rye in East Sussex try "Simon the Pie man" near the church.

Beginners Guide to Unix - part 2 -  Files and Filesystem

On this page I will give you guidelines as to how unix is setup with regards to the filesystem and the location of important files, and commands to let you look at them.

1. So let us look at the Raspberry Pi root(highest level) filesystem, for this we will use the ls -l command from Beginners Guides 1.
pi@raspberrypi:~$  ls -l /[Return or Enter]
Note this command uses the l(ist)(file)s command with 2 flags at the end, the first allows us to see a long listing(-l) and the / means run from the root(highest level) of the filesystem and will display as follows.

------------------------------------------------------
pi@raspberrypi:~$  ls -l /
total 69
drwxr-xr-x  2 root root      4096 Feb 13 10:29 bin
drwxr-xr-x  2 root root      1024 Jan  1  1970 boot
drwxr-xr-x  2 1999 pi        4096 Apr 16 19:36 Desktop
drwxr-xr-x 13 root root      3160 Jan  1  1970 dev
drwxr-xr-x 89 root root      4096 Jun  7 12:04 etc
drwxr-xr-x  3 root root      4096 Apr 18 18:21 home
drwxr-xr-x 10 root root     12288 Apr 13 09:48 lib
drwxr-xr-x  2 root root         0 Jan  1  1970 media
drwxr-xr-x  5 root root      4096 Apr 12 17:20 opt
dr-xr-xr-x 80 root root         0 Jan  1  1970 proc
drwx------ 11 root root      4096 Jun  1 21:13 root
drwxr-xr-x  2 root root      4096 Apr 12 16:25 sbin
drwxrwxrwx  2 root root      4096 Feb  2  2011 sd
drwxr-xr-x  2 1999 pi        4096 Apr 16 19:19 selinux
drwxr-xr-x  2 root root      4096 Nov  8  2010 srv
drwxr-xr-x 12 root root         0 Jan  1  1970 sys
drwxrwxrwt  2 root root      4096 Jun  7 15:39 tmp
drwxr-xr-x 10 root root      4096 May  6  2011 usr
drwxr-xr-x 14 root root      4096 Jun  2 17:38 var
------------------------------------------------------

The above display shows the original listing for the Pi before anyone amends it.

2. So starting at the top we have the /bin directory - this is where most programs are installed to so is something like the [Program Files] folder in microsoft windows. Take a look whats in there it wont bite !!.
pi@raspberrypi:~$  ls -l /bin | more[Return or Enter]
As you can see we have only modified the last parameter on the ls command to reflect where the listing should start, and have added the pipe[|] symbol the (shifted \) followed my a unix program called [more].

Lets run the command and you will see that the result is similar to below, - i have shrunk my display to make it easier to read.

------------------------------------------------------
pi@rpi1:~$  ls -l /bin|more
total 4696
-rwxr-xr-x 1 root root 790844 Apr 10  2010 bash
-rwxr-xr-x 3 root root  28404 Dec 27 03:05 bunzip2
-rwxr-xr-x 3 root root  28404 Dec 27 03:05 bzcat
lrwxrwxrwx 1 root root      6 Feb  3 12:37 bzcmp -> bzdiff
-rwxr-xr-x 1 root root   2140 Dec 27 03:05 bzdiff
lrwxrwxrwx 1 root root      6 Feb  3 12:37 bzegrep -> bzgrep
-rwxr-xr-x 1 root root   4877 Dec 27 03:05 bzexe
lrwxrwxrwx 1 root root      6 Feb  3 12:37 bzfgrep -> bzgrep
-rwxr-xr-x 1 root root   3642 Dec 27 03:05 bzgrep
-rwxr-xr-x 3 root root  28404 Dec 27 03:05 bzip2
-rwxr-xr-x 1 root root   8316 Dec 27 03:05 bzip2recover
lrwxrwxrwx 1 root root      6 Feb  3 12:37 bzless -> bzmore
--More--
------------------------------------------------------

You will notice that only a few lines have been displayed with a [--More--] at the bottom of the screen.

What the command [more] does is pages the display, this is because there are too many files in that directory to fit on one screen so they will scroll up your display fairly quickly and you will miss them.
To page through the listing just press the [space bar],
or to scroll one line at a time press [Return].
If you want to stop the command at any time press [ctrl][c] that is the [Ctrl] key and the [c] at the same time.

[ctrl-c] is the keystrokes needed to stop a unix command, think of it as an "Oh dear i didnt mean to do that" key combination. This will stop pretty much any programs you might be running, so is worth remembering.

If you look at the detailed listing above you will see the x character in the permissions area which means that these are programs [-rwxr-xr-x]. In Microsoft Windows a [.exe] program means executable, but in unix the file extension (if there is one) doesnt mean anything, the permissions show if the file is a program or not.

3. Lets go back to the main folder listing so we can see the other folders.
pi@raspberrypi:~$  ls -l /[Return or Enter]

/bin
  The main executables folder
/boot
  The folder where the startup programs are found
   keep clear of this one.
/Desktop
  This is the folder that is used by the X windows desktop
/dev
  The files in this folder are the devices in the system (unix sees everything as files in the system so /dev/eth0 is the ethernet port)
  keep well clear of this one.
/etc
  This folder is usually used for system configuration files
  You will need at some time to edit files in here, but be careful.
/home
  This folder is usually used for the users on your Pi's home directories. lets just prove that this is where you are when you logged in so type in
pi@raspberrypi:~$  pwd[Return or Enter]

------------------------------------------------------
pi@rpi1:~$ pwd
/home/pi
------------------------------------------------------

As you can see firstly the pwd command means p(rint) w(orking) d(irectory) - when you login as Pi you are put into the /home/pi folder which you can use to put your files as other users apart from root(god) cannot see into this folder on a multi user unix system.

/lib
  This folder is usually used for system library files so is a bit like the c:\windows\system32 folder on your PC.
/media
  probably used for mounting media.
/opt
  This is usually used for optional programs.
/proc
  This is a folder that usually shows the running programs.
  again keep well clear of this folder.
/root
  This is root(god)'s home folder.
/sbin
  This is where the system maintenance and/or administrative task programs are found.
/sd
  Not sure what these are for
/selinux
  Not sure what these are for
/srv
  Not sure what these are for
/sys
  Not sure what these are for
/tmp
  This folder is for temporary files, you can use it but the files in it are deleted on system boot.
/usr
  This folder is for user installed programs - quite often system shell programs are written and put in /usr/local/bin.
/var
  This is usually where variable data in the system is stored - such as logs/mail etc


Useful commands that you may have missed above
  ls for listing files
  ls -l for detailed listing of files
  more to page through lists
  pwd print working directory

© simonthepiman.com 2012->2024
email:
simon@villagenet.co.uk

hosted by VillageNetThe Raspberry Pi Foundation is a UK registered charity which exists to promote the study of computer science and related topics, especially at school level, and to put the fun back into learning computing.

Please Note:- any mention of the Raspberry Pi computer on these pages refers to the Raspberry Pi Foundation's product, who also have trademark rights to the term 'Raspberry Pi'.