CompTIA Linux+ XK0-006 Practice Test Questions and Exam Dumps Part 17: Q321–Q340

View Full CompTIA XK0-006 Exam Dumps and Practice Test Dumps.

 

Question 321

Which command can show the environment variables available to the current shell?

  1. env
  2. varshell
  3. showenvs
  4. shellvars -l

Correct Answer: 1

Explanation

The env command displays environment variables available to the current shell environment. These variables can contain information such as executable search paths, language settings, home directories, and application configuration values. Environment variables are commonly used by scripts and applications to receive configuration without hardcoding values into source code. Administrators should avoid placing sensitive credentials in environment variables unless the security implications are understood. Environment variables can also be inspected or changed for specific processes when troubleshooting application behavior.

Question 322

Which shell variable determines the directories searched when a command is entered without its full path?

  1. $HOME
  2. $PATH
  3. $SHELL
  4. $USER

Correct Answer: 2

Explanation

The $PATH environment variable contains a list of directories that the shell searches when locating executable commands. When a user types a command such as python instead of its full path, the shell checks the directories listed in $PATH. An incorrect PATH can cause commands to be reported as not found or can cause an unexpected version of a program to run. Administrators should check PATH carefully when troubleshooting command execution and software installation problems.

Question 323

Which command can display the full path of an executable that the shell would use?

  1. whereis
  2. which
  3. locatebin
  4. findcmd

Correct Answer: 2

Explanation

The which command can display the path to an executable found through the current PATH settings. For example, which python3 can help determine which Python executable will run when the command is entered. This is useful when multiple versions of software are installed. Administrators should remember that which focuses on executable lookup through PATH, while other tools such as whereis may provide additional information. Checking the actual executable path can help resolve version and configuration problems.

Question 324

Which Linux utility is commonly used to locate files by searching a database of previously indexed paths?

  1. locate
  2. searchdb
  3. filefind
  4. pathscan

Correct Answer: 1

Explanation

The locate command searches a database containing indexed filesystem paths. It can find files much faster than scanning the entire filesystem with a command such as find. However, the database may not contain very recent files if it has not been updated. This makes locate useful for quick searches but less suitable when current filesystem state is required. Administrators should understand whether the search database is up to date before relying on its results.

Question 325

Which command identifies the type of data stored in a file by examining its contents?

  1. typeof
  2. file
  3. identify-file
  4. datainfo

Correct Answer: 2

Explanation

The file command examines a file and reports information about its type based on its contents and other characteristics. It can identify text files, executable files, archives, images, and many other formats. This is useful when a filename extension is missing or misleading. For example, an administrator can use file to determine whether a downloaded object is actually a script or compressed archive. File identification can be an important step when investigating unfamiliar or suspicious files.

Question 326

Which command can calculate a cryptographic checksum for a file using SHA-256?

  1. sha256sum
  2. hashfile
  3. sha-check
  4. cryptsum

Correct Answer: 1

Explanation

The sha256sum command calculates a SHA-256 checksum for a file. Checksums can be used to verify that a file has not changed between two points in time or during transfer. For example, administrators can compare a downloaded software package’s checksum with the value provided by a trusted source. A matching checksum indicates that the data is identical for that hash calculation, although the trustworthiness of the source providing the expected checksum must also be considered.

Question 327

Which Linux utility can securely copy files while preserving an encrypted SSH connection?

  1. scp
  2. copyssh
  3. securecp
  4. netcopy

Correct Answer: 1

Explanation

The scp utility copies files between systems using SSH, providing encryption during transfer. It can be used to copy files to or from remote Linux systems when appropriate SSH access is available. Administrators should use secure authentication and verify the destination before transferring sensitive data. For more advanced synchronization requirements, tools such as rsync over SSH may provide better efficiency. Although SCP is convenient, administrators should follow organizational security policies when transferring confidential files.

Question 328

Which command is commonly used to synchronize directories efficiently between Linux systems?

  1. rsync
  2. syncdir
  3. dircopy
  4. remotesync

Correct Answer: 1

Explanation

rsync is commonly used to synchronize files and directories efficiently. It can transfer only the differences between source and destination, reducing bandwidth and transfer time compared with copying everything again. It can also work over SSH for secure remote synchronization. Administrators often use rsync for backups, deployments, and data replication. Options should be reviewed carefully because an incorrect source or destination can cause unwanted changes. Testing with a dry-run option can help verify what will happen before making changes.

Question 329

Which rsync option performs a dry run without actually changing the destination?

  1. -n
  2. -x
  3. -p
  4. -z

Correct Answer: 1

Explanation

The -n option tells rsync to perform a dry run. It shows what rsync would do without actually making the changes. This is useful when testing backup or synchronization commands, especially when deleting or overwriting files could cause data loss. Administrators should use dry runs when building unfamiliar rsync commands and carefully review the output. Once the source, destination, and options are confirmed, the command can be run without the dry-run option.

Question 330

Which Linux command can display the current user’s login shell?

  1. echo $SHELL
  2. echo $PATH
  3. echo $TERM
  4. echo $USERID

Correct Answer: 1

Explanation

The SHELL environment variable commonly identifies the user’s current shell, such as Bash or another shell. Running echo $SHELL can therefore provide a quick indication of the shell associated with the current environment. However, administrators should understand that environment variables can sometimes differ from the account’s configured login shell. The configured shell can be checked through account information such as /etc/passwd or appropriate user-management commands when troubleshooting login behavior.

Question 331

