Final Review Flashcards

(100 cards)

1
Q

What command would you use to keep a record of every command you type and the output of those commands?

A

script

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What key would you press to get the last command you typed?

A

up arrow

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What keys would you hit to go to the beginning of the command line?

A

Control A

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

How do you abort a running program?

A

Control C

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What would you type at the command line to get the man page for the ls command?

A

man ls

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

If you wanted to use one of the characters that have special meaning to Unix in a filename, what TWO things could you do?

A

put a backslash in front of it or quote it

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What would you type on the command line if you wanted to go to the directory /home?

A

cd /home

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What would you type at the command line to delete the file named memo.txt?

A

rm memo.txt

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What would you type at the command line to copy the file named memo.txt to memo.bak?

A

cp memo.txt memo.bak

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What would you type at the command line to move the file named memo.txt into the directory named work?

A

mv memo.txt work

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What would you type at the command line if you wanted to see the value of the variable SHELL?

A

echo $SHELL

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

If you started typing the name of a file on the command line and wanted Unix to supply the rest, what would you do?

A

hit the Tab key

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What would you type at the command line if you wanted to find all lines in the file results.txt that contained the word “homework”?

A

grep homework results.txt

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What would you type at the command line if you wanted to find all lines in the file results.txt that DID NOT contain the word “homework”?

A

grep -v homework results.txt

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What would you type at the command line if you wanted to see all the lines in numbers.txt sorted in REVERSE NUMERIC order?

A

sort -nr numbers.txt

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

If you saw the following prompt, what is your CURRENT DIRECTORY?

it244gh@vm75:/courses/it244/s19/ghoffman$

A

/courses/it244/s19/ghoffman

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

What would you type at the command line if your wanted to find all lines in the file red_sox.txt that had the word “Win”, but NOT the word “Rays”?

A

grep Win red_sox.txt | grep -v Rays

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

What would you type at the command line if your wanted to find all lines in the file red_sox.txt that had the word “Win”, but NOT the word “Rays”, and have the lines sorted alphabetically?

A

grep Win red_sox.txt | grep -v Rays | sort

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

What program would you use to find where the program file for tar is located?

A

which or whereis

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

What command would you use to find out all the users currently logged on to the machine you are using?

A

finger or who

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
21
Q

What is the name of the directory at the top of the Unix filesystem?

A

root

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
22
Q

What symbol is used to represent the top of the Unix filesystem?

A

/

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
23
Q

What do you call the directory directly above your current directory?

A

the parent directory

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
24
Q

What directory are you in when you first log in to a Unix machine?

A

