UNIX File System by Tero Toikkanen, CAP02S
UNIX Multi-user system Multi-user system Multi-tasking system Multi-tasking system Wide selection of tools for software development Wide selection of tools for software development Open architecture Open architecture
Some UNIX variants LINUX (Caldera, Debian, Mandrake, RedHat, Slackware, SuSE...) LINUX (Caldera, Debian, Mandrake, RedHat, Slackware, SuSE...) BSD (FreeBSD, NetBSD, OpenBSD) BSD (FreeBSD, NetBSD, OpenBSD) HP-UX HP-UX Solaris Solaris IRIX IRIX Compaq Tru64 UNIX (discontinued) Compaq Tru64 UNIX (discontinued)
KISS The general principle: ”Keep It Simple, Stupid” The general principle: ”Keep It Simple, Stupid” Programs perform one well defined task properly Programs perform one well defined task properly Almost all data is presented as text Almost all data is presented as text Programs can be combined like LEGO- blocks Programs can be combined like LEGO- blocks
RTFM Learn to use the documentation Learn to use the documentation man and info commands man and info commands Internet resources Internet resources –Website of the variant or distribution –HOW-TO’s –Tutorials
The Basics of UNIX File system Hierarchical tree -structure Hierarchical tree -structure File-spesific security rights File-spesific security rights Files may be shared Files may be shared Almost everything can be considered to be a file, so a file can contain anything Almost everything can be considered to be a file, so a file can contain anything Even directories are files, they just contain a list of other files Even directories are files, they just contain a list of other files Case-sensitive file names Case-sensitive file names
Mounting All UNIX systems usually have at least one permanent non-removable hard disk system. The root directory and the directories below it are stored on this disk. Its structure is known as the root file system. All UNIX systems usually have at least one permanent non-removable hard disk system. The root directory and the directories below it are stored on this disk. Its structure is known as the root file system. If an additional hard disk is added, UNIX creates a separate new filesystem on this disk. Before it can be used, it must be attached to the root file system. This is called mounting an additional filesystem. If an additional hard disk is added, UNIX creates a separate new filesystem on this disk. Before it can be used, it must be attached to the root file system. This is called mounting an additional filesystem.
Mounting example 1
Mounting example 2 Filesystem blocks Used Available Mounted on /dev/hda / /dev/hda /usr /dev/hda /home /dev/hda /boot /dev/hdb /scratch /dev/hdb /tmp /dev/fd /floppy
File types A file can be e.g.: A file can be e.g.: –Text file –Data file –Source Code file –Executable file –Shell program –Link –Device file
file-command Used to determine file type Used to determine file type Usage: Usage: – file file e.g: e.g: – file * – file /dev/hda1 Output examples Output examples – ASCII text – c program text – character special (Device file)
cd,ls - and pwd -commands cd cd ~ ls ls -a ls -l la -p pwd
Root-directory / /dev/net /etc/opt /export/sbin /home/stand /kernel/tmp /lost+found/usr /mnt/var
Security rights Example file Example file -rwxr-x--- 1 ex1 users 512 Sep 11 10:28 a.ps File type indicatior | Permissions for file owner | | Permission for group members | | | Permissions for others | | | | - rwx r-x ---
File tools rm - remove file (or directory) rm - remove file (or directory) cp - copy file to another location cp - copy file to another location mv - move file to another location mv - move file to another location mkdir - create new directory mkdir - create new directory rmdir - remove directory rmdir - remove directory
ch-commands chmod chmod –Change permission mode for file chown chown –Change owner for file chgrp chgrp –Change group for file
chmod Usage: Usage: – chmod o+r datafiles chmod [augo][+-=][rwx] file
cat and more cat - Display, combine, append, copy, or create files cat - Display, combine, append, copy, or create files –Usage: cat [option] file more - Display all or parts of a file one screen at a time more - Display all or parts of a file one screen at a time –Usage: more [option] file
More info