File System homework:

You are going to use various commands to accomplish the following: Note that I have command hints, but  not all the commands have hints.

  1. Use echo $HOME to determine your home directory.
  2. Echo $HOME once more and redirect the output into a file named file1. (Remember that >  redirects the output to the filename that follows the >. so type: echo $HOME > file1)
  3. Show all the characters in file1 uppercase by using the tr translate command. type: tr a-z A-Z < file1 (though it should also work as tr [a-z] [A-Z] < file1) 
  4. Use du to find out how many disk blocks your home directory, its files and its subdirectories and their files use. (du alone is only the directories. du * gives all subdirectories and their contents. Use info du for more options.)
  5. Place the du results into file2.
  6. Create a subdirectory called assnfile .
  7. Copy file1 and file2 into this assnfile directory from your home directory. (cp file1 assnfile and cp file2 assnfile)
    1. 7.a Create a link for each file. Name the links linkToFile1 and linkToFile2 (cd assnfile; ln file1 linkToFile1; ln file2 linkToFile2)
  8. Copy file2 to file2a in the same assnfile folder. (cp file2  file2a  )
  9. Use ls –l to see permissions
  10. Make a listing of all filenames with the number 2 in it, and place those results into file3. Verify that file3 has you (owner) with read permission and your group and the rest of the world with no permission. (ls –l to verify permissions)
  11. Use vi linkToFile2 to change anything inside the file.
  12. Use vi your file2 name and see the file was changed.
  13. Remove your file2 and see that the linkToFile2 still has the same file contents. (ls –l to verify)
  14. Recreate file2 as a new file, not linked from your old linked file. cp linkToFile2 file2
  15. Copy file2 to file2copy. 
  16. Use Vi to change one line in file2copy and to remove another line and duplicate one other line and add yet one more line. The duplicated line should be right underneath the line it duplicates.
  17. Use diff between file2 and file2copy to see the differences. (diff file2 file2copy)
  18. Use diff between file2 and file2copy and place the results into diffFile. diff file2 file2copy > diffFile
  19. Use the uniq command on file2copy and see that the duplicated line is not in the output (uniq fiile2copy
  20. Use comm between file2 and file2copy (both sorted) with the 3 column options (-1,-2 and -3) to see which one gives only the new and changed lines in the file2copy, and then write that to commFile. comm <(sort file1) <(sort file2) > commFile (Note that this creates a file called commFile that will contain the differences.
  21. Create a shell script named file4maker that will place the results of ls into file4 and then rename file4 to file4r. chmod +x so that it is executable, and then use ./file4maker to run the script. When you are done, your file4r should exist.  chmod +x file4maker
  22. Use tar to zip your assnfile folder.  use ls to display and see assnfile and then  tar -c -f hwk.tar assnfile
  23. Use tar commands to verify that you zipped all the files you meant to zip. tar tvf hwk.tar
  24. Use filezilla to transfer the tar file to your own computer.
  25. Upload the tar file to moodle.