Você está na página 1de 8

UNIX NOTES Linux is a flavor of UNIX and it is not a user friendly & it is case sensitive.

It was introduced in 1991 by Linux Torald. OS:-An OS is software that manages the computer hardware and provides a convenient and safe environment for varying programs. It acts as an interpreter between program & the hardware resources (monitor, keyboard etc). Linux Architecture:-

Kernel:-A set of functions that wakeups the heart of an operating system. It is used to provide application interface between program and physical devices. a) Service provide by the kernel. b) Controls execution of process. c) Scheduling process Fairley for execution on cpu. d) Allocate memory for execution. Shell:-A shell is the command interpreter to the kernel. It is the interface between user and kernel. The kernel after processing the commands gives backs to the shell. Vendors Flavors AT & T bells Sys.III, Sys.V Sun C Solaris IBM AIX HP HP-UX SG IRIX SCO SCO-UNIX BSD Free-BSD File System:-File system provides organized way of storing and retrieving the data. This is classified in 4 types. They are 1. Physical file system 2. Logical 3. Swap in Linux(virtual in windows) 4. Network file system: it supports files to be shared over networks Swap:-In the hard disk the space supports to the RAM for system performance. It acts as a temporary RAM. In windows it is called virtual file the system. Linux File System Hierarchy:-

This is the root directory. It is a top of the file system structure all the other directories are mounted under it. Page 1 of 8

/boot /root / bin(binarys) /sbin /var /usr /etc /dev /temp /proc /obd /media /lib

It contains the kernel the core of the OS. It also contains the files relating to booting the system. Such as boot loader and the initiate RAM Disk. It is the default home directory for root (administrator cd /home it contains all normal users home directory) It contains commands which are used by normal users and also administrators. It contains administrator related commands. It is not used by normal users. It contains variable information such as locks, print mail, ftp, account, cache. (Unix System Resource) It contains the program and application which are available for users. It contains device loads through which the OS through the hardware & software device. It contains device temp files gives to the system. It is a mount point for virtual information about the current running system process. It contains the 3rd party S/W. Ex:- media player, yahoo messenger. It is the default location for removable devices such as dvd, predictive, etc. It contains librarys need by number of different applications as well as linux kernel.

pwd present working directory / current working directory. ls Listing the files & directories. ls -l long list ls -a it shows hidden files ls -r reverse order. ls -R to see the particular data of the nested files ls -d directory name is shows. ls -l -S (prod db) list the files along with time & date. ls -l -s means block size. Ls -lt list the file along with time & date clear /(ctrl+l) clear the screen. Valid card character:* means Multiple Characters. ? means Single Character. Ex: ls r* to shows list files start with r. File creations are 3 types:1. cat 2. touch 3. vi editor cat:- By using this we can create new files and also adding new line to an existing file and also we can see file contents. Ex:[root@ravi44 ~]# cat > t1 Ravindra Reebin Sreenadth [root@ravi44 ~]# cat t1 Ravindra Reebin Sreenadth Page 2 of 8

Adding new lines:- [root@ravi44 ~]# cat >> t1 Tulasi viraja [root@ravi44 ~]# cat t1 Ravindra Reebin Sreenadth Tulasi viraja [root@ravi44 ~]# cat > t2 Rama krishna vijay[root@ravi44 ~]# [root@ravi44 ~]# cat t1 t2 >> t3 [root@ravi44 ~]# cat t3 Ravindra Reebin Sreenadth Tulasi viraja Rama krishna vijay[root@ravi44 ~]# touch: it will creates only n number of empty files but we cannot insert any single character or byte data and we can change date & time stamp of file or directory. Ex:[root@ravi44 ~]# touch empty [root@ravi44 ~]# touch -t 11230832 t1 [root@ravi44 ~]# ls -ltr total 216 -rw-r--r-- 1 root root 91738 Mar 16 17:56 install.log.syslog -rw-r--r-- 1 root root 64026 Mar 16 17:56 install.log -rw-r--r-- 1 root root 1144 Mar 16 17:56 anaconda-ks.cfg drwxr-xr-x 2 root root 4096 Mar 16 18:27 Desktop -rw-r--r-- 1 root root 18 Apr 14 16:04 t2 -rw-r--r-- 1 root root 58 Apr 14 16:05 t3 -rw-r--r-- 1 root root 0 Apr 14 16:15 empty -rw-r--r-- 1 root root 40 Nov 23 2012 t1 vi editor:- Visual Interface Editor. It is use for supporting to insert or manage the data. Editors at different OS. For Window Notepad DOS EDIT LINUX Command mode vi, ex, nani, etc Syntax: vi <filename> In vi editor these are 3 modes available. 1. Insert mode 2. Command mode 3. Execute mode Steps for vi editor managing:We open a file with vi command, then the files opened in command mode. When will we go to Save & Exit that is execute mode. Page 3 of 8

Press i, I, a, A, q, o automatically go to insert mode for command mode. Press Esc key we can enter into the command to insert mode. In the command mode we can do some actions like copy, delete. - Press Shift + : we enter into the execution mode from command mode in that we can save, replace etc. - If we want to move from insert mode to execute mode and from execute mode to insert mode 1st we must move into command mode. i Insert the data at current cursor position I at the beginning of line cursor. a append after cursor position A Append at the end of line o Insert a line below & enter into insert mode O Insert a line above r Replace single character. R Replace the world s Delete the current cursor position after insert S/cc deletes the entire line & insert. c Delete the after cursor position line. Command mode options: Dd 2dd Ldw d7w X 10x X 10X Yy 5yy P U Ctrl+r Gg G 99G Shift+zz H L J K /<find> N delete a line Deletes 2 lines Deletes one word Deletes 7 words Delete single character after cursor position Delete 10 characters after cursor position Delete single character before cursor position Delete 10 characters before cursor position Copy a line Copy 5 lines Paste Undo Redo Goto 1st line Go to last line Go to 99th line Save & Exit Move to left side Move to right side Move to next line Move to above line We can find a particular word Go to the next searching word

