Visit here for our full LPI 010-160 exam dumps and practice test questions.
Question 76
Which command is used to display the current working directory in Linux?
A) cd
B) ls
C) pwd
D) mkdir
Answer: C
Explanation:
The pwd command, which stands for print working directory, displays the absolute path of the current directory where the user is located in the filesystem hierarchy. This command is fundamental for navigation and orientation within the Linux filesystem, helping users understand their current location especially when working with relative paths or complex directory structures.
When executed without any options, pwd displays the full path from the root directory to the current location. For example, if a user is working in the documents folder within their home directory, pwd might display /home/username/documents. This absolute path representation starts from the root directory indicated by the leading forward slash and shows every directory in the path to the current location.
The pwd command supports two primary options that affect how symbolic links are handled. The -L option, which is typically the default behavior, displays the logical path including any symbolic links that were followed to reach the current directory. The -P option displays the physical path, resolving all symbolic links to show the actual directory location in the filesystem without link references.
Understanding the current working directory is essential for many Linux operations. Relative paths in commands are interpreted relative to the current working directory. For example, if the current directory is /home/username and a user references documents/file.txt, the system interprets this as /home/username/documents/file.txt. Knowing the current directory helps users construct correct relative paths and understand command behavior.
The cd command changes directories rather than displaying the current location. The ls command lists directory contents. The mkdir command creates new directories. While these commands relate to directory navigation and management, only pwd specifically displays the current working directory path, providing the essential location information users need for filesystem navigation and command execution.
Question 77
Which file contains user account information in Linux?
A) /etc/shadow
B) /etc/group
C) /etc/passwd
D) /etc/hosts
Answer: C
Explanation:
The /etc/passwd file serves as the primary database for user account information on Linux systems, containing essential details about each user account including username, user ID, default shell, and home directory location. This text file maintains one line per user account with fields separated by colons, making it human-readable while providing the system with critical user configuration data.
Each line in /etc/passwd contains seven colon-separated fields in a specific order. The first field contains the username used for login. The second field historically contained the encrypted password but now typically contains an x indicating that password information resides in the more secure /etc/shadow file. The third field contains the numeric user ID, a unique number identifying the user to the system. The fourth field contains the primary group ID number.
The fifth field contains the GECOS field, which traditionally stores user information like full name and contact details, though its contents vary by system and organizational policy. The sixth field specifies the user’s home directory path where personal files are stored. The seventh field defines the login shell, the command interpreter launched when the user logs in, such as /bin/bash or /bin/sh.
The /etc/passwd file is world-readable, meaning any user can view its contents, because many system utilities need access to username and ID mappings for proper operation. Commands like ls use this file to display usernames instead of numeric UIDs in file listings. This readability is why actual passwords moved to the restricted /etc/shadow file where only privileged processes can access them.
The /etc/shadow file stores encrypted passwords separately with restricted permissions. The /etc/group file contains group information not individual user accounts. The /etc/hosts file maps hostnames to IP addresses for network configuration. Only /etc/passwd contains the comprehensive user account information including usernames, IDs, home directories, and default shells that define user accounts on Linux systems.
Question 78
What is the purpose of the sudo command in Linux?
A) To shut down the system
B) To execute commands with elevated privileges as another user, typically root
C) To display system uptime
D) To search for files
Answer: B
Explanation:
The sudo command, standing for superuser do, enables authorized users to execute commands with elevated privileges, typically as the root user, without requiring knowledge of the root password or logging in as root directly. This mechanism provides controlled privilege escalation where regular users can perform administrative tasks while maintaining accountability through logging and granular permission control through configuration policies.
When a user executes a command prefixed with sudo, the system checks the /etc/sudoers configuration file to determine whether that user is authorized to run the requested command with elevated privileges. If authorized, sudo prompts for the user’s own password, not the root password, as verification. After successful authentication, sudo executes the specified command with root privileges or as another specified user, then returns to normal user privileges.
The sudo approach provides several security advantages over traditional root login. It creates audit trails logging which users executed which commands with elevated privileges, enabling accountability and security monitoring. It implements the principle of least privilege by granting elevated access only for specific commands rather than full root access. It eliminates the need to share the root password among multiple administrators since each uses their own password.
Configuration through the /etc/sudoers file enables fine-grained control over who can execute what commands. Administrators can grant users permission to run all commands, specific commands only, or commands with specific arguments. Time limits can cache authentication so users don’t need to re-enter passwords for multiple sudo commands within a short period. User and group-based rules enable role-based access control aligned with organizational structures.
The shutdown command powers down systems. The uptime command displays system running time. The find command searches for files. While sudo can be used to execute these commands with elevated privileges, its core purpose is not performing these specific functions but rather providing the controlled privilege escalation mechanism that enables executing any authorized command with higher permissions.
Question 79
Which command is used to change file permissions in Linux?
A) chown
B) chmod
C) chgrp
D) umask
Answer: B
Explanation:
The chmod command, short for change mode, modifies file and directory permissions on Linux systems, controlling who can read, write, or execute files. This essential command enables administrators and file owners to implement access control policies by setting permissions that determine which users and groups can interact with files and how they can interact with them.
Linux permissions operate on three categories of users: the file owner, members of the file’s group, and all other users. For each category, three permission types exist: read permission allowing viewing file contents or listing directory contents, write permission allowing modifying files or creating and deleting files in directories, and execute permission allowing running files as programs or entering directories.
The chmod command supports two notation systems for specifying permissions. Symbolic notation uses letters where u represents user owner, g represents group, o represents others, and a represents all categories. Operators include + to add permissions, – to remove permissions, and = to set exact permissions. For example, chmod u+x file.txt adds execute permission for the owner, while chmod go-w file.txt removes write permission from group and others.
Numeric or octal notation uses three-digit numbers where each digit represents permissions for one user category. Each permission type has a numeric value: read equals 4, write equals 2, and execute equals 1. The sum of desired permissions creates the digit. For example, chmod 755 file.txt sets read, write, and execute for the owner, and read and execute for group and others.
The chown command changes file ownership not permissions. The chgrp command changes group ownership. The umask command sets default permissions for newly created files. While these commands relate to file access control, only chmod directly modifies the permission settings that control read, write, and execute access to existing files and directories.
Question 80
What does the command “ls -l” display in Linux?
A) Hidden files only
B) A long listing format with detailed file information including permissions, ownership, and timestamps
C) Only directories
D) File contents
Answer: B
Explanation:
The ls -l command displays directory contents in long listing format, providing detailed information about each file and directory including permissions, link count, owner, group, size, modification time, and filename. This comprehensive view enables users to understand file characteristics and attributes beyond simple filenames, supporting informed decisions about file management and access control.
The long listing format presents each file on a separate line with multiple columns of information. The first column displays the file type and permissions using a 10-character string. The first character indicates file type where dash represents regular files, d represents directories, l represents symbolic links, and other letters represent special file types. The remaining nine characters represent read, write, and execute permissions for owner, group, and others.
The second column shows the number of hard links pointing to the file. For directories, this number indicates the number of subdirectories plus two for the directory itself and its parent reference. The third and fourth columns display the owner username and group name, identifying who owns the file and which group has group permissions. The fifth column shows file size in bytes unless different units are specified with additional options.
The sixth, seventh, and eighth columns display the modification timestamp showing when the file was last modified. For recent files, this shows month, day, and time. For older files, it shows month, day, and year. The final column contains the filename. For symbolic links, the listing also shows the link target after an arrow indicating where the link points.
The ls command without options shows only filenames. The -a option shows hidden files. The -d option shows directory information rather than contents. The cat command displays file contents. Only the -l option provides the comprehensive long listing format showing detailed file metadata including permissions, ownership, size, and timestamps essential for system administration and file management.
Question 81
Which command is used to create a new directory in Linux?
A) touch
B) mkdir
C) rmdir
D) cp
Answer: B
Explanation:
The mkdir command, short for make directory, creates new directories in the Linux filesystem. This fundamental file management command enables users and administrators to organize files into hierarchical structures by creating folders that contain related files and subdirectories, supporting logical organization of data and programs.
When executed with a directory name, mkdir creates a new directory with that name in the current working directory. For example, mkdir documents creates a new directory named documents. The command can also accept absolute or relative paths to create directories in locations other than the current directory, such as mkdir /home/username/projects creating a projects directory in the specified location.
The mkdir command supports several useful options that extend its functionality. The -p option creates parent directories as needed, enabling creation of entire directory paths in a single command. For example, mkdir -p dir1/dir2/dir3 creates all three directories even if dir1 and dir2 do not exist. Without the -p option, mkdir would fail if parent directories are missing.
The -m option sets permissions for the newly created directory at creation time rather than requiring a separate chmod command. For example, mkdir -m 755 newdir creates a directory with specific permissions. The -v option provides verbose output showing which directories were created, useful in scripts or when creating multiple directories to confirm successful operations.
Directory creation respects file permissions and ownership rules. Users can only create directories in locations where they have write permission. Newly created directories inherit the group ownership from the parent directory depending on system configuration. Default permissions applied to new directories can be controlled through the umask setting.
The touch command creates files not directories. The rmdir command removes directories. The cp command copies files and directories. Only mkdir provides the specific functionality for creating new directories in the Linux filesystem hierarchy.
Question 82
What is the purpose of the grep command in Linux?
A) To compress files
B) To search for patterns or text within files and output matching lines
C) To change file ownership
D) To display disk usage
Answer: B
Explanation:
The grep command, whose name derives from globally search for a regular expression and print, searches through text files or input streams for lines matching specified patterns, displaying matching lines to standard output. This powerful text processing tool enables users to locate specific information within files, filter command output, and analyze log files, making it indispensable for system administration and text data processing.
Basic grep usage involves providing a search pattern and one or more files to search. For example, grep error logfile.txt searches logfile.txt for lines containing the word error and displays those lines. The pattern matching is case-sensitive by default, so error would not match Error unless case-insensitive options are used. Multiple files can be searched simultaneously with grep pattern file1.txt file2.txt.
The grep command supports regular expressions enabling sophisticated pattern matching beyond simple text strings. Regular expressions use metacharacters to define flexible search patterns. For example, grep ‘^error’ file.txt finds lines starting with error using the caret anchor. Square brackets create character classes, asterisks indicate repetition, and pipes specify alternatives creating powerful search capabilities.
Common grep options extend its functionality. The -i option performs case-insensitive searches matching both uppercase and lowercase. The -v option inverts matching, displaying lines that do not match the pattern, useful for filtering out unwanted content. The -r option recursively searches directories. The -n option displays line numbers with matching lines. The -c option counts matching lines without displaying them.
Advanced options include -A to display lines after matches, -B for lines before matches, and -C for context lines both before and after. The -E option enables extended regular expressions with additional metacharacters. The -F option treats patterns as fixed strings disabling regular expression interpretation for literal searches.
File compression uses commands like gzip. Ownership changes use chown. Disk usage display uses du or df. Only grep provides pattern searching and text matching functionality for finding specific content within files and input streams.
Question 83
Which file contains group information in Linux?
A) /etc/passwd
B) /etc/shadow
C) /etc/group
D) /etc/fstab
Answer: C
Explanation:
The /etc/group file contains group account information on Linux systems, defining groups and their memberships. This text file lists all groups on the system along with group IDs and group members, enabling the system to implement group-based permissions and access control where files and resources can be shared among users who belong to the same group.
Each line in /etc/group represents a single group and contains four colon-separated fields. The first field contains the group name, a human-readable identifier for the group such as users, developers, or administrators. The second field traditionally held group passwords but now typically contains an x or asterisk since group passwords are rarely used in modern systems. If group passwords are used, the encrypted password resides in /etc/gshadow.
The third field contains the group ID, a numeric identifier that the system uses internally to reference the group. Group IDs typically start from 1000 for regular groups on modern systems, with lower numbers reserved for system groups. The fourth field contains a comma-separated list of usernames for supplementary group members, users who belong to this group in addition to their primary group defined in /etc/passwd.
Understanding the relationship between /etc/passwd and /etc/group is important. Each user has a primary group specified in their /etc/passwd entry, which becomes the default group for files they create. Users can also belong to supplementary groups listed in /etc/group, gaining permissions associated with those groups. The groups command displays which groups a user belongs to combining primary and supplementary memberships.
Group management commands interact with /etc/group including groupadd to create new groups, groupmod to modify existing groups, and groupdel to remove groups. The usermod command with the -G option manages user group memberships updating /etc/group accordingly.
The /etc/passwd file contains user information. The /etc/shadow file stores password data. The /etc/fstab file defines filesystem mounts. Only /etc/group contains the group definitions and membership information that enable group-based access control on Linux systems.
Question 84
What does the command “cat filename” do in Linux?
A) Creates a new file
B) Displays the contents of a file to standard output
C) Deletes a file
D) Compresses a file
Answer: B
Explanation:
The cat command, short for concatenate, displays file contents to standard output, enabling users to view text files directly in the terminal. While its name reflects its original purpose of concatenating multiple files, the most common usage is displaying single file contents, making it a fundamental tool for quickly viewing text file contents without opening an editor.
When executed with a filename as an argument, cat reads the entire file and outputs its contents to the terminal. For example, cat readme.txt displays the entire contents of readme.txt. This simple operation is extremely useful for viewing configuration files, reading documentation, examining logs, and verifying file contents. The output appears immediately in the terminal where it can be read, redirected, or piped to other commands.
The cat command can process multiple files in sequence, displaying them one after another. For example, cat file1.txt file2.txt displays file1 followed by file2. This concatenation capability enables combining multiple text files into a single output stream that can be redirected to create merged files or piped to other commands for processing.
Several options modify cat behavior. The -n option numbers all output lines, useful for referencing specific lines in files. The -b option numbers non-empty lines only. The -s option suppresses repeated empty lines, condensing multiple blank lines into single blank lines. The -E option displays dollar signs at line ends, revealing line terminators. The -T option displays tabs as ^I characters, making whitespace visible.
The cat command works best for small to medium files that fit comfortably on screen. For larger files, commands like less or more provide paginated viewing with scrolling capabilities. The cat command should only be used with text files since binary files will produce unreadable output and may disrupt terminal display.
The touch command creates files. The rm command deletes files. Compression uses gzip or similar tools. Only cat displays file contents to standard output for viewing and processing.
Question 85
Which command is used to remove files in Linux?
A) delete
B) remove
C) rm
D) del
Answer: C
Explanation:
The rm command, short for remove, deletes files and directories from the Linux filesystem. This powerful command permanently removes specified files from the system without moving them to a trash or recycle bin, making it essential for file management while requiring careful use since deleted files typically cannot be recovered without specialized tools or backups.
Basic rm usage involves specifying one or more filenames to delete. For example, rm file.txt deletes the file named file.txt from the current directory. Multiple files can be deleted with a single command using rm file1.txt file2.txt file3.txt. Wildcard patterns enable deleting groups of related files such as rm *.tmp deleting all files with the tmp extension.
The rm command supports several important options that modify its behavior. The -i option prompts for confirmation before deleting each file, providing a safety mechanism against accidental deletions. The -f option forces deletion without prompts, overriding write protection and suppressing error messages. The -v option provides verbose output showing which files are being deleted.
Deleting directories requires the -r option which recursively removes directories and their contents. For example, rm -r directoryname deletes the directory and everything inside it. This recursive deletion is powerful but dangerous since entire directory trees can be removed with a single command. Combining options like rm -rf is particularly risky as it forcefully deletes directories without prompts.
Important safety considerations include double-checking filenames before executing rm commands, using -i for interactive confirmation when deleting important files, avoiding rm -rf especially with wildcards or as the root user, and maintaining regular backups since rm deletions are immediate and permanent. The file contents are not securely erased immediately but rather the filesystem references are removed making space available for reuse.
Delete, remove, and del are not standard Linux commands. Only rm provides the file deletion functionality, and understanding its power and permanent nature is critical for safe filesystem management.
Question 86
What is the purpose of the man command in Linux?
A) To manage user accounts
B) To display the manual pages and documentation for other commands
C) To mount filesystems
D) To monitor system performance
Answer: B
Explanation:
The man command, short for manual, displays comprehensive documentation for Linux commands, system calls, library functions, configuration files, and other system components. This built-in help system provides detailed reference information including command syntax, available options, usage examples, and related commands, making it an essential resource for learning command functionality and troubleshooting issues.
Manual pages, commonly called man pages, are organized into numbered sections covering different documentation types. Section 1 contains user commands and executable programs. Section 2 documents system calls. Section 3 covers library functions. Section 4 describes special files and devices. Section 5 documents file formats and conventions. Section 6 contains games and screensavers. Section 7 provides miscellaneous information. Section 8 documents system administration commands.
When executed with a command name, man displays the corresponding manual page using a pager program typically less. For example, man ls displays the manual page for the ls command. Users can scroll through documentation using arrow keys, search for text using forward slash followed by search terms, and exit using the q key. Manual pages follow a standard structure including NAME, SYNOPSIS, DESCRIPTION, OPTIONS, and EXAMPLES sections.
If a topic exists in multiple manual sections, man displays the first match by default. Specific sections can be requested by including the section number before the command name such as man 5 passwd to view the file format documentation for /etc/passwd rather than the passwd command documentation. The -k option searches manual page names and descriptions for keywords enabling discovery of relevant commands.
The apropos command provides similar keyword searching functionality. The info command offers an alternative documentation system with hyperlinked text. The –help option available with most commands provides brief usage information. However, man remains the primary comprehensive documentation source providing detailed reference material for nearly every aspect of Linux systems.
User account management uses commands like useradd and usermod. Filesystem mounting uses mount. Performance monitoring uses commands like top. Only man provides access to the comprehensive manual page documentation system.
Question 87
Which command displays the first few lines of a file in Linux?
A) tail
B) head
C) cat
D) more
Answer: B
Explanation:
The head command displays the first portion of files, by default showing the first 10 lines of each specified file. This command is useful for previewing file contents, examining file headers, viewing the beginning of log files, and quickly checking file format without displaying entire file contents that might overwhelm the terminal with output.
Basic head usage involves providing one or more filenames as arguments. For example, head logfile.txt displays the first 10 lines of logfile.txt. When multiple files are specified, head displays the first lines of each file preceded by a header showing the filename, enabling easy identification when previewing multiple files with a single command.
The -n option, which can also be specified as a hyphen followed by a number, controls how many lines to display. For example, head -n 20 file.txt or head -20 file.txt displays the first 20 lines. The -c option displays a specific number of bytes instead of lines, useful for viewing binary file headers or examining file structure at the byte level.
The head command is particularly valuable when working with large files where displaying entire contents would be impractical. Log files, CSV data files, and text documents often have meaningful information at the beginning such as headers, metadata, or recent entries. Using head enables quick inspection of this information without processing the entire file.
Combining head with other commands through pipes creates powerful workflows. For example, ls -l | head displays the first 10 files in a long directory listing. Processes can be limited using ps aux | head. Log file analysis often uses head to view the beginning of files while tail views the end, together providing understanding of file structure and content range.
The tail command displays the end of files not the beginning. Cat displays entire file contents. More provides paginated viewing. Only head specifically displays the first lines of files, making it the essential tool for previewing file beginnings and examining file headers.
Question 88
What does the command “cp source destination” do in Linux?
A) Moves a file
B) Copies a file or directory from source to destination
C) Deletes a file
D) Creates a link
Answer: B
Explanation:
The cp command, short for copy, creates duplicates of files and directories, copying them from a source location to a destination location while leaving the original unchanged. This fundamental file operation enables backing up files, duplicating configurations, distributing files to multiple locations, and creating working copies for editing without risking original data.
Basic cp usage requires specifying a source file and destination. For example, cp file.txt backup.txt creates a copy of file.txt named backup.txt in the same directory. The destination can specify a different directory such as cp file.txt /backup/file.txt copying the file to another location. If the destination is a directory without a filename, cp uses the original filename in the destination directory.
Multiple source files can be copied to a directory destination with cp file1.txt file2.txt file3.txt /destination/. This creates copies of all specified files in the destination directory maintaining their original filenames. Wildcard patterns enable copying multiple related files such as cp *.txt /backup/ copying all text files.
The -r option enables recursive copying of directories and their contents. For example, cp -r sourcedir destdir copies the entire directory tree. Without -r, attempting to copy a directory results in an error. The -i option prompts before overwriting existing files providing protection against accidental data loss. The -v option displays verbose output showing which files are being copied.
The -p option preserves file attributes including timestamps, permissions, and ownership where possible. This is valuable when backups should maintain original metadata. The -u option performs update copying, copying only when source files are newer than destination files or when destination files do not exist, enabling efficient incremental backups.
The mv command moves files rather than copying. The rm command deletes files. The ln command creates links. Only cp creates duplicate copies of files and directories from source to destination locations.
Question 89
Which command is used to change file ownership in Linux?
A) chmod
B) chown
C) chgrp
D) chattr
Answer: B
Explanation:
The chown command, short for change owner, modifies file and directory ownership on Linux systems, changing which user account and optionally which group owns specific files. This administrative command is essential for managing access control, transferring file ownership between users, and ensuring appropriate ownership after file creation or copying operations that may not preserve original ownership.
Basic chown usage requires root privileges or ownership of the files being modified. The command syntax is chown user:group filename where user specifies the new owner username or numeric UID and group optionally specifies the new group ownership. For example, chown john file.txt changes file.txt ownership to user john. The group portion can be omitted to change only user ownership.
The colon separator enables changing both user and group ownership simultaneously. For example, chown john:developers file.txt assigns ownership to user john and group developers. If the user portion is omitted but the colon is present, only group ownership changes such as chown :developers file.txt. This group-only syntax is functionally equivalent to using chgrp.
The -R option enables recursive ownership changes for directories and their contents. For example, chown -R john:developers /home/john/project changes ownership of the project directory and everything within it. This recursive functionality is valuable after extracting archives, copying directory trees, or reorganizing file structures where ownership needs updating throughout.
Numeric UIDs and GIDs can replace names when names are not available or when working with accounts that do not appear in local user databases. The –reference option copies ownership from a reference file such as chown –reference=file1.txt file2.txt making file2.txt ownership match file1.txt.
The chmod command changes permissions not ownership. The chgrp command changes group ownership specifically. The chattr command modifies file attributes. Only chown provides comprehensive ownership modification capabilities changing both user and group ownership of files and directories.
Question 90
What is the purpose of the df command in Linux?
A) To display free memory
B) To show disk space usage for mounted filesystems
C) To find files
D) To format disks
Answer: B
Explanation:
The df command, short for disk free, displays disk space usage information for all mounted filesystems, showing total space, used space, available space, and usage percentages. This essential system monitoring command enables administrators and users to track filesystem capacity, identify storage constraints, plan capacity expansions, and troubleshoot space-related issues before filesystems fill completely.
When executed without arguments, df displays information for all currently mounted filesystems including physical disk partitions, network filesystems, and virtual filesystems. The default output shows filesystem name or device, total blocks, used blocks, available blocks, percentage used, and mount point. This comprehensive view enables quick assessment of storage status across the entire system.
The -h option displays sizes in human-readable format using units like megabytes, gigabytes, and terabytes rather than raw block counts. For example, df -h shows sizes as 50G or 1.5T making the output much easier to interpret. This human-readable format is extremely popular for interactive use where quick understanding matters more than precise byte counts.
The -T option adds filesystem type information showing whether each filesystem is ext4, xfs, nfs, tmpfs, or other types. This additional detail helps understand storage characteristics and troubleshoot filesystem-specific issues. The -i option displays inode usage instead of block usage, revealing how many file entries are used versus available, which can become a limiting factor separate from space capacity.
Specific filesystems can be examined by providing mount points or device names as arguments. For example, df -h /home shows information only for the filesystem containing /home. The -x option excludes specific filesystem types such as df -x tmpfs omitting temporary filesystems from the output.
The free command displays memory usage not disk space. The find command searches for files. Disk formatting uses commands like mkfs. Only df provides filesystem disk space usage information essential for storage capacity monitoring and management.