Linux 101
Filesystem Management
Filesystem Basics
mount <device> <mountpoint>
/ umount
mounting
…
bin dev var home
dir1
hard
a b c d
link dir2 dir3 dir4
Partition
Partition
super … …
block
index nodes, i-nodes data blocks
Managing Links
LINK
Different identity for the same file
Hard link Soft link (symbolic)
ln [options] target [link]
-s, --symbolic
-f, --force
-I, --interactive
Advantages
• make data available in multiple places without duplication
• give multiple names to the same command
Hard links cannot be created between filesystems
File Ownership
Linux file security is build upon:
• file ownership
• file permissions
• owner
• owner
ownership permissions • group
• group
(two tiered) (three tiered) • others
Files can be owned by non-login accounts
User and Group are represented internally by numbers
can only be run by root
chown [options] [newowner][:newgroup] filename
chgrp [options] newgroup filename
File Permissions
group permissions
- r w x r – x r - x
file type code owner permissions others (world) permissions
r read 4
w write 2 Symlinks always have 777
x execute 1 permissions.
Changing the permissions on a
SUID s in owner execute bit
symlink affects the targeted file.
SGID s in group execute bit
Sticky bit t in world execute bit
Changing Permissions
chmod [options] [mode[,mode]] filename
octal number NNNN
mode
symbolic form = <permission-set> <op> <perms>
u + r
g - w
o = x
a X
s
Permissions can only be adjusted by owner and root. t
Set Default Mode:
umask <mask> u
g
Mask is subtracted from 0666 for files and o
0777 for directories.
File Attributes
-
chattr + attr file
=
Attributes:
a - append only
i - immutable
s - secure deletion
t - no tail merge
A - no access time updates
j - journal (not on ext2)
Disk Quotas
quotas require support in the kernel
in the filesystem
mount options in /etc/fstab:
usrquota grpquota
edquota <user>
edquota -t set grace period
quotacheck on a filesystem basis
Locating Files
Filesystem Hierarchy Standard (FHS)
shareable unshareable
static /usr /etc
/opt /boot
/home /var/run
variable /var/mail /var/lock
find [path…] [expression…]
locate <search_string>
Searches for binary, configuration and
whereis documentation of a program
which
Searches environment path for the first occurrence
of the program