LINUX PROGRAMMING AND ADMINISTRATION PRESENTED BY HARISH.R
LINUX PROGRAMMING AND ADMINISTRATION
PRESENTED BY
HARISH.R
OVERVIEW OF PRESENTATION
INTRODUCTION TO UNIX AND LINUX
FILES AND DIRECTORIES IN LINUX
INSTALLATION IN LINUX
BASIC COMMANDS
USER AND GROUP ADMINISTRATION
LILO
UNIX
HISTORY OF UNIX
MULTICS
UNICS
UNIX
Started in 1965 by AT & T, GE MIT
Created by Ken Thompson in 1969
Written in 100% C Language and released in 1973
UNIX
Commercial products
1. SunOS, Solaris
2. HP-UX
3. AIX
4. SCO UNIX
What is GNU / UNIX
A free Unix-type operating system developed under the
GNU General Public License.
Open source
Popular
Support most of the platforms available
General Characteristics of UNIX
Multi-user & Multi-tasking
Over 30 Years Old.
Large Number of Applications
FLAVOURS OF UNIX
These can be grouped into two categories: Open Source and Proprietary
Proprietary: (redistribution and modification prohibited or restricted; not free)
Solaris
IRIX
Mac OS X
Open Source: (source code is readily available and free to modify)
RedHat
Debian
SuSE
Slackware
History of LINUX
In Sept 1991, Linus Torvalds, a second year student of
Computer Science at the University of Helsinki, developed the
preliminary kernel of Linux, known as Linux version 0.0.1
CHARACTERISTICS OF LINUX
is a Unix-like computer operating system
Predominantly known for its use in servers.
supported by corporations such as Dell, Hewlett-Packard, IBM, Novell, Oracle
Corporation, Red Hat, and Sun Microsystems
USED AS AN OPERATING SYSTEM
Computer hardware
desktop computers
supercomputers
Video game players
PlayStation 2
PlayStation 3
Several Arcade Games
Embedded devices
Mobile Phones
Routers
Wristwatches
Stage lighting systems
Where might you find Linux?
LINUX DISTRIBUTION
Red Hat Linux
Open Linux
Debian GNU/Linux
SuSE Linux
Mandrake Linux
Slackware
LINUX DISTRIBUTION
Features of Linux
OPEN SOURCE: Free Software along with source code and Documentation.
MULTITASKING: Capable of running multiple application and process at the same time.
MULTIPLE-USER: Allow Multiple user to login and use the resources at same time.
PORTABILITY : Can be installed on all hardware architecture.
Features of Linux
SCALABILITY : Same Operating Systems can be used on a desktop to a Super Computer.
RELIABILITY : Large Server have been successfully being running without a single second of down time.
USER INTERFACE
Linux can be controlled by
text-based command line interface (CLI)
graphical user interface (GUI) (usually the default for desktop)
through controls on the device itself (common on embedded machines)
On desktop machines, KDE, GNOME and Xfce are the most popular user interfaces
File system hierarchy standard (fhs)
/
bootroot bin
optdevusrsbinhom
e
mediaetcvar
LINUX INSTALLATION
WHAT IS A PARTITION
A partition is a means of dividing your hard disk into multiple sections,
each of which is treated as a separate disk by your operating system.
This allows you to be able to boot different operating systems from the
same disk, for example, Linux and Windows.
Partitions cannot be moved or resized without destroying the data on
them.
WHAT IS A FILE SYSTEM
File systems can be considered as being the directory
structures on a disk partition that contains all the files.
Most Windows users would be familiar with the analogous
terms "folders" and "subfolders", whereas Linux users would be
familiar with the terms "directories" and "sub-directories".
/boot partition
The /boot partition contains the Linux kernel which is the "master
control program", not only for controlling the boot process, but also
the normal functioning of Linux.
Redhat Linux creates this partition automatically. This reduces the
need to reformat the "root" partition if it becomes corrupted.
SWAP PARTITION
Used as a location to place data temporarily if RAM memory becomes full.
Red Hat automatically creates this partition and usually makes it about
twice the amount of system RAM.
To create swap partition
]#fdisk /dev/partition name
N=new
L=logical
SWAP PARTITION
Format swap
]#mkswap /dev/partition name and ID
To on the swap
]#swapon /dev/partition name and ID
HARDWARE REQUIREMENTS
PROCESSOR MINIMUM RECOMMENDED
RAMTEXT 96 MB 256 MB
GUI 128 MB 512 MB
HARD DISK
TEXT 1 GB As per requirement
GUI 3 GB As per requirement
RECOMMENDED PARTITIONS
Partitions Size
/boot 100 MB
/ 3000 MB
/usr 6000 MB
/var 2000 MB
/home 2000 MB
swap Twice the RAM ( Minimum 4 GB )
Red hat installation
DUAL BOOT UBUNTU INSTALLATION
BASIC COMMANDS IN LINUX
Print working directory
Print the name of the current working directory
[root@comp~]# pwd
List of files and directories
Options:
-l Long list including attributes
-a All files and directories including hidden.
-d For a particular file or directory.
-R Recursive to see the tree.
To see the list of files and folders
[root@comp~]# ls <options> <arguments>
Creation of files
Files can be created by using any of the three methods given below:
Cat command
Touch command
Vi editor
Cat (concatenation command)
To create a file
[root@comp~]# cat > <filename>
To view the contents of the file
[root@comp~]# cat <filename>
Touch command
To create a zero byte file
[root@comp~]# touch <filename>
To create a multiple zero byte file
[root@comp~]# touch <first file> <second file> <third file>
Vi editor
To create a file
[root@comp~]# vi <filename>
Creating a directories
To create multiple directories
[root@comp~]# mkdir <first dir> <second dir> <third dir>
To create a directory
[root@comp~]# mkdir <file name>
Copying
Options:
-r Recursive
-v Verbose
-p Copy with permissions
To copying a file or directory
[root@comp~]# cp <options> <source file> <destination file>
Moving and renaming
To move a file or directory to a different locations
[root@comp~]# mkdir <source file or directory> <destination>
Rename a file or directory
[root@comp~]# mv <old name> <new name>
Deleting
Options
-r Recursive
-f forcefully
To remove or delete an empty directory
[root@comp~]# rmdir <dir name>
To remove or delete a file or directory
[root@comp~]# rm <options> <file or dir name>
Other commands
To see the date
[root@comp~]# date
To see the calender
[root@comp~]# cal
Vi EDITORS
Editors
Editors are used for adding, modifying and / or deleting text.
The different editors used
• Windows :notepad
• LINUX / UNIX zx
1.CLI Based : EX, ED, VI
2.GUI based : Emacs, Gedit, nedit, nano, pico
Vi Editors
Vi editors is a screen oriented text editors written by Bill joy in 1976.
This is the most commonly used editor for editing files in Linux.
Vi editor modes
Vi editors has three modes of operations
Command modeInsert modeEx mode
Insert mode
i - Inserts the text at the current cursor position.
I - Inserts the text in beginning of line.
a - Adds the text after the current cursor position.
A - Adds the text at the end of the line.
o - Insert the text one line below current cursor point.
O - Insert the text one line above current cursor point.
Command mode
dd - Deletes a line. ndd - Deletes ‘n’ lines. yy - Copies a lines. nyy - Copies ‘n’ lines. p - Put (Paste the deleted or
copied text). u - Undo (you can undo 1000 times)
Ex mode
:q - Quit without saving. :w - Write(save). :wq - Save and quit. :se nu - Set line numbers. :se nonu - Remove line numbers. :88 - This cursor goes to line
84.
USER ADMINISTRATION
Users
In computing, a user is a person who uses a computer or internet service.
A user will have a user account that identifies the user by a user name.
To logon a system, a user is required to authenticate himself with a password for the purposes of accounting, security, logging.
Users
Red hat Linux uses a User private group scheme
When a user is created a group with the same as the user name is also created.
This becomes the primary group.
A user can have only primary group.
Users
When a user is created in UNIX and LINUX, the following are also created by default.
Home directory /home/[username]
Mail account /var/spool/mail/[username]
Unique user identifier (UID) and the Group Identifier (GID).
Creating a user
Adding a user
[root@comp~]# useradd <username>
Or
[root@comp~]# useradd <options> <arguments> <username>
Options for creating user
Options:
-u UID
-c Comment
-g Primary group name
-G Secondary group name
-d Home directory
User password
Creating or changing a user password
[root@comp~]# passwd <username>
Modifying a user
Options:
-l Change the login name.
-L Lock the account.
-U Unlock the account.
Modifying user properties
[root@comp~]# usermod <options> <arguments> <username>
Deleting a user
Options:
-r Recursively
Deleting a user
[root@comp~]# userdel <options> <arguments> <username>
GROUP ADMINISTRATION
Group
Group is a collection of user to whom the same permission are to be applied.
There are two types of groups
1. Primary
2. Secondary
Creating a group
Options:
1. -g GID
Creating a group
[root@comp~]# groupadd <group name>
Or
[root@comp~]# groupadd <options> <arguments> <group name>
Modifying a group
Options:
-g GID
-n Group Name
Modifying a group
[root@comp~]# groupmod <options> <arguments> <group name>
Deleting a group
Deleting a group
[root@comp~]# groupdel <options> <arguments> <username>
ACCESS PERMISSIONS
Access Permissions
There are three defined categories of users.
The categories are:
owner — The owner of the file or application.
others — All users with access to the system.
group — The group that owns the file or application.
Access permissions
There are three permissions for any file, directory or application program.
The following lists the symbols used to denote each, along with a brief description:
r — Indicates that a given category of user can read a file.
w — Indicates that a given category of user can write to a file.
x — Indicates that a given category of user can execute the file.
LILO
Introduction to LILO
LILO or Linux Loader is a boot loader for Linux.
A boot loader is a small program that exists in the system and loads the operating
system into the system’s memory when the system boots.
Boot loader also starts the operating system.
LILO
LILO is a flexible boot loader for Linux, which is independent of a file system.
LILO loads itself into the computer’s memory in two stages
Stage1 – This stage, also known as primary boot loader is read into
memory by the BIOS from the master boot record
Stage 2 - This stage, also known as secondary boot loader is read into memory and it displays the Red Hat Linux initial screen
Configuring LILO
To install LILO, it is necessary to know the location of /boot partition.
It is also necessary to know the location of other installed operating systems
LILO can be installed for the first time using a shell script named QuickInst
LILO can be uninstalled using the lilo –u command
NETWORK FILE SYSTEM (NFS)
A network file system is any computer file system that support sharing of files over a computer network..
It is a centralized file storage system.
The client cannot differentiate whether the file is stored locally or remotely.
NETWORK FILE SYSTEM (NFS)
The Nfs Environment Contains The Following Components:
Nfs Server
- A System That Contains The File Resources To Be Shared With Other System Over The Network.
Nfs Cilent
- A System That Mounts The File Resources Shared Over The Network And Presents The File Resources As If They Were Local
DISK QUOTAS
Quotas are used to restrict the amount of hard disk spaces occupied by a user.
BACKUP
Backup is copy of data on a computer system.
,
Backup Levels
1. Level 0
2. Level 1
3. Level 2
Software tools in LINUX
Office Productivity suites
1. Applix ware
2. Star office
3. Corel office
Graphical tools
GIMP
File Transfer Protocol
File transfer protocol (FTP) is one of the oldest member of the TCP/IP protocol stack and is still in common use.
As the name suggests, it is optimized for transferring files.
FTP Server for LINUX
vsFTP Very Secure FTP Daemon
WU-FTP Washington University’s (St. Louis)
Proftpd Professional FTP Daemon
FTP Commands
ls
cd
put
mput
get
mget
bye
DIFFERENCE BETWEEN LINUX AND MICROSOFT
LINUX
Cost: Open Source, freely downloaded from Internet.
Usage: installed on a wide variety of computer hardware, ranging from mobile phones, tablet computers and video game consoles, to mainframes and supercomputers.
MICROSOFT
Cost: Windows can be expensive. Cost around $50 to $ 450 depending on the version of Windows.
Usage: On PC's desktops, laptops, servers and some phones.
File System: Ext2, Ext3, Ext4, Jfs, ReiserFS, Xfs, Btrfs, FAT, FAT32, NTFS
Developer/Company : Linus Torvalds
License: GNU/Free
Security: Linux has had about 60-100 viruses listed till date. None of them actively spreading nowadays.
Examples: Redhat, Ubuntu, Fedora, Boss, Debian, Mint
File System: FAT, FAT32, NTFS, exFAT
Developer/Company: Microsoft
License: Proprietary
Security: There have been more than 60,000 viruses in Windows. Anti Virus cost about $20 to $400.
Examples: Windows XP, Windows 7, Windows 8/8.1,
Thank you