Linux
Linux
Linux
System Administrator
• Ultimate authority in a Linux environment.
• Has the responsibility to govern the system
and care everything
• Under Linux, every file and program must be
owned by a user. Each user has a unique
identifier called a user ID. Each user must
also belong to atleast one group,
• Group - a collection of users established by
the system administrator.
• Like users, groups also have unique
identifiers called group IDs.
Duties of a System Administrator
• The administrator of Linux has all the rights required to
control the working of the system. He is responsible for
system maintenance.
• Adding, removing, or updating user account
information, resetting passwords, etc.
• Applying operating system updates, patches, and
configuration changes.
• Allocates storage space
• Assigns access permissions
• Prevents unauthorized permissions and ensure security.
• Installing and configuring new hardware and software.
Becoming the super user
• After typing the password, the prompt for the regular user ($)
will be changed to root user prompt #.
#cat /var/log/messages
Access files
• /etc/hosts - Contains a list of known hosts (in
the local network).
• /etc/hosts.allow - lists host computers that are
allowed to use certain TCP/IP services from the
local computer.
• /etc/hosts.deny - lists host computers that are
not allowed to use certain TCP/IP services from
the local computer.
• Following is a sample /etc/hosts file:
IPAddress Hostname Alias
127.0.0.1 localhost
208.164.186.1 deep.openna.com deep
208.164.186.2 mail.openna.com mail
208.164.186.3 web.openna.com web
Managing User Accounts
Adding Users
#passwd chris
Changing password for user chris
New UNIX password:
Retype new UNIX password:
Options
• -c “comment” provides a description of the new user
account.
#useradd –c “MarySmith” mary
45
Mounting (continued)
46
Mounting (continued)
47
/mnt directory
usually used as mount point for other mounted file
systems such as windows partitions.
Mount command
• The mount command is used to mount a file system
to the Linux operating system.
• The syntax for mount command is
Mount <[-t type] [options]> <device>[directory]
• When mount command is displayed without options
a list of file systems mounted on the system is
displayed.
49
• In the syntax for the mount command - type is
optional and is used to specify the type of file
system.
• Examples of types of file systems
• ISO9660 the standard file system used for CD-ROMS
• MSDOS the standard file system used by MS-DOS
• Vfat the standard file system used by windows 3x
and 9x
50
Some examples of device files
• /dev/fd0 the primary floppy drive
• /dev/fd1 the secondary floppy drive
• /dev/cdrom refers to CDROM Drive
Options
• rw specifies that the file system can be both read
from and written to.
51
Device name for Floppy drive -fd
IDE hard drive – hd
SCSI hard drive – sd
53
• ro specifies that the file system can be read from but
cannot be written to.
• Example of mount command to mount a floppy
• # mount –t vfat /dev/fd0 /mnt/floppy
54
Unmount command
Syntax
Unmount [device][directory]
Example
unmount /mnt/floppy
unmount /dev/fd0
55
Removable storage devices are handled by
udev and HAL( Hardware Abstract Layer)
boot dev
fd hd
cat cp
Data files
…
Directory Structure of Linux File System
Directory Content
Common programs, shared by the system, the system
/bin
administrator and the users.
/lost+foun Every partition has a lost+found in its upper directory. Files that were
d saved during failures are here.
/misc For miscellaneous purposes.
/sbin Programs for use by the system and the system administrator.
/tmp Temporary space for use by the system.
/usr Programs, libraries, documentation etc. for all user-related programs.
Storage for all variable files and temporary files created by users,
/var such as log files, the mail queue, the print spooler area, space for
temporary storage of files downloaded from the Internet.
File naming Conventions
…
/ home/ckc/b
The Working Directory(Home Directory)
One directory is
designated the current
working directory
if you omit the leading /
then path name is
relative to the current
working directory
Use pwd to find out
where you areCurrent
working
directory
doc/ab ab
~/doc/ab
/home/ckc/doc/ab
Some Special File Names
Some file names are special:
/ The root directory (not to be confused
with the root user)
. The current directory
.. The parent (previous) directory
~ My home directory
Examples:
./a same as a
../stud/x go up one level then look in
directory stud for x
Types of Files in Linux
File
File
Directory Special
Ordinary files
simple/ordinary file
All files created by a user
Include all data ,pgm, object and executable files
A user can modify it
…
Types of Files in Linux
Directory Files
File systems typically
have directories which allow the user
to group files into separate collections
This may be implemented by associating
the file name with an an inode in
a Linux-like file system.
The directory file is automatically
created by the OS.
…
The directory file has the same name as the directory and
contains information about the files stored in the directory.
O inserts a blank line above the current line and allows to insert text
Rtext<esc> Replaces characters at the current cursor position with the specified
text , until <Esc> Key is pressed
Cursor Movement Commands
<Ctrl>d or D Scrolls down half-screen
dw Deletes a word
dd Deletes a line
cw Changes a word
cc Changes a line
X Deletes the character before the current cursor position
• Eg:
• :1,$s/director/member/g
• :1,50s/unsigned//g
• :3,10s/director/member/g
• :.s/director/member/g only the current line
• :$s/director/member/g only the last line
\<part search for all strings which begin with the word 'part'
part\> search for all strings which end with the word 'part'
\<part\> only the whole word 'part' will qualify
will search for strings which contain any character in
[m-s]ing the range „m‟ to 's' and is followed by 'ing'
search for all strings which contain the characters
'art', with 'art' being preceded by any character
[^p]art other than 'p'
All words which begin with characters 'wing' and
wing* ends with any character
Regular Expressions
Agarwal
aggarwal
Agrawal
#include +<stdio.h>
Expression Significance
Matches one or more occurrences of the
ch+ character ch.
Matches zero or one occurrence of the
ch? character ch.
$cat pattern1
1,2p
7,9p
$p
Deleting Lines(d)
Sed „/director/d‟ emp.lst >olist
sed –n „/director/!p‟ emp.lst >olist
select all lines except those containing director , and save them
in olist.
Substitituion(s)
Syntax:
[address]s/expression1/expression2/flags
Eg:
sed „s/ | /:/‟ emp.lst |head –n 2
sed „s/ | /:/g‟ emp.lst
sed „1,3s/ | /:/g‟ emp.lst
sed „1,5s/director/member /g‟ emp.lst
sed „s/[Aa]gg*[ar][ar]wal/Agarwal/g‟ emp.lst
sed „s/ ^ / 2 /g‟ emp.lst
sed „s/ $ /.00 /g‟ emp.lst
• pr
• - Prepares a file for printing by adding suitable headers,footers and
formatted text.