UNIX / Linux File System Basics - Unix/Linux

What is UNIX / Linux File system Basics?

A file system is a logical collection of files on a partition or disk. A partition is a container for information and can span a complete hard constrain if wanted.

Your hard drive can have different partition which usually hold only one file system, such as one file system housing the /file system or another containing the /home file system.

One file system per partition allows for the logical preservation and administration of differing file systems.

Everything in UNIX is consider to be a file, including physical devices such as DVD-ROMs, USB devices, and floppy drives.

Directory Structure

UNIX uses a hierarchical file system arrangement, much like an upside-down tree, with root (/) at the base of the file system and all other directories distribution from there.

A UNIX file system is a collection of files and directory that has the following properties −

  • It has a root directory (/) that contains other files and directories.
  • Each file or directory is uniquely identified by its name, the directory in which it resides, and a unique identifier, typically called an anode.
  • By convention, the root directory has an anode number of 2 and the lost found directory has an anode number of 3. Anode numbers 0and 1 are not used. File anode numbers can be seen by specifying the -I option to less command.
  • It is self-contained. There are no dependencies between one file system and another.

The directories have exact purposes and commonly hold the same types of in order for easily locating files. Following are the directory that exists on the main versions of UNIX −

S.No. Directory & Description
1
/
This is the root directory which should contain only the directories needed at the top level of the file structure
2
/bin
This is where the executable files are located. These files are available to all users
3
/dev
These are device drivers
4
/etc
Supervisor directory commands, configuration files, disk configuration files, valid user lists, groups, ethernet, hosts, where to send critical messages
5
/lib
Contains shared library files and sometimes other kernel-related files
6
/boot
Contains files for booting the system
7
/home
Contains the home directory for users and other accounts
8
/mnt
Used to mount other temporary file systems, such ascdromandfloppyfor theCD-ROMdrive andfloppy diskette drive, respectively
9
/proc
Contains all processes marked as a file byprocess numberor other information that is dynamic to the system
10
/tmp
Holds temporary files used between system boots
11
/usr
Used for miscellaneous purposes, and can be used by many users. Includes administrative commands, shared files, library files, and others
12
/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
13
/sbin
Contains binary (executable) files, usually for system administration. For example,fdiskandifconfigutlities
14
/kernel
Contains kernel files

Navigating the File System

Nowadays that you recognize the basics of the file system, you can start navigating to the files you require. The following commands are used to navigate the system −

S.No. Command & Description
1
cat filename
Displays a filename
2
cd dirname
Moves you to the identified directory
3
cp file1 file2
Copies one file/directory to the specified location
4
file filename
Identifies the file type (binary, text, etc)
5
find filename dir
Finds a file/directory
6
head filename
Shows the beginning of a file
7
less filename
Browses through a file from the end or the beginning
8
ls dirname
Shows the contents of the directory specified
9
mkdir dirname
Creates the specified directory
10
more filename
Browses through a file from the beginning to the end
11
mv file1 file2
Moves the location of, or renames a file/directory
12
pwd
Shows the current directory the user is in
13
rm filename
Removes a file
14
rmdir dirname
Removes a directory
15
tail filename
Shows the end of a file
16
touch filename
Creates a blank file or modifies an existing file or its attributes
17
whereis filename
Shows the location of a file
18
which filename
Shows the location of a file if it is in your PATH

You can use Manage Help to check total syntax for each command mention here.

The do Command

The first way to direct your partition space is with the do (disk free) command. The command do -k (disk free) display the disk space usage in kilobytes, as exposed below –

Some of the directory, such as /devices, shows 0 in the Kbytes, used, and advantage columns as well as 0% for capacity. These are particular (or virtual) file systems, and although they reside on the disk under /, by themselves they do not consume disk space.

The do -k output is generally the same on all UNIX systems. Here's what it usually includes −

S.No. Column & Description
1
Filesystem
The physical file system name
2
kbytes
Total kilobytes of space available on the storage medium
3
used
Total kilobytes of space used (by files)
4
avail
Total kilobytes available for use
5
capacity
Percentage of total space used by files
6
Mounted on
What the file system is mounted on

You can use the -h (human readable) option to display the output in a format that show the size in easier-to-understand notation.

The du Command

The du (disk usage) command enables you to identify directories to show disk space usage on a particular directory.


This command is helpful if you want to decide how much space a exacting directory is taking. The following command display number of blocks devoted by each directory. A single block may take either 512 Bytes or 1 Kilo Byte depending on your system.

The -h option make the output easier to understand –

Mounting the File System

A file scheme must be mounted in order to be usable by the system. To see what is currently mounted (available for use) on your system, use the following command –

The /mint directory, by the UNIX standard, is where temporary mounts (such as CDROM drives, remote network drives, and floppy drives) are located. If you want to mount a file system, you can use the mount command with the following syntax –

For instance, if you want to mount a CD-ROM to the directory /mint/carom, you can kind –

This assumes that your CD-ROM device is called /dev/carom and that you desire to mount it to /mint/carom. Demote to the mount man page for more exact information or type mount -h at the command line for help information.


After mounting, you can use the cod command to navigate the newly accessible file system through the mount point you just complete.

Amounting the File System

To unmeant (remove) the file system from your system, use the umountcommand by recognizes the mount point or device.

For instance, to unmeant carom, use the following command.

The mount command enable you to contact your file systems, but on most modern UNIX systems, the auto mount function make this process invisible to the user and requires no intervention.

User and Group Quotas

The user and group quotas offer the mechanism by which the amount of space used by a single user or all users within a exact group can be limited to a value define by the manager.

Quotas control around two limits that allow the user to take some action if the amount of space or number of disk blocks start to go above the manager defined limits −

  • Soft Limit − If the user exceed the limit defined, there is a grace period that allows the user to free up some space.
  • Hard Limit − When the hard limit is reach, regardless of the grace period, no further files or blocks can be due.

There are a number of commands to manage quotas −

S.No. Command & Description
1
quota
Displays disk usage and limits for a user of group
2
edquota
This is a quota editor. Users or Groups quota can be edited using this command
3
quotacheck
Scans a filesystem for disk usage, creates, checks and repairs quota files
4
setquota
This is a command line quota editor
5
quotaon
This announces to the system that disk quotas should be enabled on one or more filesystems
6
quotaoff
This announces to the system that disk quotas should be disabled for one or more filesystems
7
repquota
This prints a summary of the disc usage and quotas for the specified file systems

You can use Manage Help to make sure total syntax for each command mention here.

All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd DMCA.com Protection Status

Unix/Linux Topics