May 23, 2021 UNIX Getting started
A file system is a logical collection of files on a partition or disk. A partition is a container of information that can span the entire hard disk if needed.
Your hard drive can have different partitions, but usually contains only one file system, such as
/file
system and the other that
/home
file system.
A file system partition allows logical maintenance and management of different file systems.
Everything in UNIX is considered a file, including physical devices such as DVD-ROMs, USB devices, floppy drives, and so on.
UNIX uses a file system hierarchy, like an upside-down tree, where the root directory (/) is the bottom of the file system from which all other directories spread.
The UNIX file system is a collection of files and directories with the following properties:
Directories have specific purposes, often storing the same type of information for the purpose of making it easier to locate files. The following are the directories that exist on the major UNIX versions:
Directory | Describe |
---|---|
/ | This is the root directory and contains only the directories required for the top-level file structure. |
/bin | This is where the executable files are located. They are available to all users. |
/dev | These are device drivers. |
/etc | Parent directory commands, profiles, disk profiles, valid user lists, groups, Ethernet, hosts, etc. all kinds of places to send important information. |
/lib | Contains shared library files, such as other kernel-related files. |
/boot | Contains files related to system startup. |
/home | Contains the user's home directory and other accounts. |
/mnt | Used to mount other temporary file systems, such as CD-ROM drives and floppy drives for discs and floppy disks, respectively. |
/proc | Mark as a file that contains all processes that are marked with process numbers or other information. This file is a dynamic system. |
/tmp | Contains all temporary files during system startup. |
/uer | Used for a variety of purposes and can be used by many users. Includes executive orders, shared files, library files, and more. |
/var | Typically contains longer files, such as logs and print files and any other type of file, the amount of data that the file contains can vary. |
/sbin | Contains binary (executable) files, typically used for system management. For example, fdisk and ifconfig functions. |
/kernel | Contains kernel files. |
Now that you have the basics of the file system, you can start navigating to the files you need. The following are the commands that can be used to navigate to the file system:
Command | Describe |
---|---|
cat filename | The file name is displayed. |
cd dirname | Move to a determined directory. |
cp file1 file2 | Copy a file/directory to the specified location. |
file filename | Identify file types (binary, text, etc.). |
find filename dir | A file/directory was found. |
head filename | Displays the beginning of a file. |
less filename | Browse a file from the end or start location. |
ls dirname | Displays the contents of the specified directory. |
mkdir dirname | Create a specified directory. |
more filename | Browse a file from start to finish. |
mv file1 file2 | Move the location of a file/directory or rename a file/directory. |
Pwd | Displays the directory in which the user is currently located. |
rm filename | Delete a file. |
rmdir dirname | Delete a directory. |
tail filename | Displays the end of a file. |
touch filename | Create a blank file or modify the properties of an existing file. |
whereis filename | The location of a file is displayed. |
which filename | If the file is within your path, display its location. |
The first way to manage partitioned space is the df (disk idle) command. The command df -k (disk idle) shows disk space usage in thousands of bytes, as follows:
$df -k
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/vzfs10485760 7836644 2649116 75% /
/devices0 0 0 0% /devices
$
Some directories, such
/devices
are displayed as 0 in thousands of bytes, with 0% of the available columns and capabilities.
These special (or virtual) file systems, although they reside on disk, do not themselves take up disk space.
The output of
df -k
on all UNIX systems.
It generally includes:
Column | Describe |
---|---|
Filesystem | The name of the physical file system. |
kbytes | The total byte of free space on the storage media. |
used | The total byte of space used by the file. |
avail | The total byte of free space. |
capacity | The proportion of space and total used by the file. |
Mounted on | The file system is being installed. |
You
-h
(readable) option to set the output format for display, easy-to-understand symbols, appropriate size, and so on.
The du (disk usage) command enables you to display disk space usage in a particular directory by specifying a directory.
This command is useful if you want to determine how much space a particular directory is using. T he following command shows the number of blocks consumed by each directory. Depending on the system, a block may require 512 bytes or 1 kbyte.
$du /etc
10 /etc/cron.d
126/etc/default
6 /etc/dfs
...
$
-h
option makes the output easier to understand:
$du -h /etc
5k/etc/cron.d
63k /etc/default
3k/etc/dfs
...
$
The file system must be installed for the normal use of the system. In order to view the file system currently installed (available) on your system, you can use this command:
$ mount
/dev/vzfs on / type reiserfs (rw,usrquota,grpquota)
proc on /proc type proc (rw,nodiratime)
devpts on /dev/pts type devpts (rw)
$
The
/mnt
UNIX contract is where temporary mounts (e.g. CD-ROM drives, remote network drives, floppy disk drives) are installed.
If you need to mount the file system, you can use the mount command with the following syntax:
mount -t file_system_type device_to_mount directory_to_mount_to
For example, if you want to mount a CD-ROM to
/mnt/cdrom
you can enter:
$ mount -t iso9660 /dev/cdrom /mnt/cdrom
Suppose your CD-ROM device is
/dev/cdrom
and you want to mount
/mnt/cdrom
You can refer to the installation man page for more specific information or types, and enter
-h
for help information.
After installation, you can use the cd command to browse the available new file systems through mount points.
Uninstall (delete) the file system from your system by identifying mount points or devices. Implement using the umount command.
For example, you can uninstall a disc using the following command:
$ umount /dev/cdrom
The mount command gives you access to your file system, but in most modern UNIX systems, loading functions make this process invisible to the user and does not require user intervention.
Mechanisms that provide quotas for users and groups: The amount of space used by individual users or all users in a particular group can be limited by values defined by administrators.
There are two restrictions on quota operations. If the amount of space or disk blocks starts to exceed the administrator-defined limit, allow the user to take action:
There are many commands to manage quotas:
Command | Describe |
---|---|
quota | Displays disk usage and restrictions for one user in the group. |
edquota | This is a quota editor. You can use this command to edit user or group quotas. |
quotacheck | Scan file systems to use, manufacture, inspect, and repair quota files for disk use |
setquota | This is also a command line quota editor. |
quotaon | The system announces that disk quotas should be enabled on one or more file systems. |
quotaoff | The system announces that disk quotas on one or more file systems should be disabled. |
repquota | Prints a summary of disk usage and quotas for the specified file system |
You can use Manpage help to see the full syntax of each command mentioned here.