Unit 1: Linux Command Line and User Management - Subjective Questions
CSE493 — Linux System Administration • Practice Questions with Detailed Answers
20 questions
Explain the different methods of accessing the Linux command line. Compare accessing the command line through a local console with accessing it through a desktop environment.
The Linux command line is a text-based interface used to execute commands and administer the system.
- Local console: A user can access a virtual terminal directly from the machine, usually by pressing a key combination such as
Ctrl+Alt+F3. The user then logs in with a username and password. This method is useful when the graphical interface is unavailable. - Desktop environment: A terminal emulator, such as GNOME Terminal, can be opened from the graphical desktop. It provides command-line access while allowing the user to continue using graphical applications.
- Main differences:
- A local console does not require a graphical interface.
- A desktop terminal runs within the graphical environment.
- Both provide access to shells, commands, files, and system-management tools.
The local console is more suitable for system recovery, while a desktop terminal is convenient for everyday administration.
Describe the process of executing commands using the Bash shell. Explain the role of the shell prompt, command syntax, options, and arguments.
Bash is a command interpreter that reads commands entered by the user and executes them.
A typical command has the following structure:
command [options] [arguments]
- The shell prompt indicates that Bash is ready to accept input. For example,
$commonly represents a normal user, while#generally represents the root user. - The command specifies the program to run, such as
lsorpwd. - Options modify command behavior. They commonly begin with
-or--, such asls -l. - Arguments identify the objects on which the command operates, such as a file or directory.
- Bash searches directories listed in the
PATHenvironment variable to locate commands. - After execution, the command returns an exit status. A status of
0usually means success, while a nonzero value indicates an error.
Bash also supports variables, pipes, redirection, wildcards, command history, and tab completion.
Explain the Linux File System Hierarchy. Describe the purpose of /, /home, /etc, /var, /usr, /tmp, and /root.
The Linux File System Hierarchy organizes files and directories in a tree structure that begins at the root directory, /.
/: The top-level directory containing all other filesystems and directories./home: Contains personal directories and files belonging to ordinary users./etc: Stores system-wide configuration files./var: Contains variable data, including logs, mail queues, caches, and spool files./usr: Contains most user programs, libraries, documentation, and shared read-only data./tmp: Stores temporary files created by applications and users. Its contents may be removed automatically./root: The home directory of the root, or superuser, account.
Other important directories include /bin for essential commands, /dev for device files, /proc for process and kernel information, and /boot for boot-related files. Understanding this hierarchy helps administrators locate configuration files, user data, programs, and logs.
Compare absolute and relative pathnames in Linux. Give suitable examples showing how each is used to access files and directories.
A pathname identifies the location of a file or directory.
- An absolute pathname starts from the root directory
/and specifies the complete location. It does not depend on the user's current working directory. For example:/home/student/notes.txt/etc/ssh/sshd_config
- A relative pathname starts from the current working directory. It does not begin with
/. For example, if the current directory is/home/student, thennotes.txtrefers to/home/student/notes.txt. .represents the current directory...represents the parent directory.
For example, cd /var/log always changes to the same directory, whereas cd ../admin depends on the current location. Absolute paths are reliable in scripts and administrative commands, while relative paths are shorter and convenient for interactive work.
Explain how files can be located by name in Linux. Compare the use of the find and locate commands, including their advantages and limitations.
Linux provides several commands for locating files by name.
- The
findcommand searches directories in real time. Example:find /home -name "report.txt"find /var -type f -name "*.log"
- The
locatecommand searches a prebuilt database of file paths. Example:locate report.txt
Comparison:
findsearches the current filesystem directly, so it can locate recently created files.findsupports conditions such as file type, owner, permissions, size, and modification time.locateis usually faster because it searches an indexed database.locatemay not find files created after the database was last updated.- Access restrictions may prevent either command from displaying certain paths.
Administrators should use find when accuracy and advanced conditions are required, and locate when a quick name-based search is sufficient.
Describe the major command-line tools used to manage files and directories in Linux. Include examples of creating, copying, moving, renaming, and deleting files.
Common file-management tools include:
touch file.txt: Creates an empty file or updates its timestamp.mkdir project: Creates a directory.cp source.txt backup.txt: Copies a file.cp -r source_dir destination_dir: Recursively copies a directory.mv oldname.txt newname.txt: Moves or renames a file.rm file.txt: Deletes a file.rm -r directory: Deletes a directory and its contents recursively.rmdir emptydir: Removes an empty directory.ls: Lists directory contents.file filename: Identifies the type of a file.
The -i option can request confirmation before overwriting or deleting, while -v often displays the operation being performed. Administrators should verify pathnames carefully before using commands such as rm, especially with recursive or superuser privileges.
Explain pathname expansion in Bash. Describe the use of *, ?, and bracket expressions, and distinguish pathname expansion from regular expressions.
Bash performs pathname expansion, also called globbing, before executing a command. It replaces patterns with matching filenames.
*matches any sequence of characters, including an empty sequence. Example:ls *.txtlists files ending in.txt.?matches exactly one character. Example:ls file?.logmatchesfile1.logbut notfile10.log.- Bracket expressions match one character from a set or range. Examples:
file[12].txtmatchesfile1.txtandfile2.txt.file[a-c].txtmatches files containinga,b, orcin that position.
- A leading dot is usually not matched by
*unless the pattern explicitly begins with..
Pathname expansion is performed by the shell on filenames. Regular expressions are pattern languages used by tools such as grep, sed, and awk, and they have different rules and purposes.
Explain shell expansion and quoting in Bash. Discuss variable expansion, command substitution, tilde expansion, and the effects of single and double quotation marks.
Shell expansion allows Bash to replace special expressions with values before a command runs.
- Tilde expansion:
~expands to the current user's home directory, while~userrefers to another user's home directory. - Variable expansion:
$HOMEis replaced by the value of theHOMEvariable. - Command substitution:
$(date)replaces the expression with the output of thedatecommand. - Pathname expansion: Wildcards such as
*.confare expanded to matching filenames.
Quoting controls expansion:
- Single quotes:
'${HOME}'preserve the characters literally; no variable or command substitution occurs. - Double quotes:
"$HOME"allow variable and command substitution but prevent word splitting and pathname expansion in the resulting value. - Backslash:
\can escape the special meaning of the next character.
Correct quoting is important when filenames or variable values contain spaces, wildcard characters, or shell metacharacters.
Explain how a Linux administrator can obtain help in Red Hat Enterprise Linux using the man, pinfo, and /usr/share/doc resources.
Red Hat Enterprise Linux provides several documentation sources.
- The
mancommand displays manual pages. For example,man lsopens the manual forls. Manual pages are organized into sections, such as section1for user commands and section5for file formats.man 5 passwdspecifically opens the password-file documentation. - The
pinfocommand provides an interface for reading GNU Info documentation. It is useful for software whose documentation is organized as linked nodes rather than traditional manual pages. - The
/usr/share/docdirectory contains package-specific documentation such as README files, examples, changelogs, and licensing information. - Commands such as
apropos keywordorman -k keywordsearch manual-page descriptions.
An administrator should begin with man for command syntax, use pinfo for detailed GNU documentation, and inspect /usr/share/doc for package-specific guidance and examples.
Describe how Red Hat Enterprise Linux users can obtain help from Red Hat. Explain the role of local documentation, Red Hat documentation, and support services.
Red Hat provides multiple sources of technical assistance.
- Installed documentation: Manual pages, Info pages, package documentation, command help options, and configuration examples are available locally.
- Red Hat product documentation: Official online documentation explains installation, configuration, security, networking, storage, and system administration procedures for specific releases.
- Red Hat Knowledgebase: Subscribers can search solutions, known issues, technical articles, and troubleshooting procedures.
- Red Hat support cases: Customers with an applicable subscription can submit support cases and provide logs, configuration details, and diagnostic information.
- Community resources: Red Hat-related forums and project documentation can help with general questions, but official documentation should be preferred for supported procedures.
A good troubleshooting process is to identify the exact product version, reproduce the issue, inspect logs and error messages, consult local and official documentation, and then contact support with precise diagnostic information when necessary.
Explain the techniques used to create, view, and edit text files from the Linux command line. Include the purposes of cat, less, head, tail, and a shell text editor.
Text files can be managed using both commands and editors.
touch file.txtcreates an empty file.cat file.txtdisplays the complete contents of a short file and can combine multiple files.less file.txtdisplays a file page by page and supports searching and navigation. It is more suitable for large files.head file.txtdisplays the first lines, whiletail file.txtdisplays the last lines.tail -f /var/log/messagescan follow a log file as new lines are added.- A shell editor such as
vimornanoallows the user to create and modify text interactively. - Output redirection can create a file from command output, for example,
ls > listing.txt.
These tools are especially useful for inspecting logs, editing configuration files, and creating scripts when a graphical interface is unavailable.
Explain output redirection in Bash. Distinguish between >, >>, standard error redirection, and pipes, giving suitable examples.
Linux commands normally use standard input, standard output, and standard error.
>redirects standard output to a file and overwrites the file if it exists:ls -l > listing.txt
>>appends standard output to a file:date >> system.log
2>redirects standard error:find / -name "config" 2> errors.txt
&>redirects both standard output and standard error in Bash:command &> result.txt
- A pipe, written as
|, sends the output of one command directly to another command:ps aux | lessgrep "failed" /var/log/messages | wc -l
Redirection stores or transfers data, while a pipe connects commands into a processing sequence. Careful use of > is important because it can destroy existing file contents.
Compare editing text files from the shell prompt with editing them using a graphical editor. State the advantages, limitations, and appropriate uses of both methods.
Text files can be edited through terminal-based editors or graphical editors.
Shell-based editing:
- Editors such as
vim,vi, andnanorun in a terminal. - They work over remote connections and when no graphical environment is available.
- They are suitable for server configuration, scripts, and emergency recovery.
vimprovides powerful navigation, searching, macros, and automation but has a steeper learning curve.nanois simpler but provides fewer advanced features.
Graphical editing:
- Editors such as GNOME Text Editor provide menus, mouse support, syntax highlighting, and convenient text selection.
- They are easier for many beginners and useful for general document editing.
- They require a working graphical session and may not be available on remote or minimal servers.
Administrators should use a terminal editor for remote or recovery work and a graphical editor when convenience and desktop integration are more important.
Explain the Linux concepts of users, groups, user IDs, and group IDs. How do these concepts support file ownership and access control?
Linux identifies users and groups numerically and symbolically.
- A user account represents an individual or service that can access the system.
- Each user has a unique UID, or user ID.
- A group is a collection of users used to manage shared access.
- Each group has a unique GID, or group ID.
- Every file has an owning user and an owning group.
- File permissions are defined for the owner, group, and other users.
For example, permissions such as -rw-r----- mean that the owner can read and write, members of the owning group can read, and all other users have no access. A user's primary group is associated with the account by default, while supplementary groups provide additional access. This model allows administrators to grant access to teams without assigning permissions individually to every user.
Describe the methods of gaining superuser access in Linux. Compare using su with using sudo, and explain why superuser access should be used carefully.
The superuser, commonly called root, has unrestricted control over the system.
su -starts a login shell as root after authenticating with the root password. The-loads root's login environment.sudo commandruns a single command with elevated privileges after authenticating according to the sudo policy.sudo -istarts an interactive root login shell when a complete administrative session is required.
Comparison:
suchanges the current identity and generally requires the root password.sudogrants controlled, logged, and often temporary privilege to authorized users.sudosupports fine-grained policies, allowing specific users to run selected commands.
Superuser commands can modify or delete critical system files, change permissions, or affect all users. Administrators should use the least privilege necessary, verify commands carefully, and avoid using root for routine activities.
Explain how local user accounts are managed in Linux. Describe the purposes of useradd, usermod, and userdel, including important account properties.
Local user accounts are stored and managed on the individual Linux system.
useradd usernamecreates a user account. Options can specify the home directory, login shell, UID, and supplementary groups.usermodmodifies an existing account. For example,usermod -aG developers aliceaddsaliceto thedeveloperssupplementary group. The-aoption is important because it preserves existing supplementary groups.userdel usernameremoves an account.userdel -r usernamealso removes the user's home directory and mail spool, so it must be used carefully.
Important account properties include the username, UID, primary group, supplementary groups, home directory, login shell, password status, and account expiration information. After creating a user, an administrator normally assigns a password and verifies ownership and group membership. Account changes should follow organizational security and naming policies.
Describe how local groups are created, modified, and deleted in Linux. Explain the difference between a user's primary group and supplementary groups.
Groups simplify the management of shared permissions.
groupadd groupnamecreates a local group.groupmodchanges group properties, such as its name or GID.groupdel groupnamedeletes a group, provided it is not the primary group of an existing user.usermod -aG groupname usernameadds a user to a supplementary group.gpasswd -d username groupnamecan remove a user from a supplementary group.id usernamedisplays the user's UID, primary GID, and supplementary groups.
The primary group is the default group associated with a user's new files and processes. A user can belong to multiple supplementary groups, which provide additional permissions to shared resources. Group membership changes may require the user to log out and log back in before the new group information appears in the session.
Explain how user passwords are managed in Linux. Include password creation, modification, expiration, and basic security practices.
The passwd command is used to manage user passwords.
- A user can change their own password by running
passwd. - An administrator can set another user's password with
sudo passwd username. passwd -l usernamelocks a password, whilepasswd -u usernameunlocks it.passwd -e usernameforces the user to change the password at the next login.chagemanages password aging, including minimum age, maximum age, warning period, and account expiration. For example,chage -l usernamedisplays aging information.
Password information is stored in protected form in /etc/shadow, while account information is commonly stored in /etc/passwd. Good practices include using long, unique passwords, enforcing suitable aging policies where required, avoiding shared accounts, locking inactive accounts, and protecting access to password databases.
Describe the relationship among /etc/passwd, /etc/group, and /etc/shadow. Explain the main fields stored in each file and why their permissions are important.
These files contain core local account and group information.
/etc/passwdcontains one line per user. Important fields include username, a password placeholder such asx, UID, primary GID, comment or user information, home directory, and login shell./etc/groupcontains group names, GIDs, and lists of supplementary group members./etc/shadowstores password hashes and password-aging information, including the last password change, minimum and maximum age, warning period, and account expiration values.
The password hashes in /etc/shadow must be protected because they can be targeted for password cracking. Typically, /etc/passwd and /etc/group are readable by ordinary users so programs can resolve account information, while /etc/shadow is restricted to root and authorized system components. Administrators should use account-management commands instead of manually editing these files whenever possible.
A user reports that they cannot access a configuration file. Derive a systematic command-line procedure to diagnose the problem using ownership, groups, permissions, and superuser access.
A systematic diagnosis can proceed as follows:
- Confirm the pathname and inspect the file:
ls -l /path/to/filefile /path/to/file
- Check the user's identity and group membership:
id username
- Examine each directory in the path because directory execute permission is required to traverse it:
namei -l /path/to/file
- Compare the file's owner and group with the user's UID and groups.
- Interpret the permission bits for owner, group, and others.
- Check for special access controls if ordinary permissions appear correct, such as ACLs using
getfacl. - Test access as the affected user rather than assuming the administrator's access is equivalent.
- If authorized, use
sudofor the required operation and record the reason.
The administrator should correct the ownership, group membership, or permissions with appropriate commands such as chown, chgrp, or chmod, while granting only the minimum required access.
Explain the different methods of accessing the Linux command line. Compare accessing the command line through a local console with accessing it through a desktop environment.
The Linux command line is a text-based interface used to execute commands and administer the system.
- Local console: A user can access a virtual terminal directly from the machine, usually by pressing a key combination such as
Ctrl+Alt+F3. The user then logs in with a username and password. This method is useful when the graphical interface is unavailable. - Desktop environment: A terminal emulator, such as GNOME Terminal, can be opened from the graphical desktop. It provides command-line access while allowing the user to continue using graphical applications.
- Main differences:
- A local console does not require a graphical interface.
- A desktop terminal runs within the graphical environment.
- Both provide access to shells, commands, files, and system-management tools.
The local console is more suitable for system recovery, while a desktop terminal is convenient for everyday administration.
Did this save you a night before the exam?
LPU Notes is free, and it stays free. Ads cover part of the server bill. The rest comes out of a student's own pocket: the domain, the storage, and keeping the site up through the weeks everyone needs it at once.
The payment button didn't load. An ad blocker or a filtered network is the usual reason. to try again.
Nothing here is ever locked, and nothing unlocks. Chip in only if it was worth it. What it pays for →