Devices, Linux Filesystems and the Filesystem Hierarchy
Devices, Linux Filesystems and the Filesystem Hierarchy
TEACH A COURSE 2
Objectives
Create Partitions and Filesystems Manage File Permissions and Ownership
◦ Disk Drives Under Linux ◦ Linux Access Control
◦ Setting Access Modes
Maintain the Integrity of Filesystems
◦ Monitoring Free Disk Space and Inodes ◦ Setting Up a Workgroup Directory
◦ Monitoring Disk Usage
Create and Change Hard and Symbolic Links
◦ Modifying a Filesystem
◦ Why Links?
◦ Checking and Repairing Filesystems
Control Filesystem Mounting and Unmounting Find System Files and Place Files in the Correct
◦ Managing the Filesystem Table Location
◦ Mounting Filesystems ◦ Datatypes
◦ Unmounting Filesystems ◦ The root Filesystem
◦ Options:
◦ d: delete partition
◦ l: List the known partition types
◦ m: Display the brief help menu for these commands.
◦ n: Add a new partition
◦ p: Display the partition table
◦ q: Quit without saving changes.
◦ t: Change a partition’s system ID (Linux ext2 partitions are type 83)
◦ w: Write (save) the partition table to disk and exit
➢fdisk command:
➢Modifying a Filesystem
◦ Using tune2fs command
Table structure
The table itself is a 6 column structure, where each column designates a specific parameter and must be set up in the correct
order. The columns of the table are as follows from left to right:
•Device: usually the given name or UUID of the mounted device (sda1/sda2/etc).
•Mount Point: designates the directory where the device is/will be mounted.
•File System Type: nothing trick here, shows the type of filesystem in use.
•Options: lists any active mount options. If using multiple options they must be separated by commas.
•Backup Operation: (the first digit) this is a binary system where 1 = dump utility backup of a partition. 0 = no backup. This is an
outdated backup method and should NOT be used.
•File System Check Order: (second digit) Here we can see three possible outcomes. 0 means that fsck will not check the
filesystem. Numbers higher than this represent the check order. The root filesystem should be set to 1 and other partitions set
to 2.
TEACH A COURSE 28
Control Filesystem Mounting and Unmounting
1.auto/noauto: controls whether the partition is mounted automatically on boot (or not).
2.exec/noexec: controls whether or not the partition can execute binaries. In the name of security, this
is usually set to noexec.
3.ro/rw: controls read and write privileges - ro = read-only, where rw= read-write.
4.nouser/user: controls whether or not the user has mounting privileges. This defaults to noexec for all
user accounts.
5. sync và async: This is the option for reading and writing to the file system. sync means all is done at
the same time, this option is usually applied to floppy disks
6.defaults: rw, suid, dev, exec, auto, nouser, and async
TEACH A COURSE 29
Control Filesystem Mounting and Unmounting
➢ Mounting Filesystems
◦ Filesystems are mounted using the mount command
◦ At boot time, those filesystems with a nonzero pass number in /etc/fstab are checked and automatically mounted
➢ Mounting Filesystems
◦ Filesystem types
◦ Ext2: The standard Linux filesystem.
◦ Ext3: A journaling filesystem that is backward-compatible with ext2
◦ Msdos: The MS-DOS FAT filesystem, limited to “8.3” filenames (eight characters, a dot, and a three-character
extension).
◦ Ntfs: The native MS Windows partition since Windows 2000
◦ Iso9660: The CD-ROM format
◦ Nfs: Remote servers.
◦ Swap: Swap partitions
➢Mounting Filesystems
➢ Unmounting Filesystems
◦ Filesystems can be unmounted
using the umount command
➢ Quota Command
➢ quotaon Command
➢quotaoff Command
➢ quotacheck Command
➢ edquota Command
➢ repquota Command
➢Enabling Quotas
◦ Note that you may enable user quotas only, group quotas only, or both, as your needs dictate
➢Enabling Quotas
➢ The mode
➢ ls -al
➢ The mode
◦ SUID:
◦ The SUID property is for executable files only and has no effect on directories.
◦ This offers anyone temporary root access for the duration of the command.
◦ An example of an SUID program is passwd. This command needs special access to manipulate the shadow password file
(/etc/shadow), and runs as user root
◦ On the other hand,SUID can be a security risk if access is granted unwisely. For example, consider a situation where /bin/vi was
set to SUID mode. Any user would be able to edit any file on the system!
➢ SUID
➢SGID
➢ Sticky bit
➢ The mode
➢ Umask
Bash permission của file: 666 = 110110110
umask: 022 = 000010010
NOT (umask) = NOT (000010010 ) = 111101101
110 110 110 AND 111 101 101 = 110 100 100 = 644.