Linux Foundations_2 Flashcards

1
Q

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.

A

Set one or more executable bits using chmod.

Ex: chmod +x scriptname

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

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.

A

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.

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

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.

A

They enable the script to take different actions in response to variable data.

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

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.

A

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.

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

True or false: Valid looping statements in Bash include for, while, and until.

A

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.

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

True or false: The following script launches three simultaneous instances of the terminal
program.
#!/bin/bash
terminal
terminal
terminal

A

False

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

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

A. #!/bin/sh

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

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

A

echo

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

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

A

case

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

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

A

exit

ex:#!/bin/bash

Some commands here

Exit the script with a status of 0 (success)
exit 0

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

Which one of the following choices is known as the shebang combination? ?
(#/!/bin/sh)
(#!/bin/sh)
(#/bin/sh/!)
(#/bin!/sh)

A

(#!/bin/sh)

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

With which command can we check to see if a command is built -in or a file?
type
file
touch
echo

A

type - Good job! ✅
The command type will show if a command is an alias, function, built-in keyword or file.

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

Which of the following quotes will allow the expansion of variables?
Double Quotes “”
Sngle Quotes ‘’
The backslash \

A

Double Quotes “” - Good job! ✅
Yes, these allow for variable expansion

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

What is each document in an info page known as?
doc
page
link
node

A

node✅

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

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

A

lspci

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

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

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.

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

True or false: An EM64T CPU is capable of running a Linux distribution identified as being
for the AMD64 CPU.

A

True

18
Q

True or false: UDF is a good filesystem to use for a Linux installation on a hard disk.

A

False.

UDF (Universal Disk Format) is typically used for optical media like CDs and DVDs,

19
Q

True or false: The Linux kernel includes drivers for various disk controllers, network adapt-
ers, and USB interfaces, among other things.

A

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.

20
Q

Two currently popular X software packages in Linux are and (Select two).
A. xFree86
B. X.org
C. Wayland
D. GNOME
E. KDE Plasma

A

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.

21
Q

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

A

chown tony somefile.txt

22
Q

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.

A

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.

23
Q

Which of the following commands can you use to change a file’s group?
A. groupadd
B. groupmod
C. chmod
D. ls
E. chown

A

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.

24
Q

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.

A

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.

25
Q

True or false: Only root can use the chmod command.

A

False

26
Q

True or false: Only root can change a file’s ownership with chown.

A

True

27
Q

The option causes chown to change ownership on an entire directory tree.
A. -L
B. -R
C. -H
D. -P
E. -f

A

-R.

The -R option (recursive) makes chown apply the change to all files and subdirectories within the specified directory, effectively changing ownership for the entire directory tree.

28
Q

The three-character symbolic string represents read and execute permission but no
write permission.
A. -wx
B. –x
C. r-x
D. rwx

A

r-x

The symbolic string r-x represents read (r) and execute (x) permissions, but no write (w) permission. Here’s a breakdown of the options:

29
Q

The chmod symbolic representation allows all users execute access to a file without
affecting other permissions.
A. u+x
B. u-x
C. g+x
D. a-x
E. a+x

A

a+x

30
Q

You want to set the sticky bit on an existing directory, subdir, without otherwise altering
its permissions. To do so, you would type chmod subdir.
A. o+t
B. o+w
C. a+t
D. g+t
E. a+w

A

a+t

The chmod a+t subdir command sets the sticky bit on the directory subdir without altering its other permissions. The sticky bit (indicated by t) ensures that only the owner of a file within the directory, the directory’s owner, or the root user can delete or rename the files.

31
Q

Which two commands set the IP address, subnet mask, and default router information on
an interface using the command line? (Choose two.)
A. netstat
B. ping
C. nmtui
D. ip
E. route

A

D. ip
E. route

32
Q

Which command displays the duplex settings for an Ethernet card?
A. ethtool
B. netstat
C. iwconfig
D. iwlist
E. route

A

ethtool

33
Q

Which command displays what processes are using which ports on a Linux systems?
A. iwconfig
B. ip
C. ping
D. nmtui
E. ss

A

ss

34
Q

What network setting defines the network device that routes packets intended for hosts on
remote networks?
A. Default router
B. Netmask
C. Host name
D. IP address
E. DNS server

A

Default router

35
Q
A
36
Q

What device setting defines a host that maps a host name to an IP address?
A. Default router
B. Netmask
C. Host name
D. IP address
E. DNS server

A

DNS server

37
Q

Which command would you use to find the mail server for a domain?
A. dig
B. netstat
C. ping6
D. host
E. ss

A

dig

38
Q

Which ifconfig format correctly assigns an IP address and netmask to the eth0 interface?
A. ifconfig eth0 up 192.168.1.50 netmask 255.255.255.0
B. ifconfig eth0 255.255.255.0 192.168.1.50
C. ifconfig up 192.168.1.50 netmask 255.255.255.0
D. ifconfig up
E. ifconfig down

A

ifconfig eth0 up 192.168.1.50 netmask 255.255.255.0

39
Q

What command displays all the available wireless networks in your area?
A. iwlist
B. iwconfig
C. ifconfig
D. ip
E. arp

A

iwlist

40
Q

What command can you use to both display and set the IP address, netmask, and default
router values?
A. ifconfig
B. iwconfig
C. router
D. ifup
E. ip

A

ip

41
Q
A