LPI 010-160 Linux Essentials Certificate Exam, version 1.6 Exam Dumps and Practice Test Questions Set1 Q1-20

Visit here for our full LPI 010-160 exam dumps and practice test questions.

Question 1

Which command is used to display the current working directory in Linux?

A) ls
B) cd
C) pwd
D) whoami

Answer: C) pwd

Explanation:

In Linux, the filesystem is hierarchical, and the concept of the “current working directory” is fundamental. The current working directory is where the shell is currently operating. Commands like cp, mv, and rm act on files relative to this location unless an absolute path is provided. The pwd command, which stands for “print working directory,” outputs the full path of the current directory, starting from the root directory /. For example, executing pwd in a home directory might return /home/user. This is particularly important for scripts and administrative tasks because many commands use relative paths. Without knowing your current directory, you risk performing operations in the wrong location.

A) ls – This command lists the contents of the current directory or a specified directory. While it is extremely useful for seeing what files exist, it does not provide the full path of the directory. For example, ls in /home/user/Documents will show all files in that folder, but it doesn’t indicate you are in Documents.

B) cd – The cd command changes your location in the filesystem. Typing cd /var/log moves you to the /var/log directory. However, cd does not display your current directory; it only changes it. To verify your location after using cd, you would still need to use pwd.

D) whoami – This command outputs the current user’s login name. It’s useful in multi-user environments or when using sudo to check effective privileges but provides no information about the current directory.

Mastering pwd is critical for Linux administration, automation, and scripting. Scripts often use pwd to dynamically reference directories, ensuring commands act on the correct paths. Combined with cd and file manipulation commands, it forms a core part of Linux navigation skills.

Question 2

Which file contains essential information about all user accounts on a Linux system?

A) /etc/shadow
B) /etc/passwd
C) /etc/group
D) /etc/hosts

Answer:

B) /etc/passwd

Explanation:

The /etc/passwd file is one of the most important configuration files in Linux. It contains essential details for every user account, including the username, UID (user ID), GID (group ID), home directory, and default shell. Each line in /etc/passwd corresponds to a single user account and is structured in fields separated by colons. For instance:
john:x:1001:1001:John Doe:/home/john:/bin/bash
Here, john is the username, 1001 is both the UID and GID, and /bin/bash is the user’s default shell. The x indicates that the password is stored in /etc/shadow for security.

A) /etc/shadow – This file stores encrypted passwords and additional password-related information, like password aging, but does not contain general user account details like home directories or shells. Access to this file is restricted to root for security reasons.

C) /etc/group – Stores group information, including group names, GIDs, and group members. While it is important for permissions, it does not include individual user details such as passwords, UID, or default shell.

D) /etc/hosts – Used for mapping hostnames to IP addresses for network configuration. It is unrelated to user accounts and serves a completely different purpose.

Understanding /etc/passwd is essential for Linux administration. Many commands, such as id, getent passwd, and finger, rely on this file to retrieve user information. Even though modern systems separate password data into /etc/shadow for security, /etc/passwd remains central for identifying accounts and configuring permissions and home directories.

Question 3

Which command lists all files, including hidden ones, in a directory?

A) ls
B) ls -a
C) ls -l
D) dir

Answer: B) ls -a

Explanation:

In Linux, files whose names start with a dot (.) are hidden. These include configuration files such as .bashrc or .profile. By default, the ls command does not show hidden files. Using ls -a includes all files, both visible and hidden. For example, running ls -a in a home directory might show .bashrc, .profile, and .ssh in addition to normal files. This is critical for Linux users and administrators because hidden files often contain system or user configuration data.

A) ls – Lists only visible files and directories. It’s useful for quick directory overviews but cannot show hidden files.

B) ls -a – Correct. The -a option stands for “all,” including hidden files. Combining it with -l (ls -la) shows detailed information for all files, including permissions, ownership, and size.

C) ls -l – Lists files in long format with details like permissions, owner, size, and modification date, but it does not include hidden files unless combined with -a.

D) dir – A less commonly used command in Linux for listing directory contents. Its behavior depends on the system but typically does not include hidden files.

Understanding how to list hidden files is important for troubleshooting, editing configuration files, and verifying system settings. Hidden files are not meant to be permanently invisible—they are simply omitted from casual views to reduce clutter and prevent accidental modification. System administrators often use ls -a in combination with grep or less to filter and view specific hidden files in scripts or troubleshooting tasks.

