FX4 Flashcards

1
Q

Question:
What is the purpose of the PATH environment variable?

A. It allows the execution of commands without the need to know the location of the executable.
B. It increases security by preventing commands from running in certain locations.
C. It specifies the location of a user’s home directory.
D. It indicates the location of the default shell to be used when a user logs in.
E. It contains the absolute path to the current directory.

A

Answer:
✅ A. It allows the execution of commands without the need to know the location of the executable.

Explanation:

The PATH environment variable contains a list of directories where the system looks for executable files.
When you run a command, the shell searches these directories to find the corresponding executable.

Why other options are incorrect?

B: Security measures are managed using permissions and access control, not the PATH variable.
C: The user’s home directory is stored in $HOME, not PATH.
D: The default shell is determined by the /etc/passwd file or the $SHELL variable.
E: The absolute path to the current directory is stored in pwd, not PATH.

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

Question:
Which command sets the variable USERNAME to the value bob?

A. set USERNAME bob
B. $USERNAME==bob
C. var USERNAME=bob
D. USERNAME<=bob
E. USERNAME=bob

A

Answer:
✅ E. USERNAME=bob

Why other options are incorrect?

A: The set command is used to display environment variables, not assign them.
B: The == operator is used for comparisons, not assignments.
C: var is used in programming languages like JavaScript, not in shell scripting.
D: <= is not a valid assignment operator in Linux.

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

Question:
What command displays manual pages?

A. manul
B. man
C. help -m
D. lsman
E. info –manual

A

Answer:
✅ B. man

Explanation:

The man command displays the manual pages for commands.

Why other options are incorrect?

A: manul is not a valid command.
C: help provides brief command help but does not show full manual pages.
D: lsman does not exist in Linux.
E: info shows different documentation but is not equivalent to man.

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

Question:
Which command copies the contents of the /etc/ directory, including all subdirectories, to /root/?

