LL2b – CLI/Terminal/Files Intro

Please note: LLs must be correctly submitted in order (i.e. LL2a, LL2b, LL3, LL4, etc.).  Later or higher number labs cannot be accepted until all earlier labs have been correctly submitted so you will need to check your grades. I begin grading the previous week’s work on Monday morning following the Sunday submission deadline. To check individual LL feedback which is necessary to correct errors and resubmit, please see: https://docs.hvcc.edu/dl/?p=6889. At this juncture students need to make sure their LL2a was accepted to work on this LL2b.

Reminder: Comp Sci (CS) is a precise discipline requiring exacting attention to detail and complete and discrete understanding.   This is especially the case with learning Linux as a listing is not the same as a long listing or a complete listing.  To this extent, you will need to reread the Linux Labs and the assigned readings throughout the course with exacting attention to detail as future labs will be based on, draw from and extend past material.  Please understand this is what is required to succeed in this discipline.

Required Reading

Please read all LLs in their entirety before beginning and please review previous LLs and their required readings as necessary for both content and the screenshot and submission instructions in LL2a.

The Linux Command Line by Shotts – 1.2, 1.3, 1.4, 1.8

1.2 => Navigation, 1.3 => Exploring the System, 1.4 => Manipulating Files & Directories, 1.8 => Advanced Keyboard Tricks

This can also be downloaded from the Syllabus link directly above.  I recommend you try each command but note that some commands like revealing virtual terminal sessions are not supported for general users (students) on an enterprise system (AcadNX) because security is a primary concern. Also not all commands will provide information since our user directories are empty but trying the commands will show you error messages which are important to see and understand.

Note each week’s reading may also cover components for future Linux Labs so you may need to reread past chapters each week as necessary.If you just follow these labs without doing the reading, it is likely you will successfully progress to a point (even very far along), and then at some point in a future Linux Lab, something will go wrong and you will be absolutely lost because you will not have the knowledge to understand what is going on.  Please note this happens every semester and the faculty will quickly identify whether the reading has been done.

Now if you encounter difficulties, it is unfortunate but welcome to IT as in IT we learn from our mistakes.  If everything just worked out of the box, we (CS/IT professionals) would be less necessary. So if something goes wrong in the labs (i.e. commands don’t work, command not found, etc.), research the command and its permissible options and arguments (defined below) and check your spelling and spaces (Linux is case sensitive and it is easy to miss spaces reading Linux commands, options, and arguments).  With this basis, please read the materials with high attention to detail.  If you use a search engine (e.g. Google) to research these commands, please research from an Ubuntu perspective (e.g. Google “Ubuntu Linux” followed by the command ) as there may be minor variations across Linux distributions with the more advanced commands (99.9% of the commands used in these labs will be generic and therefore the same across distributions).

Getting help: Please see the bottom of this presentation for instructions on getting help and the required information/screenshots noting this is our introduction to IT Support/Help Desk functionality.

Linux Command Line Interface (CLI) Introduction

Since this is the first Command Line Interface (CLI) lab I will provide some additional background to supplement the reading and provide clarity.

First, note you will also see or hear the CLI correctly referenced as the “Terminal”, “Shell” or Command Line Interpreter (CLI).  

I may also use the terms Linux and Ubuntu interchangeably as Ubuntu is a Linux variant or distribution.  

Critically important:  Please understand the distinction between a command, option, and argument noting options and arguments are also referenced in the text as parameters (i.e. they vary according to context/need). This understanding is absolutely necessary for both your reading comprehension but also to communicate with me and your classmates.  Linux has predefined commands and options.  A command must be the 1st component of a Shell/CLI command and invokes or executes a program/executable (e.g. ls, cd, pwd, etc.).  Commands may have predefined options to further define the functionality of the command and options are prefaced by a hyphen or minus sign to communicate this to the OS (e.g. in the command “ls -l”, the “-l” option directs the ls command to display a long listing). Arguments are user-supplied and will contain items not pre-identified by Linux.  As an example, below I will ask you to create directories with your name and Linux had no way to know you would be creating a directory with your name so the directory name is an argument. A basic summary: Commands come 1st followed by options and then arguments.

Files and Processes Introduction (very basic introduction)

Everything in Linux is either a process or a file.

A process is an executing program identified by a unique PID (process identifier) and we will cover this later. 

A file is a collection of data and includes both files and directories however, note that Linux also treats other things (actually everything else such as input/output (I/O) devices) as files. This greatly simplifies the programming interface as we (and processes) interact with files, directories, and devices in the same manner (i.e. writing to a file is the same as writing/outputting to a printer, the screen, or even the network).

Basic text files are created by users using text editors or by running compilers that create executable files but also generate “artifact” text files. Examples of text files include; a document (report, essay etc.) or the text (source code) of a program written in some high-level programming language. Executable files contain binary instructions comprehensible directly to the machine or scripts comprehensible to the OS. Directories contain information about their contents, which may be a mixture of other directories (sub-directories) and ordinary files.

Directories (folders in the PC world)

All files are grouped together in the directory structure. The file-system is arranged in a hierarchical structure, like an inverted tree. The top of the hierarchy is traditionally called root and is denoted by the backslash (i.e. /).  Note that the term “root” is also used to denote the “system administrator or super user (su)”.

In the diagram below, we see that the system’s root directory contains 6 subdirectories (bin, dev, home, etc, tmp and usr). These root level directories are restricted for system administration (Sys Admin). The system’s home directory contains the sub-directories bill and patrick which will be the individual user’s home directories.  Note that names within a directory (namespace) must be unique and each  directory is a different namespace meaning files or directories can have the same name as long as they are not in the same directory.  As an example please see that both the bill and patrick directories have a sub-directory titled school.  To disambiguate/differentiate files and directories we often have to provide the file or directory’s full path name where different levels are separated by backslashes. Disambiguate means to uniquely identify files/directories in the namespace where the namespace is all defined names. Using the school sub-directory example, we can distinguish between the school directories by completely specifying /home/bill/school and /home/patrick/school.

General Linux Lab Instructions

To complete each lab you will have to open up a Terminal as you did in LL2a and connect to the HVCC Ubuntu Acadnx server. You will 1st take an Introductory Screenshot to demonstrate your connection to the Acadnx server and capture the time and system state.

Taking a Screenshot and Submitting your Assignment

As in LL2a, for this (and future) assignment(s), you will take periodic screenshots as directed in the exercises (every exercise will have a submission screenshot or more) and paste the screenshots into a  single  LastnameFirstnameLL2b.pdf document, 1 screenshot/exercise per page with the exercise heading number for each screenshot (in future labs you replace the x with the correct LL number… e.g. 3 for LL3, 4 for LL4, 5 for LL5, etc.). Note not every number will have an associated exercise but I need to include numbers to break up the content so that it can be communicated for assistance. Again, please recognize we must learn to follow directions and code conventions/standards with exacting attention to detail to succeed in this discipline so submissions that do not follow the directions/code conventions will require corrections and resubmissions.

In contrast to LL2a, Windows users please use the Windows Snipping Tool to take a screenshot of just the terminal as today’s high-resolution monitors make it too hard to read the small font of the Terminal window when taking a screenshot of the entire monitor.  Windows Snippet Tool instructions here but I also made a quick video of the process below:  https://support.microsoft.com/en-us/help/13776/windows-use-snipping-tool-to-capture-screenshots (Mac users please continue to use command-shift-4 to take a picture of just the terminal)

As in LL2a, you must preface each screenshot with the exercise number as listed in the tutorials so that I know what step the screenshot documents and again, 1 screenshot per page please.  When complete, please save the file in .pdf format and upload this file as directed in the corresponding BB Lecture Module (LMx). Note I will not accept assignments that do not adhere to this single pdf file format with proper screenshot headings 1 per page. (For this lab an example of my file would be LoobyJamesLL2b.pdf).

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

Intro ScreenShot

1. Open or launch your SSH application (e.g. Mac Terminal or Win PuTTy). Please resize your Terminal to make it larger to capture as much as possible but note you may not capture everything and this will be fine. If possible just take a screenshot/picture of your open terminal as if you include other items the text in the Terminal can be very small making it harder for me to see your commands. Paste this screenshot into your correctly named pdf document and label or title this screenshot “Intro Screenshot”.

Linux Lab Typographical Conventions

These tutorials will use the following typographical conventions (and you should return to read these conventions as necessary).

Characters written in bold font are Linux commands and options to be typed into the computer as they stand.

Characters written in italic font  indicate non-specific file or directory names where you will have to submit components or elements specific to you/your environment (i.e. arguments).  As an example, in a future lab you will create a directory with your name however I cannot specify instructions for everyone’s name so I will write  FirstnameLastname.  You will replace FirstnameLastname with your name using the same uppercase/lowercase formatting (recall from the reading that Linux is case sensitive).  As an example; if I was to do this, I would create a directory titled JamesLooby.  

Words inserted within square brackets like [Ctrl] or [Enter] indicate keys to be pressed although square brackets can also denote command options as presented in the reading.