Question 4

Which command changes file or directory permissions in Linux?

A) chmod
B) chown
C) ls
D) umask

Answer: A) chmod

Explanation:

Linux uses a permission system to control who can read, write, or execute files. Permissions are assigned to three categories: owner, group, and others. The chmod command changes these permissions. Permissions can be represented numerically (e.g., 755) or symbolically (e.g., u+rwx,g+rx,o+rx). For instance, chmod 644 file.txt sets read and write for the owner and read-only for the group and others. Understanding permissions is vital for system security and proper access control.

A) chmod – Correct. Used to modify permissions for files or directories.

B) chown – Changes the owner and/or group of a file but does not modify permissions. For example, chown user:group file.txt transfers ownership.

C) ls – Lists files; the -l option shows permissions but does not modify them.

D) umask – Sets the default permissions for new files or directories created in the current session but does not modify existing file permissions. For example, a umask of 022 ensures new files are readable by everyone but writable only by the owner.

Proper use of chmod is essential to secure sensitive files and directories. For example, configuration files in /etc or SSH keys in .ssh require strict permissions to prevent unauthorized access. Misconfigured permissions can lead to security breaches, accidental file deletion, or denial of access. Administrators often combine chmod with chown and umask to control access effectively across users and groups.

Question 5

Which shell is the most commonly used in Linux systems?

A) bash
B) sh
C) zsh
D) csh

Answer:

A) bash

Explanation:

A shell is a program that provides a command-line interface to interact with the operating system. Among Linux systems, bash (Bourne Again Shell) is the default shell for most distributions due to its flexibility, scripting capabilities, and robust features. Bash supports command history, tab completion, environment variables, functions, and scripting constructs like loops and conditionals, making it suitable for both interactive use and automation.

A) bash – Correct. Widely adopted as the default shell. Its scripting language is compatible with sh scripts and offers additional features, making it the most versatile.

B) sh – The original Bourne shell, less feature-rich than bash but highly compatible. Many scripts still use sh for portability, but interactive use is limited.

C) zsh – Z shell is highly customizable and popular among power users due to plugins, themes, and enhanced completion features. It is not the default shell in most distributions.

D) csh – C shell, historically used on BSD systems. It supports C-like syntax but lacks features and flexibility compared to bash and zsh.

Choosing the right shell depends on familiarity, scripts to run, and workflow needs. Bash remains the standard because it balances usability, scripting power, and compatibility. Advanced users may prefer zsh or fish for enhanced interactivity, but bash is universally available on almost every Linux system, making it the best choice for learning and scripting.

Question 6

Which command is used to display the first 10 lines of a text file in Linux by default?

A) tail
B) head
C) less
D) cat

Answer:

B) head

Explanation:

In Linux, viewing the contents of a text file can be done using multiple commands, each with different use cases. The head command is specifically designed to display the beginning portion of a file. By default, it shows the first 10 lines, though this can be adjusted using the -n option, such as head -n 20 file.txt to display the first 20 lines. This command is extremely useful for previewing files without opening the entire content, particularly for large log files or configuration files where only the start of the file is relevant.

A) tail – Opposite of head, the tail command displays the last part of a file. By default, it shows the last 10 lines. It also supports the -f option for “follow,” which allows real-time monitoring of logs or outputs appended to a file. For instance, tail -f /var/log/syslog is commonly used by system administrators to monitor system activity in real time.

B) head – Correct. Primarily used to preview the beginning of files. This can be combined with pipelines or other commands to filter or process data efficiently. For example, head /etc/passwd | grep root allows administrators to quickly check if the root account is present in the file. Using head helps save time and resources when dealing with large files.

C) less – This command is used to view the entire contents of a file one screen at a time. Unlike head, it does not limit output to a fixed number of lines. It allows scrolling, searching, and navigation within the file. While extremely powerful for examining files interactively, it is not designed to display only the first few lines by default.

D) cat – Short for “concatenate,” cat displays the entire contents of a file to standard output. It does not automatically limit the output, which can be overwhelming for very large files. While cat is useful for viewing smaller files or combining multiple files into a single output, head is preferable when only the beginning of a file is needed.

Understanding the difference between head, tail, less, and cat is critical for Linux users. Administrators often use head to quickly verify configuration files, monitor log file beginnings, or inspect sample data. By knowing the purpose of each command, users can avoid opening unnecessarily large files fully and can focus only on relevant sections, improving efficiency and resource management.

Question 7

Which command displays the manual or help documentation for other Linux commands?

A) help
B) man
C) info
D) whatis

Answer: B) man

Explanation: Linux provides multiple ways to access command documentation and usage instructions. The man command, short for “manual,” is the traditional and most widely used method for accessing detailed information about commands. Typing man ls displays the manual page for the ls command, showing its options, usage, and description. Manual pages are organized into sections such as user commands, system calls, and configuration files, which helps users locate the relevant information efficiently. man is essential for both beginners learning command syntax and advanced users troubleshooting or exploring features.

A) help – Displays built-in help for shell built-in commands, such as cd or echo. While useful for simple guidance, it is limited to shell-builtins and does not provide information about external binaries or complex commands. For example, help cd shows how to use the cd command, but it cannot be used for programs like grep or tar.

B) man – Correct. Provides comprehensive manuals for almost all installed commands, including detailed options, examples, and references to related commands. For instance, man grep lists every option, syntax, and behavior of the grep command. Manual pages are often extensive and contain multiple sections such as NAME, SYNOPSIS, DESCRIPTION, OPTIONS, EXAMPLES, and SEE ALSO.

C) info – Offers more structured documentation than man with hyperlinked sections, often used for GNU software. While info provides more examples and navigational features, it is less common than man in daily use. For example, info coreutils gives detailed pages for commands like ls, cp, and mv.

D) whatis – Provides a brief one-line description of a command. It is useful for quickly identifying what a command does but does not provide detailed instructions. For example, whatis ls returns “ls (1) – list directory contents.”

Using man effectively is critical for Linux users. Manual pages not only explain options but also provide contextual examples, references to related commands, and explanations of exit codes. Users who learn to navigate man efficiently can perform complex tasks without relying on external tutorials, making it an indispensable skill for certification exams and real-world Linux administration.

Question 8 Which command shows the current logged-in user?

A) who
B) whoami
C) id
D) users

Answer: B) whoami

Explanation: Linux systems often have multiple users logged in simultaneously, and understanding your current user identity is critical for permissions, executing commands, and administrative tasks. The whoami command displays the effective username of the current session. For instance, after switching to root using sudo -i, whoami will return “root,” indicating that the current session has administrative privileges.

A) who – Lists all users currently logged into the system along with their login terminals and login times. While it shows your session, it is more oriented toward multi-user monitoring rather than identifying your own username.

B) whoami – Correct. Provides a simple, single-line output showing the effective username. It is particularly useful in scripts or troubleshooting when permissions need to be verified. For example, if a script runs commands under different users, whoami can be used to ensure proper execution context.

C) id – Displays the user ID (UID), group ID (GID), and group memberships of the current user or specified user. While more detailed than whoami, it is not as straightforward for simply checking the username. Example: id john shows UID, GID, and groups associated with user “john.”

D) users – Lists all logged-in users in a single line. Similar to who, it is helpful for monitoring sessions but does not specifically indicate which user is running the current shell session.

Knowing the current user is important for Linux Essentials because file permissions, ownership, and sudo privileges depend on it. whoami is a lightweight, immediate way to confirm effective user identity. Combined with commands like id, administrators can fully understand permission scopes and group memberships, which is essential when configuring access controls or performing secure operations.

Question 9 Which of the following commands can display the content of a file page by page?

A) cat
B) less
C) head
D) tail

Answer: B) less

Explanation: Viewing files efficiently is critical in Linux, especially when dealing with large files such as logs or configuration files. The less command allows users to scroll through a file one screen at a time, both forward and backward. Unlike cat, which outputs all content at once, less improves readability, reduces scrolling errors, and saves terminal buffer space. You can navigate using arrow keys, search using /pattern, or jump to a specific line with G. For example, less /var/log/syslog allows administrators to inspect system logs interactively without overwhelming the terminal with thousands of lines.

A) cat – Displays the entire file content sequentially without pagination. While useful for small files or concatenating files, it is not practical for large files because output may scroll past the terminal buffer too quickly to read.

B) less – Correct. Designed for interactive file viewing. Supports forward and backward navigation, searching, and line jumps. Unlike more, it does not restrict backward navigation, making it the preferred command for paginated viewing.

C) head – Displays the first 10 lines of a file by default. It is used for previewing the beginning of a file but cannot scroll through the entire content interactively.

D) tail – Displays the last 10 lines of a file by default. It is commonly used with the -f option to monitor live updates to log files but does not allow page-by-page navigation.

Efficient use of less improves workflow, helps administrators examine large configuration or log files, and allows the combination of filters and searches within files. It is a core tool for Linux Essentials and real-world system management.

Question 10 Which of the following commands is used to search for a pattern in a file?

A) find
B) grep
C) locate
D) which

Answer: B) grep

Explanation: 

Pattern searching is a frequent task in Linux, from log analysis to scripting and data extraction. The grep command stands for “Global Regular Expression Print” and searches text files for lines that match a specified pattern. For example, grep root /etc/passwd lists all lines containing the word “root” in /etc/passwd. grep supports regular expressions, case-insensitive searches (-i), line numbers (-n), and recursive search (-r), making it highly versatile.

A) find – Searches for files and directories based on names, sizes, permissions, or modification times, not for content inside files. For example, find /home -name “*.txt” searches for all .txt files in /home.

B) grep – Correct. Specifically designed to search inside files for patterns. It is one of the most widely used commands in Linux for filtering output from other commands or scripts. Example: ps aux | grep apache finds processes related to Apache.

C) locate – This refers to tools like locate, which rely on an indexed database of file paths to provide extremely fast search results compared to scanning the filesystem in real-time. The database is typically updated periodically using a command like updatedb. While locate is efficient for finding filenames, it cannot perform content-based searches or detect newly created files until the database is refreshed.

D) which – The which command is useful for determining which version of a program will run when a command is executed, especially if multiple versions are installed. It scans the directories listed in the PATH environment variable in order and returns the first match. This helps avoid confusion when scripts or users rely on specific executable locations.

Mastering grep is essential for Linux Essentials. It is used for troubleshooting, extracting information from logs, and automating tasks. Combined with other commands via pipelines, grep allows efficient text processing and filtering, making it indispensable for both beginners and experienced administrators.

Question 11 Which command is used to display the current date and time in Linux?

A) date
B) time
C) cal
D) clock

Answer: A) date

Explanation:
In Linux, tracking system date and time is essential for logging, scheduling, and general system administration. The date command displays the current system date and time by default. For example, the running date may produce output like Thu Nov 14 15:30:00 UTC 2025. This output includes the weekday, month, day, time, time zone, and year, which is helpful for scripting, log analysis, and verifying system clock settings.

A) date – Correct. Besides showing the current date and time, it can also format output (date “+%Y-%m-%d %H:%M:%S”) or set the system date with appropriate permissions (sudo date -s “2025-11-14 15:30:00”). date is frequently used in automated scripts to timestamp files, generate log entries, or schedule events with cron jobs. Understanding date is crucial for exam questions because it illustrates knowledge of system utilities and time management in Linux.

B) time – Measures how long a command takes to execute. For instance, time ls reports the real, user, and system time consumed by the command. It does not show the current date or system clock. While related to time in a performance sense, it is not used for date or calendar information.

C) cal – Displays a calendar for the current month or a specified year (cal 2025). While it shows dates in a calendar format, it does not provide the exact current system time or allow precise timestamp operations. It is primarily for visual reference.

D) clock – Older Linux systems used clock or hwclock to interact with the hardware clock, but modern systems typically use date or timedatectl to manage time. While clock can display or set hardware time, it is rarely used for day-to-day display of the current time in modern Linux distributions.

Understanding date and related time utilities is critical in Linux Essentials. System administrators often rely on it to schedule cron jobs, compare log timestamps, and troubleshoot time-related issues. For example, automated backup scripts may use date to create timestamped filenames (backup_$(date “+%Y-%m-%d”).tar.gz). Additionally, knowing how date differs from time, cal, and clock ensures a solid understanding of Linux system utilities, which is a frequent topic in the certification exam.

Question 12 Which command is used to display disk space usage in Linux?

A) df
B) du
C) free
D) lsblk

Answer: A) df

Explanation: 

Disk space management is critical in Linux, especially when monitoring filesystem usage and avoiding full disk issues that can halt services. The df command, short for “disk filesystem,” reports the total, used, and available space on mounted filesystems. By default, df outputs sizes in blocks, but the -h option provides human-readable output in KB, MB, or GB (df -h). For example, df -h / might show that the root filesystem has 50GB total space, 20GB used, and 30GB available, along with the filesystem type and mount point.

A) df – Correct. Provides an overview of space usage per filesystem. It is often used by administrators to monitor disk usage, detect full partitions, and plan storage allocation. df is essential for troubleshooting disk issues, preparing for software installations, or verifying that log directories have sufficient space.

B) du – Measures disk usage of specific files or directories. For example, du -sh /home/user displays the total size of the user’s home directory. While du is more granular than df, it focuses on individual directories rather than the overall filesystem usage.

C) free – Shows memory usage, including RAM and swap, not disk usage. free -h provides a summary of available, used, and total memory. Confusing memory and disk usage is a common beginner mistake.

D) lsblk – Displays information about block devices, partitions, and mount points in a tree format. While it shows the structure of storage devices, it does not summarize disk usage for mounted filesystems.

Understanding the distinction between df and du is particularly important for Linux Essentials. While df provides a high-level overview of available space on mounted filesystems, du is used to drill down into directories consuming the most space. Both are fundamental tools for system monitoring, capacity planning, and diagnosing disk-related issues. Administrators frequently combine df with grep or awk to automate disk space reporting in scripts, ensuring proactive maintenance and avoiding service interruptions.

Question 13 Which command is used to display the currently running processes?

A) ps
B) top
C) jobs
D) systemctl

Answer:
A) ps

Explanation: 

Monitoring running processes is a key skill in Linux administration. The ps command, short for “process status,” lists processes running in the current shell or for the entire system. By default, ps without options shows processes in the current terminal session. Common options include ps aux (all processes with user and CPU/memory info) and ps -ef (full-format listing). For example, ps aux | grep apache shows all Apache processes, their PIDs, CPU/memory usage, and owner.

A) ps – Correct. Provides static snapshots of running processes. Administrators often use it to check for hung processes, monitor resource usage, or verify background services. It is also fundamental for process management scripts.

B) top – Displays running processes dynamically, updating every few seconds. It allows sorting by CPU, memory, and other parameters. While interactive and more visual, it does not provide a static snapshot suitable for scripts, which is why ps is often preferred for scripting.

C) jobs – Lists background jobs started in the current shell session using & or Ctrl+Z. It does not show system-wide processes, only jobs launched from that terminal.

D) systemctl – Manages system services (start, stop, enable, disable) rather than showing active processes. It is service-oriented, not process-oriented, although stopping services can indirectly affect running processes.

Understanding ps is critical because it forms the foundation for process management. Linux administrators use it to locate PIDs, kill misbehaving processes, check ownership, and analyze CPU and memory usage. Combined with grep or awk, ps enables automated monitoring scripts. Unlike top or jobs, it can be captured in logs or scripts, making it essential knowledge for Linux Essentials and real-world system management.

Question 14 Which of the following commands can display your current environment variables?

A) env
B) export
C) set
D) printenv

Answer: A) env

Explanation:
Environment variables store configuration information for shell sessions and applications. They include variables like PATH, HOME, and USER. Viewing environment variables helps understand the current configuration, troubleshoot issues, and configure applications.

A) env – Correct. Lists all current environment variables in the session. For example, env | grep PATH shows the directories the shell searches for executables. It can also be used to run commands with modified environments (env VAR=value command).

B) export – Used to create or modify environment variables and make them available to child processes. Running export VAR=value sets a variable, but by itself, it doesn’t display all current variables.

C) set – Shows both shell variables and functions, including environment variables, in alphabetical order. It is more verbose than env and includes shell-specific variables that are not strictly environment variables.

D) printenv – Can also list environment variables and is functionally similar to env. Unlike env, it only prints variables and does not run commands with modified environments.

Understanding how to view and manipulate environment variables is crucial in Linux Essentials. Variables like PATH, LANG, and HOME affect command execution, localization, and shell behavior. Admins must know env, export, and printenv to troubleshoot misconfigured applications, scripts, or shell sessions effectively.

