Advertisement
Guest User

Untitled

a guest
Jun 19th, 2017
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.32 KB | None | 0 0
  1. 1. The man pages can be found in /usr/share/man/ . The files for the man pages pertaining to a program can be found in man1/ and are compressed using gzip. Do the following exercises:
  2. a. Copy all the man pages that pertain to md5 to a new directory in ~.
  3. mkdir assignment4
  4. cd /usr/share/man/man1
  5. cp md5sum.1.gz ~/assignment4
  6. cp md5.1ssl.gz ~/assignment4
  7. cp md5sum.textutils.1.gz
  8. b. Extract the files using gunzip.
  9. gunzip md5sum.1.gz
  10. gunzip md5sum.textutils.1.gz
  11. gunzip md5.1ssl.gz
  12. c. Search all the files for any lines pertaining to "passin". List the line numbers and file names for any matches. What is "passin"?
  13. cat -n * | passin
  14. 144 [\fB\-passin arg\fR]
  15. 181 .IP "\fB\-passin arg\fR" 4
  16. 182 .IX Item "-passin arg"
  17. passin is an arguement
  18. 2. You know there is an important file in /etc that contains a reference to the ethernet card. The name of the card is "eth0" in standard Unix-like distros. List all the filenames in /etc and all its subdirectories that contain any mention of "eth0".
  19. cd /etc/
  20. grep -cr "etc0" * | grep -v [:][0]
  21.  
  22. avahi/avahi-daemon.conf:1
  23. byobu/statusrc:1
  24.  
  25. 3. The ps command outputs a list running processes. We will examine this command in further detail, but for now just know that the "-e" flag prints all currently running processes.
  26.  
  27. a. Use ps -e in combination with grep to get a list of all currently running terminal processes. (Note that by default the 'X' terminal runs on terminal 7.) You will need to figure out a good regex to use.
  28. ps -e | grep tty
  29. b. How many "daemon" processes are running? What are their names?
  30. 7 processes
  31. dbus-daemon
  32. avahi-daemon
  33. avahi-daemon
  34. dbus-daemon
  35. rtkit-daemon
  36. udisks-daemon
  37. udisks-daemon
  38. c. What are the "PID"s (Process ID) for these daemon processes? Which column do you think is the PID? It seems odd that there is no headers to the columns when you pipe the command to grep... why do you think that happens? Could you modify your regex to somehow fix that?
  39.  
  40. If you ps -e then the headers show up because its the ful command. If you grep you are only searching for certain files. You can grep the first field to solve this.
  41.  
  42. 4. The next portion of the assignment requires you to interact with your /etc/passwd file. You may need to use the "sudo" command to access it. If you work from ~ and use absolute paths to /etc and output using relative paths, you can minimize the risk of damaging your installation.
  43. a. Use the "cut" command on your /etc/password file to extract all the usernames. Sort them in alphabetical order.
  44. cut -d: -f1 /etc/passwd | sort
  45. b. How many of the users contain the word "daemon"?
  46.  
  47. cut -d: -f1 /etc/passwd | sort | grep daemon
  48. c. Use the cut command to extract the default shell of each user. How many use "bash"? How many use "null"? How many use "sh"? How many use "false"?
  49.  
  50. cut -d: -f7 /etc/passwd | sort | grep bash 3
  51. cut -d: -f7 /etc/passwd | sort | grep null 0
  52. cut -d: -f7 /etc/passwd | sort | grep false 12
  53. cut -d: -f7 /etc/passwd | sort | grep sh 18
  54. 5. Find your .bash_history file. It should be in ~. If you do not find one or have one (which I find highly unlikely) email me and one will be provided.
  55. a. How many lines are their in the file?
  56. 169 lines
  57. b. How many times have you used the "grep" command? The "sort" command? The "cut" command? How many variations of the "ls" command have you used (different set of flags is a variation). Note that there are certain flags you can append to "sort" to remove duplicates.
  58. cat .bash_history | grep -c grep 11
  59. cat .bash_history | grep -c cut 0
  60. cat .bash_hostory | grep -c ls* 73
  61. cat .bash_hostory | grep -c sort 0
  62.  
  63. c. What is the three most common first, second, and third arguments you used in your commands?
  64. cat .bash_history | grep -o [-][Aa-Zz]* | sort -d | uniq -c | sort -nr
  65.  
  66. 6 -cr
  67. 5 -e
  68. 3 -a
  69. d. How many different commands have you read the man pages for? What are they, in alphabetical order?
  70. grep ^man .bash_history | sort -d | uniq -c | cat -n
  71. I have 10 man page lookups
  72. man ~$, alias, cd, cron, free, init, init.d, man, nano, unalias
  73. 6. Create a compressed archive called assignment_4_<yourname>.tar.gz that contains the following:
  74. a. A file containing your answers to questions 1-5 called "answers".
  75.  
  76. b. A file containing all important commands you used to complete these questions called "commands".
  77. c. Your .bash_history file. Rename it to "bash_history" (no period).
  78.  
  79. Good luck!
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement