Menu

UNIX TUTORIALS - Unix - File System Basics

Unix - File System Basics

ADVERTISEMENTS

Directory Structure:

DirectoryDescription
/This is the root directory which should contain only the directories needed at the top level of the file structure.
/binThis is where the executable files are located. They are available to all user.
/devThese are device drivers.
/etcSupervisor directory commands, configuration files, disk configuration files, valid user lists, groups, ethernet, hosts, where to send critical messages.
/libContains shared library files and sometimes other kernel-related files.
/bootContains files for booting the system.
/homeContains the home directory for users and other accounts.
/mntUsed to mount other temporary file systems, such as cdrom and floppy for the CD-ROM drive and floppy diskette drive, respectively
/procContains all processes marked as a file by process number or other information that is dynamic to the system.
/tmpHolds temporary files used between system boots
/usrUsed for miscellaneous purposes, or can be used by many users. Includes administrative commands, shared files, library files, and others
/varTypically contains variable-length files such as log and print files and any other type of file that may contain a variable amount of data
/sbinContains binary (executable) files, usually for system administration. For example fdisk and ifconfig utlities.
/kernelContains kernel files

ADVERTISEMENTS

Navigating the File System:

CommandDescription
cat filenameDisplays a filename.
cd dirnameMoves you to the directory identified.
cp file1 file2Copies one file/directory to specified location.
file filenameIdentifies the file type (binary, text, etc).
find filename dirFinds a file/directory.
head filenameShows the beginning of a file.
less filenameBrowses through a file from end or beginning.
ls dirnameShows the contents of the directory specified.
mkdir dirnameCreates the specified directory.
more filenameBrowses through a file from beginning to end.
mv file1 file2Moves the location of or renames a file/directory.
pwdShows the current directory the user is in.
rm filenameRemoves a file.
rmdir dirnameRemoves a directory.
tail filenameShows the end of a file.
touch filenameCreates a blank file or modifies an existing file.s attributes.
whereis filenameShows the location of a file.
which filenameShows the location of a file if it is in your PATH.

ADVERTISEMENTS

The df Command:

ColumnDescription
FilesystemThe physical file system name.
kbytesTotal kilobytes of space available on the storage medium.
usedTotal kilobytes of space used (by files).
availTotal kilobytes available for use.
capacityPercentage of total space used by files.
Mounted onWhat the file system is mounted on.

User and Group Quotas:

CommandDescription
quotaDisplays disk usage and limits for a user of group.
edquotaThis is a quota editor. Users or Groups quota can be edited using this command.
quotacheckScan a filesystem for disk usage, create, check and repair quota files
setquotaThis is also a command line quota editor.
quotaonThis announces to the system that disk quotas should be enabled on one or more filesystems.
quotaoffThis announces to the system that disk quotas should be disabled off one or more filesystems.
repquotaThis 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/cdrom

Unmounting the File System:

$ umount /dev/cdrom