You are on page 1of 26

LINUX SHELL

WHAT IS SHELL
• Shell is an command language interpreter that
executes commands read from the standard
input device (keyboard) or from a file.

• Shell is a user program or it's environment


provided for user interaction.
IMPORTANCE OF SHELL SCRIPT
• Administrator can automate tasks such as
backup data, monitoring log files checking
system health
• Shell script can take input from user, file and
output them on screen.
• Useful to create our own commands.
• Save lots of time.
VARIOUS LINUX SHELL
Shell Name Developed by Where Remark

BASH ( Bourne- Brian Fox and Free Software Most common shell in Linux. It's Freeware
Again SHell ) Chet Ramey Foundation shell.
CSH (C SHell) Bill Joy University of The C shell's syntax and usage are very
California (For similar to
BSD) the C programming language.
KSH (Korn David Korn AT & T Bell Labs Originally available in rpm-based systems
SHell) as part of the pdksh package.
TCSH SHELL Bill Joy -- TCSH is an enhanced but completely
compatible version of the Berkeley UNIX C
shell (CSH).
ASH SHELL Kenneth -- Lightweight version of Berkeley Unix sh
Almquist shell.
Good shell for embedded system.
SHELL INTERFACE
SHELL INTERFACE DESCRIPTION

Shell prompt •The shell is the program that interacts between you and the
operating system.
•For Linux system has no GUI
•Default prompt for regular user : $
•Default prompt for root user : #
Terminal windows •A program that opens up a window and then runs a shell in that
window.
•For Linux system has GUI
•To launch : Application  Accessories  Terminals
Virtual terminals •Ways to have multiple shell session open at once outside of GUI.
•Can switch between virtual terminals like switch between workspace
on GUI.
•Press Ctrl + Alt + F1 (or F2, F3, F4, F5 and F6) to display on of six
virtual terminals.
•To return to GUI press CTRL + Alt + F7
LINUX TEXT EDITOR
TEXT EDITOR DESCRIPTION
vi editor  Vi has two modes:  Command mode to edit, save,
or quit; Text mode to type.  
 Use the Esc key to change from one mode to the
other.
pico (PIne  Start the Pico editor by typing pico at the prompt
COmposer) followed by a file name. Exp:    pico newfile.txt
editor  The blinking cursor indicates where may begin
typing.
joe (Joe’s Own  A terminal-based text editor for Unix systems,
Editor) available under the GPL.
 Use control and arrow keys to move around.
 Press Ctrl + C to exit without save and Ctrl – X to
save and exit
TEXT EDITOR DESCRIPTION
mcedit editor  A free cross-platform orthodox file manager.
(Midnight  a console application with a text user interface. The
Commander main interface consists of two panels which display the
Editor) file system.
 Arrow keys control file selection, the insert key is used to
select files and the Function Keys perform operations
such as renaming, editing and copying files.
emacs (Editor  Emacs falls somewhere between the straightforward
MAcroS) editor Pico and the complicated Vi.
 Typing emacs followed by a file name at the prompt. 
 To type : hold down the Ctrl key and press a letter.
Graphical text  Nedit: 'Nirvana Editor' is a text editor and source code
editors: Nedit, editor for the X Window System.
Xedit  Xedit: XEDIT performs the role of user interface manager
for many programs. For example, the FULIST program
which is a general purpose file manager on VM is written
as XEDIT macros
FILE SYSTEM TYPES
TYPE DESCRIPTION
Bfs Boot file system
Ext2 Second Extended file system

Ext3 Third Extended file system


