Answered step by step
Verified Expert Solution
Link Copied!
Question
1 Approved Answer

please make your Terminal window larger by resizing the window if you have not already done so so that we capture as much as possible

please make your Terminal window larger by resizing the window if you have not already done so so that we capture as much as possible (drag lower right corner with your mouse).  Again note you may not capture everything in future labs but this will be alright.  Take a screenshot and paste it into your submission file with the exercise number heading (i.e. (exercise 2.1).

Moving on,

That was a nice gentle introduction but ls is an important and powerful command and many people use it after almost every command to verify what took place 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, let's introduce the Linux man command and the description and options for the ls command so please enter:

$ 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.

2.2 Making Directories

clear

First let's clear the screen so that it is less confusing so please enter the clear command.  Again, I provide the $ prompt but you know you should not be typing this.

$ clear

Now in the future I will ask you to clear the screen but I will not provide the syntax again (which of course is just the clear command).

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 #lowercase ciss100

To see the directory you have just created, type

$ ls  

Now every time you directory or file, you should perform a ls to verify it was created correctly and to check your spelling recalling Linux is case sensitive. Note if you perform a mkdir ciss100 again in the same directory Linux will tell you the directory already exists and this applies to files as well.  Please do this as it is important to see error messages as the error messages will assist with our corrections.

You now have the below directory structure graphically where ciss100 is a subdirectory of your home directory denoted by the ~/

      ~/

ciss100

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 (options are system defined or predefined). 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.

To list all files in the ciss100 subdirectory from your home directory (i.e. ~/) enter,

$ ls ciss100

Now while still in your home directory, please make another directory titled: "CISS100" (uppercase CISS100) and perform a ls to see that  "ciss100" and "CISS100" are different directories.  Could you have done this in Windows (i.e. make a ciss100 and CISS100 directory in the same directory)?  Why not... because Linux is case sensitive and Windows is not case sensitive so Linux has a much larger namespace (i.e. possible names).

Now your directory structure with 2 subdirectories graphically is:

~/

ciss100        CISS100

Exercise 2.2 -  mkdir screenshot

Take a screenshot and paste it into your submission file (on a new page) with the exercise number heading

Please clear your screen after taking your screenshot and before continuing.

2.3 Changing to a different directory

cd (change directory)

The command cd directory means change the current working directory to 'directory' where directory is the target directory and the directory must exist and be navigable from the command. The current working directory may be thought of as the directory you are in, i.e. your current position in the file-system tree.  One last time, my format  cd directory indicates cd is a command and directory is a user-supplied argument. If the directory does not exist you will get an error message (in this case where we are in your home directory you would have had to create the 'directory' before trying to change directories into it). To this extent much like when you create a directory you should perform a ls prior to changing directories and definitely perform a ls if you try to change directories and you receive an error message as you need this system information to resolve the issue.

To change to the directory you have just made, type

$ cd ciss100

Now look at your prompt and see how it has changed as it will show you where you are in the directory system or in other words, the path of your present working directory (pwd).  Now type ls to see the directory contents of your present working directory (pwd should be ciss100).  This should be empty and of course you do not see the ciss100 directory listed as you saw when performing the ls from the parent directory.  This reveals that only items in the pwd are visible if using a standard ls.  Note, while located in the ciss100 subdirectory, you can view the contents of the ciss100 parent directory with a ls ~/. Please perform a ls ~/ to verify you see your home directory's contents and note this command/argument pair (i.e. ls ~/) will always perform a listing of the user's home directory (Again, ~/ is the user's home directory not to be confused with the system's home directory which is /home and you now see the need for precise exacting attention to detail in our terminology. My best advice here is for students to slow down and read very carefully.

Exercise 2.3 - subdirectory name

Make another directory inside the ciss100 directory named after your first and last name in CamelCase notation (i.e. no spaces between your first and last name).  For me, my directory would be JamesLooby (also research CamelCase notation as necessary and note from this point on you are responsible for researching any term or command you do not understand). Perform a directory listing to ensure you created it correctly.  My directory structure is now the following where my home directory (~/) has subdirectories ciss100 and CISS100 and the ciss100 directory has a JamesLooby subdirectory.  Your structure will of course have a subdirectory with your name in Camel Case notation.

~/

ciss100        CISS100

JamesLooby

Screenshot - take a screenshot and paste the screenshot into your submission file on a new page and do not forget the screenshot heading

Please clear your screen after taking your screenshot and before continuing.

2.4 The directories . and ..

Still in the ciss100 directory (you can see this from your prompt's path - path precedes the $), type

$ ls -a

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

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

Now enter:

$ ls .. # this should look familiar as it shows the directory above your present current working directory (cwd).

Now enter the following:

$ cd . # again recall there must be a space between the command and argument

Did your prompt change?  Perform another listing to verify nothing changed and while 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.

In Linux, .. means the parent of the current directory so cd .. will take you one directory up the hierarchy (parent directory and in this case back to your home directory). Try it now.

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

To see where you are, look at your prompt which contains your present directory path and perform another directory listing as you did above.

Now you could cd .. back to your home directory however  typing cd with no argument returns you to your home directory so lets try this by entering the following commands from the top level directory to your FirstnameLastname directory (for me this is ciss100/JamesLooby)

$ cd ciss100

$ cd JamesLooby # again use your FirstnameLastname directory name per the typographical conventions

$ cd  # This returns you to your home directory and is very useful if lost in the file system

Now let's change to the FirstnameLastname subdirectory from your home directory directly and then change directories back to our home directory directly.  To do this I would change directories to my home directory if necessary and then enter:

$ cd ciss100/JamesLooby 

$ cd #of course this returns us to our home directory

Lastly note you could view the contents of the ciss100/JamesLooby subdirectory from your home directory using the command: ls ciss100/JamesLooby

Exercise 2.4

Please take a screenshot and paste the screenshot into your document with the appropriate heading on a fresh page.

Please clear your screen after taking your screenshot and before continuing.

2.5 Pathnames

pwd (print working directory)

Pathnames enable you to determine 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 if necessary) and then type

$ pwd

The full pathname should look something like this: /home/YourUserName which means YourUserName is a subdirectory of the home directory which in turn is a subdirectory of the root directory denoted with the foward slash.

2.6 More about home directories & pathnames

Understanding pathnames

First, type cd to get back to your home-directory if necessary, then type the following to list the contents of your ciss100 directory.

$ ls ciss100

Now type

$ ls FirstnameLastname # for me this 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 so its not visible at your present level as you can only see what's in your present directory (e.g. return to the Linux tree structure file representation to see this). 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 your/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 in the command. To list the contents of your UserName directory from your home directory, you must type the following from your top level user directory.

$ 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 the following would list:

$ ls ~ #try it if you don't know

What do you think this would list:

$ ls ~/.. #try this noting I could also enter "cd .." and then ls 

Well think about this... the '~' means the home directory and "/.." means go up one level so that "~/.." so this is the "/home" directory where all user accounts are located.  Enter a "cd .." to go up one level and perform another listing.  Perform another "cd .." and then a perform a listing and you will see that you are at root which was covered in the first reading as well as in class.

2.7 Removing files and directories and touch

Please research the rm and rmdir commands used to remove files and directories respectively (they are in the reading but you can also use Internet Search with the term "Linux rmdir).  Then please read about the touch command here: http://www.linfo.org/touch.html

Navigate to your home directory if necessary and create a file with your initials using touch (form me this would be jgl).

$ touch jgl  #please substitute your initials for mine

Now make sure it is there by performing a listing (i.e. ls) and notice it may be a different color.

Now remove this initial file name as follows:

$ rm jgl   #you should verify it is gone with a ls

Exercise 2.7

Please take a screenshot and paste this into your submission file with the proper exercise heading.

Please clear your screen after taking your screenshot and before continuing.

Exercise 2.8

Please navigate (change directories) to your home directory and remove the uppercase CISS100 directory using a command from this lab other than rm (critically, please do not use rm -r or rm with any option or find/delete as this can be dangerous since it can delete an entire directory tree structure or). Please perform a directory listing to show that CISS100 subdirectory is gone and then take a screenshot and paste this into your submission file with the proper exercise heading.

rm myfile functionality where rm is the command, myfile is the argument
 

This has the effect of removing the file myfile using the rm system program.  The shell searches the filestore for the file containing the program rm, and then requests the kernel, through system calls, to execute the program rm on myfile in the present working directory. When the process rm myfile has finished running, the shell then returns the Linux prompt $ to the user, indicating that it is waiting for further commands. Note something similar happens in a graphical user OS interface (e.g. Windows, Mac OSX) however few people are actually aware of what is happening under the hood. Note this will become clear in LL3.

2.9 Exploration

Use the commands ls, pwd and cd to explore the file system as you see fit knowing this will pay big dividends in the future.  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 visible in your present working directory 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.  Try listing the contents of the ciss100/Username directory from the top level (I would enter $ ls ciss100/JamesLooby) and following this navigate to the ciss100/Username directory and perform a listing on the home directory using the tilde.

Assignment Submission

Please submit the single .pdf file with your pasted screenshots titled with the exercise number in the Blackboard (BB) Lecture Module 2 (LM2) Linux Lab2b (LL2) Assignment Folder (i.e. browse and upload from your computer).  I also recommend you save a copy in your personal Windows/Mac/Linux system.

Additional useful tool - Filename Completion - By typing part of the name of a command, filename or directory and pressing the [Tab] key, the shell will complete the rest of the name automatically. If the shell finds more than one name beginning with those letters you have typed (recall namespace ambiguity), it will beep, prompting you to type a few more letters before pressing the tab key again.

History - The shell keeps a list of the commands you have typed in. If you need to repeat a command, use the cursor keys to scroll up and down the list or type history for a list of previous commands.

Summary

Again,  you must research the commands (and the options) used in the labs on Wikipedia and I also recommend you view them in the manual (man) pages so that you can become adept with the man page nomenclature and conventions.  As an example, to view the man page for ls please type the following in the terminal $ man ls (of course the $ prompt is provided and will not be retyped).  The man page will show you all the available options and again, arguments are user specified and will not be listed in the man pages.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image
Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Microeconomics An Intuitive Approach with Calculus

Authors: Thomas Nechyba

1st edition

538453257, 978-0538453257

More Books

Students explore these related Computer Network questions