Linux Foundations_2 Flashcards
After using a text editor to create a shell script, what step should you take before trying to
use the script by typing its name?
A. Set one or more executable bits using chmod.
B. Copy the script to the /usr/bin/scripts directory.
C. Compile the script by typing bash
scriptname, where
scriptname is the
script’s name.
D. Run a virus checker on the script to be sure it contains no viruses.
E. Run a spell checker on the script to ensure it contains no bugs.
Set one or more executable bits using chmod.
Ex: chmod +x scriptname
Describe the effect of the following short script, cp1, if it’s called as cp1 big.c big.cc:
#!/bin/bash
cp $2 $1
A. It has the same effect as the cp command—copying the contents of big.c to big.cc.
B. It compiles the C program big.c and calls the result big.cc.
C. It copies the contents of big.cc to big.c, eliminating the old big.c.
D. It converts the C program big.c into a C++ program called big.cc.
E. The script’s first line is invalid, so it won’t work.
C. It copies the contents of big.cc to big.c, eliminating the old big.c.
Here’s the explanation:
The script cp1 uses the cp command to copy the file $2 (the second argument, big.cc) to $1 (the first argument, big.c).
As a result,the contents of big.cc are copied into big.c, overwriting the old big.c file.
What is the purpose of conditional expressions in shell scripts?
A. They prevent scripts from executing if license conditions aren’t met.
B. They display information about the script’s computer environment.
C. They enable the script to take different actions in response to variable data.
D. They enable scripts to learn in a manner reminiscent of Pavlovian conditioning.
E. They cause scripts to run only at specified times of day.
They enable the script to take different actions in response to variable data.
True or false: A user types myscript laser.txt to run a script called myscript. Within
myscript, the $0 variable holds the value laser.txt.
false.
When a user runs a script by typing myscript laser.txt, the $0 variable within the script holds the value of the script’s name, which in this case is myscript. The $1 variable would hold the value laser.txt.
True or false: Valid looping statements in Bash include for, while, and until.
True.
In Bash scripting, valid looping statements include for, while, and until. These loops are used to execute a block of code repeatedly based on certain conditions.
True or false: The following script launches three simultaneous instances of the terminal
program.
#!/bin/bash
terminal
terminal
terminal
False
You’ve written a simple shell script that does nothing but launch programs. To ensure that
the script works with most user shells, the first line should be .
A. #!/bin/sh
B. /bin/sh
C. # /bin/sh
D. bash
E. #!bash
A. #!/bin/sh
The Bash scripting command is used to display prompts for a user in a shell script.
A. case
B. while
C. if
D. echo
E. exit
echo
The Bash scripting command is used to control the program flow based on a variable
that can take many values (such as all the letters of the alphabet).
A. case
B. while
C. if
D. echo
E. exit
case
The Bash scripting command controls the return value generated by a script, inde-
pendent of the other commands used in the script.
A. case
B. while
C. if
D. echo
E. exit
exit
ex:#!/bin/bash
Some commands here
Exit the script with a status of 0 (success)
exit 0
Which one of the following choices is known as the shebang combination? ?
(#/!/bin/sh)
(#!/bin/sh)
(#/bin/sh/!)
(#/bin!/sh)
(#!/bin/sh)
With which command can we check to see if a command is built -in or a file?
type
file
touch
echo
type - Good job! ✅
The command type will show if a command is an alias, function, built-in keyword or file.
Which of the following quotes will allow the expansion of variables?
Double Quotes “”
Sngle Quotes ‘’
The backslash \
Double Quotes “” - Good job! ✅
Yes, these allow for variable expansion
What is each document in an info page known as?
doc
page
link
node
node✅
Which of the following commands provides the most information about your mother-
board’s features?
A. lscpu
B. Xorg -configure
C. fdisk -l /dev/sda
D. lspci
E. http://localhost:631
lspci
Why might you want to partition a hard disk? (Choose all that apply.)
A. To install more than one OS on the disk
B. To use ext4fs rather than ReiserFS
C. To turn a PATA disk into an SATA disk
D. To separate filesystem data from swap space
E. To separate the disk’s cache from its main data
A. To install more than one OS on the disk: Partitioning allows you to set aside different sections of the disk for different operating systems.
D. To separate filesystem data from swap space: Creating separate partitions for your filesystem and swap space can improve system performance and organization.
True or false: An EM64T CPU is capable of running a Linux distribution identified as being
for the AMD64 CPU.
True
True or false: UDF is a good filesystem to use for a Linux installation on a hard disk.
False.
UDF (Universal Disk Format) is typically used for optical media like CDs and DVDs,
True or false: The Linux kernel includes drivers for various disk controllers, network adapt-
ers, and USB interfaces, among other things.
True.
The Linux kernel indeed includes drivers for a wide range of hardware, including various disk controllers, network adapters, USB interfaces, and many other devices.
Two currently popular X software packages in Linux are and (Select two).
A. xFree86
B. X.org
C. Wayland
D. GNOME
E. KDE Plasma
B. X.org
C. Wayland2
oth X.org and Wayland are popular display server protocols used in Linux2. X.org has been the traditional choice for many years, while Wayland is a newer, more modern alternative that aims to improve performance and security.
What command would you type (as root) to change the ownership of somefile.txt from
ralph to tony?
A. chown ralph:tony somefile.txt
B. chmod somefile.txt tony
C. chown somefile.txt tony
D. chown tony somefile.txt
E. chmod tony somefile.txt
chown tony somefile.txt
Typing ls -ld wonderjaye reveals a symbolic file mode of drwxr-xr-x. Which of the
following are true? (Choose all that apply.)
A. wonderjaye is a symbolic link.
B. wonderjaye is an executable program.
C. wonderjaye is a directory.
D. wonderjaye may be read by all users of the system.
E. wonderjaye may be written by any member of the file’s group.
C. wonderjaye is a directory.
True. The initial d indicates that wonderjaye is a directory.
D. wonderjaye may be read by all users of the system.
True. The permissions r-x for both group and others allow all users to read (r) the directory.
Which of the following commands can you use to change a file’s group?
A. groupadd
B. groupmod
C. chmod
D. ls
E. chown
chown
The chown command is used to change the ownership of a file, including its group. You can specify the new owner and group in the format owner:group.
True or false: A file with permissions of 755 can be read by any user on the computer,
assuming all users can read the directory in which it resides.
True. The permissions 755 mean that the owner has read, write, and execute permissions (7), while the group and others have read and execute permissions (5). So, if all users can read the directory, they can also read the file.