Sei sulla pagina 1di 9

Unix Terminology ================ Unix will understand each everything as a FILE file,directory file,cdrom file,printer file,terminal file,usb file

Different types of Files ======================== 1. Regular Files =---created/delted and modified as a normal user 2.Directory Files --> groucvbbvp of files 3.Special Files character special files --STDIN STDOUT STDERR block special files --HDD,TERMINAL<Printer cdrom files Unix is case sensitive langauage.need to be more caution space configuration File systems $df --disk free mount points Files system Architecture---upside down tree Switching user ============== $/#su <username> --> no whre using in real time $su - <username> #su - <username> 1. # ------> $ --> root user can switch to any other account with ot asking p asswd 2. $ -------> $ --->only paswd security 3.$ ----> # --> need to have root passwd Indulging with Files:==================== 1.Working with files:1.1.creating Files:a. touch --empty files b. cat --to create new file/store data to file/view present in afile $touch <sample> #touch <sample> $/#touch f1 f2 f3 f4 f5 f6 $/#cat > <fname> --it will create new file if the fname is not existed in my current working directory if fname is existed in my CWD it over wirte the data $cat >fname ------------------------------------the data

ctl + D $cat fname --> to view data present in afile $cat < fname -->to view data present in afile $ cat >>fname --> if file exist --it will append /add the data EOF if file not exist --create a new file store the dat

$ls --to list all the files present in my current working directory

1.2 Removing Files $rm <fname> 2.Working with Directories ========================= 2.1 Creating Directories $mkdir <dname> $mkdir dir1 dir2 dir3 dir4 dir5 $pwd /home/aswini $ls dir1 dir2 dir3 dir4 $cd dir1 $pwd /home/aswini/dir1 $cd .. $pwd $/home/aswini 2.2 Removing Directories $rmdir <dname> --> used to delete an empty dir $rm -ir <dname> --> recursively deltes all files 3.Renaming files ================= $mv <oldfname> <new fname> $

4.Copying files =============== $/#cp <options> <srcfname> <desfname> if des file is not existed --new file 5.creating hidden files $cat >.hidden

Comparing Files ================ $/#cmp <file1> <file2> --if two file sare same throw o/p as nothing --if two files are different throw an error msg diff command ============ $/#diff <file1> <file2> 1d0 < aaa 3c2 < ccc --> c c 7a7 > hhh 1c --represnts line number present in file1 2c --status a added c changed d deleted 3c --represnts line number present in file2 < (data) -->refers in file1 > (data) -->refers in file2 Word count:-=========== $wc <options> <fname>

ls -F fname / --directory * --executable @ --link files Permissions of Files ===================== rw-rw-rw- ---> Set of 9 char represents permissions of a files There 3 types of perm for 3 types of user read r write w execute x 4 2 1

user/owner group

u g

other

o apple

rw- | rw- | rw-

rw- | rw- | r-- latest 6 6 4 U g o

Changing permission can be done by two user ---owner/root $/#chmod [who][+/-/=][r/w/x] fname $chmod o+w fname rw- --x r-614 644 $chmod 644 fname rw-rw-r-644 664 rwx rwx r-x 775 dir file

umask ---user masking hiding the details umask ---002 files umask 666 022 --644 777 022 --755

Dir umask

chmod 644 fname rw-r--r-#/$find <dir> -name fname -print Redirection Operators ===================== > --->redirection output operator < --->redirection input operator Filters ======= what is Filter?

1.grep filter(Global REgex Print It) $/#grep <options> <pattern> <fname> -i -c -n -l -v emp1 emp2 emp3 emp4 emp...empn giri grep -i 4333 emp1 Searching Patterns =================== 1.Character pattern default 2.Word Pattern "\<pattern\>" 3.Line Pattern Anchors ^ --Starting of th eLIne $ --Ending of the line grep --doesnt support to serch multiple patterns $fgrep (faster grep) $fgrep -i "unix >shell >perl" stud extended grep (egrep) egrep <options> <apttern> stud Piping Concept(|) ============== join n number of commands redir ops let us connect command to files Piping let us connect commad to commads $/#LHC | RHC 1.how many sub directories presnt in my current working directory tee -->used to display as well to redirect the o/p to other files cut filter ========== $/#cut -f <fieldname> fname --default it will take tab as deleimeter sort filter $/#sort <fname> --ascending order --ASCII values of 1st character sorting the files based on fields

$sort -f +pos1 -pos2 fname + including -excluding uniq filter =========== $uniq fname pre -requisite --uniq always takes sorted files as a input tr --filter (translated character) ================================= grep opt fname cut f fname sort fname uniq fname cat fname $tr "T" "t" <fname Sed fileter -----------sed --search and replace the new patterns $/#sed "s/oldpattern/new pattern/g" stud $/#

Wild card characters/shell meta character/File substitution char ================================================================ * reprenst any number of any combination of char ? Any single chracter [...] Any single char in a enclosed list [!..] Any single char other than enclosed list Range opertaor $ls $ls $ls $ls $ls $ls a* List all files begining with char a *e List all files ending char is "e" a*e ?? List all the files whose names are 2 char long a?e [abcdef]* -->ls a* b* c* d

Processes ========= Process status $ps --to running process at this moment unix assign a uniq number to every process running memory

pid 8412 PID strts from 0 ---max 32767 www.orkut.com ps -ef|grep -i cmd/process name Back ground process =================== Logout time --->5.30pm 5.25PM run sorting of file 1TB The nohup command ================= $nohup sort fname pid sending output to nohup.out Killing process =============== kill <pid> kill -9 <pid> -9 --sure kill signal forcebly to terminate a process RUN Levels --Init Levels ========================= init --command to change system runlevels init init init init init init 0 1 2 3 5 6 ----> shut down server ---->server in to signle user mode(maintenance mode) ---->Bring the serverto multi user mode without resource sharing ---->Multiuser mode with resource sharing ---->Multi user mode with resource sharing ----> shut down and reboot server

Potrebbero piacerti anche