104 Devices, Linux Filesystems, Filesystem Hierarchy Standard KT Flashcards
104.1 Create partitions and filesystems
The following is a partial list of the used files, terms and utilities:
fdisk gdisk parted mkfs mkswap
fdisk
Command: fdisk is a dialog-driven program for creation and manipulation of partition tables. It understands GPT, MBR, Sun, SGI and BSD partition tables.
fdisk [options] device
gdisk
Command: GPT fdisk (aka gdisk) is a text-mode menu-driven program for creation and manipulation of partition tables. It automatically converts a MBR partition table or BSD disklabel stored without a MBR carrier partition to the GPT format.
gdisk [ -l ] device
parted
Command: parted is a program to manipulate disk partitions. It supports multiple partition table formats, including MS-DOS and GPT. It is useful for creating space for new operating systems, reorganising disk usage, and copying data to new hard disks.
parted [options] [device [command [options…]…]]
mkfs
Command: mkfs is used to build a Linux filesystem on a device, usually a hard disk partition. This mkfs frontend is deprecated in favour of filesystem specific mkfs. utils.
mkfs [options] [-t type] [fs-options] device [size]
mkswap
Command: mkswap sets up a Linux swap area on a device or in a file.
mkswap [options] device [size]
104.2 Maintain the integrity of filesystems
The following is a partial list of the used files, terms and utilities:
du df fsck e2fsck mke2fs tune2fs xfs_repair xfs_fsr xfs_db
du
Command: Summarize disk usage of the set of FILEs, recursively for directories.
du [OPTION]… [FILE]…
du [OPTION]… –files0-from=F
df
Command: df displays the amount of disk space available on the file system containing each file name argument. If no file name is given, the space available on all currently mounted file systems is shown.
df [OPTION]… [FILE]…
fsck
Command: fsck is used to check and optionally repair one or more Linux filesystems.
fsck [options] – [fs-options] [ …]
e2fsck
Command: e2fsck is used to check the ext2/ext3/ext4 family of file systems.
e2fsck [ -pacnyrdfkvtDFV ] [ -b superblock ] [ -B blocksize ] [ -l|-L bad_blocks_file ] [ -C fd ] [ -j external-journal ] [ -E extended_options ] [ -z undo_file ] device
mke2fs
Command: mke2fs is used to create an ext2, ext3, or ext4 filesystem, usually in a disk partition (or file) named by device.
mke2fs [-c|-l filename] [-b block-size] [-C cluster-size]
[-i bytes-per-inode] [-I inode-size] [-J journal-options]
[-G flex-group-size] [-N number-of-inodes]
[-d root-directory]
[-m reserved-blocks-percentage] [-o creator-os]
[-g blocks-per-group] [-L volume-label]
[-M last-mounted-directory] [-O feature[,…]] [-r fs-revision] [-E extended-option[,…]] [-t fs-type] [-T usage-type ]
[-U UUID] [-e errors_behavior][-z undo_file]
[-jnqvDFSV] device [blocks-count]
tune2fs
Command: tune2fs allows the system administrator to adjust various tunable filesystem parameters on
Linux ext2, ext3, or ext4 filesystems.
tune2fs [ -l ] [ -c max-mount-counts ]
[ -e errors-behavior ] [ -f ] [ -i interval-between-checks ]
[ -I new_inode_size ] [ -j ] [ -J journal-options ]
[ -m reserved-blocks-percentage ]
[ -o [^]mount-options[,…] ] [ -r reserved-blocks-count ] [ -u user ] [ -g group ] [ -C mount-count ]
[ -E extended-options ] [ -L volume-label ]
[ -M last-mounted-directory ] [ -O [^]feature[,…] ]
[ -Q quota-options ] [ -T time-last-checked ] [ -U UUID ]
[ -z undo_file ] device
xfs_repair
Command: xfs_repair repairs corrupt or damaged XFS filesystems.
xfs_repair [ -dfLnPv ] [ -m maxmem ] [ -c subopt=value ]
[ -o subopt[=value] ] [ -t interval ] [ -l logdev ] [ -r rtdev ] device
xfs_fsr
Command: xfs_fsr improves the organization of mounted filesystems. The reorganization algorithm operates on one file at a time, compacting or otherwise improving the layout of the file extents (contiguous blocks of file data).
xfs_fsr [-v] [xfsdev | file] …
xfs_db
Command: xfs_db is used to examine an XFS filesystem.
xfs_db [ -c cmd ] … [ -i|r|x|F ] [ -f ] [ -l logdev ] [ -p progname ] device
104.3 Control mounting and unmounting of filesystems
The following is a partial list of the used files, terms and utilities:
/etc/fstab /media/ mount umount blkid lsblk
/etc/fstab
/etc/fstab file is a system configuration file that contains all available disks, disk partitions and their options.
/media/
/media/ directory contains subdirectories which are used as mount points for removeable media such as floppy disks, cdroms and zip disks.
mount
Command: The mount command serves to attach the filesystem found on some device to the big file tree.
mount [-fnrsvw] [-t fstype] [-o options] device dir
umount
Command: The umount command detaches the mentioned file system(s) from the file hierarchy.
umount [-dflnrv] {directory|device}…
blkid
Command: The blkid program is the command-line interface to working with the libblkid(3) library. It can determine the type of content (e.g. filesystem or swap) that a block device holds, and also the attributes (tokens, NAME=value pairs) from the content metadata (e.g. LABEL or UUID fields).
blkid –label label | –uuid uuid
lsblk
Command: lsblk lists information about all available or the specified block devices. The lsblk command reads the sysfs filesystem and udev db to gather information.
lsblk [options] [device…]
104.5 Manage file permissions and ownership
The following is a partial list of the used files, terms and utilities:
chmod
umask
chown
chgrp
chmod
Command: chmod changes the file mode bits of each
given file according to mode, which can be either a symbolic representation of changes to make, or an octal number representing the bit pattern for the new mode bits.
chmod [OPTION]… MODE[,MODE]… FILE…
chmod [OPTION]… OCTAL-MODE FILE…
umask
Command: umask() sets the calling process’s file mode creation mask (umask) to mask & 0777 (i.e., only the file permission bits of mask are used), and returns the previous value of the mask.
umask [-p] [-S] [mode]
chown
Command: chown changes the user and/or group ownership of each given file.
chown [OPTION]… [OWNER][:[GROUP]] FILE…
chgrp
Command: Change the group of each FILE to GROUP.
chgrp [OPTION]… GROUP FILE…
104.6 Create and change hard and symbolic links
The following is a partial list of the used files, terms and utilities:
ln
ls
ln
Command: In the 1st form, create a link to TARGET with the name LINK_NAME. In the 2nd form, create a link to TARGET in the current directory. In the 3rd and 4th forms, create links to each TARGET in DIRECTORY. Create hard links by default, symbolic links with –symbolic. By default, each destination (name of new link) should not already exist. When creating hard links, each TARGET must exist.
ln [OPTION]… [-T] TARGET LINK_NAME
ln [OPTION]… TARGET
ln [OPTION]… TARGET… DIRECTORY
ln [OPTION]… -t DIRECTORY TARGET…
ls
Command: List information about the FILEs (the current directory by default).
ls [OPTION]… [FILE]…
104.7 Find system files and place files in the correct location
The following is a partial list of the used files, terms and utilities:
find locate updatedb whereis which type /etc/updatedb.conf
find
Command: find searches the directory tree rooted at each given starting-point by evaluating the given expression from left to right, according to the rules of precedence.
find [-H] [-L] [-P] [-D debugopts] [-Olevel] [starting-point…] [expression]
locate
Command: locate reads one or more databases prepared by updatedb(8) and writes file names matching at least one of the PATTERNs to standard output, one per line.
locate [OPTION]… PATTERN…
updatedb
Command: updatedb creates or updates a database used by locate(1). If the database already exists, its data is reused to avoid rereading directories that have not changed.
updatedb [OPTION]…
whereis
Command: whereis locates the binary, source and manual files for the specified command names.
whereis [options] [-BMS directory… -f] name…
which
Command: which returns the pathnames of the files (or links) which would be executed in the current environment, had its arguments been given as commands in a strictly POSIX-conformant shell.
which [-a] filename …
type
Command: Display information about command type. For each NAME, indicate how it would be interpreted if used as a command name.
type [-afptP] name [name …]
/etc/updatedb.conf
A configuration file for updatedb(8). /etc/updatedb.conf is a text file. Blank lines are ignored. A # character outside of a quoted string starts a comment extending until end of line.