Vfat Microsoft extended FAT (VFAT) file
system
REISERS Journaled file system
vxfx Veritas file system
bfs features
• used on UnixWare to store files necessary to
its boot process.
• It does not support directories, and only
allows contiguous allocation for files, to make
it simpler to be used by the boot loader.
Ext2 features
• Improve file system’s capability to recover
from crashes
• choice for flash-based storage media (such as
SD cards, and USB flash drives) since its lack of
a journal minimizes the number of writes and
flash devices have only a limited number of
write cycles.
Ext3 features
• Includes journaling features
• is journaling which improves reliability and
eliminates the need to check the file system
after an unclean shutdown.
• considered safer than the other Linux file
systems due to its relative simplicity and wider
testing base.
REISERS features
• Metadata-only journaling, its most-publicized
advantage over what was the stock Linux file system
at the time, ext2.
• provided tools to resize (both grow and shrink)
ReiserFS file systems offline.
• Tail packing, a scheme to reduce internal
fragmentation. Tail packing, however, can have a
significant performance impact. Reiser4 may have
improved this by packing tails where it does not hurt
performance.
Vxfx features
• With on-line defragmentation and resize support
turned on via license
• can run in single instance mode or in a parallel
access/cluster file system mode. This latter mode
allows for multiple servers to simultaneously access
the same file system
• Because Cluster File System shares the same binaries
and same on-disk layout as single instance VxFS,
moving between cluster and single instance mode is
straightforward.
MOUNT AND UN-MOUNT
• Use mount command to see which available
disk partitions are actually mounted and
where they are mounted
• Command : $ mount
• When a disk partition is mounted on Linux file
system, all directories and subdirectories
below that mount point are stored on that
partition.
DEVICES MOUNT DEVICES UN-MOUNT
DEVICES
CD-ROMS # mount /dev/cdrom /mnt/cdrom # umount /mnt/cdrom

Hard Disk # mount /dev/sdb1 /drive2 # umount /drive2

Partition

Floppy # mount /dev/fd0 /mnt/floppy # umount /mnt/floppy

Disk
USB # mount /dev/usbdisk /mnt/usbdisk # umount /mnt/usbdisk

storage
MONITOR FREE SPACE ON MOUNTED FILE
SYSTEM

• To see the amount of space available on all


the mounted file system on Linux computer,
type df
File system 1k blocks Used Available Use % Mounted on

/dev/hda3 30645460 2958356 26130408 11 % /

/dev/fd0 1412 13 1327 1% /mnt/floppy


MONITOR FREE SPACE ON
MOUNTED FILE SYSTEM
• To produce output in human-readable use
command df -h

File Size Used Available Use % Mounted on


system
/dev/hda3 30G 2.9G 2.6G 11 % /

/dev/fd0 1.4M 13k 1.2M 1% /mnt/floppy


CAUSE FOR FILE SYSTEM ERRORS
File system corruption
• Using a corrupt file system on other kernels
can still result in the file system being
shutdown if the problem has not been
rectified (on disk), making it seem like other
kernels are affected.
• The xfs_check tool, or xfs_repair -n, should be
able to detect any directory corruption.
Syncing
• When only parts of the disk cache have been
written, the controller doesn't even see that
the disks are out of sync.
• As the disks can resort cached blocks and
might have saved the superblock info, but
then lost different data contents.
• So, turn off disk write caches before using the
RAID function.
Bad disk blocks
• As a consequence of this behavior, the
corrupted partition cannot be fixed and data
remains inaccessible.
• Need to partition and reformat the hard drive
to a partition scheme that fsck can understand.
• After the partition has been reformatted, need
to restore lost data from last available backup.
CHECKING FILE SYSTEM
fsck
• is used to check and optionally repair one or more
Linux file systems.
• program will try to handle file systems on different
physical disk drives in parallel to reduce the total
amount of time needed to check all of the file
systems.
• The following example checks the file system on the first
partition of the second hard disk on a Linux system:
fsck /dev/sdb1
e2fsck
• is used to check a Linux second extended file
system (ext2fs).
• supports ext2 file systems containing a journal,
which are also sometimes known as ext3 file
systems
• by first applying the journal to the file system before
continuing with normal e2fsck processing.
• After the journal has been applied, a file system will
normally be marked as clean.
Reiserfsck
• searches for a Reiserfs file system on a
device, replays any necessary
transactions, and either checks or repairs
the file system.
HARD DISK QUOTAS
• Use the hard disk quotas command to limit user
space.
• Example of commands:
 quota - display a user's file system disk quota and
usage;
 edquota - Edit user quotas for file system;
 repquota - Summarize quotas for a file system;
 quotaon - Turn file system quotas on and off;
 quotaoff - Turn file system quotas off

You might also like