Name:
Using your browser, save a copy of http://andersje.github.io/corporate-linux-admin/labs/lab2.datafile into your /tmp directory. Using that datafile, you can complete all questions on this worksheet. Write the correct answer after each question.
- using grep, pick out all the lines containing 134.29 from the sample file:
- Invert the answer to the above question. That is, pick out all the lines which do NOT contain 134.29
- Now display all lines which contain the word server:
- Now display all lines which contain the word work:
- Now display all lines which contain the word workstation:
- If the answers to #4 and #5 did not produce the same result, explain why:
- Using a pipe, alter the answer to #5 such that it is sorted by the first column
- Using a pipe, alter the answer to #5 such that it is reverse sorted numerically (that is, 5 would come before 4) by the third column
- remove all duplicate entries from the answer to the previous question:
- Use awk to display the first two columns of data from the datafile:
- Modify the answer to the previous question such that it is sort by the first column:
- Modify the answer to the previous question such that all duplicates are removed, and results are stored in a file named "number12.txt":
- Now, use the wc command to determine how many lines of data are produced:
- Now, use the wc command to print ONLY the number of lines of data are produced:
- How many lines of data were produced?
- Show the command to find all files on the system which are sockets (type s):
- Show the command to find all files on the system owned by user jeremy:
- Alter the above question so that all error messages are discarded:
- Alter the answer from the previous question so that the results are redirected into the file /tmp/jeremy.out:
- Alter the answer from the previous question so that all error messages are redirected into the file /tmp/jeremy.err:
Extra Credit
- Show the single command that will remove all 'other' permissions from all files and directories under /home, and won't affect ANY user or group permissions:
- (3 points) A coworker comes to you, and shows you this command:
grep apsrp hostlist.txt | sort -u | grep -v 2235 hostlist.txt
They complain that the output contains many things which do not contain "apsrp". Why is that?