Beware of spaces between commands, options and arguments and this of course means you absolutely must know the difference between Linux Commands that the OS understands, Options that go along with specific Commands and Arguments that the user provides.

To begin please connect to the HVCC AcadNX Ubuntu environment as you did in LL2a.

2.0 Basic Linux CLI Syntax (please research and understand syntax vs semantics).

The $ (dollar sign) will be used as the CLI prompt consistent with our Ubuntu bash instances (Now did you understand everything in that sentence — if not please research what seemed foreign as you may possibly want to Google and research linux bash or Ubuntu bash).

I will repeat this as students continually misinterpret this.  In my examples, I will provide a dollar sign ($) prompt but you should not type the $, only type the commands, options and arguments following the system supplied $ prompt.  Invariably I will get questions from students that include the $ prompt in their commands and get a “command not found” error. Please do not take offense if my response to the question is “please reread the instructions” as we all must learn to read discriminantly for our professional futures.

Note, if your prompt ends in a ‘#’ instead of a ‘$’ you are logged in as a superuser or SU or admin but this is not possible for you in the HVCC AcadNX environment.  This will be possible in your Virtual Machines in LL9 and beyond.

First, let’s type in something that is invalid in Linux so that we can see an error message.  At the command prompt (username@acadnx.hvcc.edu:~$) type in some gibberish and you may choose anything (I will simply provide the $ but you should not type this although that would be gibberish as well)

$ some-error-stuff

Linux will respond, command not found because it is is not one of Linux’s registered commands.  Please read these CLI error messages as they serve to inform and even teach us. Note you will see variations of this in the future if you mistype commands, don’t provide the necessary spacing, options or arguments and always keep in mind that Linux is case sensitive.

Now let’s try a valid command from the Shotts’ text so please type the following again noting the $ sign is the prompt and we are not retyping the $

$ date

I recommend you try all commands in the Shotts text as you read about them but as presented in LL2a a generic ls will not reveal anything as you have not created any files or directories yet. Now press the up-arrow key on your keyboard and you will see the date command appear again.  Press it again and you will see the command you entered prior to the date command.  This alerts you that the Linux CLI or Shell recalls your command history and users/admins will use this functionality to speed up their work.

Linux Lab Typographical Conventions & CLI Syntax Example:

To provide a complete example of our typographical conventions presented above, consider the following complete example:

I may ask you to enter the following.

ls anydirectory # extra info [Enter] 

This means after the Linux prompt dollar sign prompt ($), type the ls command followed by an argument which in this case is the name of some directory.  In this case you will be supplying the name of the anydirectory which at this point does not exist.  To continue the example, I could write ls jameslooby where you will be replacing jameslooby with your name. Now if you entered the above you will receive an error as you have not created a directory called “anydirectory” or “jameslooby”.

The # (pound sign or hash tag) indicates a Linux Comment where everything following the # on a line is ignored by the CLI.  I will use the comment field to present extra descriptive information as necessary.  Note it is not necessary for you to type this comment on the command line beyond the 1st instance to see that it is a comment and ignored by the command line interpreter. As a bit of history, the English Pound Sign £ is not represented on our keyboards so they simply chose the # sign to use in its place.

Lastly, please don’t forget to press the [Enter] key as commands are not sent to the computer until this is done (which of course makes the command execute).  Now note I will assume you know to press the [Enter] key to enter the command so I will largely omit this.

Example for you to try: to demonstrate that this works please enter the following at the terminal prompt:

$ ls -al # gobbly gook

Note that you will have additional information tailored to you before the $ prompt that will include your name and your present working directory or path.  If you received an error you did not type the command and command line options in correctly and this should serve as a lesson.  You should know from the reading that ls is the command and -al are options for the ls command. The -a changes the ls output to be a complete listing (with hidden files that begin with a “.”) and the -l changes the ls output to a long listing which displays full information about the file/directory.

Note there is a space after ls command before -al option.  This is necessary so that the Linux CLI knows where the command ends and the option or argument begins.  The space after the # is irrelevant as it is a comment.  Also note filenames and their extensions cannot contain spaces in contrast to Windows and now consider this with your pdf submission filename format. You will see this in practice if you look at the ciss100.com=> Lecture Modules => Powerpoints as the Powerpoint filenames do not contain a space.

Now type the following and compare the command output to illustrate that the # and what follows it is used to denote a single line comment and has no impact on the command’s output.

$ ls -al #comment is ignored and has no bearing on execution

