Upload
linuxloonie
View
38
Download
1
Embed Size (px)
DESCRIPTION
Learn GNU Linux in Tamil
Citation preview
1
- 2
.
:// .http kaniyam com
2 /GNU Linux - - 2
2013
2013 .
:
:
. ,
. . .
, , . . www kaniyam com . . .
::// . /http bit ly kaniyam
This work is licensed under a - 3.0 Creative Commons Attribution ShareAlike Unported License.
3/ GNU Linux .
4 . , . , " .
, -MySQL . , "" . . , . .
, /GNU -Linux .
, , .
1 , ' / - GNU Linux - 2'
, .
.
.
, 29 2013
: 87@ .nithyadurai gmail com
: :// . .http nithyashrinivasan wordpress com
5
1...................................................................................................................................9 Linux - .............................................................................9
2.................................................................................................................................15-Users ........................................................................................................15
sudo command.............................................................................................................15 adduser command.......................................................................................................16
su command.................................................................................................................17 -user sudo .............................................17
chown command..........................................................................................................19 chgrp command...........................................................................................................20
owner -group .......................................................20 userdel Command........................................................................................................21 Groups ...........................................................................................................................23
/ / :etc shadow file ......................................................................................................27 3.................................................................................................................................29
Disk Management............................................................................................................29-Partition :..........................................................................................29
-fdisk :........................................................................................................30 4................................................................................................................................36
Mount Unmount...................................................................................................36-Mount :........................................................................................36
Unmount :....................................................................................................37/ /etc fstab..................................................................................................................37
Filesystem :......................................................................................................38 :Mount Options .........................................................................................................38
-file mount :.......................................................................................39 -file system repair :.................................................................................41
5.................................................................................................................................42 Process Management......................................................................................................42
ps command.................................................................................................................42 pstree command..........................................................................................................42
top command................................................................................................................43 Kill command................................................................................................................44
6.................................................................................................................................45 :.............................................................45
:.....................................................................................45:repositories ..............................................................................................................45
-repo ...................................................................................46-Source :........................................................................................46
:..................................................................................46 :..........................................................................................47 - :upgrade ................................................................................................48
6 :...........................................................................................................48 :.......................................................................48
Deb file :..................................................................................................48 7.................................................................................................................................50
Shell Programming .............................................................................50 -Shell Script ........................................................................................50 -Shell Script .............................................................................................51
Variables........................................................................................................................51 Global Variables............................................................................................................51
Local Variables..............................................................................................................52 -local variable :......................................................................52
-Local variables -Global variables .................................................53 Special Variables..........................................................................................................54
8.............................................................................................................................55 - 2Shell Script ....................................................................................................................55
# Hash .........................................................................................55 Escape Mechanism .....................................................................................................55
Command substitution................................................................................................56 Positional Parameters..................................................................................................57
File descriptors.............................................................................................................58 Shift Command.............................................................................................................61
exit Command..........................................................................................................61 Numerical Comparisons..............................................................................................61 & Arithmetic Operators Expressions........................................................................62 Conditional Operators.................................................................................................63
9.................................................................................................................................64 3Shell Scripting ............................................................................................................64
Programming language Constructs..............................................................................64 If Statement..................................................................................................................64
case Statement............................................................................................................65 for Loop..........................................................................................................................67
while Loop......................................................................................................................69 until Loop.......................................................................................................................70
Functions........................................................................................................................72 10...............................................................................................................................74
Job Scheduling..................................................................................................................74 at command..................................................................................................................74
crontab ..........................................................................................................................74 11...............................................................................................................................77
Rsync backup .........................................................................................77 ;......................................................................................................77
.....................................................................................................................85.......................................................................................................................85........................................................................................................................85.............................................................................................................86 ........................................................................................................86
7 30, 2013 , .
: . .. , , , ( )
: . , 2004- , . ( )
8
, ,
- , . .. 100 (6500 ) .
, " " MySQL 5000 .
: :// .http jasanpictures com
9 1
Linux -
, Linux . .
Linux 20- 70- . 1969- & AT T -subsidiary Bell
Laboratories Unix . -unix Linux .
Linux . GNU Minix .
GNU
1983- Richard M Stallman GNU .
-Cambridge Massachusetts Institute of Technology Artificial
Intelligence .
Stallman . -source code . .
&AT T -unix $40,000 .
" -unix source-code "
. . -Stallman . source code -source code
10
. -Stallman . .
1983- Stallman GNU. .
Stallman :
========, 27, 1983 12:35:59 EST
( ) GNU GNU is Not Unix -Unix compatible software system . , , .
GNU kernel -C Programs -utilities . , , ,editor shell C Compiler
, linker assembler . ,text editor , , a YACC an Empire game spreadsheet -applications
. online -hardcopy documentation .
-GNU unix . -unix . .
========== .
GNU GNU is Not Unix . Unix . . -unix
-windows . , Stallman Manifest GNU ( GPL General Public License) .
-GPL () .
11
( #0)Freedom
, ( #1)Freedom
( #2)Freedom
-Program , -programs ( #3).Freedom
. . GPL . , .
1990- GNU components . Emacs
, , text editor Compiler gcc GNU C Compiler debugger gdb stallman .
compiler , . , compilers ++, C Pascal Fortran . GCC GNU Compiler
Collection .
-Richard Stallman 1990- -GNU System . -component kernel . -kernel ( GNU Hurd )
-Mach -set of server process implement . Mach Carnegie Mellon Utah micro kernel .
kernel .
12
:Minix
1990- -Intel Microprocessor , -Microsoft . Microsoft
desktop , server . Intel -Intel compatible processors , -unix
-workstations . -unix based system , versions
-Intel .
-Unix -processors ( : & ) eg SGI MIPS . -Unix
-Intel Processor OS . 1987- Andrew Tanenbaum Minix -OS
. -Netherlands , Amsterdam -Vrije University . -Minix -OS .
OS . C -Assembly language 12,000 .
-Tanenbaum " : " Operating Systems Design and Implementation Minix . Linus Torvalds
-Minix -Linux .
:Linux
1991- Linus Benedict Torvalds Finland, Intel-Processor Unix
-kernel . Minix -prototype .
-Minix -kernel GPL . Linus Torvalds -kernel Linux .
1991- 25-August , -Minix news group -Torvalds .
.
13
:
Minix !!!
. . GNU . . -Minix . -Minix . . .
(1.08) bash (1.40)-gcc port . .
@ . . torvalds kruuna helsinki fi .
================ .
Torvalds Freax / 0.11-kernel makefile -programs . Ari lemmke -FTP site -system load
-directory / / pub OS Linux . Linux -OS .
1991- Torvalds - .
-Torvalds .
1992- Linux - , .
-Torvalds . Torvalds . - Linux . Linux . Linux - GPL , Linux -versions
14
.
Linux . compile -distribution format .
Linux GNU / GNU Linux Distribution .
, Red Hat Caldera . Debian distribution . - , , X windows system KDE
GNOME -GUI -distributions .
Torvalds . 0.01-version acknowledgement
-copyrights . , GNU-license .
-Linux .
1992- February / -GNU Linux distributions floppy-disk
, -floppy disk .
linux . GNU / -GNU Linux .
-GCC Compiler linux . GPL . Torvalds version0.12- GPL .
/ GNU Linux / -GNU Linux . / GNU Linux .
15
2
-Users
-user management -commands .
root ?
-Ubuntu install -root account . -root disable ubuntu developers . -root . sudo -tool .
-sudo -root .
-Ubuntu install / / etc sudoers -file . sudo
-admin group .
sudo command
-sudo -root user command.
-root -sudo . -sudo , root user .
-root . -sudo . -adduser command .
16
adduser command
sudo -adduser command -user . .
$ adduser harini
, harini user .
users / / etc passwd . harini user .
$ cat /etc/passwd
password x . / / etc shadow -users encrypt -password . .
17
$ sudo cat /etc/shadow
su command
su switch user . su . logout login .
$ su harini
-user sudo
root user sudo , user --user sudo . -harini sudo
, / / -etc group -harini . .
18
nano -vi editor . -nano -file open .
-arrow mark key -sudo entry . -sudo entry -comma ' ' harini type + ctrl O . -file overwrite .
19
-harini sudo
chown command
-chown command -file -owner . -LKG file , user Nithya . Harini , -command .
$ chown harini LKG
20
chgrp command
-chgrp command -file -group . -LKG file , group Nithya . Harini , -command .
$ chgrp harini LKG
owner -group
chmod command owner -group .
$ chmod nithya:shrini LKG
21
-owner -nithya , -group -shrini . -colon -dot .
userdel Command
-userdel command -user .
$ userdel harini
:Password Policy
password . . password 4 , -entropy checks .
22
/ / . / - etc pam d common password -file .
password :
-user , -password . -password .
-password command .
$ sudo chage -l shrini
23
-command .
$ sudo chage shrini
-password .
- sudo chage l shrini .
Groups -groups command. groups
-groups .
24
$ cat /etc/group
-groups command.
$ groups shrini
-group commands .
$ sudo addgroup clg$ sudo delgroup clg
25
clg group , .
-group :
$ sudo delgroup --only-if-empty group
-user -group :
$ sudo usermod -G group -a user
User :
-user backup .
$ sudo deluser --backup-to /location/to/put/backup/user --remove-home user
-User
-user home directory $ sudo deluser --remove-home user
26
, user home directory -user ownership -file
$ sudo deluser --remove-all-files user
-Group
-user -Group .
$ id user
/ / etc passwd file
/ / etc passwd text file . -file . root .
system user human user .
/ / -etc passwd :
. -file : . 7 .
27
1. : username
2. : password . x . / / etc shadow -file .
3. ( ) : User id UID (user id ) . 0 -root . 1-999 -system user -human user .
4. ( ) : Group id GID , ( Primary group id/ / ) -etc group .
5. : User Id info . . , , . finger .
6. : home directory (home directory ). .
7. / : command shell login command shell / / . bin bash command .
$ less /etc/passwd
$ grep nithya /etc/passwd
/ / :etc shadow file
/ / -etc passwd . / / etc shadow -file .
encryption . root . : .
28
1. Username :
2. Password : ( encryption )
3. : 1, 1970last password change Jan
4. Minimum : . .
5. Maximum : . .
6. Warn :
7. Inactive : ,
8. expire :
5 md algorithm encryption .
29
3
Disk Management
Hard disk .
/ /dev sda : Primary Master/ /dev sdb : Primary slave/ /dev sdc : Secondary Master/ /dev sdd : Secondary slave
-hard disk / / dev sda .
partition .
/ / 1dev sda/ / 2dev sda/ / 3dev sda/ / 4dev sda...
4 primary partition . 4 extended , -logical partition .
fdisk , -partition .
: . root . , . , . .
-Partition : -partition
$ sudo fdisk-l
30
1. -disk -partition
$ sudo fdisk -l /dev/sda
-fdisk :
, partition . . m
# fdisk /dev/sda
The number of cylinders for this disk is set to 9729.There is nothing wrong with that, but this is larger than 1024,and could in certain setups cause problems with:1) software that runs at boot time (e.g., old versions of LILO)2) booting and partitioning software from other OSs (e.g., DOS FDISK, OS/2 FDISK)
Command (m for help): mCommand action a toggle a bootable flag b edit bsd disklabel c toggle the dos compatibility flag d delete a partition
31
l list known partition types m print this menu n add a new partition o create a new empty DOS partition table p print the partition table q quit without saving changes s create a new empty Sun disklabel t change a partition's system id u change display/entry units v verify the partition table w write table to disk and exit x extra functionality (experts only)
2. -partition
# fdisk /dev/sda
The number of cylinders for this disk is set to 9729.There is nothing wrong with that, but this is larger than 1024,and could in certain setups cause problems with:1) software that runs at boot time (e.g., old versions of LILO)2) booting and partitioning software from other OSs (e.g., DOS FDISK, OS/2 FDISK)
Command (m for help): p
Disk /dev/sda: 80.0 GB, 80026361856 bytes255 heads, 63 sectors/track, 9729 cylindersUnits = cylinders of 16065 * 512 = 8225280 bytesDisk identifier: 0xf6edf6ed
Device Boot Start End Blocks Id System/dev/sda1 1 1959 15735636 c W95 FAT32 (LBA)/dev/sda2 1960 5283 26700030 f W95 Ext'd (LBA)/dev/sda3 5284 6528 10000462+ 7 HPFS/NTFS/dev/sda4 6529 9729 25712032+ c W95 FAT32 (LBA)/dev/sda5 * 1960 2661 5638752 83 Linux/dev/sda6 2662 2904 1951866 83 Linux/dev/sda7 2905 3147 1951866 83 Linux/dev/sda8 3148 3264 939771 82 Linux swap / Solaris/dev/sda9 3265 5283 16217586 b W95 FAT32
Command (m for help): dPartition number (1-9): 8
Command (m for help): dPartition number (1-8): 7
Command (m for help): dPartition number (1-7): 6
Command (m for help): wThe partition table has been altered!
Calling ioctl() to re-read partition table.
32
WARNING: Re-reading the partition table failed with error 16: Device or resourcebusy.The kernel still uses the old table. The new table will be used atthe next reboot or after you run partprobe(8) or kpartx(8)Syncing disks.
3. -partition
-partition , cylinder , -partition () cylinder .
, p print .
# fdisk /dev/sda
The number of cylinders for this disk is set to 9729.There is nothing wrong with that, but this is larger than 1024,and could in certain setups cause problems with:1) software that runs at boot time (e.g., old versions of LILO)2) booting and partitioning software from other OSs (e.g., DOS FDISK, OS/2 FDISK)
Command (m for help): nFirst cylinder (2662-5283, default 2662):Using default value 2662Last cylinder, +cylinders or +size{K,M,G} (2662-3264, default 3264):Using default value 3264
w .
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
WARNING: Re-reading the partition table failed with error 16: Device or resourcebusy.The kernel still uses the old table. The new table will be used atthe next reboot or after you run partprobe(8) or kpartx(8)Syncing disks.
mkfs format .
33
# mkfs.ext3 /dev/sda7
4. -boot flag -partition boot a . .
# fdisk /dev/sda
The number of cylinders for this disk is set to 9729.There is nothing wrong with that, but this is larger than 1024,and could in certain setups cause problems with:1) software that runs at boot time (e.g., old versions of LILO)2) booting and partitioning software from other OSs (e.g., DOS FDISK, OS/2 FDISK)
Command (m for help): p
Disk /dev/sda: 80.0 GB, 80026361856 bytes255 heads, 63 sectors/track, 9729 cylindersUnits = cylinders of 16065 * 512 = 8225280 bytesDisk identifier: 0xf6edf6ed
Device Boot Start End Blocks Id System/dev/sda1 1 1959 15735636 c W95 FAT32 (LBA)/dev/sda2 1960 5283 26700030 f W95 Ext'd (LBA)/dev/sda3 5284 6528 10000462+ 7 HPFS/NTFS/dev/sda4 6529 9729 25712032+ c W95 FAT32 (LBA)/dev/sda5 * 1960 2661 5638752 83 Linux/dev/sda6 3265 5283 16217586 b W95 FAT32/dev/sda7 2662 3264 4843566 83 Linux
Partition table entries are not in disk order
Command (m for help): aPartition number (1-7): 5
Command (m for help): p
Disk /dev/sda: 80.0 GB, 80026361856 bytes255 heads, 63 sectors/track, 9729 cylindersUnits = cylinders of 16065 * 512 = 8225280 bytesDisk identifier: 0xf6edf6ed
Device Boot Start End Blocks Id System/dev/sda1 1 1959 15735636 c W95 FAT32 (LBA)/dev/sda2 1960 5283 26700030 f W95 Ext'd (LBA)/dev/sda3 5284 6528 10000462+ 7 HPFS/NTFS/dev/sda4 6529 9729 25712032+ c W95 FAT32 (LBA)/dev/sda5 1960 2661 5638752 83 Linux/dev/sda6 3265 5283 16217586 b W95 FAT32/dev/sda7 2662 3264 4843566 83 Linux
34
Partition table entries are not in disk order
Command (m for help):
5. -partition order
-logical partition , , . . Partition out of order Partition table
.entries are not in disk order
6, 7, 8 Sda sda sda . 6 sda , 7 sda . 9 sda , 6 sda . f .
.
$ fdisk /dev/sda
The number of cylinders for this disk is set to 9729.There is nothing wrong with that, but this is larger than 1024,and could in certain setups cause problems with:1) software that runs at boot time (e.g., old versions of LILO)2) booting and partitioning software from other OSs (e.g., DOS FDISK, OS/2 FDISK)
Command (m for help): p
Disk /dev/sda: 80.0 GB, 80026361856 bytes255 heads, 63 sectors/track, 9729 cylindersUnits = cylinders of 16065 * 512 = 8225280 bytesDisk identifier: 0xf6edf6ed
Device Boot Start End Blocks Id System/dev/sda1 1 1959 15735636 c W95 FAT32 (LBA)/dev/sda2 1960 5283 26700030 f W95 Ext'd (LBA)/dev/sda3 5284 6528 10000462+ 7 HPFS/NTFS/dev/sda4 6529 9729 25712032+ c W95 FAT32 (LBA)/dev/sda5 * 1960 2661 5638752 83 Linux/dev/sda6 3265 5283 16217586 b W95 FAT32/dev/sda7 2662 3264 4843566 83 Linux
Partition table entries are not in disk order
Command (m for help): x
Expert command (m for help): fDone.
Expert command (m for help): wThe partition table has been altered!
35
Calling ioctl() to re-read partition table.
WARNING: Re-reading the partition table failed with error 16: Device or resourcebusy.The kernel still uses the old table. The new table will be used atthe next reboot or after you run partprobe(8) or kpartx(8)Syncing disks.
36
4
Mount Unmount
P -artition .
file system . 3, 4, ext ext, ReiserFS Btrfs / .filesystems
Journalins Filesystem . index , file index . , , hard
-disk .
m kfs file system .
sudo mkfs.ext4 /dev/sda5sudo mkfs.reiserf5 /dev/sda6 file system mount .
mount -raw / device partition / folder .
Mount , , , disk partition Linux network share windows network share iso file / cd dvd folder .
-Mount :
root sudo .
1:
sudo mount /dev/sda5 /songs
/ / 5 dev sda / -songs mount . /ls songs /cd songs / / 5 dev sda -file .
37
2:
sudo mount -t iso9660 movie.iso /media/movie
. movie iso -ISO file / / media movie -folder mount .
-folder mount . mount point . mount -filesystem , mount .
Unmount :
mount filesystem unmount.
- root . mount file folder , unmount
.
sudo umount /media/movie
/ /etc fstab
boot -filesystem -mountpoint mount . / / etc fstab file .
6 column . filesystem .
38
Filesystem :
filesystem :
3/ 4 ext ext : / file system9660 iso : iso file
proc : proc virtual file system vfat : 16, 32 fat fat file system auto : filesystem
nts : network file systemsmbfs : network file system
:Mount Options
Mount - o , .
/ / -etc fstab .
noauto : boot mount . / cd dvd .
ro : - Read Only mount users : root (mount ) unmount
. user : , mount unmount
39
/ / -etc fstab 5 , column dump . , dump restore backup . filesystem 1 , / / cd dvd usb -removable media 0 .
6 -column - pass no . boot file system check .
/ root 1-boot mount -file system 0
-file system 2
-file mount :
iso file -file device mount .
1.44 MB file .
dd if=/dev/zero of=disk.img bs=1024 count=1400 = dd disk dump
= if input file = of output file = bs block size
= count count of dump operation
-file .
file system back level copy .
dd if=/dev/sdb1 of=usb.imgmount -o loop usb.img /mnt/disk
40
disk :
disk space :
df
-disk space , . Mount point .
df -h
- h human readable , MB GB .
-folder :
< >du foldername
-folder .
du -hdu -sh
41
-file system repair :
, , , filesystem .
- Hardware . .
< > < >fsck option device
sudo fsck /dev/sda5
.
sudo fsck -y -f /dev/sda5
- = y yes for questions- = f force
fdisk file system unmount .
42
5
Process Management
process . parent process child process . init process .
-process pid refer .
ps command
-ps command -process .
ps
ps ax, ps -aux, ps -ef, ps -l .
pstree command
-pstree command -process , parent process -child process
tree .
pstree
43
top command
- top command process -process . -output
real time monitoring .
$ top
44
Kill command
-process . -process -signal
$ kill 2180
-screenshot -terminal 2180 pid . 2180 kill , terminal .
killall
, program , kill .
45
6
:
, synaptic software center GUI , -command .
Apt
, , . , , , user interface module library translation . . dependancy .
Package management system , , .
Redhat -distribution yum , , debian ubuntu , APT Arch-linux pacman .
:
sudo apt-cache search [search term 1] [search term 2] [search term n]
:repositories, , , debian ubuntu centos suse distribution
package . repository .
-repository . , .
46
, -debian ubuntu / / / .etc apt sources list repository .
-repo
sudo add-apt-repository [repository name here]sudo add-apt-repository ppa:tualatrix/ppa
-Source : -repo repo .
sudo apt-get update
:
:
sudo apt-get install [package name 1] [package name 2] [package name n]
47
, -repository .
:
sudo apt-get remove [package name 1] [package name 2] [package name n]
48
configuration file directory purge .
sudo apt-get remove purge
- :upgrade
sudo apt-get upgrade ...
upgrade
sudo apt-get upgrade , , .
sudo apt-get -s upgrade , simulate .
:
-repo -deb file .
sudo apt-get clean
:
sudo dpkg list
, .
Deb file :
49
/ debian ubuntu packages deb . , .
sudo dpkg -i
50
7
Shell Programming
, -shell , -program .
-shell -programming language . -programming language
, programming constructs logical , conditional operators command, , substitution escape mechanisms positional parameters
-shell .
-Shell Script
-unix -commands . commands " "shell script.
, , , date ls uname echo -unix commands ' 1' example -file . .
1 example shell script . -script , -output .
51
-Shell Script
-shell script .
1: sh -unix command -script file -argument -shell script . .
1 example -shell script -unix commands -output .
2: chmod unix command file -execute permission -script file execute . .
Variables
-Unix , -variables , local variables global variable . .
Global Variables
Global Variables unix , . environment variables .
PATH -variable -directory . 1 PS -variable -shell prompt , HOME -variable -home directory .
$ ( ) dollar -variables , .
52
$ $PATH $ $PS1$ $HOME
Local Variables
-shell environment -variable local variable. -shell environment , . ' ' shell variables .
-local variable :
, a b 2 -variable -shell environment .
-variables echo . .
53
-variables -shell script , .
variables . local variables -shell environment . shell variables
-global variables , .
-environment shell variables set -command .$ set
-Local variables -Global variables
-local variable -global variable export command.
, a b 2 -local variable -global variable , -shell environment -export command .$ export a$ export b
54
-variables -shell script . .
Special Variables
Local variable global variable -unix -variable .
$# positional parameters .
$- -shell options ,$? execute -command exit . $$ -shell process .$! -background command process .$0 execute -command .$* -Positional parameters .
55
8
- Shell Script 2
# Hash
# type , type , execution .
shell script , # ,
-shell script .
. ec sh -file -comment , run .
-output -comment .
Escape Mechanism
. * ( ) Asterisk symbol echo .
56
-echo command *- . * -unix .special character
* , Unix. -character
-unix .
-special characters -character -unix , -character backslash
(\) .
* . escape mechanism .
Command substitution
. -unix command echo .
57
ls .
-ls command -backticks echo .
ls -command -output echo . command substitution .
Positional Parameters
-Shell script -command line -arguments . -shell script $1
-argument , $2 -argument , $3 -argument .
$0 -shell script , $* command-line -arguments .
$1,$2,$3 , -arguments -position , positional parameters .
. arguments sh -shell script .
58
. -arguments sh -command line -arguments .
arguments , -shell script positional-parameters -output .
File descriptors
File descriptors 0,1 2 , standard input standard output -standard error .
-shell script , commands , error messages ,
program .
59
-descriptors , error messages , -file ,
program .
man xyz command -error . -error descriptor 2-
-file .
$ man xyz 2> file2
man ls xyz , -command ls -output , -xyz -error . , -output -file , -error -file .
$ man ls xyz 1> opfile 2> errfile
60
output error -file -command .
$ man ls xyz > operrfile 2>&1
61
Shift Command
-shell script $1 $9 positional-parameters . ,
-shift command .
exit Command
-exit command -shell script . -shell script 0-, 1- .
Numerical Comparisons
-shell script . , 3 5 .
3 - 5 (3 eq 5 ( ) equals )
3 - 5 (3 ne 5 ( ) not equals )
3 - 5 (3-gt 5- ( ) greater than )
3 - 5 (3-lt 5- ( ) greater than )
3 - 5 (3-ge 5- ( ) greater than or equal to )
3 - 5 (3-le 5- ( ) greater than or equal to )
-command line .
$ [ 3 -eq 3 ] && echo true $ [ 3 -eq 5 ] && echo true $ [ 3 -lt 5 ] && echo true $ [ 3 -lt 2 ] && echo true
62
-command 3 - 3 eq true . 3 - 5 eq true . -commands .
& Arithmetic Operators Expressions
, , , +, -, *, / arithmetic operators . -shell script . .
$ expr 6 + 4$ expr 6 - 4$ expr 6 \* 4$ expr 6 / 4 * -operators , \ -escape operator .
, / -operator , , .
63
Conditional Operators
-commands -successful execution -failed execution -commands execute . && || conditional
execution operators .
&& -operator -successful execution ,|| -operator -failed execution
-commands execute .
$ grep Apple fruits && echo found || echo Not found$ grep Mango fruits && echo found || echo Not found
64
9
3Shell Scripting
Programming language Constructs
-Shell -programming language & , looping branching , operations on variables file creation argument passing
. -shell , -DOS -batch files .
If Statement
-If Construct -condition -set of commands execute .
:syntax
if (condition)then
commandselse
commandsfi
:
2. example sh -file -if statement , run .
65
fruits -file Apple if command.
fruits -file absolute path . -shell script absolute path -files .
case Statement
Case statement -option , -commands execute .
:syntax
case value in choice1) commands; ;choice2) commands; ; . . . esac
:
3. example sh -file -case statement , run .
66
options echo statement . read function
input , choice -variable .
case statement -choice variable 1 pwd-command , 2 -date , 3 -who command
execute . * 1,2,3 , " message echo
statement .
-input , output .
67
for Loop
-list -output .
:syntax
for in do
Commandsdone
:
4. example sh -file -for loop , run .
68
-seq 1 10 argument , 1 command 10 .
-command backticks -output -for loop -condition .
1 10 -loop statement execute , output .
69
.
while Loop
-while loop condition -loop -commands execute .
:syntax
while do
Commandsdone
70
:
5. example sh -file -while loop , run .
i -variable 1 assign . -while loop condition , i ,variable
5 -loop execute .
-loop i variable . -i 5- loop output .
until Loop
-until loop -while loop . until-loop condition -loop -commands
execute .
71
:syntax
until do
Commandsdone
:
6. example sh -file -until loop , run .
output .
72
Functions
-shell script function . -commands , logical -function .
-functions .
function input , parameter .
:Syntaxfunction_name () {commands}
:
. functions sh -file -function , run .
73
1 , 2 value value 2 -variables read function 2 . 2
(), add (), sub (), mul () div 4 functions.
-functions 2 1 value 2 value 2 variables -function
-parameter .
output .
74
10
Job Scheduling
-Shell -jobs schedule at crontab 2 commands . .
at command
/ command shell script execute schedule at command .
$ touch india | at 16.39
touch command 4:39 -PM india -file .
crontab
-Crontab / -command shell script , execute .
-crontab file . - crontab e -file open .
.
- minute (0 59 ) - hour (0 23 ) - day of month (1 31 ) - month (1 12 ) - day of week (0 6 ) (0= )Sunday
75
touch command 25- 4. 40 -crontab command .
$ crontab -e 40 16 25 * * touch trade (press)Esc:wq (press)Enter
40 , 16 ,
25 . *
, * .
-crontab schedule commands l -option . .
$ crontab -l
76
77
11
Rsync backup
. , .
rsync , , , .
;
: source file directory destination . , Source file directory . backup, .
: , ssh
- encryption - , .
:bandwidth , . ( ). compress , . ( ). extract bandwidth .
: . root .
:Syntaxrsync
source destination , network . , , IP hostname destination full path .
78
- 1; directory sync .
- zvr options .
$ rsync -zvr /var/opt/installation/inventory/ /root/tempbuilding file list ... donesva.xmlsvB.xml.sent 26385 bytes received 1098 bytes 54966.00 bytes/sectotal size is 44867 speedup is 1.63$
,
- = - z compress - = - v verbose - = - r recusrsive .
timestamp .
$ ls -l /var/opt/installation/inventory/sva.xml /root/temp/sva.xml-r--r--r-- 1 bin bin 949 Jun 18 2009 /var/opt/installation/inventory/sva.xml-r--r--r-- 1 root bin 949 Sep 2 2009 /root/temp/sva.xml
. .
2: metadata sync .
Rsync - a option sync .
- = a archive mode symbolic link
permissionstimestamp
, owner group
- a .
79
$ rsync -azv /var/opt/installation/inventory/ /root/temp/building file list ... done./sva.xmlsvB.xml.sent 26499 bytes received 1104 bytes 55206.00 bytes/sectotal size is 44867 speedup is 1.63$
timestamp sync .
$ ls -l /var/opt/installation/inventory/sva.xml /root/temp/sva.xml-r--r--r-- 1 root bin 949 Jun 18 2009 /var/opt/installation/inventory/sva.xml-r--r--r-- 1 root bin 949 Jun 18 2009 /root/temp/sva.xml
3: -file rsync
$ rsync -v /var/lib/rpm/Pubkeys /root/temp/Pubkeys
sent 42 bytes received 12380 bytes 3549.14 bytes/sectotal size is 12288 speedup is 0.99
4: local remote sync
remote , , IP () , hostname destination directory path .
@username hostname: / / / / .full path to destination
remote (password ) rsync .
' ' Passwordless ssh , password , remote rsync .
$ rsync -avz /root/temp/ [email protected]:/home/shrini/temp/Password:building file list ... done./rpm/rpm/Basenamesrpm/Conflictname
sent 15810261 bytes received 412 bytes 2432411.23 bytes/sectotal size is 45305958 speedup is 2.87
80
5: remote local rsync .,
= source remote = destination local
.
$ rsync -avz [email protected]:/var/lib/rpm /root/tempPassword:receiving file list ... donerpm/rpm/Basenames.sent 406 bytes received 15810230 bytes 2432405.54 bytes/sectotal size is 45305958 speedup is 2.87
6: remote shell
- e option remote shell . - e ssh encryption rsync .
$ rsync -avz -e ssh [email protected]:/var/lib/rpm /root/tempPassword:receiving file list ... donerpm/rpm/Basenames
sent 406 bytes received 15810230 bytes 2432405.54 bytes/sectotal size is 45305958 speedup is 2.87
7: -Destination , overwrite .
-destination File . rsync -source . - u option.
$ ls -l /root/temp/Basenamestotal 39088-rwxr-xr-x 1 root root 4096 Sep 2 11:35 Basenames
$ rsync -avzu [email protected]:/var/lib/rpm /root/tempPassword:receiving file list ... done
81
rpm/
sent 122 bytes received 505 bytes 114.00 bytes/sectotal size is 45305958 speedup is 72258.31
$ ls -lrttotal 39088-rwxr-xr-x 1 root root 4096 Sep 2 11:35 Basenames
8: -directory structure rsync
Directory Tree (File ) rsync - d .
$ rsync -v -d [email protected]:/var/lib/ .Password:receiving file list ... donelogrotate.statusCAM/YaST2/acpi/
sent 240 bytes received 1830 bytes 318.46 bytes/sectotal size is 956 speedup is 0.46
9: Progress
-file rsync , . rsync . -- progress . rsnapshot .
$ rsync -avz --progress [email protected]:/var/lib/rpm/ /root/temp/Password:receiving file list ...19 files to consider./Basenames 5357568 100% 14.98MB/s 0:00:00 (xfer#1, to-check=17/19)Conflictname 12288 100% 35.09kB/s 0:00:00 (xfer#2, to-check=16/19)...sent 406 bytes received 15810211 bytes 2108082.27 bytes/sectotal size is 45305958 speedup is 2.87
82
10: -Destination delete
-source file delete , -target delete . .
delete -- delete .
# Source and target are in sync. Now creating new file at the target.$ > new-file.txt
$ rsync -avz --delete [email protected]:/var/lib/rpm/ .Password:receiving file list ... donedeleting new-file.txt./
sent 26 bytes received 390 bytes 48.94 bytes/sectotal size is 45305958 speedup is 108908.55
11: rsync
source file , target file rsync . -- existing . [/var/lib/rpm ]$ > new-file.txt
$ rsync -avz --existing [email protected]:/var/lib/rpm/ [email protected]'s password:receiving file list ... done./
sent 26 bytes received 419 bytes 46.84 bytes/sectotal size is 88551424 speedup is 198991.96
12: / source destination
- i .
:Source$ ls -l /var/lib/rpm-rw-r--r-- 1 root root 5357568 2010-06-24 08:57 Basenames-rw-r--r-- 1 root root 12288 2008-05-28 22:03 Conflictname-rw-r--r-- 1 root root 1179648 2010-06-24 08:57 Dirnames
83
:Destination$ ls -l /root/temp-rw-r--r-- 1 root root 12288 May 28 2008 Conflictname-rw-r--r-- 1 bin bin 1179648 Jun 24 05:27 Dirnames-rw-r--r-- 1 root root 0 Sep 3 06:39 Basenames
$ rsync -avzi [email protected]:/var/lib/rpm/ /root/temp/Password:receiving file list ... done>f.st.... Basenames.f....og. Dirnames
sent 48 bytes received 2182544 bytes 291012.27 bytes/sectotal size is 45305958 speedup is 20.76
13:
-rsync , .
$ rsync -avz --include 'P*' --exclude '*' [email protected]:/var/lib/rpm/ /root/temp/Password:receiving file list ... done./PackagesProvidenameProvideversionPubkeys
sent 129 bytes received 10286798 bytes 2285983.78 bytes/sectotal size is 32768000 speedup is 3.19
14: file size limit
-- - max size option -file rsync .
$ rsync -avz --max-size='100K' [email protected]:/var/lib/rpm/ /root/temp/Password:receiving file list ... done./ConflictnameGroup
84
InstalltidNameSha1headerSigmd5Triggername
sent 252 bytes received 123081 bytes 18974.31 bytes/sectotal size is 45305958 speedup is 367.35
15: -file sync
, source target file rsync file rsync - w .
network bandwidth . checksum , .
# rsync -avzW [email protected]:/var/lib/rpm/ /root/tempPassword:receiving file list ... done./BasenamesConflictnameDirnamesFilemd5sGroupInstalltidName
sent 406 bytes received 15810211 bytes 2874657.64 bytes/sectotal size is 45305958 speedup is 2.87
85
.
, , . . . , ,
.
. .
. @ .editor kaniyam com
.
:
.
.
, .
. ,
. . , , , , ,
.
. @ . editor kaniyam com
.
86
, . @ . editor kaniyam com .
.
.
.
.
.
2013 .
:// . / / - /3.0/ http creativecommons org licenses by sa .
, , , , , , .
: . @ .editor kaniyam com +91 98417 95468
.
: . , 4, , 42, , - 600 059 . : +91 98417 95468 @ .tshrinivasan gmail com
:
L ibreOffice Writer 4.0.3.3 | Kubuntu Linux 13.04 | 2.8Gimp
87
Creative Commons .
.
- Name Nithya Duraisamy - 006101540799ICICI
- , .Branch Mcity branch chengalpattu - 0000061IFSC code ICIC
88
/ - GNU Linux - 3
Basics of Networking Basic Network Settings
Domain Name Server Network File Server Dynamic Host Control Protocol
Printing Apache Web server
Ssh
.
http://kaniyam.com : http://bit.ly/kaniyamThis work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.GNU/Linux . 30, 2013 , . : . .. , , , ( ) : . , 2004- , . ( ) , ,- , . .. 100 (6500 ) . , " MySQL" 5000 .: http://jasanpictures.com 1Linux - 2Users- sudo commandadduser commandsu command user- sudo chown commandchgrp command owner group- userdel CommandGroups/etc/shadow file:
3Disk ManagementPartition- :fdisk- :
$ fdisk /dev/sdaThe number of cylinders for this disk is set to 9729.There is nothing wrong with that, but this is larger than 1024,and could in certain setups cause problems with:1) software that runs at boot time (e.g., old versions of LILO)2) booting and partitioning software from other OSs(e.g., DOS FDISK, OS/2 FDISK)Command (m for help): pDisk /dev/sda: 80.0 GB, 80026361856 bytes255 heads, 63 sectors/track, 9729 cylindersUnits = cylinders of 16065 * 512 = 8225280 bytesDisk identifier: 0xf6edf6edDevice Boot Start End Blocks Id System/dev/sda1 1 1959 15735636 c W95 FAT32 (LBA)/dev/sda2 1960 5283 26700030 f W95 Ext'd (LBA)/dev/sda3 5284 6528 10000462+ 7 HPFS/NTFS/dev/sda4 6529 9729 25712032+ c W95 FAT32 (LBA)/dev/sda5 * 1960 2661 5638752 83 Linux/dev/sda6 3265 5283 16217586 b W95 FAT32/dev/sda7 2662 3264 4843566 83 LinuxPartition table entries are not in disk orderCommand (m for help): xExpert command (m for help): fDone.Expert command (m for help): wThe partition table has been altered!Calling ioctl() to re-read partition table.WARNING: Re-reading the partition table failed with error 16: Device or resource busy.The kernel still uses the old table. The new table will be used atthe next reboot or after you run partprobe(8) or kpartx(8)Syncing disks. 4Mount UnmountMount- :Unmount :/etc/fstabFilesystem :Mount Options: file- mount :file system- repair :
5Process Managementps commandpstree commandtop commandKill command
6 : :repositories: repo- Source- : : : - upgrade: : :Deb file :
7Shell Programming Shell Script- Shell Script- VariablesGlobal VariablesLocal Variables local variable - :
Local variables- Global variables- Special Variables 8
Shell Script- 2Hash # Escape MechanismCommand substitutionPositional ParametersFile descriptorsShift Commandexit Command
Numerical ComparisonsArithmetic Operators & ExpressionsConditional Operators
9Shell Scripting 3Programming language ConstructsIf Statementcase Statementfor Loopwhile Loopuntil LoopFunctions
10Job Schedulingat commandcrontab
11Rsync backup ;