Unixnew 2
Unixnew 2
UNIT 2
THE UNIX FILE SYSTEM
INTRODUCTION:
Unix file system is a logical method of organizing and storing large amounts of information in a
way that makes it easy to manage. A file is a smallest unit in which the information is stored.
Unix file system has several important features. All data in Unix is organized into files. All files
are organized into directories. These directories are organized into a tree-like structure called the
file system. Files in Unix System are organized into multi-level hierarchy structure known as a
directory tree. At the very top of the file system is a directory called “root” which is represented
by a “/”. All other files are “descendants” of root.
The Unix file system is a hierarchical file system used by Unix-based operating systems to store
and organize files and directories. It is a tree-like structure that starts with a single directory
called the root directory, which is denoted by a forward slash (/) character.
1. Hierarchical organization: The hierarchical structure of the Unix file system makes it
easy to organize and navigate files and directories.
2. Robustness: The Unix file system is known for its stability and reliability. It can
handle large amounts of data without becoming unstable or crashing.
1. Complexity: The Unix file system can be complex to understand and manage,
especially for users who are not familiar with the command line interface.
2. Steep learning curve: Users who are not familiar with Unix-based systems may find
it difficult to learn how to use the Unix file system.
PRINT WORKING DIRECTORY (pwd):
pwd command
pwd stands for Print Working Directory. It prints the path of the working directory, starting
from the root. pwd is shell built-in command(pwd) or an actual binary(/bin/pwd). $PWD is
an environment variable that stores the path of the current directory.
Syntax of `pwd` command in Linux
$ pwd [OPTIONS]
A home directory, also called a login directory, is the directory on Unix-like operating
systems that serves as the repository for a user's personal files, directories and programs.
• The simplest of these is to use the cd (i.e., change directory) command without any options
or arguments (i.e., input files), i.e., by merely typing the following and then pressing the
ENTER key:
ls command:
$cd
• The tilde (the wavy horizontal line character) is used to represent users' home directories on
Unix-like operating systems, including users' home directories that are used to store web pages
on Unix-like web servers. Thus, a user could also return to its home directory by using the tilde
as an argument to cd, i.e. $ cd
cd $HOME
ABSOLUTE PATHNAME:
An absolute pathname, also referred to as an absolute path or a full path, is the location of
a filesystem object (i.e., file, directory or link) relative to the root directory.
The absolute pathname of the current directory can be found by using the pwd command, which
accepts no arguments (i.e., input data) and is usually used without options, i.e.
$ pwd
1.cd:
Above, / represents the root directory. and used `pwd` to check the current location path
or we can say current directory name.
In above snapshot the root contains all the subfolders like afs, dev,bin , lib etc.
1. mkdir:
mkdir command in Linux allows the user to create directories (also referred to as folders
in some operating systems). This command can create multiple directories at once as well
as set the permissions for the directories. It is important to note that the user executing
this command must have enough permission to create a directory in the parent directory,
or he/she may receive a ‘permission denied’ error.
Syntax:
$ mkdir [options...] [directories ...]
For example:
command
$ mkdir Sushmitha._gfg
command:
$ mkdir –help
• –version:
It displays the version number, some information regarding the license and exits.
command:
$ mkdir –version
2. rmdir:
The rmdir command is useful when you want to remove the empty directories from the
filesystem in Linux. This command lets you specify the terminal to remove a particular
directory right from the terminal.
rmdir <options> <directory>
rmdir command is similar to the rm command, but rmdir only removes empty directories.
for example if we want to remove the file folder1 which is present then we use the
command:
$ rmdir folder1
$ ls
• --help:
we will use the help flag to list down all the available options for the rmdir command:\
$ rmdir –help
$ rmdir –help
• –version:
This option displays the version information and exit.
$ rmdir –version
RELATIVE PATHNAME:
A relative pathname contrasts with an absolute pathname in that it tells the location of a filesystem
object relative to the current directory (i.e., the directory in which the user is currently working)
rather than from the root directory.
Unlike the absolute path that starts from the root directory, the relative paths start from the present
working directory. Thus, the relative path changes depending on your current directory.
*For example, if I am in portfolio and want to change to sushmitha I can do this with a cd command
followed by the relative pathname between portfolio like this (first using pwd to show where I
am): cd ../.. where .. is used to move back to parent directory.