Anda di halaman 1dari 9

TOP50UNIXCOMMANDSUSEDINSHELL

SCRIPTING.

1:SystemCommands
2:GenericCommands
3:BackupCommands
4:PermissionCommands.

SYSTEMCOMMANDS
1. ssh

2.

SSHallowsusersofUnixworkstationstosecuretheirterminalandfile
transferconnections.Thispageshowsthestraightforwardwaystomake
thesesecureconnections.
SSHprovidesthefunctionalequivalenttothe'rlogin'utility,butin
asecurefashion.SSHisfreelyavailableforUnixbasedsystems,
andshouldbeinstalledwithanaccompanyingmanpage.
sshconnectsandlogsintothespecifiedhostname(withoptionaluser
name).Theusermustprovehis/heridentitytotheremotemachineusing
oneofseveralmethodsdependingontheprotocolversionused.
whoami
Itprintstheeffectiveusername.
Printtheusernameassociatedwiththecurrenteffective
userID.
whoamiisacommandfoundonmostUnixlikeoperatingsystems,
Itisaconcatenationofthewords"WhoamI?"andprintsthe
effectiveuserid(username)ofthecurrentuserwheninvoked.

GeneralSyntax:
$
whoami
Itwillprintcurrentusername.
i.e.mithilesh

3.

who showwhoisloggedon
UNIXmaintainsanaccountofalluserswhoareloggedontosystem.
It'softenagoodideatoknowtheiruserid'ssocanmailthem
messages.Thewhocommanddisplaystheinformativelistingofusers.
ItsgeneralSyntaxis:
$ who
mithileshpts/12010120218:17(station80.example.com)
yogeshpts/22010120218:20(station122.example.com)
gauravpts/32010120218:21(station80.example.com)
hduser4pts/42010120218:21(station71.example.com)
rootpts/92010120216:59(172.24.0.250)

Here1stcolumnshowstheusernameof5userswhoareloggedonserver.
2ndcolumnshowsdevicenamesoftheirrespectiveterminal.Theseare
thefilenamesassociatedwiththeterminals.(mithilesh'sterminalis
pts/1).3rd,4th,5thcolumnshowsdateandtimeofloggingin.
Lastcolumnshowsmachinenamefromwheretheuserhasloggedin.
Ithas2moreoptionswhichcanbeused.
1:whoH
2:whou
HTheoptionprintsthecolumnheaders.
uTheoptionprintswithsomemoredetailslikePID,IDLEtime.
Example:
$whoHu
Itwillprint..

NAMELINETIMEIDLEPID
COMMENT
mithileshpts/12010120218:17.21590(station80.example.com)
yogeshpts/22010120218:2000:2721643(station122.example.com)
gauravpts/32010120218:2100:2621679(station80.example.com)
hduser4pts/42010120218:2100:0121681(station71.example.com)
rootpts/92010120216:5901:2520460(172.24.0.250)

4 .

w Showwhoisloggedandwhattheyaredoing.
UNIXmaintainsanaccountofalluserswhoareloggedontosystembut
alongwiththat,italsoshowswhatthatparticularuserdoingonhis
machine.
Italsodisplaysinformationabouttheuserscurrentlyonthemachine,
andtheirprocesses.Theheadershows,inthisorder,thecurrenttime,how
longthesystemhasbeenrunning,howmanyusersarecurrentlylogged
on,andthesystemloadaveragesforthepast1,5,and15minutes.
ItsgeneralSyntaxis:
$w
Itwillshowthebelowoutput.
18:57:52up1day,23:26,5users,loadaverage:0.00,0.00,0.00
USERTTYFROMLOGIN@IDLEJCPUPCPUWHAT
mithilespts/1station80.exampl18:170.00s1.26s0.10sw
yogeshpts/2station122.examp18:2037:120.38s0.38sbash
gauravpts/3station80.exampl18:2136:140.10s0.10sbash
hduser4 pts/4 station71.exampl 18:21 1:41 1.45s 1.15s sqlplus
rootpts/9172.24.0.25016:591:34m0.47s0.47sbash
Thefollowingentriesaredisplayedforeachuser:loginname,thetty
name,theremotehost,logintime,idletime,JCPU,PCPU,andthe
commandlineoftheircurrentprocess.
TheJCPUtimeisthetimeusedbyallprocessesattachedtothetty.
ThePCPUtimeisthetimeusedbythecurrentprocess,namedin
the"what"field.

5 .

uname knowingyourmachinecharecteristic.
Unamecommanddisplayscertainfeaturesoftheoperating
systemrunningonyourmachine.Bydefaultitsimplydisplays
thenameofoperatingsystem.
I.e$uname
Linux
LinuxsystemsimplyshowsLinux.
Usingsuitableoptionsyoucandisplaycertainkeyfeaturesof
operatingsystem.
Currentrelease(r).
SinceUNIXcommandsvariesacrossversionssomuchsothatyou'll
needtouseroptiontofindouttheversionofyouroperating
system.
i.e.$unamer
2.6.18194.el5
Thisistheversionofyouroperatingsystem.