Execute mode commands: :q :q! Quite Quite with forcefully


Page 4 of 8

:w :wq :wq! :x :se nu :se nonu Replacing the words:-

Save Save & quite Save quite forcefully Save & Exit Set number (col set number ) command Set no number removes line numbers

:1, $s/existing word/ new word/gc 1 means replace starts from 1st line $ replace can do upto last line s means substitute g means global c conformation Navigation commands: Cd Change directory or move into another directory Syntax: cd <directory name> cd .. Move to one level back Note: 1st dot is represents current working directory. Double dots means parent working directory. cd ../.. Move to the 2 level back cd Move to the last working directory cd ~ Move to the current user login home directory Copy / move the file directories: only copy the files. Syntax: cp <source path> <destination path> Copy the directory:Syntax: cp -r <source path> <destination path> Move the file/directory:Syntax: mv <source path> <destination path> Remove file/directory command:Syntax: rm <filename> removing the file rm -f <filename> remove file forcefully rmdir <directory name> remove the directory forcefully Links:- There are 2 types of links. 1. Hard link 2. Soft link Def: gives a pointer to the particular file, the particular file is called link. Hard Link Syntax: ln <source> <destination> Soft Link Syntax: ln s <sourcecode> <destination>
Page 5 of 8

Original & link file will have the same Inode number will have different. inode number It cannot create across portions It can be create a partions. Editing of original file will replicate in the copy file Size of hard link file is same as original file. Size of soft link file is equal to number of characters in the original file path If original file is delete/corrupt then by Doesnt access the data. using link file accessing the data. Fdisk -l :- hard disk information Df df k df h du h du sh <filename> cat /etc/passwd cat /etc/group groupdel <groupname> cal Date date +%b date +%B date +%D date +%y date +%Y gcalctool (or) gnome-calculator man(manuals) Swap Addition:swapon s swapoff /dev/sda3 (or) swapon /dev/sda3 free It shows swap memory size. These are used to show the details. It shows the RAM size and shows the swap size how much free or used. Mar 16 17:56 install.log.syslog It means disk free. It shows the mount points in kilobyte. It shows the mount points in GB. du means disk use filename/directory name/mount point. Ex: du h /d01 Shows the total size of file or directory. To see how many users used To see the group To delete groups Shows calendar To see the date & time It shows the 3 digits of the month. It shows the full name of the month It shows the date in number It shows the year in 2 digits. It shows the year in full. To open calculator window To show the documentation of the commands. Ex:- man ls, man df.

-rw-r--r-- 1 root root 91738 1. Type: it is a file. it has 3 options d means directory l linked - file 2. Acess permission: rwx user

Page 6 of 8

r-- - groups r-- - others 3. 1 means link. 4. User/owner of the file. 5. Group 6. Sizing bytes 7. Data & time 8. File/directory/link name In types are different options are there they are P Process file S Socket file B Block device C Character device file Access mode Access Level Read(R) User Write (w) Group Execute (x) Others File permission mode:- 2 types of file open 1) Symbolic Mode:- In this mode we use characters. 2) Numerical/absolute. Permission Identification characters Read r Write w Execute x User u Group G Others O Controllers:Add the permission use +. Remove the permission use -. Equal the permission use =. Absolute mode or Numerical:- In this mode we will use numbers. The read permission for 4. Write permission for 2. Execute permission for 1. Permissions Number Nill 0 Execute 1 Write 2 Write & Execute 3 Read 4 Read & Execute 5 Read & Write 6 Read, Write & Execute 7 Default Permissions:- When a file is create with the help of cat, touch, vi commands. It automatically creates permissions 644. Ex:- cat > gf ls -trl gf
Page 7 of 8

-rw-r--r-- 644
Read & Write permission to user. Read permission for Group & Others. Actually in the basic UNIX file system, when a file is created, to get permissions are 666 but this labs (security). So when is file is created in UNIX system. It makes sum bits with a mass value (022). After masking we get the default value 644. 022 is the default Umask value UMASK. U is nothing but universal mask. root or super user umask value is 0022 and for normal user 022. Default directory permission:- When a directory is created with the help of mkdir command. We will get 755 permission d rwx r-x r-x" 755. Actually in basic unix system permissions are created 777, but in unix it mask some bits with mask value 022. After masking we will get 755 permissions. chmod to change the mode. chmod command can be assigned by the owner of the file or root user by using this command add/removing the permissions as required. Ex: chmod gxx t1 Chmod R 611 t1 R means recursively top :- load average press u & type user name. q means quite. vmstat : virtual memory statistics. iostat: i/p status of the cpu. Hostname: ip address will be shown. Ex:hostname i - give ip To set this ip address we give the command is vi /etc/hosts/ Ex: 127.0.0.1 localhost.localdomain localhost 192.168.10.44 ravi44.coredba.com ravi44 Save & Exit. After service network restart Ping <ip address / hostname> netstat means network statistics. Ex:-netstat Note: to see the present unix version command is uname a.

Page 8 of 8

Você também pode gostar