Unit 4 & Unit 5
Unit 4 & Unit 5
A boot block may contain the bootstrap code that is read into the
machine upon booting.
The first few blocks on any partition may hold a boot program, a
short program for loading the kernel of the operating system and
launching it. Often, on a Linux system, it will be controlled by LILO or
Grub, allowing booting of multiple operating systems. It's quite
simple (and common) to have a multiple boot environment for both
Linux and a flavour of Windows.
Super Block
A superblock describes the state of the file system:
how large it is;
how many files it can store;
where to find free space on the file system;
who has ownership of it
.
I node Block
Internal representation of a file is called an "inode" (contraction of term - index node) which
contains all the required information and description of the file data and its layout on disk. Inodes
resides on the disk and the kernel reads them into an into memory which we can call as in-core
inodes. Disk inodes contains the following information:
- File access permissions and time (last access / modified etc.)
- File ownership information.
- Type of the file (regular / directory / block special / pipe)
- Number of links to the file
- File size and organization on disk (the file data may spread across several different and far-
spaced disk location)
The In-core copy of inodes contains all of the above information, but it also contains the
following additional information:
- Status (locked / process is waiting for it to become unlocked / in-core copy has been modified
and thus differs from the copy on the disk / mounted)
- Logical Device number of the file system
- Inode Number. Since inodes are stored in a sequential manner on the disk, the kernel uses an
identifier of that array to refer to its in-core copy.
- Pointer to other in-core inodes. Kernel maintains a hash queue of inodes according to the
logical device number and the inode numbers. Kernel also maintains a list of free inodes.
- Reference count which indicates the number of instances of the file that are currently active.
Data block
data blocks - blocks containing the actual contents of
files
The Unix file system allocates data blocks (blocks
that contain a file's contents) one at a time from a
pool of free blocks.
Unix uses 4K blocks. Moreover, a file's blocks are
scattered randomly within the physical disk.
Storing and accessing files
vi, gedit, touch (commands)
Types of unix file system files
An ordinary file can contain data, such as text for documents or programs.
Eg image files, binary exe files
A link is not a kind of file but instead is a second name for a file. With a
link, only one file exists on the disk, but it may appear in two places in the
directory structure. This can allow two users to share the same file. Any
changes that are made to the file will be seen by both users.
Hard links can be used to assign more than one name to a file, but they
have some limitations. They cannot be used to give a directory more than
one name, and they cannot be used to link files on different computers.
symbolic link is a file that only contains the name (including the full
pathname) of another file.
Symbolic links can be used to assign more than one name to a file or
directory, or to make it possible to access a file from several locations.
Ls prefix eg Ls- l
• Copying cp command
• Removing rm command
Absolute mode (Numeric mode)
Chmod (Absolute)
The ps command lists all of the active processes running on the machine. If you use ps
without any options, information is printed about the processes associated with your
terminal.
Ps command options
Process Types
daemon
Priority
Nice
sleep
Wait
Ps
termination
Exit
Kill
Batch Command
• batch will queue the commands to be
executed when the load on the system
permits
• The batch command is especially handy when
you have a command or set of commands to
run but don’t care exactly when they are
executed.
Process priority
• Processes on a UNIX system are sequentially
assigned resources for execution.
• The kernel assigns the CPU to a process for a
time slice; when the time has elapsed, the
process is placed in one of several priority
queues
Nice Command
• The nice command allows a user to execute a command
with a lower-than-normal priority The process that is
using the nice command and the command being run
must both belong to the time-sharing scheduling class.
• You can decrease the priority of a command by using
nice to reduce the nice value. If you reduce the priority
of your command, it uses less CPU time and runs slower
• $ nice −19 proofit ( Reduce 19 priority for process)
Sleep Command
• The sleep command does nothing for a
specified time.
• sleep time
• $ (sleep 3600; who >> log) & provides a
record of the number of users on a system in
an hour. It creates a process in the background
that sleeps (suspends operation) for 3,600
seconds; and then wakes up