520 likes | 720 Views
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
E N D
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? 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
2 • 2) What Unix command will list the home directories for all of the students in this class?
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}’
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)?
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
4 • 4) Where should you add an alias to make sure it is available anytime you log in to a Unix system?
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
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?
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
6 • 6) If you forget your password on a Unix system, who can recover it for you?
6 • 6) If you forget your password on a Unix system, who can recover it for you? • No one!
7 • 7) What command will show you the last ten commands that you entered?
7 • 7) What command will show you the last ten commands that you entered? • history • history | tail 10 • history 10
8 • 8) What command will list your aliases?
8 • 8) What command will list your aliases? • alias
9 • 9) What command will show you how long a Unix system has been running (i.e., since its last reboot)?
9 • 9) What command will show you how long a Unix system has been running (i.e., since its last reboot)? • w • uptime
10 • 10) What does the command “chmodugo+x filename” do?
10 • 10) What does the command “chmodugo+x filename” do? • Gives everyone execute permission to the file named filename
11 • 11) How do you exit display of a man page?
11 • 11) How do you exit display of a man page? • q
12 • 12) What Unix command would you use to count the words (i.e., just the words) in the /etc/motd file?
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
13 • 13) What Unix command will show you whether Apache is running on a Unix system?
13 • 13) What Unix command will show you whether Apache is running on a Unix system? • ps –ef | grep apache • ps –ef | grep http
14 • 14) What command will count the number of Apache processes running on a Unix system?
14 • 14) What command will count the number of Apache processes running on a Unix system? • ps –ef | grep apache | wc -l
15 • 15) Who can add files to the /tmp directory on vader?
15 • 15) Who can add files to the /tmp directory on vader? • Everyone!
16 • 16) What does the command ps -ef | awk '{print $1}' | sort | uniq –c do on a Unix system?
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
17 • 17) Write a Unix script that will loop through each argument provided
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
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
18 • 18) A case statement ends with what keyword?
18 • 18) A case statement ends with what keyword? esac
19 • 19) What error do you get if you mistype the shebang line in a bash script?
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
20 • 20) What does an exit command with an argument (e.g., exit 1) indicate?
20 • 20) What does an exit command with an argument (e.g., exit 1) indicate? The script exited with some type of error condition
21 • 21) What variable can be used to display the name of a script from within the script?
21 • 21) What variable can be used to display the name of a script from within the script? $0
22 • 22) What does x*) ls ~/bin;; do in a case statement? Explain the entire line.
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
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?
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
24 • 24) What does an if command end with?
24 • 24) What does an if command end with? fi