Objective: Becoming familiar with simple commands including cd, pwd, ps, cat as well as transferring files between two systems. Remember, the best way to learn about what a command can accomplish is by using the man command. For example, man ps will show that this command can be used to print out current processes.
Create a cs160a directory in your home directory on hills and keep your file structure organized by creating a directory asmt01 under it and then another directory part1 under asmt01. Your tree structure could look like the following:
[grwoo@agnes ~]$ tree cs160a cs160a |-- asmt01 |-- part1
You can practice this part of the assignment before starting a script session. Remember:
mkdir part1
creates a directory and:
rm -r part1
removes a directory.
It is very easy to use cat to create a file. You simply redirect stdout to a file using the > operator. To create (or overwrite) a file named test, you can do:
cat > test
Now cat will read lines from stdin (which you redirected to the file test using the above command). Now, you can type anything you want. When you are finished typing, hit enter (or return) and then use a ^D(control-D) to end the file and return to the $ prompt. You have created the file test.
You can quickly show the contents of the file test by doing:
cat test
Start in your home directory. You should have a cs160a/asmt01 directory, but asmt01 should not have a part1 directory in it. Perform the following sequence in order. Use step markers so that your assignment is easy to follow. You will be graded on how clean your script file is and step markers are very helpful for that.
Start script to record the session in a file. You can just let it use the default name typescript. We will change it to the final name later.
[Enter the step marker first, as with the remaining steps]. Then use commands to go to the cs160a/asmt01 directory, then create the new part1 directory and go to it. Finally, use the command to show what directory you are in and list the contents of the current directory. Stay in the part1 directory for the rest of this Part One
Now use cat to create the file linux. Then type in the answer to the question "What's one thing that already annoys you about the Linux shell?". Your answer must consist of multiple lines of text. Don't forget to break your own lines. You must type ENTER (or return) at the end of the line for it to redisplay correctly later. Signal the end-of-file by carefully typing in ^D. Then list the contents of the current directory and use cat to redisplay the contents of the file linux.
Create a file named pinky.txt that contains the output of the command pinky -l xxx where xxx is your hills login (such as jdoe123) and the option is a lower-case L. (Hint: use cat to redirect the output of the command to pinky.txt) Again, list the directory when you are done and redisplay pinky.txt with cat.
Append the pinky.txt file to the linux file. Then display the resulting linux file.
Execute the command cat linux | wc -l (that's lower-case L). Can you interpret the output? Type a comment into your script session with your answer.
Rename the linux file to aboutme. Then list the current directory. Then, copy aboutme to your home directory and list your home directory.
Exit script. After exiting script, cat the script output file to ensure it is readable, then rename it to asmt01p1.script
You have now created the following directories and files in your home directory: cs160a, cs160a/asmt01, cs160a/asmt01/part1. Check the result asmt01p1.script
Find out what the course Slack channel is from your peers and either ask or answer a UNIX/LINUX related question. Make sure to use your CCSF username so that I can give you points for this part.
For this assignment, you will copy an entire tree directory structure to your area and operate on it according to the instructions. Make sure you keep in mind the visualization of your directory tree structure. It might be helpful to run through this exercise a few times before starting your script session
It is essential when using Linux at the command-line that you know where you are in the file structure. Once you login to the Linux machines, you can use the installed binary tree to draw out visualizations of the directory file structures. Download part3 using either of the following commands:
Grab part3 using wget and unzip or from the public course area
cp -r /pub/cs/grwoo/cs160a/asmt01 .
Copy all the JPEG image files from the images directory to the personal directory. Then, use a second command to list the personal directory with attributes (a long listing with the options -ls -l).
List the attributes (ls -l) of each file in the resumes directory whose name starts with by
Move all the files in resumes/old to the resumes directory. Then, using a second command, delete the empty resumes/old directory. Finally (with another command), list resumes.
Move all the files in all subdirectories of reports to the reports directory. Then in a second command, remove all the empty subdirectories of reports.
List all the files in the tmp directory whose name starts witha n uppercase character.
List all the files in the tmp directory whose name contains a character that is not ASCII
Delete all the files in the tmp directory whose name contains a character that is neither a letter nor a number. Then, using a second command, list the tmp directory.
List the part3 directory recursively, adding the option to mark directories. Then exit script
Redo this part until you reduce the number of mistakes. Don't forget to delete your part3 directory completely between attempts.
Rename the script output file to asmt01p3.script when you are finished. After examining it, transfer it to your local machine and upload to Canvas