LL1 – File & Directory Intro


First, VB and Microsoft sometimes have issues.  If you have not taken a snapshot of your guest Ubuntu OS, please do so now so that you can return to it if necessary (snapshot directions are at the end of the installation tutorial/procedure).  Note you will have to redo the labs to get the proper files and directory structure if you have to revert to a previous snapshot however you should be reviewing all past material in any event.  On that note you may wish to take periodic snapshots after each lab (and you should be doing this in Microsoft Windows as well but Microsoft calls it saving the system state).

If you encounter difficulties, it is unfortunate but welcome to IT as in IT we learn from our and our system’s mistakes.  If everything just worked out of the box, we would be less necessary.  So should something go wrong please Google the error message.  As an example, every semester a few students encounter a “Failed to load VMMR0.r0 (VERR_LDR_MISMATCH_NATIVE)” error message and the Google results quickly found the following to resolve the issue by going to C:\USERS\<username>\AppData\Local\VirtualStore\Program Files and then rmdir /s Oracle.

Lastly, you must do the required reading and note you will likely have to read this material several times as it will continue to make more sense with each reading.  If you just follow these labs it is likely you will successfully progress to a point (even very far along) and then at some point, something will go wrong and you will be lost. I will quickly identify whether the reading has been done and my instructions will likely be to return to the beginning to read the material and redo the labs to put the proper file and directory structure in place.  Please do not skimp on the necessary preparation as the labs will go very quickly if you perform the proper preparation/reading and the entire process (reading + labs) will take longer due to mistakes should you not perform the required reading.



Again note as previously presented, everything appears to be a file to Unix/Linux so the title of this lab is actually redundant (i.e. a directory is a file) and this will be explored further throughout these labs.

For this (and future) assignment(s), you will take periodic screenshots as directed (Screenshot instructions provided in the installation and “Linux Lab Intro” components) and paste the screenshots into a single LastnameFirstnameLL1.odt LibreOffice Word document (LastnameFirstnameLLx.odt in future labs where you replace the x with the LL number).  You should preface each screenshot with the exercise number as listed in the tutorials so that I know what step the screenshot documents.  When complete, please upload this file as directed in the appropriate BB Lecture Module (LM).

Please resize/expand/enlarge your Terminal window but note that while the screenshot may not capture every command you have entered, it will demonstart your present state and that is all that is necessary.  Please note these instructions will be standard for the rest of the course.

Important – if something goes wrong in the labs (i.e. commands don’t work), check your spelling and spaces (it is easy to miss spaces reading Linux commands and arguments).  With this basis, please read the materials with a high attention to detail.

Required Reading

Please read Chapter 2 of the GNU/Linux Basic Operating System that can be downloaded from the Syllabus.  Note Chapter 2 will also cover components in future Linux Labs so you should reread this chapter as necessary.  Also please review the LL Intro and Installation directions as necessary for both content and screen shot instructions.

So here we go beginning with LL1 and we will follow these labs in order.  Again, please note that these labs will require that you research the commands in advance in the text and online and you should plan on returning to previous labs over time to reinforce the material. 

1.1 Listing files and directories

ls (list)

When you first login, your current working directory is your home directory. Your home directory has the same name as your user-name, for example, jameslooby (or j.looby on the HVCC VDI Ubuntu instance), and it is where your personal files and subdirectories are saved.

To find out what is in your home directory, type

$ ls # ls is short for list

The ls command lists the contents of your current working directory.  These files and directories are inserted by default by the System or in a production environment, the System Administrator when your account was created.

Note ls does not, cause all the files in your home directory to be listed, but only those ones whose name does not begin with a dot (.) Files beginning with a dot (.) are known as hidden files and usually contain important program configuration information. They are hidden because you should not change them unless you are very familiar with Linux!

To list all files in your home directory including those whose names begin with a dot, type

$ ls -a

ls is an example of a command which can take options