Question 15 

Which command is used to display the currently mounted filesystems?

A) mount
B) df
C) lsblk
D) fdisk

Answer: A) mount

Explanation: 

Linux systems use the concept of mounting devices to access storage. Mounted filesystems are attached to specific directories, known as mount points. The mount command, when run without options, displays all currently mounted filesystems along with device names, mount points, filesystem types, and mount options. For example, running mount may show /dev/sda1 on / type ext4 (rw,relatime), which indicates that the root filesystem is mounted as read/write.

A) mount – Correct. Displays all mounted filesystems and their details. Administrators use it to verify mounts, troubleshoot missing drives, or prepare for unmounting or remounting filesystems.

B) df – The df command provides a summary of disk space usage for all mounted filesystems, including total size, used space, available space, and usage percentage. It is particularly helpful for monitoring storage capacity and identifying filesystems approaching full utilization. While df gives an overview of disk consumption, it does not show detailed mount options, filesystem types, or in-depth inode usage. To obtain more detailed information, other commands like mount or lsblk may be required. Using df -h presents the information in a human-readable format, making it easier to interpret sizes in KB, MB, or GB.

C) lsblk –The lsblk command provides a hierarchical view of all block devices on a Linux system, including hard drives, SSDs, and removable media. It shows device names, sizes, types (disk, partition, or LVM), and associated mount points if available. While it is useful for understanding the storage layout, lsblk focuses on the structural organization of devices rather than actively reporting which devices are currently mounted or their usage statistics. Combining lsblk with other commands like df or mount gives a fuller picture of both the physical device structure and the runtime filesystem status. This makes it valuable for system administrators during storage configuration and troubleshooting.

D) fdisk – The fdisk command is a powerful utility in Linux used for managing disk partitions on block devices. With fdisk, administrators can create, delete, resize, or modify partitions, set partition types, and write partition tables to disks. It operates at the device level, directly modifying the disk’s partition table, which makes it essential for preparing new disks or restructuring existing storage. However, fdisk does not provide information about currently mounted filesystems or their usage; it only shows the defined partitions on a disk. For a complete view of active filesystems, it is often combined with commands like mount or df. Proper caution is required when using fdisk, as incorrect changes can result in data loss.

Understanding mount is essential for system administration. Proper mounting ensures correct file access, permissions, and disk usage tracking. Misconfigured mounts can lead to data loss or system errors. Combining mount with df or lsblk provides a complete view of storage health and organization.

Question 16 

Which command is used to copy files in Linux?

A) mv
B) cp
C) rm
D) touch

Answer: B) cp

Explanation: 

Copying files is a fundamental operation in Linux. The cp command creates a duplicate of a file or directory at a specified location. By default, it copies files but can also copy directories using the -r (recursive) option. For example, cp file.txt /backup/file.txt creates a copy of file.txt in the /backup directory. cp also supports options like -i (interactive) to prompt before overwriting and -p to preserve file attributes.

A) mv – The mv command in Linux is primarily used for moving files or directories from one location to another, effectively changing their path in the filesystem. It can also be used to rename files or directories by specifying a new name in the same location. Unlike the cp command, which creates a duplicate, mv does not retain the original; the source file is removed after the operation completes. The command works across directories and can move multiple files at once. Options such as -i prompt for confirmation before overwriting existing files, while -v provides verbose output showing what actions are performed. Care must be taken when moving important files, especially across filesystems, to avoid accidental data loss. This command is fundamental for filesystem organization, cleanup, and restructuring in Linux environments.

B) cp – Correct. The cp command in Linux is used to create copies of files or directories, preserving the original while generating duplicates at a specified location. It is widely used for backup purposes, testing changes safely without modifying the original file, or replicating directory structures across locations. Using options like -r or -R allows recursive copying of directories along with their contents. The -i option prompts before overwriting existing files, and -v provides verbose output showing each copied file. Proper use of cp ensures data safety, supports workflow efficiency, and helps maintain organized and reliable file management practices in Linux systems.

