Devices, Linux Filesystems, Filesystem Hierarchy Standard Flashcards
fdisk
Used to partition a disk device
How many partitions can you have by default? (Without extended or logical partitions)
4
fdisk -n
Interactive mode
mkfs -t ext3 mydev
Makes mydev an ext3 file system
mkfs -c
Used to check the device for bad blocks before building the file system
mkswap
Turns a file system into swap
du
Used to estimate file space usage
du -c
Produce a grand total
du -h
Human readable
du –max-depth N
Print the total for a directory only if it is N or fewer levels below the command line argument
du -b
Makes output in bytes
dumpe2fs
Obtains file system info
mke2fs
equivalent of “mkfs -t ext2/3/4”
tune2fs
Allows you to change the file system parameters
Note: file system must be unmounted
fsck -A
Check all file systems in /etc/fstab
fsck -a
Attempt to automatically repair all errors
fsck -C
Display completion/progress
fsck -N
Don’t execute, just show what would happen
debugfs
Interactively modify a file system
mount -a
Causes all file systems in /etc/fstab to be mounted as indicated
mount -o
Override mount options in /etc/fstab when manually mounting partition
unmount -f
Forcibly unmount a filesystem
/etc/fstab
Configuration file containing persistent file system mounts (for mounting on boot)
quotaon
Turns quotas on
edquota
Edit a quota
edquota -p
Duplicate the quotas of the prototypical user for each user specified
repquota -a
Print quotas of all the file systems configured with a quota mount option file at its root
repquota -g
Print only group quotas
repquota -u
Print only user quotas
repquota -v
Print a header line before printing each filesystem quota
How to set the setuid bit for a file
chmod 4777 myfile (the 4 is what matters, the 777 could be any other set of permissions)
How to set the setgid bit for a file
chmod 2777 myfile (the 2 is what matters, the 777 could be any other set of permissions)
Sticky Bit
A permission bit that is set on a file or a directory that lets only the owner of the file/directory or the root user to delete or rename the file.
chgrp mygroup file1
Changes the group of file1 to mygroup
chown root file1
Changes the owner of file1 to root
ln -s file1 file2
Makes a symbolic link to file1 called file2
ln file1 file2
Makes a hard link to file1 called file2
find mydir -name myfile
Looks for a file named myfile starting at mydir
find /etc -perm 777
Will return all files in the /etc directory that has 777 permissions
find /etc -size 1M
Finds everything starting at /etc that is up to 1MB
find /etc -maxdepth 1
Will restrict the search to only the /etc directory
find /home -user mmiller
Will find all things associated with the user mmiller
which
Display path the indicated command is in (if in PATH variable)
whereis
Locates the sources/binary and manuals section for specific files
/etc/updatedb.conf
The database used by the locate command
locate
Reads from a database to find files by name.
Note: always do updatedb before using locate
/etc
Holds system configuration files
/boot
Holds important boot files like the Linux kernel, initial RAM disk, and boot loader config files
/bin
Holds program files that are critical for normal operations and that ordinary users may run
/sbin
Holds program files that are critical for normal operation and that ordinary users seldom run. (but root uses)
/lib
Holds libraries
/usr
Holds programs and data used in normal system operation bu that aren’t critical for a bare-bones boot of the system
/home
Users’ home directories
/root
Root user’s home directory (different than /)
/var
Holds files that change often
/var/tmp
Holds temporary files (But should not be deleted when the computer reboots)
/tmp
Holds temporary files (And should be deleted when the computer reboots)
/mnt
The traditional mount point for removable media
/media
The new mount point for removable media
/dev
Holds device files, providing low-level access to the system’s hardware
usr/local/bin
and
usr/local/sbin
The locally compiled programs
repquota -s
A more readable format for the repquota command
quotacheck
Builds the database of file system information that quota commands will use