CPS393 u1Lab: commands: cd, cat, ls, pwd, cp, mkdir, mv, vim, chmod, touch ------------------------------------ Part 1 ------------------------------------ 1. Move around directories, list entries in directories, and verify current directory using: cd, ls, pwd commands as follows: Move into your home directory: cd Move into the course directory: cd /usr/courses/cps393/dwoit/ List the entries there: ls Change into the labs directory cd labs List the entries there: ls Change into the first lab cd u1Lab List the entries there: ls Change back into your HOME directory: cd Move back-and-forth between your home directory and the previous directory (/usr/courses/cps393/dwoit/labs/u1Lab) by using the following command over and over: cd - Each time you change directories, verify you are in the correct directory by using the following command: pwd 2. Use mkdir to create directories as follows: Move into your home directory: cd Verify you are there: pwd Make directory cps393: mkdir cps393 Verify it was created: ls Move into dir cps393: cd cps393 Verify you are there: pwd Make dir labs: mkdir labs Verify it was created: ls Move into dir labs: cd labs Make directories for the first 4 labs: mkdir vimLab u1Lab u2Lab u3Lab Verify they were created: ls 3. Use mv and cp: When you did vimLab, you copied file vimTutorial.txt from /usr/courses/cps393/dwoit/labs/vimLab/ to your home directory and modified it with vim. Move your own vimTutorial.txt file from your home directory into your vimLab directory: Move into your home dir: cd Verify vimTutorial.txt is there: ls (If vimTutorial.txt isn't there, do 4.1 below before continuing) MOVE it into vimLab dir: mv vimTutorial.txt cps393/labs/vimLab/ Verify it moved there: ls cps393/labs/vimLab/ Copy myInfo.txt (the file you created for vimLab) from your home directory to your cps393/labs/vimLab/ directory, and verify file is in both dirs: Verify myInfo.txt is in home dir: ls (If myInfo.txt isn't there, do 4.2 below before continuing) COPY it into vimLab dir: cp myInfo.txt cps393/labs/vimLab/ Verify it is in both dirs: ls myInfo.txt cps393/labs/vimLabs/myInfo.txt 4.1. Only do this if you need to, as per 3 above. In the vimLab, you were supposed to create a copy of vimTutorial.txt in your home directory. But if it's not there now, then either you didn't do vimLab (so go and do it first before continuing on with 3 above), or you copied the file into the wrong directory. Try to find it by using cd and ls (or tree) to hunt around your filetree. Then use mv to move it from wherever it is into your home directory. If you can't locate your file, then just copy the original into your home directory first, before continuing on with 3 above: cd cp /usr/courses/cps393/dwoit/labs/vimLab/vimTutorial.txt . 4.2. Only do this if you need to, as per 3 above. In vimLab, you were supposed to create a file named myInfo.txt in your home directory. If it's not there now, either you didn't do vimLab (so go do it before continuing with 3 above), or you created it into the wrong directory. Try to find it as above, and use mv to move it from whereever it is into your home directory. If you can't locate it, then re-do the creation of myInfo.txt from vimLab now before continuing on with 3 above. 5. Look at the man page for the ls command: man ls Find an option of the "ls" command that lists directory contents so that color is used to distinguish file types. Find an option of the "ls" command so that directory names are listed with a trailing / character. Remember: when in a man page, "space bar" goes down a page, "b" goes back up a page, "enter" goes down one line, "/abc" searches for the string "abc", "n" searches for the next occurrence of the string you searched for last, "q" quits the man page. ------------------------------------ Part 2 ------------------------------------ You will create a file for most of the following questions. Files are named: u1Labq0X where X is the question number (e.g., u1Labq02). All these files should be under your cps393/labs/u1Lab/ directory. 1. Move into your cps393/labs directory From within labs, do the ls command with the option you found above to list in color. Use output redirection (the ">" character) to capture the output of this ls command into a file named u1Labq01 cat the file. Depending on the ls option you used, you might see the colors when you cat the file, or not. 2. Use chmod to change some permissions on your files/dirs as follows: file vimLab/myInfo.txt permissions rw- for user, --x for group, and --- for other. directory labs permissions rwx for user, r-x for group, and --- for other. Use the mouse to copy and paste the actual commands you used into file u1Labq02: If you're using putty, copy-paste like this: -"select" whole ls command with the mouse so it's highlighted (this is putty's "copy") -vim u1Labq02 -open a new line: o -right-click mouse (this is putty's "paste" ) -press escape a couple of times -:wq to save and exit If you are not using Putty, then do the above, except copy-paste as usual (typically by selecting from a context-menu). 3. Move into your home directory and verify you're there. From within your home directory, use the ls command to get a long listing for myInfo.txt in vimLab, and for labs as follows: Specify myInfo.txt using an ABSOLUTE path name. Specify labs using an RELATIVE path name. (hint: .. goes up a directory) Your command should look like the following (with ### replaced appropriately)": ls -ld ######myInfo.txt ######labs Copy the actual ls command you used into file u1Labq03 as above. 4. Use output redirection (the ">") to capture the OUTPUT from your ls command from question 3, and save it into file u1Labq04 5. In your home directory, create a directory named Inv, and inside Inv create a file named F that contains at least 3 lines. What are the minimum owner (your) permissions on Inv and F that allow you to display the contents of F, AND allow you to see F in a listing of Inv. i.e., "ls Inv" lists F and "cat Inv/F" displays contents of F. Answer in u1Labq05 6. Give a sequence of commands that will help you determine if the first 3 lines of file F are identical to the last 3 lines of file L. Use head, tail, diff. Answer in u1Labq06 ------------------------------------ Part 3: Submit ------------------------------------ 7. In your home directory, create a directory named ABC containing 3 directories, (DEF, GHIJ, KL) and 4 files (f1, f2, f2, f4) organized into the following filetree. > cd > tree -F ABC/ ABC/ ├── DEF/ │   ├── f1 │   ├── f2* │   └── f3 └── GHIJ/ ├── f4 └── KL/ 3 directories, 4 files > Give f2 execute permissions (so that tree -F appends "*"). Into a file named u1Lab/u1Labq07 type the exact commands you used to create the filetree and change permissions, one command per line. The TA should be able to reproduce the filetree by typing in the commands from your u1Labq07 file in the order given. After doing so, they should get the same filetree as above when they type: tree -F ABC/ Submit u1Labq07 by the due date.