C) rm –The rm command in Linux is a powerful utility used to delete files and directories permanently. Unlike commands such as cp or mv, it does not create copies or move files—it completely removes them from the filesystem. When used with the -r option, it can recursively delete directories and their contents. Additional flags like -f force deletion without prompts, while -i prompts the user for confirmation before each removal, providing a safety mechanism. Misusing rm, especially with root privileges or on critical system directories, can cause irreversible data loss. Therefore, understanding its options and exercising caution is essential for safe system administration and effective file management.

D) touch – The touch command in Linux is primarily used to create new, empty files quickly or to update the access and modification timestamps of existing files. Unlike commands such as cp, which duplicates file content, touch does not modify the file’s content. It is often used in scripting and system administration to generate placeholder files, trigger processes that rely on file timestamps, or ensure that certain files exist before operations. Combined with options like -c (which prevents creating a file if it does not exist) or -t (to set a specific timestamp), touch provides flexibility for managing file metadata efficiently without altering the actual data within the files.

Copying files safely is critical in Linux. Administrators often combine cp with options to preserve attributes or recursively copy directories. Knowledge of cp versus mv and rm is tested in Linux Essentials to ensure safe file operations without unintended deletion.

Question 17

Which command is used to remove a file in Linux?

A) rm
B) rmdir
C) del
D) unlink

Answer: A) rm

Explanation: 

The rm command is used to remove files permanently in Linux. Unlike graphical systems, deletion is immediate; files are not moved to a trash folder. To delete a file, simply use rm filename. Recursive deletion of directories requires the -r option (rm -r folder). Safety options include -i to prompt for confirmation before each removal.

A) rm – Correct. Deletes files or directories (with -r). It is essential to use with caution because data recovery is not straightforward.

B) rmdir – Removes empty directories only. It will fail if the directory contains files.

C) del – Not a standard Linux command; used in DOS/Windows.

D) unlink – Removes a single file at a time. Functionally similar to rm but less commonly used interactively.

Understanding rm versus rmdir and unlink ensures safe file management in Linux Essentials and daily administration. Misusing rm -r can delete critical system files, so caution and understanding options are important.

Question 18

Which command shows the last few lines of a file?

A) head
B) tail
C) cat
D) less

Answer:B) tail

Explanation:

tail displays the end of a file, usually the last 10 lines by default. It is commonly used to monitor logs. The -f option allows real-time viewing of file updates, such as tail -f /var/log/syslog.

A) head – Displays the first lines of a file, not the last.

B) tail – Correct. Ideal for monitoring recent log entries or output.

C) cat – Displays the full file content sequentially, not limited to the last lines.

D) less – Allows interactive scrolling through a file; it does not automatically display only the last lines.

Knowing tail is critical for troubleshooting and monitoring system activity in Linux Essentials. Real-time monitoring with -f is frequently used by administrators to track errors or system events efficiently.

Question 19

Which command shows the Linux kernel version?

A) uname -r
B) version
C) kernel
D) lsmod

Answer: A) uname -r

Explanation:

uname displays system information. The -r option shows the kernel release version, such as 5.15.0-60-generic.

A) uname -r – Correct. Standard method to identify kernel version, useful for troubleshooting hardware compatibility and system updates.

B) version – Not a valid command in Linux.

C) kernel – Not a standalone command; sometimes referenced in /proc/version.

D) lsmod – Lists loaded kernel modules, not the kernel version.

Knowing the kernel version is essential for updates, module compatibility, and certification exam scenarios.

Question 20

Which of the following commands can create a new empty file?

A) touch
B) cp
C) mkdir
D) nano

Answer: A) touch

Explanation: 

touch creates an empty file or updates timestamps. For example, touch file.txt creates a new file if it does not exist.

A) touch – Correct. The touch command offers a fast and efficient way to create empty files, which is particularly useful in testing, scripting, or setting up placeholders in a directory structure. It allows developers and administrators to prepare environments, simulate file presence, or trigger automated processes that rely on file existence without adding any content.

B) cp – The cp command is specifically designed to duplicate existing files or directories from one location to another. Unlike commands that create empty files, cp preserves the content of the source files, and with options like -r for directories or -p for preserving permissions and timestamps, it ensures accurate replication of data.

C) mkdir – Creates directories, not files.

D) nano – Opens a text editor to create or edit files; it is interactive and not suitable for automated file creation.

Understanding touch is essential for scripting, testing, and basic file management in Linux Essentials. It is frequently tested as a basic command for creating files efficiently.

 

img