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.
- Use echo $HOME to determine your home directory.
- 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)
- 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)
- 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.)
- Place the du results into file2.
- Create a subdirectory called assnfile .
- Copy file1 and file2 into this assnfile directory from your home directory. (cp file1 assnfile and cp file2 assnfile)
- 7.a Create a link for each file. Name the links
linkToFile1 and linkToFile2 (cd assnfile; ln
file1 linkToFile1; ln file2 linkToFile2)
- Copy file2 to file2a in the same assnfile folder. (cp file2
file2a )
- Use ls –l to see permissions
- 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)
- Use vi linkToFile2 to change
anything inside the file.
- Use vi your file2 name and see
the file was changed.
- Remove your file2 and see that the
linkToFile2 still has the same file contents. (ls –l to verify)
- Recreate file2 as a new file, not
linked from your old linked file. cp
linkToFile2 file2
- Copy file2 to file2copy.
- 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.
- Use diff between file2 and file2copy
to see the differences. (diff
file2 file2copy)
- Use diff between file2 and file2copy and place the
results into diffFile. diff
file2 file2copy > diffFile
- Use the uniq command on
file2copy and see that the duplicated line is not in the output (uniq fiile2copy
- 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.
- 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
- Use tar to zip your assnfile folder. use ls to
display and see assnfile and then tar -c -f hwk.tar assnfile
- Use tar commands to verify that you
zipped all the files you meant to zip. tar tvf hwk.tar
- Use filezilla to transfer the
tar file to your own computer.
- Upload the tar file to moodle.