A. copy /etc /root
B. cp -r /etc/* /root
C. cp -v /etc/* /root
D. rcp /etc/* /root
E. cp -R /etc/. /root

A

Answer:
✅ B. cp -r /etc/* /root

Explanation:

The -r (recursive) option is required to copy directories.

Why other options are incorrect?

A: copy is a Windows command, not Linux.
C: -v enables verbose mode but does not copy directories.
D: rcp (remote copy) is deprecated.
E: The . pattern does not work as expected in Linux.

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

Question:
Which command sorts the lines of data.csv in alphabetical order?

A. a..z data.csv
B. sort data.csv
C. abc data.csv
D. wc -s data.csv
E. grep –sort data.csv

A

Answer:
✅ B. sort data.csv

Explanation:

The sort command sorts lines in a file alphabetically.

Why other options are incorrect?

A & C: These are not valid Linux commands.
D: wc counts words, lines, and characters but does not sort.
E: grep is used for searching, not sorting.

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

Question:
Which of the following examples shows the general structure of a for loop in a shell script?

A. for *.txt as file => echo $file
B. for *.txt ( echo $i )
C. for file in *.txt do echo $i done
D. for ls *.txt exec {} \;
E. foreach @{file} { echo $i }

A

Answer:
✅ C. for file in *.txt do echo $i done

Explanation:

The correct for loop syntax in Bash is:
[for file in *.txt; do echo $file; done]
It iterates over all .txt files and prints their names.

Why other options are incorrect?
A, B, E: These are invalid syntax in Bash.
D: This syntax resembles find, not a for loop.

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

Question:
Which operator in a regular expression matches the preceding character either zero or one time?

A. ?
B. *
C. +
D. %
E. $

A

Answer:
✅ A. ?

Explanation:

The ? operator makes the preceding character optional (zero or one occurrence).

Why other options are incorrect?

B (*): Matches zero or more times.
C (+): Matches one or more times.
D (%): Not a regex operator in Linux.
E ($): Matches the end of a line.

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

Question:
The file script.sh in the current directory contains the following content:\n#!/bin/bash\necho $MYVAR\n

The following commands are used to execute this script:\n\n\nMYVAR=value -\n./script.sh\n

The result is an empty line instead of the content of the variable MYVAR. How should MYVAR be set in order to make script.sh display the content\nof MYVAR?

A.”!MYVAR=value”,
B.”env MYVAR=value”,
C.”MYVAR=value”,
D.”$MYVAR=value”,
E.”export MYVAR=value”

A

Answer:
✅ E. export MYVAR=value

Explanation:

Variables set in the shell only apply to that shell instance.
export MYVAR=value makes the variable available to child processes, including script.sh.

Why other options are incorrect?

A: ! is not used for variable assignment.
B: env MYVAR=value only applies to a single command execution, not a script.
C: This sets MYVAR but does not pass it to child processes.
D: $MYVAR=value is incorrect syntax.

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

Question:
What is the return value of a shell script after successful execution?

A. 1
B. 0
C. -1
D. -255
E. 255

A

Answer:
✅ B. 0

Explanation:

In Linux, 0 indicates success, while nonzero values indicate errors.

Why other options are incorrect?

A, C, D, E: Nonzero values are used for error codes.

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

Question:
Which command creates a ZIP archive poems.zip containing all .txt files in the current directory?

A. zip *.txt > poems.zip
B. zcat *.txt poems.zip
C. zip poems.zip *.txt
D. zip cfz poems.zip *.txt
E. cat *.txt | zip poems.zip

A

Answer:
✅ C. zip poems.zip *.txt

Explanation:

The zip command archives multiple files into one .zip file.

Why other options are incorrect?

A, E: > and | do not work with zip.
B: zcat is used for viewing compressed files.
D: The cfz flags are from tar, not zip.

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

Question:
Which of the following statements are true for shell scripts? (Choose two.)

A. It has the executable permission bit set.
B. It starts with the two-character sequence #!.
C. It is located in /usr/local/scripts/.
D. It is located in /etc/bash/scripts/.
E. It is compiled into a binary file compatible with the current machine architecture.

A

Answer:
✅ A. It has the executable permission bit set.
✅ B. It starts with the two-character sequence #!.

Explanation:

A script must be executable (chmod +x script.sh).
It begins with #! (shebang) to specify the interpreter.
Why other options are incorrect?

C, D: Scripts can be stored anywhere.
E: Shell scripts are interpreted, not compiled.

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

Question:
Which command extracts the contents of file1.tar.gz?

A. tar -czf file1.tar.gz
B. ztar file1.tar.gz
C. tar -xzf file1.tar.gz
D. tar –extract file1.tar.gz
E. detar file1.tar.gz

A

Answer:
✅ C. tar -xzf file1.tar.gz

Explanation:

tar -xzf extracts compressed tar files.

Why other options are incorrect?

A: -czf creates, not extracts.
B, E: Not real commands.
D: –extract needs -f file1.tar.gz.

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

Question:
Which command finds all lines in operating-systems.txt that contain “linux” (case-insensitive)?

A. igrep linux operating-systems.txt
B. less -i linux operating-systems.txt
C. grep -i linux operating-systems.txt
D. cut linux operating-systems.txt
E. cut [Ll] [Ii] [Nn] [Uu] [Xx] operating-systems.txt

A

Answer:
✅ C. grep -i linux operating-systems.txt

Explanation:

grep -i performs case-insensitive searches.

Why other options are incorrect?

A: igrep does not exist.
B: less is for viewing files.
D, E: cut extracts columns, not searches text.

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

Question:
Which one of these is true about Linux passwords?

A. All passwords can be decrypted using an admin master password.
B. Passwords may never start with a non-letter.
C. Users cannot change their password once set.
D. Passwords are only stored in hashed form.
E. Passwords may be at most six characters long.

A

Answer:
✅ D. Passwords are only stored in hashed form.

Explanation:

Linux passwords are hashed using algorithms like SHA-512.
Example: Stored in /etc/shadow.
Why other options are incorrect?

A: No master password can decrypt hashes.
B, E: No such length/start restrictions.
C: Users can change passwords using passwd.

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

Question:
Which of the following are web servers? (Choose two.)

A. Apache
B. Postfix
C. Curl
D. Dovecot
E. NGINX

A

Answer:
✅ A. Apache
✅ E. NGINX

Explanation:

Apache and NGINX are widely used web servers.
Why other options are incorrect?

B: Postfix is a mail server.
C: Curl is a command-line tool.
D: Dovecot is an IMAP/POP3 server.

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

Question:
Which Linux distribution is derived from Red Hat Enterprise Linux (RHEL)?

A. Raspbian
B. openSUSE
C. Debian
D. Ubuntu
E. CentOS

A

✅ Answer: E. CentOS

Explanation:

CentOS is a free, community-supported rebuild of RHEL, maintaining full binary compatibility.
It provides an enterprise-level OS without Red Hat’s support costs.
Why other options are incorrect?

A: Raspbian is based on Debian and designed for Raspberry Pi.
B: openSUSE is derived from SUSE Linux Enterprise.
C: Debian is an independent distribution.
D: Ubuntu is based on Debian, not RHEL.

17
Q

Question:
Which statement is true about Free Software?

A. It is developed by volunteers only.
B. It may be modified by anyone using it.
C. It must always be available free of charge.
D. It only runs on Linux.
E. It is only distributed as a compiled binary.

A

✅ Answer: B. It may be modified by anyone using it.

Explanation:

Free Software, as per the Free Software Foundation (FSF), grants users the freedom to run, modify, and share the software.
Example: GNU/Linux and LibreOffice.
Why other options are incorrect?

A: Free software can be developed by individuals, companies, or volunteers.
C: “Free” refers to freedom, not price. Paid versions can exist.
D: Free software runs on multiple platforms, not just Linux.
E: Free software often includes source code, not just binaries.

18
Q

Question:
How is a new Linux instance provisioned in an IaaS cloud environment?

A. The standard Linux installer must be run through a remote console.
B. After purchasing a Linux distribution, the vendor delivers it to a cloud instance.
C. The installation must be prepared in a local VM and copied to the cloud.
D. The cloud provider offers pre-prepared images of popular Linux distributions.
E. A provider-specific configuration file must be uploaded to the cloud provider.

A

✅ Answer: D. The cloud provider offers pre-prepared images of popular Linux distributions.

Explanation:

In Infrastructure as a Service (IaaS), cloud providers offer pre-configured images (e.g., AWS AMIs, Azure VMs).
Users can quickly deploy instances without manual installation.
Why other options are incorrect?

A: Manual installation is not required in most cloud platforms.
B: No need to purchase Linux; most distributions are free.
C: While possible, it’s inefficient.
E: Cloud configurations (e.g., Terraform) exist, but pre-built images are standard.

19
Q

Question:
What are the differences between a private web browser window and a regular web browser window? (Choose three.)

A. Private browsing prevents printing or storing websites.
B. Private browsing does not store cookies persistently.
C. Private browsing does not allow website logins.
D. Private browsing does not keep records in the browser history.
E. Private browsing does not send regular stored cookies.

A

Explanation:

Private browsing (Incognito mode) limits tracking by:
Not storing cookies persistently (B).
Not keeping browser history (D).
Not sending stored cookies from regular sessions (E).
Why other options are incorrect?

A: Private mode does not restrict printing or saving pages.
C: Logins work, but cookies and session data are deleted after closing the window.

20
Q

Question:
What is the preferred source for installing applications on a Linux-based OS?

A. The vendor’s version management system.
B. A CD-ROM disk.
C. The distribution’s package repository.
D. The vendor’s website.
E. A retail store.

A

✅ Answer: C. The distribution’s package repository.

Explanation:

Linux distros provide secure, up-to-date software through package managers:
Debian/Ubuntu: apt
Red Hat/Fedora: dnf
Arch: pacman
These repositories ensure security, compatibility, and easy updates.

Why other options are incorrect?
A: “Version management systems” like Git track code, not software installations.
B: CD-ROMs are outdated.
D: Vendor websites may offer outdated or insecure software.
E: Linux software is not typically sold in retail stores.