Filesystem

The Linux file system includes directories containing files and directories, each directory of which can contain yet more files and directories. Our own home directory, however, probably doesn’t contain any directories (except and of course), which prevents us from exploiting what we call the virtual file cabinet of the file system. Managing filesystems is one of the important tasks of Systems Administrator. Linux filesystems when originally designed to favor its users.

Linux filesystems look like an inverted tree, so that a root is at top and then branches underneath it. Major tasks for Systems administrators are

Tasks

  • Making files available to users.

  • Managing and monitoring the system’s disk resources.

  • Protecting against file corruption, hardware failures, user errors through backup.

  • Security of these file systems, what users need and have access to which files.

  • Adding more disks, tape drives, etc when needed.

rootdirectory
etcContains all system configuration files and the files which maintain information about users and groups
binContains all binary executable files (command that can be used by normal user also)
usrDefault directory provided by Linux OS to create users home directories and contains manual pages
tmpSystem or users create temporary files which will be removed when the server reboots
devContains all device files i.e. logical file names to physical devices
devicesContains all device files i.e. physical names of physical devices
homeDefault directory allocated for the home directories of normal users when the administrator don’t specify any other directory
varContains all system log files and message files
sbinContains all system administrator executable files (command which generally normal users don’t have the privileges)

How do we login to Linux system

We need to have an account created by linux administrator for that particular system. For example if We want to login to linux systems named dba-15, open up a new session to dba-15 and at prompt enter the user name and password as supplied by Administrator.

File Types

There are four types of files in the Linux file system.

Ordinary Files

An ordinary file may contain text, a program, or other data. It can be either an ASCII file, with each of its bytes being in the numerical range 0 to 127, i.e. in the 7-bit range, or a binary file, whose bytes can be of all possible values 0 to 255, in the 8-bit range.

Directory Files

Suppose that in the directory x we have a, b and c, and that b is a directory, containing files u and v. Then b can be viewed not only as a directory, containing further files, but also as a file itself. The file b consists of information about the directory b i.e. the file b has information stating that the directory b has files u and v, how large they are, when they were last modified, etc.

Device Files

In Linux, physical devices (printers, terminals etc.) are represented as files. This seems odd at first, but it really makes sense. This way, the same read() and write() functions used to read and write real files can also be used to read from and write to these devices.

Suppose we have a file X, and type

ln X Y

If we then run ls, it will appear that a new file, Y, has been created, as a copy of X, as if we had typed

cp X Y

However, the difference is the cp does create a new file, while ln merely gives an alternate name to an old file. If we make Y using ln, then Y is merely a new name for the same physical file X.

Relative path names

The use of the .. notation allows us to navigate the directory tree structure. The .. symbol means parent directory. Names with .. in them are relative names because their meaning depends on where they are issued (the present working directory). We can string together several .. symbols, separated by the / symbol and other directory names, to change directories.

For example, if we are in portfolio and want to change to mary, we can do this with a cd command followed by the relative path name between portfolio and mary like this (first using pwd to show where we are):

pwd
# output: /users/john/portfolio

cd ../../mary
pwd
# output: /users/mary

Directory or file references starting with .. are relative path names.

Directory or file references starting with a directory name are also relative path names. For example, if we are in the users directory, the directory reference john/portfolio is a relative path name:

pwd
# output: /users

cd john/portfolio
pwd
# output: /users/john/portfolio

Absolute path names

If we string together the unique name of all the intervening subdirectories in the file system to a particular subdirectory, we have created the absolute path name for that directory. The absolute path name allows us to switch to a directory no matter what my present working directory is.

Absolute path names always start with a /. We can navigate the file system by using absolute path names. So we could do something like shown below

pwd 
# output: /users/john
cd /users/mary
pwd 
# output: /users/mary
cd /tmp
pwd
# output: /tmp
cd /users/john/portfolio
pwd
# output: /users/john/portfolio

Every directory or file on the file system has a unique absolute path name. Although john may create a file called “test.txt” in his home directory and mary may create a file called test.txt in her home directory, the absolute path names of these files are different. John’s is called /users/john/test.txt, and Mary’s is /users/mary/test.txt.

File Security

Password security protects a system from access by an unauthorized person. In a multi-user system, each authorized user can have access to files that belong to other users or to the system files and utilities. In such an environment, it becomes essential that files should be protected so that another user does not misuse one user’s files and system files are not detected or modified.

UNIX allows users to protect their own files from other users working on the system. It also provides protection for system files. Before an explanation of the method of protecting their own files from other users working on the system. It also provides protection for system files.

Before an explanation of the method of protecting files, the following concepts will be discussed:

  • The types of files in UNIX
  • The concept of File Owner, Group Owner and Other Users.
  • Files access permissions.

The File Owner, Group Owner and Other Users File Owner

File Owner

The user who creates a file is said to be the owner of that file. The owner of a file can perform any operation on that file, e.g. copying, deleting, and editing (through some editor) etc.

Group Owner

Consider the following situation:

A project team of 5 people of the SMARTEST CONSULTANTS PVT. LTD. is working on a software development project for a private detective agency. The team is headed by an analyst. The other 4 members are all programmers. The team is working on a UNIX system. Each programmer has been given a few programs to develop. The data, provided by the detective agency, is of a highly confidential nature, and so the data file has been created in the analyst’s HOME directory.

One programmer may have to link his program to another programmer’s program in order to test his program.

In this situation, each programmer is the File Owner of his own program files. Each program, however, would also belong to the other programmers, so that they could use the programs for linking. The project team (of 5 users) is said to be the Group Owner for the file.

In UNIX, it is possible to define which user of the system is member of a group. A group of users are also given a name, just as a user is given a name. So, for the project team, the programmer Anita may be the owner of her program files. The group of users in the project team may be called PROJECT-ABC, which becomes the Group Owner of Anita’s program files.

Other Users

In the example of the SMARTEST CONSULTANTS PVT. LTD., all users of the system who are not members of the group PROJECT-ABC are referred to as Other Users for all files that belong to that group. Their Other Users are thus those users who do not have any common needs for data or programs with the Group Owner.

For e.g. people of the accounts department who use the system to generate reports, or data entry operators entering data for payroll can be referred to as Other Users for the files that belong to the group PROJECT-ABC.

To summarize:

Associated with each file in UNIX is:

  • A File Owner

  • A Group Owner which consists of users who need to share that file

  • Other users who do not belong to the group.

UNIX stores this information for each type of file on disk.

Subscribe For More Content