1 / 52

Quiz 4 Review

CSI 135. Quiz 4 Review. 1. 1) What Unix command will display information about your account only from the passwd file ?. 1. 1) What Unix command will display information about your account only from the passwd file ?. p asswd –s awk –F: ‘{print $20}’ /etc/ passwd w hoami

ollie
Download Presentation

Quiz 4 Review

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. CSI 135 Quiz 4 Review

  2. 1 • 1) What Unix command will display information about your account only from the passwd file?

  3. 1 • 1) What Unix command will display information about your account only from the passwd file? passwd –s awk –F: ‘{print $20}’ /etc/passwd whoami grep ^csi135b26 /etc/passwd grep –w ‘$USERNAME’ /etc/passwd grep $USER /etc/passwd grep ^csi135b26 /etc/passwd grep ^$USER /etc/passwd

  4. 2 • 2) What Unix command will list the home directories for all of the students in this class?

  5. 2 • 2) What Unix command will list the home directories for all of the students in this class? $ ls ~ / grep csi135b* $ grep ^csi135b /etc/passwd $ who $ cat /etc/passwd | grep ^csi135b $ awk –F: ‘{print $6}’ /etc/passwd $ ls $ ls /u/students/fall10/csi135 | grep b $ grep ^csi135b /etc/passwd | awk ‘{print $6}’

  6. 3 • 3) What Unix command will list the files in your home directory in time order (i.e., with the most recently modified files listed last)?

  7. 3 • 3) What Unix command will list the files in your home directory in time order (i.e., with the most recently modified files listed last)? $ ls -ltr

  8. 4 • 4) Where should you add an alias to make sure it is available anytime you log in to a Unix system?

  9. 4 • 4) Where should you add an alias to make sure it is available anytime you log in to a Unix system? • ~/.bash_profile • Or .bashrc

  10. 5 • 5) If you add conflicting definitions for $MYBIN to the ends of your .bash_profile and .bashrc files on vader, which will be in effect when you’re fully logged in?

  11. 5 • 5) If you add conflicting definitions for $MYBIN to the ends of your .bash_profile and .bashrc files on vader, which will be in effect when you’re fully logged in? • Those defined in .bash_profile

  12. 6 • 6) If you forget your password on a Unix system, who can recover it for you?

  13. 6 • 6) If you forget your password on a Unix system, who can recover it for you? • No one!

  14. 7 • 7) What command will show you the last ten commands that you entered?

  15. 7 • 7) What command will show you the last ten commands that you entered? • history • history | tail 10 • history 10

  16. 8 • 8) What command will list your aliases?

  17. 8 • 8) What command will list your aliases? • alias

  18. 9 • 9) What command will show you how long a Unix system has been running (i.e., since its last reboot)?

  19. 9 • 9) What command will show you how long a Unix system has been running (i.e., since its last reboot)? • w • uptime

  20. 10 • 10) What does the command “chmodugo+x filename” do?

  21. 10 • 10) What does the command “chmodugo+x filename” do? • Gives everyone execute permission to the file named filename

  22. 11 • 11) How do you exit display of a man page?

  23. 11 • 11) How do you exit display of a man page? • q

  24. 12 • 12) What Unix command would you use to count the words (i.e., just the words) in the /etc/motd file?

  25. 12 • 12) What Unix command would you use to count the words (i.e., just the words) in the /etc/motd file? • wc –w /etc/motd

  26. 13 • 13) What Unix command will show you whether Apache is running on a Unix system?

  27. 13 • 13) What Unix command will show you whether Apache is running on a Unix system? • ps –ef | grep apache • ps –ef | grep http

  28. 14 • 14) What command will count the number of Apache processes running on a Unix system?

  29. 14 • 14) What command will count the number of Apache processes running on a Unix system? • ps –ef | grep apache | wc -l

  30. 15 • 15) Who can add files to the /tmp directory on vader?

  31. 15 • 15) Who can add files to the /tmp directory on vader? • Everyone!

  32. 16 • 16) What does the command ps -ef | awk '{print $1}' | sort | uniq –c do on a Unix system?

  33. 16 • 16) What does the command ps -ef | awk '{print $1}' | sort | uniq –c do on a Unix system? Shows the number of processes being run by each user

  34. 17 • 17) Write a Unix script that will loop through each argument provided

  35. 17 • 17) Write a Unix script that will loop through each argument provided #!/bin/bash for n in $* do echo $n is a cool argument done

  36. 17 • 17) Write a Unix script that will loop through each argument provided #!/bin/bash for n do echo $n is a cool argument done

  37. 18 • 18) A case statement ends with what keyword?

  38. 18 • 18) A case statement ends with what keyword? esac

  39. 19 • 19) What error do you get if you mistype the shebang line in a bash script?

  40. 19 • 19) What error do you get if you mistype the shebang line in a bash script? -bash: ./t1: /bin/bashy: bad interpreter: No such file or directory

  41. 20 • 20) What does an exit command with an argument (e.g., exit 1) indicate?

  42. 20 • 20) What does an exit command with an argument (e.g., exit 1) indicate? The script exited with some type of error condition

  43. 21 • 21) What variable can be used to display the name of a script from within the script?

  44. 21 • 21) What variable can be used to display the name of a script from within the script? $0

  45. 22 • 22) What does x*) ls ~/bin;; do in a case statement? Explain the entire line.

  46. 22 • 22) What does x*) ls ~/bin;; do in a case statement? Explain the entire line. If argument being evaluated starts with “x”, list the files in the user’s bin directory

  47. 23 • 23) What commands might you use to prompt a user to enter a number and then read the number entered in a bash script?

  48. 23 • 23) What commands might you use to prompt a user to enter a number and then read the number entered in a bash script? echo –n “please enter a number> “ read number

  49. 24 • 24) What does an if command end with?

  50. 24 • 24) What does an if command end with? fi

More Related