-a is an example of a command line option. The options are associated with commands and change the behavior of the command.  Now to reinforce this in another author’s voice,  please read the following as it will give us the correct terminology (e.g. command, options and arguments) and note it will open in a new window so that you retain you place in this tutorial: http://bashshell.net/bash-shell/structure-of-a-command/.

There are Linux manual pages that tell you which options a particular command can take, and how each option modifies the behavior of the command.  We will use the manual pages in the terminal later but you can also access them online here: http://www.linuxmanpages.com/

Now let’s learn a little more so let’s look at a long listing using the ls long listing options argument:

ls -l

Now let’s put two option arguments together:

ls -la

Ok, that was a nice gentle introduction but ls is an important and powerful command so let’s look at all of its capabilities.  I do not expect that you will understand all of this material but it is important to read it so that you can return to reference it as necessary so as previously introduced please read this: http://en.wikipedia.org/wiki/Ls (and don’t be misled by the URL’s capitalized Ls).  For subsequent commands you will need to search Wikipedia on your own.

Now having read Wikipedia’s information, please look at the official information in the Linux man page by entering the following in your terminal:

$ man ls

You are now seeing the manual presentation of ls and you may use the spacebar to show the subsequent screens and ‘q‘ to quit (i.e. enter q without the apostrophes).  Now reviewing the commands above, we can see that ls is a command and as a command it has a manual page whereas the -a, -l and -la were options listed in the manual page.

1.2 Making Directories

mkdir (make directory)

We will now make a subdirectory in your home directory to hold the files you will be creating and using throughout the course of this and subsequent tutorials. To make a subdirectory called ciss100 in your current working directory type the command mkdir and the argument ciss100.  Please understand the difference between options and arguments where options are system (Linux) defined and arguments are user defined and supplied.

$ mkdir ciss100

To see the directory you have just created, type

$ ls  

Note you can and possibly should read about this and all future commands on Wikipedia as they are presented well and I am trying to move this course to open (free) content.  Now note in the command “mkdir ciss100”, mkdir is the command but ciss100 is an argument where arguments are specified by the user.  You could have made a directory using many other names of your choosing and of course “ciss100” will not be found in the mkdir manual page.  You may wish to view the manual page to verify this and complete your understanding of commands and their options and user generated arguments.

1.3 Changing to a different directory

cd (change directory)

The command cd directory means change the current working directory to ‘directory‘. The current working directory may be thought of as the directory you are in, i.e. your current position in the file-system tree.

To change to the directory you have just made, type

$ cd ciss100

Now type ls to see the contents (which should be empty).  Note I did not present this as $ ls as you are responsible for any material previously presented.

Exercise 1a

First, please make your Terminal window larger by resizing the window (drag lower right corner with your mouse).

Make another directory inside the ciss100 directory named after your UserName in CamelCase notation.  For me, my directory would be JamesLooby (also research CamelCase as necessary and note from this point on you are responsible for researching any term or command you do not understand).

Screenshot – Open a Libre Office file (LibreOffice found in left dashboard menu), name this file LastnameFirstnameLL1, take a screenshot and paste the screenshot into this file with the heading: Exercise 1A.   For me my filename would be LoobyJamesLL1.odt.  Again note the screenshots (this and future ones) may not capture everything you have done but they will demonstrate your current state to me and this is sufficient.

1.4 The directories . and ..

Still in the ciss100 directory, type

$ ls -a

As you can see, in the ciss100 directory (and in all other directories), there are two special directories called (.) and (..)

In UNIX, (.) means the current directory, so typing means stay where you are (the ciss100 directory).

$ cd . # NOTE: there is a space between cd and the dot

This may not seem very useful at first, but using (.) as the name of the current directory will save a lot of typing, as we shall see later in the tutorial.

(..) means the parent of the current directory, so typing

$ cd .. # Again note there is a space between cd and the two dots

will take you one directory up the hierarchy (back to your home directory). Try it now.  To see where you are perform another directory listing as you did above.  Now you could cd back to your directory however  typing

cd with no argument always returns you to your home directory so please do this.

$cd  #This is very useful if get lost in the file system – 🙂

1.5 Pathnames

pwd (print working directory)

Pathnames enable you to work out where you are in relation to the whole file-system. For example, to find out the absolute pathname of your home-directory, type cd to get back to your home-directory and then type

$ pwd

The full pathname should look something like this –


Exercise 1b

Use the commands ls, pwd and cd to explore the file system as you see fit.  You perform a ls to get directory names in your working directory and then you can use cd .. to move up levels in the directory tree and then perform a ls to get directory names and then traverse down these directories using ls DirectoryName (of course replacing DirectoryName with an actual existing directory name but your reading should have allowed you to deduce that).  BTW while I am operating in my user directory structure, I can also go up into the system directory structure.  As an example if I go up several levels (i.e. cd .. followed by cd ..), using a ls I’ll see system directories titled “bin”, “boot”, “cdrom”, etc. and I can then enter cd bin.

BTW – I recommend you do this in the HVCC VDI OpenNX Ubuntu installation at some point as this is a production server and you will see many more things.

(Remember to label the screenshot and also, if you get lost, type cd by itself to return to your home directory)

Screenshot – take a screen shot and paste this into the LibreOffice file with the heading Exercise 1B.  This screenshot will of course be very different for all users as it is highly unlikely that every student explored the file system in the same way.

1.6 More about home directories and pathnames

Understanding pathnames

First type cd to get back to your home-directory, then type

$ ls ciss100

to list the contents of your ciss100 directory.

Now type

$ ls UserName # for me this is JamesLooby so it would be ls JamesLooby

You will get a message like this –

UserName: No such file or directory

The reason is, UserName is not in your current working directory. We did this for a reason as the system is deterministic and as you work through the labs you will encounter errors but the errors are not in the system as they will be our doing.  Please do not just blindly attempt other commands as we must learn to use the system so if something happens that you cannot explain, return to the reading to establish a proper understanding and foundation.

To use a command on a file (or directory) not in the current working directory (the directory you are currently in), you must either cd  to the correct directory, or specify its full pathname. To list the contents of your UserName directory, you must type

$ ls ciss100/UserName # for me this is ciss100/JamesLooby 

~ (your home directory)

Home directories can also be referred to by the tilde ~ character. It can be used to specify paths starting at your home directory. So typing

$ ls ~/ciss100

will list the contents of your ciss100 directory, no matter where you currently are in the file system.

What do you think

$ ls ~

would list?

What do you think

$ ls ~/..

would list?

Screenshot – perform the commands above, take and paste a screenshot into your LibreOffice document with the heading Exercise 1C.  Please submit the assignment in the Blackboard (BB) Lecture Module (LM) Linux Lab1 (LL1) Assignment.

1.7 Removing files and directories

We will not use this now but for completeness, please research the rm command used to remove files and directories as you will need this later.  Most people will forget about this so this is my way to get everyone to reread and review the Linux material periodically as I stated at the outset… sorry.


Lastly, please do not forget to shutdown your system (found in gear menu in upper right quadrant).


Again, I recommend you research these commands (and the options used above) on Wikipedia but also view them in the manual (man) pages so that you can become adept with the man page nomenclature and conventions.  Again to view a man page type the following in the terminal $ man ls and research and try the ls -l command line option (i.e. enter $ ls -l ).  Again, arguments are user specified and will not be listed in the man pages.


list files and directories
ls -a list all files and directories
mkdir make a directory
cd directory change to named directory
cd change to home-directory
cd ~ change to home-directory
cd .. change to parent directory
pwd display the path of the current directory
rm remove files and directories


One Response to LL1 – File & Directory Intro

  1. Prof Looby says:

    Please read “Linux Labs Start Here” first. The screenshot instructions are clearly identified in “Linux Labs Start Here”.

Leave a Reply