Onemoreoptionwithunameis'a'.Itwilldisplayeverything
relatedtoyourmachinei.e.itwillshowyoufollowingthings
1:kernelname
2:nodename
3:kernelrelease
4:kernelversion
5:machine
6:processor
7:hardewareplatform
8:operatingsystem.

Example:$unamea

Linux,station252.example.com,2.6.18194.el5,#1SMP
TueMar1621:52:43EDT2010,i686athlon,i386GNU,Linux.

6 .

free Displayamountoffreeandusedmemoryinthesystem.
Itdisplaysthetotalamountoffreeandusedphysicalandswap
memoryinthesystem,aswellasthebuffersusedbythe
kernel.Thesharedmemorycolumnshouldbeignored;
itisobsolete.
Itsgeneralsyntaxis:
$free
Itwillshow

totalusedfreesharedbufferscached
Mem:2075468202408051388089001714056
/+buffers/cache:3011241774344
Swap:41942962814243912872
Inaboveoutputthememorydescriptionwhichisdisplayeditis
inbytes.
IfauserwantstodisplayitinrequiredformatthatisinGB,
MBorKB.
Variousoptionsusedwithitare...
1:$freek
ItwillshowtheoutputinKilobytes.
2:$freeg
ItwillshowtheouputinGegabytes.
3:$freem
ItwillshowtheoutputinMegabytes.

7.fdisk ItisapartitiontablemanipulatorforLinux.

Itismainlyusedforcreatingpartitions.
UNIXfragmentationsbecomesquiteevidentwhenitcomesto
creatingpartitions.Differentversionsofunixusedifferent
toolsforpartitioningadisk.
Thesystemadministratorwontallowyoutocreateordeletea
partition.
Itsgeneralsyntaxis:
$fdiskl
Itwillshowyoutotalsizeandeventhepartitions
ofyourharddisk.
Disk/dev/sda:160.0GB,160041885696bytes
255heads,63sectors/track,19457cylinders
Units=cylindersof16065*512=8225280bytes
DeviceBootStartEndBlocksIdSystem
/dev/sda1*11310439183Linux
/dev/sda21439293145527083Linux
/dev/sda3393078453145527083Linux
/dev/sda4784619457932733905Extended
/dev/sda578461176131455238+83Linux
/dev/sda611762130661048238183Linux
/dev/sda71306713849628941682Linuxswap/Solaris
/dev/sda8138501945745046228+83Linux
SocurrentlyinmyharddiskIhave8partitions.
Andsizeofmyharddiskis160GB.

8.psef Itreportsasnapshotofthecurrentprocesses.
Actuallypsisacommandwhichdisplaystheprocessowned
bytheuserrunningthecommand.Ifyouexecutethecommand
immediatelyafterloggingyouwillseelikethis
$ps
PIDTTYTIMECMD
19183pts/100:00:00bash
19699pts/100:00:00ps
EachlineintheoutputshowstheprocessID(PID),terminal(TTY),
cumulativeprocessortime(TIME),processname(CMD).
Variousoptionsusedwiththiscommandsare:
1:psfhere'f'standsforfulllisting.
Itwillshowyoudetailedlistingwhichalsoshowsparent
ofeveryprocess.

Eg:$psf
UIDPIDPPIDCSTIMETTYTIMECMD
root1918317770016:20pts/100:00:00bash
root1980219183016:37pts/100:00:00psf
2:psefhere'e'standsforallprocess.
Itwillshowyouallprocessrunnnigontheservermachine
andthattooindetailedlisting.
Eg:$psef

UIDPIDPPIDCSTIMETTYTIMECMD
root 1 0 0 11:55 ? 00:00:00 init [5]
root21011:55?00:00:00[migration/0]
root31011:55?00:00:00[ksoftirqd/0]
root41011:55?00:00:00[watchdog/0]
root51011:55?00:00:00[migration/1]
root61011:55?00:00:00[ksoftirqd/1]
root71011:55?00:00:00[watchdog/1]
root81011:55?00:00:00[events/0]
root91011:55?00:00:00[events/1]
root101011:55?00:00:00[khelper]
root111011:55?00:00:00[kthread]
root1999619183016:43pts/100:00:00psef
Abovecommandwillshoweachaneveryprocessrunningonservercurrently
alongwiththereparentprocessid(PPID).

9.uptime Tellhowlongthesystemhasbeenrunning.

many

Uptimegivesaonelinedisplayofthefollowinginformation.
The current time, how long the system has been running, how
usersarecurrentlyloggedon,andthesystemloadaverages
forthepast1,5,and15minutes.

Itssyntaxis:
$uptime
Itwilldisplay
16:48:27up4:53,3users,loadaverage:0.02,0.04,0.00

Anda mungkin juga menyukai