your own home directory

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
What do you call a text file containing Unix commands that is run just before the shell gives you a prompt?
a startup file
26
If you entered the following at the command line, where would you be? cd ~
your home directory
27
What does the . (dot) in your current directory mean?
your current directory
28
What does the .. (dot dot) in your current directory mean?
the parent directory of your current directory
29
What directory is the starting point for EVERY absolute path?
the root directory
30
What directory is the starting point for a relative path?
the current directory
31
By default, which account is the owner of a file or directory?
the account that created it
32
Name the three types of access permissions.
read, write and execute
33
Name the three categories of accounts which are used in assigning access permissions.
owner, group, everyone else
34
Who can change the access permissions on a file or directory?
only the owner
35
What is the name of the command you would use to change the access permissions for a file or directory?
chmod
36
What is the name of the account that can do ANYTHING on a Unix or Linux system?
root
37
If you have read permission on a directory, what can you do in it?
run ls on the directory to list its contents
38
If you have read permission on a directory, can you read the files in that directory?
no, you need read permission on each file
39
If you have write permission on a directory do you have write permission on the files it contains?
no, you need write permission on each file
40
If you have execute permission on a directory what can you do?
cd into that directory
41
What does the PATH shell variable contain?
the list of directories the shell must search to find the file to run a command
42
If you wanted to run the executable script work.sh in your current directory without using bash, what would you type at the command line?
./work.sh
43
What is a process?
a running program
44
What does a program do just before it stops running?
it sends an exit status to the shell
45
What does an exit status of 0 mean?
it means that the program encountered no errors
46
By default, where does Standard Input come from?
the keyboard
47
By default, where does Standard Output go?
to the screen
48
By default, where does Standard Error go?
to the screen
49
If you wanted to send the output of ls to the file dir_listing.txt, what would you enter at the command line?
ls > dir_listing.txt
50
If you wanted the program do_something to take input from the file data.txt what would you write at the command line?
do_something < data.txt
51
If you have a copy of the executable script bother.sh in your current directory, what would you type at the command line to run this script in the background?
./bother.sh &
52
If a command is running in the background, can it take input from the keyboard?
no
53
What would you type at the command line if you wanted to suspend a job running in the foreground?
Control Z
54
What command would you use to see all currently running jobs?
jobs
55
When using the kill command to stop a running job, what information do you give to tell it what to kill?
either the job number or the process ID
56
What does the ? meta-character match?
any single character
57
What does the * meta-character match?
zero or more occurrences of any character
58
What do the [ ] meta-characters match?
a single instance of any character between the brackets
59
What is a built-in?
a command whose code is part of the shell and does not exist as an executable file on disc
60
What command would you use the find out more about a built-in command?
help
61
If you wanted to run the executable file backup.sh in your current directory, but wanted the error messages to disappear, what would you write at the command line?
./backup.sh 2> /dev/null
62
What would you type at the command line, if you wanted to make the script cheer.sh executable?
chmod 755 cheer.sh
63
Write the hashbang line we use for scripts in this course.
! /bin/bash
64
What command would you use to make the changes you made in the startup file for your login shell take effect?
source .bash_profile
65
What is special about a GLOBAL variable?
you can use it in any subshell of the shell in which it was created.
66
What are the limitations of a LOCAL variable?
you can only use it in the shell in which it was created
67
What would you write on the command line to set the value of the LOCAL variable named team to Red Sox.
team="Red Sox"
68
If you define a local variable, can a script see the value of this variable?
no
69
What would you write on the command line to create the GLOBAL variable named school and set its value to UMass Boston.
export school="UMass Boston"
70
Write the command you would use in a script to ask the user to provide a value for a variable named dir
read -p "Directory: " dir
71
What parameter gives the total number of arguments passed to a script from the command line?
#
72
What parameter gives the full pathname of the script that is currently being run?
0
73
What parameter gives the first command line argument to a script or function?
1
74
If you wanted to use the value of the variable team inside quotes, what kind of quotes would you use?
double quotes, ""
75
If the process ID of your current shell is 15062, what is the PARENT process ID of a shell script you run from your current shell?
15062
76
What command would you run to see the last 20 commands you ran at the command line?
history 20
77
What is the name of the library of procedures that allows you to edit the command line?
the Readline library
78
Name the three things that can be completed at the command line by hitting Tab.
pathnames, commands, shell variables
79
Can aliases be made global?
no
80
Can functions be made global?
no
81
What does Bash do when it performs alias substitution?
it replaces the name of the alias with a Unix command
82
Write the command you would use to create the files foo1.txt to foo5.txt using brace expansion and the touch command.
touch foo{1,2,3,4,5}.txt
83
What does Bash do when it performs command substitution?
runs the commands inside the parentheses in a subshell and substitutes the output from those commands for the substitution expression
84
What would you write at the command line to define the alias ll whose value was ls -l ?
alias ll='ls -l'
85
Can an alias be made global?
no
86
Can a function be made global?
no
87
How is the command that follows if used to determine whether or not the statements between the then and fi keywords are executed?
if the command returns an exit status of 0 the statements are executed
88
What does the test command do?
analyze a logical expression and return an exit status that tells whether the expression is true or false
89
What is the value of the exit status returned by test to indicate that the expression is true?
0
90
Does the command that follows if need to be test?
no, it can be any command that returns an exit status
91
What do [ and ] mean when used in an if statement?
they stand for the test command
92
What are the keywords used to mark a block of commands in an if ... then statement?
then and fi
93
What are the keywords used to mark the SECOND block of commands in an if ... then ... else statement?
else and fi
94
What are the keywords used to mark the block of commands following elif?
then and either else or elif or fi
95
Is there any limit to the number of blocks of commands you can have in an if ... else ... elif statement?
no
96
In a for ... in loop, where does the loop variable get its values?
from the list of values following the keyword in
97
In a simple for loop, where does the loop variable get its values?
from the command line arguments
98
Should the loop variable in a for loop have a $ in front of it?
no
99
When does a while loop stop running?
when the command following while returns an exit status that is not 0
100
What does the break command in a loop do?
jumps completely out of the loop