Professional Documents
Culture Documents
1
lastupdates06Jan200806.54pm checkforupdatesat http://www.linuxguide.it/cmd_ver.php?v=1.1 COMMAND
Systeminformation arch unamem unamer dmidecodeq hdparmi/dev/hda hdparmtT/dev/sda cat/proc/cpuinfo cat/proc/interrupts cat/proc/meminfo cat/proc/swaps cat/proc/version cat/proc/net/dev cat/proc/mounts lspcitv lsusbtv date cal2007 date041217002007.00 clockw
DESCRIPTION
showarchitectureofthemachine showkernelversionused showhardwaresystemcomponents(SMBIOS/DMI) displaysthecharacteristicsofaharddisk performtest reading on a hard-disk showsinformationCPUinfo showinterrupts verifymemoryuse showfile(s)swap showversionofthekernel shownetworkadptersandstatistics showmountedfilesystem(s) displayPCIdevices showUSBdevices showsystemdate showthetimetableof2007 setdateandtimeMonthDayhoursMinutesYear.Seconds savechangesofdateonBIOS
linuxcommandslinev1.1www.LinuxGuide.it
Shutdown,RestartofasystemandLogout shutdownhnow init0 shutdownrhours:minutes& shutdownc shutdownrnow reboot logout FilesandDirectory cd/home cd.. cd../.. cd cd~utente cd pwd ls lsF
lsl lsa ls*[09]* tree lstree mkdirdir1 mkdirdir1dir2 mkdirp/tmp/dir1/dir2 rmffile1 rmdirdir1 rmrfdir1 rmrfdir1dir2 mvdir1new_dir cpfile1file2 cpdir/*.
showdetailsoffilesanddirectory showhiddenfiles showfilesanddirectorycontainingnumbers showfilesanddirectoriesinatreestartingfromroot createadirectorycalled'dir1' createtwodirectoriessimultaneously createadirectorytree deletefilecalled'file1' deletedirectorycalled'dir1' removeadirectorycalled'dir1'andcontentsrecursively removetwodirectoriesandtheircontentsrecursively rename/moveafileordirectory copyingafile copyallfilesofadirectorywithinthecurrentworkdirectory
Filesearch find/namefile1 find/useruser1 find/home/user1name\*.bin find/usr/bintypefatime+100 find/usr/bintypefmtime10 find/name\*.rpmexecchmod755{}; find/xdevname\*.rpm locate\*.ps whereishalt whichhalt MountingaFilesystem mount/dev/hda2/mnt/hda2 umount/dev/hda2 fuserkm/mnt/hda2 umountn/mnt/hda2 mount/dev/fd0/mnt/floppy mount/dev/cdrom/mnt/cdrom mount/dev/hdc/mnt/cdrecorder mount/dev/hdb/mnt/cdrecorder mountoloopfile.iso/mnt/cdrom mounttvfat/dev/hda5/mnt/hda5 mount/dev/sda1/mnt/usbdisk mounttsmbfsousername=user,password=pass //winclient/share/mnt/share
searchfileanddirectoryintorootfilesystemfrom'/' searchfilesanddirectoriesbelongingto'user1' searchfileswith'.bin'extensionwithindirectory'/ home/user1' searchbynaryfilesarenotusedinthelast100days searchfilescreatedorchangedwithin10days searchfileswith'.rpm'extensionandmodifypermits searchfileswith'.rpm' xtensionignoringremovable e partitionsascdrom,pendrive,etc. findfileswiththe'.ps'extensionfirstrun'updatedb' command showlocationofabinaryfile,sourceorman showfullpathtoabinary/executable
linuxcommandslinev1.1www.LinuxGuide.it
mountdiskcalledhda2verifyexistenceofthedirectory'/ mnt/hda2' unmountdiskcalledhda2exitfrommountpoint'/ mnt/hda2'first forceumountwhenthedeviceisbusy runumountwithoutwritingthefile/etc/mta busefulwhen thefileisreadonlyortheharddiskisfull mountafloppydisk mountacdrom/dvdrom mountacdrw/dvdrom mountacdrw/dvdrom mountafileorisoimage mountaWindowsFAT32filesystem mountausbpendriveorflashdrive mountawindowsnetworkshare
useraddc"NomeCognome"gadmind/home/user1s /bin/bashuser1 createanewuserbelongs"admin"gr up o useradduser1 createanewuser userdelruser1 usermodc"UserFTP"gsystemd/ftp/user1s /bin/nologinuser1 passwd passwduser1 chageE20051231user1 pwck grpck newgrpgroup_name
deleteauser('r'eliminateshomedirectory) changeuserattributes changepassword changeauserpassword(onlybyroot) setdeadlineforuserpassword checkcorrectsyntaxandfileformatof'/etc/pass d'and w usersexistence checkcorrectsyntaxandfileformatof'/etc/group'and groupsexistence logintoanewgrouptochangedefaultgroupofnewly createdfiles
linuxcommandslinev1.1www.LinuxGuide.it
PermitsonFileuse"+"tosetpermissionsand""to remove lslh ls/tmp|prT5W$COLUMNS chmodugo+rwxdirectory1 chmodgorwxdirectory1 chownuser1file1 chownuser1Rdirectory1 chgrpgruppo1file1 chownuser1:gruppo1file1 find/permu+s chmodu+s/bin/file_eseguibile chmodus/bin/file_binario chmodg+s/home/public
showpermits divideterminalinto5columns setpermissionsreading(r),write(w)and(x) accesstousers owner(u)group(g)andothers(o) removepermitsreading(r),write(w)and(x)accesstousers group(g)andothers(or changeownerofafile changeuserownerofadirectoryandallthefilesand directoriescontainedin side changegroupoffiles changeuserandgroupownershipofafile viewallfilesonthesystemwithSUIDconfigured setSUIDbitonabina ryfiletheuserthatrunningthatfile getssameprivilegesasowner disableSUIDbitonabinaryfile setSGIDbitonadirectorysimilartoSUIDbutfordirectory
chattr+afile1 chattr+cfile1 chattr+dfile1 chattr+ifile1 chattr+sfile1 chattr+Sfile1 chattr+ufile1 lsattr Archivesandcompressedfiles bunzip2file1.bz2 bzip2file1 gunzipfile1.gz gzipfile1 gzip9file1 rarafile1.rartest_file rarafile1.rarfile1file2dir1 rarxfile1.rar unrarxfile1.rar tarcvfarchive.tarfile1 tarcvfarchive.tarfile1file2dir1 tartfarchive.tar tarxvfarchive.tar tarxvfarchive.tarC/tmp tarcvfjarchive.tar.bz2dir1 tarxvfjarchive.tar.bz2 tarcvfzarchive.tar.gzdir1 tarxvfzarchive.tar.gz zipfile1.zipfile1 ziprfile1.zipfile1file2dir1
allowswriteopeningofafileonlyappendmode allowsthatafileiscompressed/decompresse automatically d bythekernel makessurethattheprogramignoresDumpthefilesduring backup makesitanimmutablefile,whichcan otberemoved, n altered,renamedorlinked allowsafiletobedeletedsafely makessurethatifafileismodifiedchangesarewrittenin synchronousmodeaswithsync allowsyoutorecoverthecontentsofafileevenifitis canceled showspecialsattributes
linuxcommandslinev1.1www.LinuxGuide.it
decompressafilecalled'file1.bz2' compressafilecalled'file1' decompressafilecalled'file1.gz' compressafilecalled'file1' compresswithmaximumcompression createanarchiverarcalled'file1.rar' compress'file1','file2'and'dir1'simultaneously decompressrararchive decompressrararchive createauncompressedtarball createanarchivecontaining'file1','file2'and'dir1' showcontentsofanarchive extractatarball extractatarballinto/tmp createatarballcompressedintobzip2 decompressacompressedtararchiveinbzip2 createatarballcompressedintogzip decompressacompressedtararchiveingzip createanarchivecompressedinzip compressinzipseveralfilesanddirectoriessimultaneously
decompressaziparchive
linuxcommandslinev1.1www.LinuxGuide.it
rpmFpackage.rpm rpmepackage_name.rpm rpmqa rpmqa|grephttpd rpmqipackage_name rpmqg"SystemEnvironment/Daemons" rpmqlpackage_name rpmqcpackage_name rpmqpackage_namewhatrequires rpmqpackage_namewhatprovides rpmqpackage_namescripts
upgradearpmpackageonlyifitisalreadyinstalled removearpmpackage showallrpmpackagesinstalledonthesystem showallrpmpackageswiththename"httpd" obtaininformationonaspecificpackageinstalled showrpmpackagesofagroup oftware s showlistoffilesprovidedbyarpmpackageinstalled showlistofconfigurationfilesprovidedbyarpmpakage c installed showlistofdependen ciesrequiredforarpmpacket showcapabilityprovidedbyarpmpackage showscriptsstartedduringinstallation/removal
rpmimport/media/cdrom/RPMGPGKEY rpmchecksigpackage.rpm rpmqagpgpubkey rpmVpackage_name rpmVa rpmVppackage.rpm rpm2cpiopackage.rpm|cpioextractmake directories*bin* rpmivh/usr/src/redhat/RPMS/`arch`/package.rpm rpmbuildrebuildpackage_name.src.rpm YUMpackagesupdaterFedora,RedHatandlike yuminstallpackage_name yumupdate yumupdatepackage_name yumremovepackage_name yumlist yumsearchpackage_name yumcleanpackages yumcleanheaders yumcleanall DEBpackagesDebian,Ubuntuandlike dpkgipackage.deb dpkgrpackage_name dpkgl dpkgl|grephttpd dpkgspackage_name
importpublickeydigitalsignature verifytheintegrityofarpmpackage verifyintegrityofallrpmpackagesinstalled checkfilesize,permiss ions,type,owner,group,MD5 checksumandlastmodificatio n checkallrpmpackagesinstalledonthesystemusewith caution verifyarpmpackagenotyetinstalled extractexecutablefilefromarpmpackage installapackagebuiltfromarpmsource buildarpmpackagefromarpmsource
linuxcommandslinev1.1www.LinuxGuide.it
downloadandinstallarpmpackage updateallrpmpackagesinstalledonthesystem upgradearpmpackage removearpmpackage listallpackagesinstalledonthesystem findapackageonrpmrepository cleanuprpmcacheerasingdownloadedpackages removeallfilesheadersthatthesystemusestoresolve dependency removefromthecachepackagesandheadersfiles
linuxcommandslinev1.1www.LinuxGuide.it
dpkgLpackage_name
showlistoffilesprovidedbyapackageinstalledonsystem
dpkgcontentspackage.deb dpkgS/bin/ping APTpackagesupdaterDebian,Ubuntuelike aptgetinstallpackage_name aptcdrominstallpackage_name aptgetupdate aptgetremovepackage_name aptgetcheck aptgetclean Viewfilecontent catfile1 tacfile1 morefile1 lessfile1
showlistoffilesprovidedbyapackagenotyetinstalled verifywhichpackagebelongstoagivenfile
linuxcommandslinev1.1www.LinuxGuide.it
head2file1 tail2file1 tailf/var/log/messages TextManipulation catfile_test|[operation:sed,grep,awk,grep, etc]>result.txt catfile_originale|[operazione:sed,grep,awk, grep,etc]>>result.txt grepAug/var/log/messages grep^Aug/var/log/messages grep[09]/var/log/messages grepAugR/var/log/* sed's/stringa1/stringa2/g'example.txt sed'/^$/d'example.txt sed'/*#/d;/^$/d'example.txt echo'esempio'|tr'[:lower:]''[:upper:]' sede'1d'result.txt sedn'/stringa1/p' sede's/*$//'example.txt sede's/stringa1//g'example.txt
syntaxtoelaboratethetextofafile,andwriteresulttoanew file syntaxtoelaboratethetextofafileandappendresultonto existingfile lookupwords"Aug"inthefileonto'messages' lookupwordsthatbeginwith"Aug"ontofile'messages' selectfromfile'messages'alllinesthatcontainnumbers searchstring"Aug"atdirectory'/var/log'andbelow replace"string1"with"string2"ontoexample.txt removeallblanklinesfromex ample.txt removecommentsandblanklinesfromexample.txt convertfromlowercaseinuppercase eliminatesthefirstlinefromfileexample.txt viewonlylinesthatcontaintheword"string1" removeemptycharactersattheendofeachrow removeonlytheword"string1"fromtextandleaveintactall
sedn'1,5p;5q'example.txt sedn'5p;5q'example.txt sede's/00*/0/g'example.txt catnfile1 catexample.txt|awk'NR%2==1' echoabc|awk'{print$1}' echoabc|awk'{print$1,$3}' pastefile1file2 pasted'+'file1file2 sortfile1file2 sortfile1file2|uniq sortfile1file2|uniqu sortfile1file2|uniqd comm1file1file2 comm2file1file2 comm3file1file2
viewfrom1thto5throw viewrownumber5 replacemorezeroswithasinglezero numberrowofafile removealllinesevenfromexample.xt t viewthefirstcolumnofline viewthefirstandthirdcolumnofline mergingcontentsoftwofilesforcolumns mergingcontentsoftwofilesforcolumnswith'+'deimiter l onthecenter sortcontentsoftwofiles sortcontentsoftwofilesomittinglinesrepeated sortcontentsoftwofilesbyviewingonlyuniqueline sortcontentsoftwofilesbyviewingonlyduplicateline comparecontentsoftwofilesbydeletingonlyuniquelines from'file1' comparecontentsoftwofilesbydeletingonlyuniquelines from'file2' comparecontentsoftwofilesbydeletingonlythelinesthat appearonbothfiles
linuxcommandslinev1.1www.LinuxGuide.it
CharactersetandFormatfileconversion dos2unixfiledos.txtfileunix.txt unix2dosfileunix.txtfiledos.txt recode..HTML<page.txt>page.html recodel|more FilesystemAnalysis badblocksv/dev/hda1 fsck/dev/hda1 fsck.ext2/dev/hda1 e2fsck/dev/hda1
linuxcommandslinev1.1www.LinuxGuide.it
repair/checkintegrit yofext3filesystemondiskhda1 repair/checkintegrit yofext3filesystemondiskhda1 repair/checkintegrit yoffatfilesystemondiskhda1 repair/checkintegrit yofdosfilesystemondiskhda1 repair/checkintegrit yofdosfilesystemsondiskhda1
linuxcommandslinev1.1www.LinuxGuide.it
mkfstvfat32F/dev/hda1 fdformatn/dev/fd0 mkswap/dev/hda3 SWAPfilesystem mkswap/dev/hda3 swapon/dev/hda3 swapon/dev/hda2/dev/hdb3 Backup dump0ajf/tmp/home0.bak/home dump1ajf/tmp/home0.bak/home restoreif/tmp/home0.bak rsyncrogpavdelete/home/tmp rsyncrogpavesshdelete/homeip_address:/tmp rsyncazesshdeleteip_addr:/home/public /home/local rsyncazesshdelete/home/local ip_addr:/home/public ddbs=1Mif=/dev/hda|gzip|sshuser@ip_addr'dd of=hda.gz' tarPufbackup.tar/home/user (cd/tmp/local/&&tarc.)|sshCuser@ip_addr 'cd/home/share/&&tarxp' (tarc/home)|sshCuser@ip_addr'cd /home/backuphome&&tarxp' tarcf.|(cd/tmp/backup;tarxf) find/home/user1name'*.txt'|xargscpav targetdirectory=/home/backup/parents
makeafullbackupofdirectory'/home' makeaincrementalbackupofdirectory'/home' restoringabackupinteractively synchronizationbetweendirectories rsyncviaSSHtunnel synchronizealocaldirectorywitharemotedirectoryviassh andcompression synchronizearemotedirect rywithalocaldirectoryviassh o andcompression makeabackupofalocalharddiskonremotehostvias h s makeaincrementalbackupofdirectory'/home/user' copycontentofadirectoryonremotedirectoryviassh copyalocaldirectoryonremotedirectoryviassh localcopypreservingpermitsandlinksfromadirectory o t another findandcopyallfileswith'.txt'extentionfromadirectoryto another
find/var/logname'*.log'|tarcvfilesfrom=| bzip2>log.tar.bz2 findallfileswith'.log'extentionandmakeanbziparchive ddif=/dev/hdaof=/dev/fd0bs=512count=1 ddif=/dev/fd0of=/dev/hdabs=512count=1 CDROM cdrecordvgracetime=2dev=/dev/cdromeject blank=fastforce mkisofs/dev/cdrom>cd.iso mkisofs/dev/cdrom|gzip>cd_iso.gz
makeacopyofMBR(MasterBootRecord)tofloppy restoreMBRfrombackupcopysavedtofloppy
linuxcommandslinev1.1www.LinuxGuide.it
burnacompressedISOimage mountanISOimage
cdparanoiaB cdparanoia"3" cdrecordscanbus NetworkingLANandWiFi ifconfigeth0 ifupeth0 ifdowneth0 ifconfigeth0192.168.1.1netmask255.255.255.0 ifconfigeth0promisc dhclienteth0 routen routeaddnet0/0gwIP_Gateway routeaddnet192.168.0.0netmask255.255.0.0gw 192.168.1.1 routedel0/0gwIP_gateway echo"1">/proc/sys/net/ipv4/ip_forward hostname hostwww.linuxguide.it
showconfigurationof anethernetnetworkcard activateaninterface'eth0' disableaninterface'eth0' configureIPAddress configure'eth0'inpromiscuousmodetogatherpackets (sniffing) activeinterface'eth0'indhcpmode showroutingtable configuradefaultgateway configurestaticroutetoreachnetwork'192.168.0.0/16' removestaticroute activateiprouting showhostname lookuphostnametoresolvenametoipaddressandviceversa
iplinkshow miitooleth0 ethtooleth0 netstattup netstattupl tcpdumptcpport80 iwlistscan iwconfigeth1 MicrosoftWindowsnetworksSAMBA nbtscanip_addr nmblookupAip_addr smbclientLip_addr/hostname smbgetRrsmb://ip_addr/share
showlinkstatusofallinterfaces showlinkstatusof'eth0' showstatisticsofnetworkcard'eth0' showallactivenetworkconnectionsandtheirPID showallnetworkservic eslisteningonthesystemandtheir PID showallHTTPtraffic showwirelessnetworks showconfigurationofawirelessnetworkcard
linuxcommandslinev1.1www.LinuxGuide.it
mountawindowsnetworkshare
linuxcommandslinev1.1www.LinuxGuide.it
iptablestfilterAINPUTptcpdporttelnetj ACCEPT allowtelnetconnectionstoinput iptablestfilterAOUTPUTptcpdporthttpj DROP blockHTTPconnectionstooutput iptablestfilterAFORWARDptcpdportpop3j ACCEPT allowPOP3connectionstoforwardchain iptablestfilterAINPUTjLOGlogprefix"DROP INPUT" loggingsullachaindiinput Logging on chain input iptablestnatAPOSTROUTINGoeth0jMASQUERADE
iptablestnatAPREROUTINGd192.168.0.1ptcp mtcpdport22jDNATtodestination 10.0.0.2:22 Monitoringanddebugging top pseafw pseopid,argsforest pstree kill9ID_Processo kill1ID_Processo lsofp$$ lsof/home/user1 stracecls>/dev/null stracefeopenls>/dev/null watchn1'cat/proc/interrupts' lastreboot lsmod freem smartctlA/dev/hda smartctli/dev/hda tail/var/log/dmesg tail/var/log/messages Otherusefulcommands aproposkeyword
redirectpacketsaddressedtoahosttoanotherhost
linuxcommandslinev1.1www.LinuxGuide.it
forceclosureoftheprocessandfinishit forceaprocesstoreloadconfiguration displayalistoffilesopenedbyprocesses displaysalistofopenfilesinagivenpathsystem displaysystemcallsmadeandreceivedbyaprocess displaylibrarycalls displayinterruptsinrealtime showhistoryreboot displaykernelloaded displaysstatusofRAMinmegabytes monitoringreliabilityofaharddiskthroughSMART checkifSMARTisactiveonaharddisk showeventsinherenttotheprocessofbootingkernel showsystemevents
linuxcommandslinev1.1www.LinuxGuide.it
manping whatiskeyword mkbootdiskdevice/dev/fd0`unamer` gpgcfile1 gpgfile1.gpg wgetrwww.example.com wgetcwww.example.com/file.iso echo'wgetcwww.example.com/files.iso'|at09:00 lddssh aliashh='history'
displayalistofcommandsthatpertainokeywordsofa t program,usefulwhenyou knowwhatyourprogramdoes, butyoudon'tknowthenameofthecommand displaytheonlinemanualpagesforexampleonping command displaysdescriptionofwhataprogramdoes createabootfloppy encryptafilewithGNUPrivacyGuard decryptafilewithGNUPrivacyGuard downloadanentirewebsite downloadafilewiththeabilitytostopthedownloadand resumelater startadownloadatanygiventime showsharedlibrariesrequiredbysshprogram setanaliasforacommandhh=history linuxcommandslinev1.1www.LinuxGuide.itwww.LinuxGuide.it
Notesonresponsibility.
LinuxGuide.itassumesnoresponsibilityandinno casecanbeattributedtophysicaldamage,moralor otherwisecausedbycontent,bycommand,from configurationsandanyothercontentpublishedon www.linuxguide.itorcopiesofthesamecontent distributedbythirdparties.