As you know from your reading, Linux is case-sensitive, so LS is not the same as ls. If you were to type LS you would get an error message since there is not LS command in the CLI or shell (the shell is the Operating System program that recognizes these commands).  The same applies to filenames, so myfile.txt, MyFile.txt and MYFILE.TXT are three separate files. Beware if copying files to a PC, since DOS and Windows do not make this distinction but many programming languages do.  Now to illustrate an incorrect or missing command and ensure that everyone recognizes an error please enter the following.

$ls – al #space between – and al is incorrect as options must immediately follow the ‘-‘

$Ls -al # note some systems will alias ls with LS, Ls etc to improve accessibility

Ok, so we’re learning that we must be very precise with out work as Linux will only accept commands and options it knows and they must be in the precise format.  Should you receive an error message the 1st step is to reread and research the command in question.

Note, having introduced the above typographical conventions, please note that I am working alone without an editorial team that creates textbooks so I will surely have omissions or errors. Now to this extent, please let me know if something is not clear as I will clarify it and we will realize Continuous Improvement consistent with contemporary best practices user-centered iterative IS design. 

2.1 Listing files and directories

First, as presented in the text and in class, 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.

ls (list) – Directory Listing

When you first login, your current working directory is your home directory. Your home directory has the same name as your username and will contain a tilde “~” to indicate it is your home directory. For me this would be  j.looby in the HVCC Ubuntu environment and you would see this in your prompt (for me this is j.looby@acadnx:~$). This home directory is where your personal files and subdirectories are saved.

To find out what is in your home directory, type ls

ls # ls is short for list

To reinforce my conventions above, you should only type ls as the $ prompt is already present and anything following the # is treated as a comment but you know this from your reading.

The ls command lists the contents of your current working directory. Since you have not created any files or directories yet, the files and directories you see(maybe none) 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 do not begin with a dot (.).  Files beginning with a dot (.) are known as hidden files and usually contain important 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 # -a is “all” option, also referred to as a complete listing

ls is an example of a command which can take options and arguments

-a is an example of a command line option. The options are system defined and  associated with commands and change the behavior of the command.  Now to reinforce this,  please read the following as it will give us the correct terminology required for further learning and communication (i.e. you will be required to use the correct terminology to communicate and receive help  with commands, options and arguments) and note it will open in a new window so that you retain you place in this tutorial: Linux Command Structure.

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 type man followed by the command in your Terminal.

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

ls -l # -l option is long listing

Now let’s put two option arguments together:

ls -la #this is a complete long listing and could be entered as $ ls -l -a 

Exercise 2.1

First, 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 create a 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 and omit any apostrophes should your name have an apostrophe).  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 (Again this is always done with directory/file creation/modification and is a requirement from this point on).  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

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.

Navigate to your home directory if necessary and create a file with your initials using touch (for me this would be jgl but you wil need to change this to your initials.).

$ 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. Note you need to perform a listing everytime you create or remove a file or directory to ensure the action was as you intended.

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.

 

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.

Below are the commands used in this lab so please be sure you understand them. Also please be sure you know the difference between a command, option and argument and relative and absolute paths.

Lastly, please use the ls command frequently.  I often type ls after every cd, cp, mv, mkdir command to verify what took place.  Below the table is a video that may help as well.

CommandDescription
cdchange directory
cd ..change directory to the parent directory (i.e. go up one level)
cd or cd ~change to home directory
lslist files and directories
ls -alist all files and directories - note -a is an option
ls -llist complete information for files and directories
mkdirmake a directory
pwddisplay the path of the current directory
rmremove a file
rmdirremove a directory
ln -screate a symbolic link
touch create an empty file
clearclears the CLI

Getting Help From Faculty

We begin to specifically learn about the IT Support/Help Desk technology and its process.  Help Desk is very difficult as lay people rarely know how to communicate their issues and rarely communicate complete and accurate information as is required to solve issues.  We are now IT professionals so we must support this process in an exemplary fashion.

To get help, We need to see exactly what you are doing and where.  With this basis,  we need to know your platform and how you’re connecting to AcadNX,  exactly which exercise you are on and we will need comprehensive screenshots of long listings for all relevant directories and file contents.  Additionally, the emails must be in accord with the email format requirements (ciss100.com => Lecture Module 1 => Contacting your Professors).

Please note when working in Linux, we use many ls commands whenever working with files (and directories) as this lets us see what is going on.  With this basis you should be performing a ls whenever you create, modify or delete a file or directory.

LL2b Help Recording

Please note the following are some examples but it is not me reproducing LL2b so please do not submit any of the recorded examples.