WorksheetsGAME: Shell Expansion
Total questions: 30
Worksheet time: 20mins
1. Display the matching file; File55 in the system using the ls command? (two answers)
ls File*
ls f*55
ls F*55
ls file*
Which command do we use to check the current language in the system?
$LANG
echo $LANG
$MYLANG
locale -a
List the matching file FileAB5; in the system using ls command.
ls File???
ls File [A5] [AB] [B5]
ls [a-z]ile???
ls File[a-z][a-z][0-9]
All of the above
Create multiple files using the command touch.
touch file{1..3}.txt
touch file{a..c}.txt
touch file{a,b}{1,2}.txt
touch file{a{1,2},b,c}.txt
all of the above
When separating two commands on the same line use _____ ,both commands will be executed sequentially with the shell waiting for each command to finish before starting the next one.
A. an ampersand
B. a semicolon
C. a double ampersand
D. a colon
The second command is executed only when the first command fails when you use:
A. | Single vertical bar
B. || double vertical bar
C. & single ampersand
D. && double ampersand
How would you escape special characters to get the following output:
I love my control characters “ # & \ ‘
A. A forward slash /
B. Double quotes “ “
C. A backslash \
D. Single quotes ‘ ‘
Why would the following command NOT be excecuted?
[student@serverX ~]$ # rm myfile.txt && echo It worked! || echo It failed!
A. It has a wrong syntax
B. Double vertical bar should not be in this command
C. The pound sign in the front makes the shell ignore this command
D. rm should always be used with an –r option
What is a return code of a “command not found” error?
A. 0
B. 1
C. 126
D. 127
How can I delete single line from history?
A. history -c
B. Ctrl +L
C. fc -l
D. history -d
If you want to run a command from the history list, what command do use to get it
A. sudo
B. !!
C. !n
D. tree
You want to open another terminal window to access the full history list from first terminal window, what option will allow you do this in the first terminal window before you open the second window?
A. history -a
B. history -c
C. history -w
D. history -t
True or False
The number of commands to remember in the command history default value is 7500.
True
False
How many arguments are in this line (not counting the command itself).
touch '/etc/cron/cron.allow' 'abc123.txt' "abc456.txt"
5
4
3
2
1
What command do we use to get the location of cat command?
find cat
ls cat
which cat
where cat
bash cat
List all current aliases.
ls
ls -la
alias
type
cat alias
How to turn on and turn off debug mode?
(display everything that normally happens in the background)
set-C ; set+C
set+x ; set-x
set-x ; set+x
setgid ; setuid
set-u ; set+u
alias dog=tac | What command should we use to remove created alias?
rm -rf
rm alias
unalias
set+a
alias c=’clear’
What command helps to you get a specific range in history?
A. ls history
B. history -5
C. fc -l
D. history -s
Which of the following commands will help to list the contents of the directory?
[root@ServerX ~/test42]# touch file{1..3}.txt
echo *
ls *
ls -l *
ll *
all of the above
What is a SHELL VARIABLE?
A. A hard, protective outer layer usually created by an animal that lives in the sea.
B. A special variable that is set by the shell and is required by the shell in order to function correctly.
C. An Energy Company
D. Any variable which has a dollar sign ($) in front of it
A $HOME variable contains:
A. User’s home address and ZIP
B. User’ executable path
C. User’s home directory location
D. None of the above
For a specific user, you can set or change environmental variables in:
A .bashrc in /usr/bin
B .bashrc in user’s home directory
C .bash_profile or .bashrc in the user’s home directory
D .birthday_bash
> echo $PS1 command shows:
A. Local Playstation Console IP address
B. Local PS/2 Mouse Driver Vendor name
C. Local bash shell prompt settings
D. None of the above
Any string can become a variable name. Is it true?
A. No, only upper case letters are allowed in a variable name.
B. Yes, Linux allows any symbol in the variable name.
C. No, special symbols and leading numerals are not allowed
D. Yes, it’s a free country.
What is the proper way to display(2 answers):
Hello "World"
A) echo Hello "World"
B) echo 'Hello "World"'
C) echo "Hello "World""
D) echo "Hello World"
E) echo "Hello \"World\""
How do we unset variables as an error?
a. set -T
b. set -t
c. set -u
d set -V
Where do you find the list of shell options :
a. man page 5
b. --help
c. man page of bash
d. whoisthis bash
True or False
Does set -u and set -o nounset both mean the same thing :
a. True
b. False
What is the command to turn on noclobber option :
a. set -N
b. set -n
c. set -C
d. set -c
