LCA File Systems & Storage Management — Questions and Answers
Question 1: Which command is used to create a new ext4 file system in Linux?
- fsck.ext4
- format
- mkfs.ext4 (Correct answer)
- mkpartfs
Correct answer: mkfs.ext4
The `mkfs.ext4` command is specifically used to create an Ext4 file system on a specified partition or device. `mkfs` stands for "make filesystem," and the `.ext4` suffix indicates the type of file system to be created. This command initializes the file system structure, making the partition ready to store data.
Question 2: What is the purpose of the `mount` command in Linux?
- To create a partition.
- To delete files.
- To format a device.
- To make a file system accessible at a specific directory (Correct answer)
Correct answer: To make a file system accessible at a specific directory
The `mount` command in Linux is used to attach a file system from a storage device to a specific directory in the existing file system hierarchy. This makes the files and directories on that device accessible through the specified mount point. Without mounting, the contents of the device cannot be accessed by the operating system.
Question 3: Which file contains the persistent mount information in Linux?
- /etc/mtab
- /etc/fstab (Correct answer)
- /etc/mount.conf
- /etc/disktab
Correct answer: /etc/fstab
The `/etc/fstab` file stores persistent mount information, meaning it defines file systems that should be mounted automatically every time the system boots. Each entry in this file specifies a device, its mount point, file system type, and various options. This ensures that critical partitions and devices are always available.
Question 4: What does the `df` command display?
- File permissions
- Used and available disk space (Correct answer)
- CPU usage
- Memory usage
Correct answer: Used and available disk space
The `df` command (disk free) reports the amount of disk space used and available on file systems. When used with the `-h` option (`df -h`), it displays the information in a human-readable format (e.g., GB, MB). This command is essential for monitoring disk usage and preventing storage-related issues.
Question 5: What is LVM primarily used for?
- File compression
- Network configuration
- Logical partition management (Correct answer)
- File permission settings
Correct answer: Logical partition management
LVM (Logical Volume Manager) provides a flexible way to manage disk space by abstracting the underlying physical storage. It allows administrators to create, resize, and move logical volumes without modifying physical partitions directly. This simplifies storage management, enabling dynamic allocation and reallocation of disk space.
Question 6: Which command checks and repairs a Linux file system?
- chkfs
- repairfs
- fsck (Correct answer)
- mount -r
Correct answer: fsck
The `fsck` command (file system check) is used to check and optionally repair a Linux file system for errors. It scans the file system structure for inconsistencies and attempts to correct them, which is crucial for maintaining data integrity after unexpected shutdowns or disk issues. It should typically be run on unmounted file systems.
Question 7: What does the `du` command do in Linux?
- Displays running processes
- Shows disk usage per file/directory (Correct answer)
- Updates software packages
- Uninstalls unused packages
Correct answer: Shows disk usage per file/directory
The `du` command (disk usage) estimates file space usage, specifically showing the amount of disk space consumed by files or directories. When run without arguments, it displays the usage for the current directory and its subdirectories. This is useful for identifying large files or directories that are consuming significant disk space.
Question 8: Which tool can be used to create and manage partitions in Linux?
- lsof
- fdisk (Correct answer)
- top
- uptime
Correct answer: fdisk
The `fdisk` utility is a command-line tool used to create, delete, and manage disk partitions on Linux systems. It allows users to view existing partitions, create new ones, change partition types, and set active partitions. While other tools like `parted` exist, `fdisk` is a classic and widely used utility for this purpose.
Question 9: What is the purpose of the `/proc/mounts` file?
- It shows memory usage.
- It lists running processes.
- It shows currently mounted file systems (Correct answer)
- It manages user accounts.
Correct answer: It shows currently mounted file systems
The `/proc/mounts` file is a virtual file in the `/proc` filesystem that provides real-time information about all currently mounted file systems. Unlike `/etc/fstab`, which lists file systems intended to be mounted, `/proc/mounts` reflects the actual state of mounted file systems at any given moment. This is useful for verifying active mounts and their current options.
Which command is used to create a new ext4 file system in Linux?