Which command can display the shell assigned to a specific user account?

  1. getent passwd username
  2. usershell username
  3. shellinfo username
  4. account-shell username

Correct Answer: 1

Explanation

The getent passwd username command can retrieve the account entry for a user through the system’s configured name service sources. The output includes fields such as the user ID, group ID, home directory, and login shell. Using getent is useful because it can work with local files and configured directory services rather than only checking /etc/passwd. This makes it valuable in environments where accounts may come from centralized authentication systems.

Question 332

Which Linux file lists shells that are considered valid login shells on many systems?

  1. /etc/shells
  2. /etc/login-shells
  3. /etc/user-shell
  4. /var/shells

Correct Answer: 1

Explanation

The /etc/shells file contains a list of valid login shells on many Linux systems. Programs can use this information when determining whether a shell is permitted for login-related operations. Administrators can inspect the file when troubleshooting why a user cannot select or use a particular shell. Only appropriate shells should normally be listed because allowing unexpected executables as login shells could create security or management problems. The actual account’s configured shell can be checked separately.

Question 333

Which command can change the default login shell for a user?

  1. chsh
  2. shellchange
  3. ushell
  4. modshell

Correct Answer: 1

Explanation

The chsh command is commonly used to change a user’s login shell. The selected shell generally needs to be listed as an approved shell on the system. Changing a login shell can affect how users interact with the system and which startup files are executed. Administrators should confirm that the new shell exists and is appropriate for the account. Service accounts often use restricted or non-interactive shells to reduce unnecessary interactive access.

Question 334

Which security principle means users should receive only the permissions required to perform their tasks?

  1. Defense in depth
  2. Least privilege
  3. Security by obscurity
  4. Open access

Correct Answer: 2

Explanation

The principle of least privilege means users, applications, and services should receive only the permissions necessary to perform their required tasks. This reduces the potential damage caused by compromised accounts, vulnerable applications, or accidental actions. Linux administrators can apply least privilege through file permissions, groups, sudo rules, service accounts, capabilities, and access-control systems. Privileged access should be granted carefully and reviewed regularly. Giving every user administrative access makes systems harder to secure and investigate.

Question 335

Which Linux mechanism allows a program to receive a specific privileged operation without giving it full root privileges?

  1. Linux capabilities
  2. Full root shell
  3. Directory ownership
  4. DNS permissions

Correct Answer: 1

Explanation

Linux capabilities divide certain traditional root privileges into smaller units that can be assigned to processes or executables. This allows an application to receive a specific capability without necessarily having unrestricted root privileges. For example, some networking operations can be permitted through specific capabilities. This supports the principle of least privilege. Administrators should carefully review capabilities because granting powerful capabilities to vulnerable programs can still create serious security risks.

Question 336

Which command can display capabilities assigned to a file on a Linux system?

  1. getcap
  2. filecaps
  3. showcap
  4. capcheck

Correct Answer: 1

Explanation

The getcap command displays Linux capabilities assigned to executable files. Administrators can use it when investigating why an application can perform a privileged operation without running as root. Capability assignments should be reviewed carefully because unnecessary privileges can increase security risk. If an unexpected executable has powerful capabilities, it may require investigation. The related setcap command can modify capabilities, but such changes should only be made when there is a clear operational and security requirement.

Question 337

Which command can display the permissions and ownership of a file in a detailed format?

  1. ls -l
  2. ls -p
  3. file -d
  4. showperm

Correct Answer: 1

Explanation

The ls -l command displays detailed information about files and directories, including permissions, ownership, size, and modification time. It is one of the most commonly used commands for checking Linux filesystem access. Administrators can use this output to identify whether a user belongs to the owning group or whether permissions are preventing access. When troubleshooting access problems, administrators should also consider ACLs, SELinux or AppArmor policies, and parent-directory permissions rather than looking only at the target file.

Question 338

Which command can recursively search text files for a specific pattern?

  1. grep -R
  2. textfind -r
  3. searchtext -all
  4. grep –files

Correct Answer: 1

Explanation

The grep -R command recursively searches files under a specified directory for matching text patterns. It is useful for finding configuration settings, log entries, application references, and other text across multiple directories. Administrators should choose the search directory carefully because recursive searches across large filesystems can consume significant resources. Binary files, permissions, and symbolic links can also affect results. Using filters or more specific paths can make searches faster and easier to interpret.

Question 339

Which command can show the amount of disk space used by a directory and its contents?

  1. du
  2. diskuse
  3. spaceview
  4. usedisk

Correct Answer: 1

Explanation

The du command reports disk usage for files and directories. It is useful when an administrator needs to determine which directories are consuming storage. Options such as -h can make the output easier to read, while additional options can control the depth or summarize specific paths. du measures filesystem usage of files and directories, while df reports available and used filesystem space overall. Comparing both can help diagnose unexpected storage consumption.

Question 340

Which situation can cause a filesystem to report available space problems even when df -h shows free disk capacity?

  1. Exhausted inodes
  2. Too many CPU cores
  3. Incorrect hostname
  4. Low network bandwidth

Correct Answer: 1

Explanation

A filesystem can run out of inodes even when it still has free data blocks. Inodes store metadata about files, so a system containing extremely large numbers of small files can exhaust available inodes before exhausting normal disk capacity. Administrators can investigate inode usage with appropriate filesystem reporting tools. This problem can affect applications that need to create new files, causing errors even though df -h appears to show free space. Monitoring both block and inode usage helps prevent this issue.