Unit 3 subjective questions Linux File System and File Management
CSE105 — Creative Engineering Workshop 20 questions with model answers. Write yours first, then compare.
-
Question 1 of 20
Explain the Linux File System Hierarchy and describe why Linux follows a single-rooted, tree-like structure.
Model answer
The Linux File System Hierarchy is a standardized, tree-like structure defined by the Filesystem Hierarchy Standard (FHS). Unlike Windows, which uses separate drive letters (C:, D:), Linux organizes everything under a single root directory denoted by
/.Key characteristics:
- Single-rooted: Every file and directory descends from the root (
/), forming one unified tree. - Everything is a file: Devices, directories, and processes are represented as files.
- Hierarchical: Directories can contain subdirectories and files, creating parent-child relationships.
- Mount points: Additional storage devices are attached (mounted) into the existing tree rather than given separate drive letters.
Why this structure is used:
- Provides a consistent and predictable layout across different Linux distributions.
- Simplifies administration and scripting since paths are standardized.
- Makes it easy to mount and integrate new devices seamlessly.
This unified approach improves portability, maintainability, and clarity of the system.
- Single-rooted: Every file and directory descends from the root (
-
Question 2 of 20
Describe the Root Directory Structure in Linux and list at least six top-level directories with their purposes.
Model answer
The Root Directory (
/) is the topmost directory in the Linux file system from which all other directories branch out.Important top-level directories:
/bin— Essential user command binaries (e.g.,ls,cp,cat) needed for basic operation./sbin— System binaries used mainly by the administrator (e.g.,fdisk,reboot)./etc— System-wide configuration files./home— Personal directories for regular users./usr— User programs, libraries, and documentation./var— Variable data such as logs, mail, and spool files./tmp— Temporary files (often cleared on reboot)./lib— Shared libraries required by binaries in/binand/sbin.
Significance:
- Every directory has a well-defined role, promoting organization.
- The root directory should not be cluttered with user files.
- Only the superuser (root) typically has permission to modify critical directories.
-
Question 3 of 20
Distinguish between the
/binand/sbindirectories in Linux with suitable examples.Model answer
Both
/binand/sbinstore executable binary programs, but they differ in who uses them and what they do./bin(User Binaries):- Contains essential commands available to all users.
- Needed for basic system operation, even in single-user mode.
- Examples:
ls,cp,mv,cat,pwd,echo.
/sbin(System Binaries):- Contains commands used mainly for system administration.
- Typically require superuser (root) privileges.
- Examples:
fdisk,ifconfig,reboot,shutdown,mkfs.
Key difference table:
Aspect /bin/sbinUsers All users Mostly root/admin Purpose General commands System maintenance Example ls,cpreboot,fdiskIn short,
/binserves everyday tasks while/sbinhandles administrative and system-level operations. -
Question 4 of 20
Explain the purpose of the
/etc,/var, and/tmpdirectories with examples of files they may contain.Model answer
These three directories serve distinct roles in managing configuration and data.
/etc(Configuration Files):- Stores system-wide configuration files and startup scripts.
- Contains text-based, editable settings.
- Examples:
/etc/passwd,/etc/fstab,/etc/hostname,/etc/ssh/sshd_config.
/var(Variable Data):- Holds files whose content changes frequently during system operation.
- Examples:
/var/log— system logs/var/mail— user mailboxes/var/spool— print and mail queues/var/cache— cached application data
/tmp(Temporary Files):- Stores temporary files created by programs and users.
- Contents are usually deleted on reboot.
- Writable by all users but with restricted deletion (sticky bit).
Summary:
/etc→ configuration/var→ dynamic/variable data/tmp→ short-lived temporary data
-
Question 5 of 20
Compare the
/usrand/optdirectories. What kinds of software are stored in each?Model answer
Both directories store software, but they differ in the type of software and how it is organized.
/usr(Unix System Resources):- Contains user applications, libraries, and documentation installed as part of the distribution.
- Read-only for most users; managed by the package manager.
- Subdirectories:
/usr/bin— non-essential user binaries/usr/lib— libraries for/usr/bin/usr/share— architecture-independent data/usr/local— locally compiled software
/opt(Optional Software):- Reserved for third-party or add-on software packages.
- Each application is usually placed in its own subdirectory (e.g.,
/opt/google/chrome). - Keeps large, self-contained applications separate from system files.
Comparison:
Aspect /usr/optContent Distribution software Third-party software Organization Shared subdirs Self-contained per app Managed by Package manager Vendor/manual install Thus,
/usrholds standard system software while/optisolates optional vendor applications. -
-
Question 6 of 20
Define Absolute Path and Relative Path. Distinguish between them with suitable examples.
Model answer
In Linux, a path specifies the location of a file or directory in the file system.
Absolute Path:
- Specifies the location starting from the root directory (
/). - Always begins with
/. - Independent of the current working directory.
- Example:
/home/user/documents/file.txt
Relative Path:
- Specifies the location relative to the current working directory.
- Does not begin with
/. - Uses special symbols:
.→ current directory..→ parent directory
- Example: If in
/home/user, thendocuments/file.txtrefers to/home/user/documents/file.txt.
Comparison:
Aspect Absolute Path Relative Path Starts with /(root)Current directory Length Usually longer Usually shorter Depends on CWD No Yes Conclusion: Absolute paths are unambiguous but longer, while relative paths are shorter and depend on your current location.
- Specifies the location starting from the root directory (
-
Question 7 of 20
Explain the
pwdandcdcommands. How are they used for navigating the Linux file system?Model answer
Both commands are fundamental for navigation in the Linux file system.
pwd(Print Working Directory):- Displays the full absolute path of the current directory.
- Helps the user identify their present location.
- Example:
Bash$ pwd /home/user/documentscd(Change Directory):- Used to move between directories.
- Common usages:
cd /etc→ move to an absolute pathcd documents→ move using a relative pathcd ..→ move to the parent directorycd ~orcd→ move to the home directorycd -→ switch to the previous directory
Example workflow:
Bash$ pwd /home/user $ cd documents $ pwd /home/user/documents $ cd .. $ pwd /home/userTogether,
pwdtells you where you are andcdlets you move around the file system. -
Question 8 of 20
Describe the
lscommand and explain at least five commonly used options with examples.Model answer
The
lscommand lists the contents of a directory (files and subdirectories).Basic usage:
Bash$ ls file1.txt file2.txt documentsCommon options:
-
-l(long format): Displays detailed information — permissions, owner, size, date.
bash
$ ls -l
-rw-r--r-- 1 user user 1024 Sep 25 10:00 file1.txt -
-a(all): Shows hidden files (those beginning with.).
bash
$ ls -a
. .. .bashrc file1.txt -
-h(human-readable): Shows sizes in KB, MB, GB (used with-l).
bash
$ ls -lh -
-R(recursive): Lists contents of subdirectories recursively. -
-t(time): Sorts files by modification time (newest first). -
-r(reverse): Reverses the sort order.
Combined example:
Bash$ ls -alhThis lists all files (including hidden) in long, human-readable format.
lsis essential for inspecting directory contents. -
-
Question 9 of 20
Explain the
mkdirandrmdircommands. How do they create and remove directories? Include examples of creating nested directories.Model answer
These commands manage the creation and removal of directories.
mkdir(Make Directory):-
Creates one or more new directories.
-
Basic usage:
bash
$ mkdir projects -
Create multiple directories:
bash
$ mkdir dir1 dir2 dir3 -
-poption (parents): Creates nested directories, and does not error if they exist.
bash
$ mkdir -p projects/2026/january
This creates the entire path in one command.
rmdir(Remove Directory):-
Removes empty directories only.
-
Basic usage:
bash
$ rmdir projects -
-poption: Removes nested empty directories.
bash
$ rmdir -p projects/2026/january
Important note:
rmdirfails if the directory is not empty.- To remove non-empty directories,
rm -ris used instead.
Thus,
mkdirbuilds directory structures whilermdircleans up empty ones. -
-
Question 10 of 20
Explain the
touchandcatcommands. Describe the multiple uses of thecatcommand with examples.Model answer
touchCommand:- Primarily used to create empty files.
- Also used to update the timestamp (access/modification time) of existing files.
- Examples:
bash
$ touch newfile.txt # creates an empty file
$ touch file1 file2 file3 # creates multiple files
cat(Concatenate) Command:A versatile command with several uses:
-
Display file contents:
bash
$ cat file.txt -
Create a file and add content:
bash
$ cat > file.txt
Hello World
(Ctrl+D to save) -
Append content to a file:
bash
$ cat >> file.txt
Additional line -
Concatenate multiple files:
bash
$ cat file1.txt file2.txt -
Combine files into a new file:
bash
$ cat file1.txt file2.txt > merged.txt -
Number lines using
-n:
bash
$ cat -n file.txt
Summary:
touchcreates/updates files, whilecatdisplays, creates, appends, and joins file contents. -
Question 11 of 20
Explain the
cp,mv, andrmcommands with their important options and examples.Model answer
These commands handle copying, moving/renaming, and deleting files and directories.
cp(Copy):-
Copies files and directories.
bash
$ cp source.txt destination.txt -
-r(recursive): Copies directories and their contents.
bash
$ cp -r dir1 dir2 -
-i(interactive): Prompts before overwriting.
mv(Move / Rename):-
Moves files or renames them.
-
Move a file:
bash
$ mv file.txt /home/user/documents/ -
Rename a file:
bash
$ mv oldname.txt newname.txt -
Does not require
-rfor directories.
rm(Remove):-
Deletes files and directories permanently.
bash
$ rm file.txt -
-r(recursive): Deletes directories and contents.
bash
$ rm -r folder -
-f(force): Deletes without prompting. -
-i(interactive): Prompts before each deletion.
Caution:
rm -rfis powerful and irreversible — use with extreme care as there is no recycle bin. -
-
Question 12 of 20
Explain the
sucommand in Linux. How does it help in switching users, and what is the difference betweensuandsu -?Model answer
The
su(Substitute User / Switch User) command allows a user to switch to another user account within the current session, most commonly to the root (superuser) account.Basic usage:
-
Switch to root:
bash
$ su
Password: -
Switch to a specific user:
bash
$ su username
Difference between
suandsu -:su(without hyphen):- Switches the user but retains the current environment (variables, working directory).
su -(with hyphen, alsosu -l):- Starts a login shell with the target user's full environment (home directory, PATH, profile settings).
Example:
Bash$ su - root # loads root's complete environmentKey points:
- Requires the target user's password.
- Switching to root grants full administrative privileges.
- Use
exitto return to the original user.
Thus,
su -is generally preferred when full administrative environment access is needed. -
-
Question 13 of 20
What is the use of the
clearandhistorycommands? Explain how the command history can be reused efficiently.Model answer
clearCommand:-
Clears the terminal screen, removing all previous output.
-
Provides a clean workspace but does not delete command history.
-
Usage:
bash
$ clear -
Keyboard shortcut:
Ctrl + L.
historyCommand:-
Displays a numbered list of previously executed commands.
-
Usage:
bash
$ history
1 ls
2 cd documents
3 pwd -
Show last N commands:
bash
$ history 5
Reusing history efficiently:
-
!n— Runs the command at line number n.
bash
$ !2 # re-runs 'cd documents' -
!!— Repeats the last command. -
!string— Runs the most recent command starting with string. -
Ctrl + R— Reverse search through history interactively. -
history -c— Clears the command history.
Summary:
cleartidies the screen whilehistorytracks and enables quick reuse of past commands. -
-
Question 14 of 20
Explain the
findcommand in detail. Describe how it can be used to search files by name, type, and size with examples.Model answer
The
findcommand searches for files and directories in a directory hierarchy based on various criteria. It is powerful and highly flexible.General syntax:
Bashfind [path] [expression]Searching by name:
Bash$ find /home -name "file.txt" # exact name $ find . -iname "*.txt" # case-insensitive, wildcardSearching by type:
Bash$ find /home -type f # files only $ find /home -type d # directories onlySearching by size:
Bash$ find . -size +100M # larger than 100 MB $ find . -size -1k # smaller than 1 KBSearching by modification time:
Bash$ find . -mtime -7 # modified in last 7 daysExecuting actions on results:
Bash$ find . -name "*.tmp" -exec rm {} \; # delete matched filesKey points:
- Searches recursively through subdirectories.
- Combines multiple conditions using operators.
- Extremely useful for automation and system administration.
Thus,
findis one of the most powerful search tools in Linux. -
Question 15 of 20
Explain the
treecommand for directory visualization. How is it useful and what are some of its common options?Model answer
The
treecommand displays the contents of a directory in a hierarchical, tree-like format, making the structure easy to visualize.Basic usage:
Bash$ tree . ├── documents │ ├── file1.txt │ └── file2.txt └── projects └── code.pyWhy it is useful:
- Provides a clear visual representation of nested directories.
- Easier to understand than repeated
lscommands. - Displays parent-child relationships at a glance.
Common options:
-
-d— Show directories only (no files).
bash
$ tree -d -
-L n— Limit display to n levels deep.
bash
$ tree -L 2 -
-a— Include hidden files. -
-f— Print the full path prefix for each file. -
-h— Show file sizes in human-readable form.
Note:
treemay need to be installed separately (e.g.,sudo apt install tree).Summary:
treeis an excellent tool for quickly visualizing and documenting directory structures. -
Question 16 of 20
Distinguish between the
duanddfcommands. Explain their purpose and important options with examples.Model answer
Both commands relate to disk usage but operate at different levels.
du(Disk Usage):- Reports the disk space used by files and directories.
- Examples:
bash
$ du folder # usage of a directory
$ du -h folder # human-readable sizes
$ du -sh folder # summary (total) size only
$ du -h --max-depth=1 # usage of subdirectories one level deep
df(Disk Free):- Reports the total, used, and available space on mounted file systems.
- Examples:
bash
$ df # disk space of all filesystems
$ df -h # human-readable format
$ df -h /home # space for a specific mount
Comparison:
Aspect dudfFocus Files/directories Filesystems Reports Space used by items Overall disk free/used Common option -sh-hSummary: Use
duto find what is consuming space anddfto check overall disk availability. -
Question 17 of 20
Explain the significance of the
/homeand/libdirectories in Linux.Model answer
/homeDirectory:- Contains the personal directories of all regular (non-root) users.
- Each user gets a subdirectory named after their username.
- Example:
/home/john,/home/mary
- Example:
- Stores user-specific data: documents, downloads, configuration files (dotfiles like
.bashrc). - Users have full control over their own home directory.
- The root user's home is separate — it is
/root, not under/home.
/libDirectory:- Contains essential shared libraries needed by the binaries in
/binand/sbin. - These libraries are similar to
.dllfiles in Windows. - Also contains kernel modules (e.g.,
/lib/modules). - Examples of contents:
- Shared object files (
.so) - System startup libraries
- Shared object files (
Comparison:
Directory Purpose Users /homePersonal user data Regular users /libShared system libraries System programs Summary:
/homestores user data while/libprovides critical libraries that keep essential programs running. -
Question 18 of 20
Write short notes on any five basic file management commands in Linux, explaining their syntax and one example each.
Model answer
Below are five essential file management commands:
1.
touch— Create empty files / update timestamps- Syntax:
touch filename - Example:
bash
$ touch report.txt
2.
cp— Copy files or directories- Syntax:
cp source destination - Example:
bash
$ cp report.txt backup.txt
3.
mv— Move or rename files- Syntax:
mv source destination - Example:
bash
$ mv report.txt final_report.txt
4.
rm— Remove files or directories- Syntax:
rm [options] filename - Example:
bash
$ rm backup.txt
5.
cat— Display or create file contents- Syntax:
cat filename - Example:
bash
$ cat report.txt
Summary: These commands (
touch,cp,mv,rm,cat) form the foundation of everyday file management in Linux, enabling users to create, copy, move, delete, and view files efficiently. - Syntax:
-
Question 19 of 20
Illustrate with an example how absolute and relative paths can be used together with commands like
cd,cp, andlsto navigate and manage files. Describe a complete practical scenario.Model answer
This scenario demonstrates combining paths with common commands in a practical workflow.
Initial situation: The user is at
/home/userand wants to organize project files.Step 1 — Check current location (using
pwd):
bash
$ pwd
/home/userStep 2 — Create a project structure (relative path):
bash
$ mkdir -p projects/website/imagesStep 3 — Navigate using a relative path:
bash
$ cd projects/website
$ pwd
/home/user/projects/websiteStep 4 — List contents:
bash
$ ls
imagesStep 5 — Copy a file using an absolute source and relative destination:
bash
$ cp /home/user/logo.png images/Here
/home/user/logo.pngis an absolute path andimages/is a relative path.Step 6 — Move up using
..(relative):
bash
$ cd ..
$ pwd
/home/user/projectsStep 7 — Return home using absolute path:
bash
$ cd /home/userKey observations:
- Absolute paths (
/home/user/logo.png) work from anywhere. - Relative paths (
images/,..) depend on the current directory. - Combining both makes navigation and file management efficient and flexible.
This integrated approach reflects real-world Linux usage.
- Absolute paths (
-
Question 20 of 20
Explain what happens internally when you use the
readcommand in a shell, and describe its typical use in scripts with an example.Model answer
The
readcommand is used to take input from the user (or standard input) and store it in one or more variables. It is widely used in shell scripts for interactive input.Basic syntax:
Bashread variable_nameHow it works internally:
- The shell pauses execution and waits for the user to type input.
- Input is read until the Enter key (newline) is pressed.
- The typed value is assigned to the specified variable.
- If multiple variables are given, the input is split by whitespace among them.
Example 1 — Basic input:
Bash$ echo "Enter your name:" $ read name $ echo "Hello, $name"Example 2 — Multiple variables:
Bash$ read first last John Doe $ echo "$first and $last"Useful options:
-
-p— Display a prompt.
bash
$ read -p "Enter age: " age -
-s— Silent input (for passwords).
bash
$ read -s -p "Password: " pass
Summary: The
readcommand enables interactive input in the shell, making scripts dynamic and user-friendly.
That's unit 3
Long answers stick best when they're tested again soon. Run the MCQs on this unit, then come back to the questions you found hardest.
Nearly through. Did unit 3 of CSE105 save you a night before the exam?
LPU Notes is free. A student pays for the servers.
Did unit 3 of CSE105 save you a night before the exam?
Then you can help keep it free for the next batch. 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.