Unit 2: Permissions, Processes, Services, SSH, and Logs - Subjective Questions
CSE493 — Linux System Administration • Practice Questions with Detailed Answers
20 questions
Explain the Linux file system permission model. Describe how permissions are assigned to the owner, group, and others.
Linux file system permissions control who can access files and directories and what operations they can perform.
Permissions are assigned to three categories:
- Owner (
u): The user who owns the file or directory. - Group (
g): Users belonging to the group associated with the file. - Others (
o): All other users on the system.
The three basic permissions are:
- Read (
r):- For a file, permits viewing its contents.
- For a directory, permits listing its entries.
- Write (
w):- For a file, permits modifying its contents.
- For a directory, permits creating, deleting, or renaming entries, normally when execute permission is also present.
- Execute (
x):- For a file, permits running it as a program or script.
- For a directory, permits entering or traversing it and accessing known entries.
For example, -rwxr-xr-- means:
- The owner has read, write, and execute permissions.
- The group has read and execute permissions.
- Others have read permission only.
Linux checks the applicable permission class based on the effective user ID and group membership of the process requesting access.
Describe how to interpret the long listing output of the ls -l command, with special reference to file type and permissions.
The ls -l command displays detailed information about files and directories. A typical entry is:
-rwxr-x--- 1 alice developers 4096 Jun 10 10:30 deploy.sh
Its fields are interpreted as follows:
- File type and permissions (
-rwxr-x---):- The first character indicates the file type.
-means regular file,dmeans directory,lmeans symbolic link,bmeans block device, andcmeans character device.- The next three characters are owner permissions.
- The following three are group permissions.
- The final three are permissions for others.
- Link count (
1): Number of hard links to the inode. - Owner (
alice): User that owns the file. - Group (
developers): Group associated with the file. - Size (
4096): File size in bytes. - Timestamp (
Jun 10 10:30): Normally the last modification time. - Name (
deploy.sh): File or directory name.
In this example, the owner has rwx, the group has r-x, and others have no permissions.
Compare symbolic and octal methods of changing permissions with chmod. Illustrate both methods with suitable examples.
The chmod command changes file or directory permissions using either symbolic notation or octal notation.
Symbolic notation
Symbolic notation uses:
ufor ownergfor groupofor othersafor all classes+to add permission-to remove permission=to set an exact permission
Examples:
chmod u+x script.shadds execute permission for the owner.chmod g-w report.txtremoves group write permission.chmod o=r file.txtgives others read permission only.chmod a+r document.txtadds read permission for everyone.
Octal notation
Each permission has a numeric value:
- Read =
4 - Write =
2 - Execute =
1
The values are added for each permission class. For example:
7 = 4 + 2 + 1, meaningrwx6 = 4 + 2, meaningrw-5 = 4 + 1, meaningr-x0means---
Thus, chmod 754 script.sh sets:
- Owner:
7, orrwx - Group:
5, orr-x - Others:
4, orr--
Symbolic notation is convenient for changing selected permissions, whereas octal notation is concise when setting the complete permission mode.
Explain how file ownership and group ownership are managed using chown, chgrp, and related options.
Every Linux file has a user owner and a group owner. Ownership determines which owner and group permission bits apply.
Using chown
The chown command changes the user owner, group owner, or both:
chown alice file.txtchanges the owner toalice.chown alice:developers file.txtchanges the owner toaliceand group todevelopers.chown :developers file.txtchanges only the group.
Using chgrp
The chgrp command changes only group ownership:
chgrp developers file.txt
Recursive changes
The -R option applies ownership changes recursively:
chown -R alice:developers /project
This affects the directory and its contents, so it must be used carefully.
Important considerations
- The superuser can normally assign files to any user or group.
- An ordinary user can usually change the group of a file only to a group of which that user is a member.
- Symbolic links require careful handling; options such as
-hmay be used when ownership of the link itself must be changed. - Ownership can be verified using
ls -l,stat, orfind.
Explain the purpose and operation of the set-user-ID, set-group-ID, and sticky-bit special permissions.
Linux provides three special permissions in addition to read, write, and execute permissions.
Set-user-ID or SUID
- Applied to executable files.
- The process runs with the effective user ID of the file owner rather than that of the user who started it.
- It appears as
sin the owner's execute position. - It is set using
chmod u+s fileor an octal mode beginning with4, such aschmod 4755 file. - SUID programs must be secured carefully because defects may allow privilege escalation.
Set-group-ID or SGID
- On an executable file, the process runs with the effective group ID of the file's group.
- On a directory, newly created entries normally inherit the directory's group, which is useful for shared project directories.
- It appears as
sin the group execute position. - It is set using
chmod g+s directoryor a mode such aschmod 2770 directory.
Sticky bit
- Commonly applied to shared writable directories.
- Users can delete or rename only entries they own, unless they own the directory or have suitable administrative privileges.
- It appears as
tin the others execute position. - It is set using
chmod +t directoryor a mode such aschmod 1777 directory. /tmpis a standard example.
An uppercase S or T indicates that the special bit is set while the corresponding execute permission is absent.
What is umask? Explain how it determines the default permissions of newly created files and directories.
umask, or user file-creation mode mask, removes selected permission bits from the application's requested mode when a new file or directory is created.
Common initial permission sets are:
- Regular files:
666, representingrw-rw-rw- - Directories:
777, representingrwxrwxrwx
The final mode is obtained by clearing the bits specified by the mask. Conceptually:
final mode = requested mode with umask bits removed
For a umask of 022:
- Files normally become
644, orrw-r--r--. - Directories normally become
755, orrwxr-xr-x.
For a umask of 027:
- Files normally become
640, orrw-r-----. - Directories normally become
750, orrwxr-x---.
Useful commands include:
umaskto display the current mask in octal form.umask -Sto display it symbolically.umask 027to set it for the current shell and its child processes.
Persistent values may be configured in shell startup files or system authentication configuration. The umask does not add permissions that the creating application did not request.
Describe how POSIX Access Control Lists provide more flexible file access than traditional Linux permissions. Explain the use of getfacl and setfacl.
Traditional permissions provide only one owner entry, one group entry, and one entry for others. POSIX Access Control Lists, or ACLs, allow permissions to be assigned to additional named users and groups.
Viewing ACLs
The getfacl command displays the ACL of a file:
getfacl report.txt
The output can include the owner, owning group, named-user entries, named-group entries, a mask, and permissions for others.
Setting ACLs
Examples include:
setfacl -m u:bob:rw report.txtgrantsbobread and write access.setfacl -m g:auditors:r report.txtgrants theauditorsgroup read access.setfacl -x u:bob report.txtremoves the ACL entry forbob.setfacl -b report.txtremoves extended ACL entries.
ACL mask
The ACL mask limits the effective permissions of named users, named groups, and the owning group. Therefore, an ACL entry may display more permissions than are effectively available if the mask is restrictive.
Default ACLs
A directory can have a default ACL that is inherited by newly created entries:
setfacl -m d:g:developers:rwx /project
ACLs are particularly useful for shared directories where multiple users and groups need different access levels.
Define a Linux process and explain process IDs, parent-child relationships, process states, and process priorities.
A process is a running instance of a program. It has allocated resources, a security context, open files, environment variables, and scheduling information.
Important process attributes include:
- PID: A unique process identifier.
- PPID: The PID of the process that created the process.
- UID and GID: User and group identities under which the process operates.
- Command: The executable and arguments associated with the process.
- Priority and nice value: Values that influence CPU scheduling.
Common process states include:
R: Running or runnable.S: Interruptible sleep.D: Uninterruptible sleep, often waiting for I/O.T: Stopped or traced.Z: Zombie, meaning the process has exited but its parent has not yet collected its status.
Most processes are created by another process, producing a parent-child relationship. Modern Linux systems typically use systemd as PID 1, which starts and supervises many system processes.
The nice value generally ranges from -20 to 19. A lower value indicates a higher scheduling priority. Commands such as nice and renice adjust this value, subject to privilege restrictions.
Explain Linux job control. Describe how foreground and background jobs are managed using jobs, bg, fg, Ctrl+Z, &, and nohup.
Job control is a shell feature used to manage multiple commands started from the same interactive shell.
Foreground jobs
A foreground job has control of the terminal and receives keyboard input. Normally, the shell waits until it finishes.
Background jobs
A command can be started in the background by appending &:
long_command &
The shell returns a job number and process ID and displays a new prompt.
Suspending and resuming jobs
Ctrl+Zsends a terminal stop signal and suspends the foreground job.jobslists jobs known to the current shell.bg %1resumes job 1 in the background.fg %1brings job 1 to the foreground.
Job specifications such as %1 refer to shell job numbers, not necessarily process IDs.
Continuing after logout
A process may receive SIGHUP when its terminal session closes. nohup makes a command ignore this signal:
nohup long_command >output.log 2>&1 &
For long-running administrative work, terminal multiplexers or properly defined systemd services may provide stronger session and supervision capabilities than basic job control.
Explain how Linux processes are terminated using kill, pkill, and killall. Compare SIGTERM, SIGKILL, SIGHUP, and SIGINT.
Linux controls processes by sending them signals. Despite its name, kill can send any specified signal.
Commands
kill PIDsendsSIGTERMto a process by PID.kill -SIGNAL PIDsends a selected signal.pkill patternsignals processes whose names or attributes match a pattern.killall namesignals processes with the specified command name.kill -llists available signals.
Important signals
SIGTERMor signal 15:- Requests orderly termination.
- Can be caught or handled by the process.
- Allows cleanup of files and resources.
- Should normally be attempted first.
SIGKILLor signal 9:- Terminates a process immediately.
- Cannot be caught, blocked, or ignored.
- May cause incomplete writes or leave application data inconsistent.
SIGHUPor signal 1:- Historically indicates terminal disconnection.
- Many daemons interpret it as a request to reload configuration.
SIGINTor signal 2:- Usually sent by
Ctrl+Cto interrupt a foreground process.
- Usually sent by
A safe termination sequence is to identify the correct process, send SIGTERM, wait and verify, and use SIGKILL only if the process does not stop.
Describe the tools and procedure used to monitor Linux process activity and investigate high CPU or memory usage.
Process monitoring combines snapshot commands, interactive tools, and system information interfaces.
Important tools
ps auxdisplays processes in a BSD-style format.ps -efdisplays processes in a full-format listing.topprovides an interactive, continuously updated view.pgrep namefinds process IDs matching a name or criteria.pidof programfinds PIDs of a program.pstreedisplays parent-child relationships.free -hsummarizes memory usage.uptimereports load averages./proc/PID/contains process-specific kernel information.
Investigation procedure
- Run
uptimeortopto examine system load. - Sort processes by CPU or memory consumption in
top, or use commands such asps aux --sort=-%cpuandps aux --sort=-%mem. - Verify the PID, owner, state, runtime, and command arguments.
- Examine process relationships with
pstreeorpsPPID fields. - Inspect relevant application and system logs.
- Determine whether the issue is CPU saturation, memory pressure, I/O waiting, or a blocked process.
- Correct the underlying problem, adjust priority if appropriate, or terminate the process safely.
Load average is not identical to CPU percentage; it reflects runnable tasks and tasks in certain uninterruptible states over time.
Explain how systemd identifies and starts system processes automatically during boot. Include units, targets, dependencies, and enablement.
systemd is the service and system manager used by many Linux distributions. It runs as PID 1 and manages system startup, services, dependencies, and system state.
Units
A unit is a resource managed by systemd. Common unit types include:
.servicefor services and daemons.socketfor socket-based activation.targetfor grouping units and representing system states.timerfor scheduled activation.mountfor file-system mount points.pathfor path-based activation
Targets
Targets group related units. For example, multi-user.target commonly represents a non-graphical multi-user environment, while graphical.target adds graphical services.
Dependencies and ordering
Unit directives can express:
- Requirement relationships, such as
Requires=andWants= - Ordering relationships, such as
After=andBefore=
Requirement and ordering are distinct: a unit may be ordered after another without requiring it.
Enablement
systemctl enable unitcreates the links required for a unit to be started through its target or another activation mechanism.systemctl disable unitremoves those enablement links.systemctl is-enabled unitreports its enablement state.
Enabled does not necessarily mean currently running, and a running service is not necessarily enabled for future boots. Automatically started processes can be investigated with systemctl list-unit-files, systemctl list-dependencies, and systemctl status.
Describe how to control system services using systemctl. Distinguish among starting, stopping, restarting, reloading, enabling, disabling, and masking a service.
The systemctl command manages services and other systemd units.
Runtime control
systemctl start servicestarts a service in the current boot.systemctl stop servicestops it.systemctl restart servicestops and starts it again.systemctl reload serviceasks it to reread configuration without a full restart, if supported.systemctl reload-or-restart servicereloads when possible and otherwise restarts.
Boot-time control
systemctl enable serviceconfigures the service to start through its defined boot dependencies or activation mechanism.systemctl disable serviceremoves that enablement.systemctl enable --now serviceboth enables and immediately starts it.systemctl disable --now servicedisables and stops it.
Masking
systemctl mask serviceprevents the unit from being started manually or as a dependency by linking it to/dev/null.systemctl unmask serviceremoves the mask.
Inspection
systemctl status serviceshows state, PID, recent logs, and failure information.systemctl is-active servicechecks runtime state.systemctl is-enabled servicechecks enablement.systemctl list-units --type=servicelists loaded service units.systemctl daemon-reloadrereads unit files after they have been modified; it does not itself restart the service.
Explain how a user accesses a remote Linux command line with SSH. Include host verification, user selection, ports, and secure file transfer.
Secure Shell, or SSH, provides encrypted remote login, command execution, and file-transfer capabilities.
Basic connection
ssh server.example.comconnects using the local username.ssh alice@server.example.comconnects as useralice.ssh -p 2222 alice@server.example.comuses TCP port2222instead of the default port22.
Host verification
On the first connection, the client displays the server's host-key fingerprint. The user should verify this fingerprint through a trusted channel before accepting it. Accepted host keys are normally stored in ~/.ssh/known_hosts.
If a known host key unexpectedly changes, SSH warns about a possible server rebuild, address reuse, or man-in-the-middle attack. The warning should be investigated rather than bypassed blindly.
Remote command execution
A single command can be run without opening an interactive shell:
ssh alice@server.example.com hostname
Secure file transfer
scp file.txt alice@server:/home/alice/copies a file over SSH.sftp alice@serverstarts an interactive secure file-transfer session.rsync -e sshcan efficiently synchronize files over an SSH transport.
The SSH client can also use options stored in ~/.ssh/config to define aliases, usernames, ports, and identity files.
Describe the complete procedure for configuring SSH key-based authentication. Explain the roles of the private key, public key, and authorized_keys file.
SSH key-based authentication uses an asymmetric key pair instead of, or in addition to, a password.
1. Generate a key pair
A user can create a modern key pair with:
ssh-keygen -t ed25519
The command creates:
- A private key, such as
~/.ssh/id_ed25519 - A public key, such as
~/.ssh/id_ed25519.pub
A strong passphrase should normally protect the private key.
2. Install the public key
The public key can be copied to the remote account with:
ssh-copy-id alice@server.example.com
It is placed in the remote user's ~/.ssh/authorized_keys file.
3. Set secure permissions
Typical permissions are:
chmod 700 ~/.sshchmod 600 ~/.ssh/authorized_keyschmod 600 ~/.ssh/id_ed25519
Ownership must also belong to the correct user.
4. Test authentication
Connect with:
ssh alice@server.example.com
If a nondefault key is used, specify it with ssh -i path/to/key or configure IdentityFile in the SSH client configuration.
Security roles
- The private key remains secret on the client and must never be distributed.
- The public key may be copied to remote systems.
- The server verifies that the client possesses the matching private key.
ssh-agentcan securely cache decrypted private keys during a login session.
Password authentication should be disabled only after key authentication has been tested in a separate active session.
Discuss how the OpenSSH server can be customized and secured through sshd_config. Describe important directives and a safe configuration procedure.
The OpenSSH server is configured primarily through /etc/ssh/sshd_config and, on some systems, included configuration fragments.
Important security directives
PermitRootLogin noprevents direct root login.PasswordAuthentication nodisables password authentication after key authentication is confirmed.PubkeyAuthentication yespermits public-key authentication.AllowUsers alice adminrestricts login to listed users.AllowGroups sshusersrestricts login to selected groups.MaxAuthTrieslimits authentication attempts per connection.PermitEmptyPasswords norejects empty passwords.X11Forwarding nodisables X11 forwarding if it is not required.AllowTcpForwarding nocan disable TCP forwarding when unnecessary.ClientAliveIntervalandClientAliveCountMaxcan detect inactive or unresponsive sessions.
Changing the listening port can reduce automated noise but is not a substitute for strong authentication and firewall controls.
Safe configuration procedure
- Back up the current configuration.
- Keep an existing administrative SSH session open.
- Edit the configuration carefully.
- Validate syntax with
sshd -t. - Reload or restart the SSH service using
systemctl. - Test a new connection in a separate terminal.
- Review service status and authentication logs.
- Configure the firewall and security controls to allow the selected SSH port.
Access restrictions, key-based authentication, timely updates, and log monitoring provide stronger protection than relying on a port change alone.
Explain the Linux system log architecture. Compare the roles of systemd-journald, syslog services such as rsyslog, applications, and log files.
Linux logging collects messages from the kernel, services, applications, and authentication components so that administrators can troubleshoot and audit the system.
Message sources
Log records may originate from:
- The Linux kernel
- System services and daemons
- Applications
- Authentication and authorization components
- The systemd service manager
- Standard output and standard error of systemd services
systemd-journald
systemd-journald collects structured journal records. It stores metadata such as unit name, process ID, user ID, priority, boot ID, and executable path. The journal is queried with journalctl.
Syslog services
A syslog daemon such as rsyslog can:
- Receive messages from local facilities and priorities.
- Filter and route records.
- Write messages to traditional text files.
- Forward logs to a remote log server.
Depending on configuration, messages collected by journald may also be made available to a syslog daemon.
Traditional log files
Text logs are commonly stored below /var/log. Exact file names vary by distribution. Examples may include general system messages, authentication events, mail logs, and cron logs.
A complete architecture may therefore include applications sending messages to journald or syslog, journald storing structured records, rsyslog writing selected messages to text files or remote destinations, and logrotate managing file size and retention.
Describe how traditional syslog files are reviewed and maintained. Explain facilities, priorities, filtering, rotation, and remote logging.
Traditional syslog records are generally stored as text files under /var/log, although exact locations depend on the distribution and configuration.
Reviewing logs
Useful commands include:
less /var/log/messagesorless /var/log/syslogtail -f logfileto follow new recordsgrep pattern logfileto search for matching recordszgrep pattern logfile.gzto search compressed rotated logs
Authentication events may be stored in files such as /var/log/secure or /var/log/auth.log.
Facilities and priorities
A syslog selector commonly combines:
- A facility, such as
auth,cron,daemon,kern,mail, orlocal0 - A priority, such as
debug,info,notice,warning,err,crit,alert, oremerg
Rules route selected messages to files, devices, users, or remote servers.
Rotation
logrotate prevents log files from growing without limit. It can:
- Rotate logs by time or size
- Retain a specified number of old files
- Compress older files
- Create replacement files with defined ownership and permissions
- Run commands after rotation when a service must reopen its log file
Remote logging
Centralized logging sends records to a remote server, improving monitoring and reducing the risk that an attacker can erase all evidence from a compromised host. Transport security, access control, time synchronization, and retention policies should be considered.
Explain how to review and filter systemd journal entries using journalctl. Provide examples based on service, boot, time, priority, and follow mode.
journalctl queries records stored by systemd-journald.
General inspection
journalctldisplays available journal records.journalctl -rshows newest records first.journalctl -ffollows new messages in real time.journalctl -n 50displays the most recent 50 records.
Filtering by service or process
journalctl -u sshd.serviceshows records for the SSH service.journalctl _PID=1234filters by process ID.journalctl _UID=1000filters by user ID.
Filtering by boot
journalctl -bshows the current boot.journalctl -b -1shows the previous boot when retained.journalctl --list-bootslists recorded boots.
Filtering by time
journalctl --since todayjournalctl --since "2025-01-10 08:00:00" --until "2025-01-10 10:00:00"
Filtering by priority
journalctl -p errshows error and more severe messages.- Priority names include
emerg,alert,crit,err,warning,notice,info, anddebug.
Additional useful forms
journalctl -kshows kernel messages.journalctl -xedisplays recent records with explanatory information when available.journalctl -o verbosedisplays extensive structured metadata.
Multiple filters can be combined, for example journalctl -u sshd.service -b --since today.
How is the systemd journal made persistent across reboots? Explain storage modes, directory requirements, size management, and verification.
The systemd journal may use volatile storage under /run/log/journal, which is lost at reboot, or persistent storage under /var/log/journal.
Enabling persistent storage
A common procedure is:
- Create the persistent journal directory if it does not exist:
mkdir -p /var/log/journal
- Apply appropriate systemd temporary-file rules where required:
systemd-tmpfiles --create --prefix /var/log/journal
- Configure
/etc/systemd/journald.confwith:Storage=persistent
- Restart
systemd-journaldor reboot, following distribution guidance.
With Storage=auto, persistence is commonly used when /var/log/journal exists; otherwise, volatile storage may be used.
Size and retention management
Relevant settings may include:
SystemMaxUse=to limit total persistent journal usage.SystemKeepFree=to reserve free disk space.SystemMaxFileSize=to limit individual journal files.MaxRetentionSec=to limit retention by age.
Administrative commands include:
journalctl --disk-usageto view journal disk use.journalctl --vacuum-size=500Mto reduce archived usage to approximately the specified size.journalctl --vacuum-time=30dto remove archived records older than the specified period.journalctl --verifyto check journal file consistency.
Persistence can be confirmed after a reboot using journalctl --list-boots and journalctl -b -1.
Explain the Linux file system permission model. Describe how permissions are assigned to the owner, group, and others.
Linux file system permissions control who can access files and directories and what operations they can perform.
Permissions are assigned to three categories:
- Owner (
u): The user who owns the file or directory. - Group (
g): Users belonging to the group associated with the file. - Others (
o): All other users on the system.
The three basic permissions are:
- Read (
r):- For a file, permits viewing its contents.
- For a directory, permits listing its entries.
- Write (
w):- For a file, permits modifying its contents.
- For a directory, permits creating, deleting, or renaming entries, normally when execute permission is also present.
- Execute (
x):- For a file, permits running it as a program or script.
- For a directory, permits entering or traversing it and accessing known entries.
For example, -rwxr-xr-- means:
- The owner has read, write, and execute permissions.
- The group has read and execute permissions.
- Others have read permission only.
Linux checks the applicable permission class based on the effective user ID and group membership of the process requesting access.
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 →