UNIX TUTORIALS - Unix - File System Basics
Unix - File System Basics
ADVERTISEMENTS
Directory Structure:
Directory | Description |
---|---|
/ | This is the root directory which should contain only the directories needed at the top level of the file structure. |
/bin | This is where the executable files are located. They are available to all user. |
/dev | These are device drivers. |
/etc | Supervisor directory commands, configuration files, disk configuration files, valid user lists, groups, ethernet, hosts, where to send critical messages. |
/lib | Contains shared library files and sometimes other kernel-related files. |
/boot | Contains files for booting the system. |
/home | Contains the home directory for users and other accounts. |
/mnt | Used to mount other temporary file systems, such as cdrom and floppy for the CD-ROM drive and floppy diskette drive, respectively |
/proc | Contains all processes marked as a file by process number or other information that is dynamic to the system. |
/tmp | Holds temporary files used between system boots |
/usr | Used for miscellaneous purposes, or can be used by many users. Includes administrative commands, shared files, library files, and others |
/var | Typically contains variable-length files such as log and print files and any other type of file that may contain a variable amount of data |
/sbin | Contains binary (executable) files, usually for system administration. For example fdisk and ifconfig utlities. |
/kernel | Contains kernel files |
ADVERTISEMENTS
Navigating the File System:
Command | Description |
---|---|
cat filename | Displays a filename. |
cd dirname | Moves you to the directory identified. |
cp file1 file2 | Copies one file/directory to specified location. |
file filename | Identifies the file type (binary, text, etc). |
find filename dir | Finds a file/directory. |
head filename | Shows the beginning of a file. |
less filename | Browses through a file from end or beginning. |
ls dirname | Shows the contents of the directory specified. |
mkdir dirname | Creates the specified directory. |
more filename | Browses through a file from beginning to end. |
mv file1 file2 | Moves the location of or renames a file/directory. |
pwd | Shows the current directory the user is in. |
rm filename | Removes a file. |
rmdir dirname | Removes a directory. |
tail filename | Shows the end of a file. |
touch filename | Creates a blank file or modifies an existing file.s attributes. |
whereis filename | Shows the location of a file. |
which filename | Shows the location of a file if it is in your PATH. |
ADVERTISEMENTS
The df Command:
Column | Description |
---|---|
Filesystem | The physical file system name. |
kbytes | Total kilobytes of space available on the storage medium. |
used | Total kilobytes of space used (by files). |
avail | Total kilobytes available for use. |
capacity | Percentage of total space used by files. |
Mounted on | What the file system is mounted on. |
User and Group Quotas:
Command | Description |
---|---|
quota | Displays disk usage and limits for a user of group. |
edquota | This is a quota editor. Users or Groups quota can be edited using this command. |
quotacheck | Scan a filesystem for disk usage, create, check and repair quota files |
setquota | This is also a command line quota editor. |
quotaon | This announces to the system that disk quotas should be enabled on one or more filesystems. |
quotaoff | This announces to the system that disk quotas should be disabled off one or more filesystems. |
repquota | This prints a summary of the disc usage and quotas for the specified file systems |
The df Command:
$df -k Filesystem 1K-blocks Used Available Use% Mounted on /dev/vzfs 10485760 7836644 2649116 75% / /devices 0 0 0 0% /devices $The du Command:
$du /etc 10 /etc/cron.d 126 /etc/default 6 /etc/dfs ... $
$du -h /etc 5k /etc/cron.d 63k /etc/default 3k /etc/dfs ... $Mounting the File System:
$ mount /dev/vzfs on / type reiserfs (rw,usrquota,grpquota) proc on /proc type proc (rw,nodiratime) devpts on /dev/pts type devpts (rw) $
mount -t file_system_type device_to_mount directory_to_mount_to
$ mount -t iso9660 /dev/cdrom /mnt/cdromUnmounting the File System:
$ umount /dev/cdrom