CS534 Operating Systems - Lab 1

Using basic commands

From your home directory (/home/your_user_name), create a subdirectory called cs534lab1...do not change to the cs534lab1 directory at this time.

Run the pwd utility to determine the path to your home directory and make note of the path.

Use the man pages to look up the following:

  1. Redirect the information found in these man pages to a file in your home directory called manstuff.txt. NOTE that manstuff.txt should contain ALL the information from all the above man pages in ONE file. Use the append feature to accomplish this task.
  2. Again, use the pwd command to display your current position in the file structure. Use the appropriate command to move to the / directory.
  3. Do a directory listing of the / directory and display ALL files and directories. Redirect the output of the directory listing to a file in /home/your_user_name directory called rootdir.txt
  4. Return to your home directory. Use the cat utility to view rootdir.txt.
  5. Use the less utility to view rootdir.txt.
  6. Create a copy of rootdir.txt in your home directory and name the file rootdir1.txt. Run a directory listing to make sure that the file exists.
  7. Using vi, open rootdir1.txt and ADD three bogus file entries to the bottom of the file listing in the same format as any other file entry in the directory listing
  8. Use the diff utility to display the differences between rootdir.txt and rootdir1.txt to the screen. Run diff against the same set of files and redirect the output to a file in your home directory named differences.txt
  9. Use the file utility to display information about rootdir.txt and rootdir1.txt to the screen. Run file against the same set of files and redirect the output to a file in your home directory named fileinfo.txt
  10. Use the head command to display the first 15 lines of the file manstuff.txt
  11. Use the tail command to display the last 15 lines of the file manstuff.txt.
  12. Perform the previous two steps again and redirect the output of both runs to a single file called headtail.txt that will be located in your home directory.
  13. Create a subdirectory under the cs534lab1 directory called tester.
  14. Copy manstuff.txt, rootdir.txt, rootdir1.txt, differences.txt, fileinfo.txt, and headtail.txt to the tester directory, and the cs534lab1 directory. Change to the tester subdirectory. Attempt to delete the tester directory and its contents while in the tester directory. Were you successful? No. Why? Change to the cs534lab1 directory and attempt to delete the tester directory WITHOUT using any switches. Were you successful? No. Why? Delete all the files in tester directory, THEN delete the tester directory from a directory at least one level above tester in the tree.
  15. Recreate the tester directory under the cs534lab1 directory, then copy the same files you copied before to tester. Remain logged in to the cs534lab1 directory. Use the appropriate command/switch combination to delete the tester directory and its contents at the same time. CAUTION: make sure that you delete tester and the files contained in tester ONLY!
  16. Run the ls –la command on the cs534lab1 directory and make a note of the file permissions of the files contained in that directory. Use the chmod command to add read and write permissions to group for the file headtail.txt
  17. Run the ls –la command on the cs534lab1 directory again and redirect the output to a file called permission1.txt located in cs534lab1. Use the chmod command to grant read and write permissions to other for the file permissions1.txt.
  18. Use the ls –la command on the cs534lab1 directory and redirect the output to a file called allfiles.txt located in cs534lab1. Use the chmod command to grant read only and execute permissions to group for the file allfiles.txt.
  19. Create a tarball (a gzipped tar file) named cs534_yourfirstname_yourlastname_lab1.tgz in your cs534lab1 directory. The compressed archive will include ALL of the files that are in your cs534lab1 directory. Use the following command to create the tarball:

tar cvzf filname.tgz *

Where: c means create an archive

               v means give a verbose listing of the files as the archive is created

               z means gzip the archive

               f stands for the filename that contains the archive

NOTE 1: Make sure that there is ONE SPACE character between the z in .tgz and the * (asterisk) that follows

NOTE 2: A dash (-) preceding the options to the tar command IS NOT REQUIRED. Including the dash will not hurt...it just won't add any functionality.

NOTE 3: The order of the options given to the tar command is important. The c MUST be first and the f MUST be last.

NOTE 4: It will be helpful to be IN the cs534lab1 directory when you create the tarball...if not, you'll have to provide a path to the files that will be included in the tarball.

NOTE 5: You can view the contents of the tarball without extracting the files from it. This feature can come in VERY handy. The command is:

tar -tzvf filname.tgz

Where:  t means list all files in the archive

               z means gunzip the archive

     v means give a verbose listing of the files

               f stands for the filename that contains the archive

At the appropriate time you will be instructed on how to deliver the lab to the instructor for evaluation whether you are working in the lab or at home.