linux

26
Learning Linux

Upload: patruni-chidananda-sastry

Post on 12-Feb-2017

222 views

Category:

Internet


0 download

TRANSCRIPT

Learning Linux

Linux Overview Its a elongated version of UNIX where UNIX is

developed from a useless OS to Advance OS Invented by LINUS , trying to make UNIX to

have a free system that completely compatible with UNIX following the POSIK standards

It can be modified to the users need and can be developed too and work on embedded system

Many software engineers are using Linux for there extensional need which are not provided by the version of windows and Macintosh

Linux versionsSome Linux versions as

SUSE Linux Ubuntu 1.0.10,Linux essential Cent OS 5,6 essential Fedora User,Desktop essential Caldera open Linux Slackware Linux

Linux advantages and disadvantages

Advantage of Linux Its free of cost Its portable to any

hardware Made to keep on running Its secure and versatile Its scalable Has short debugging time

Disadvantages of Linux There are far too many

distributions Not very user friendly Confusing for beginners Changing versions Frequent updated Sometimes complicated

Booting process Booting is a process or set of operations that loads and

hence starts the operating system starting from the point where the system is powered on

initially when the system is powered on a a relatively small program stored in read-only memory (ROM) along with a small amount of needed data, to access the nonvolatile device or devices from which the operating system programs and data can be loaded into RAM.

all the other devices are not activated so booting is the process which connect the hardware by launching a boot loader and connects to the operating system of the RAM

Booting in windows Turn on the power CPU pins are reset and registers are set to specific

values CPU jumps to address of bios Bios runs the post and necessary checks Bios runs the jump to MBR(MASTER BOOT

RECORD) Primary boot loader runs from MBR and jumps to

secondary boot loader Secondary boot loader loads operation system

Booting in LinuxBooting in Linux is done by following steps BIOS is set up it loads and perform some checks and

gives control to MBR MBR loads and it contains the info of the GRUB and

executes it GRUB loads the kernel and has knowledge of the file

system and init images KERNEL executes and runs /bin/init initial program of

RAM disk INIT initiates the run level by selecting mode of run

level RUN LEVEL runs and gives control to operating

system

Installation of Linux Cent OS 5 INSERT DISK-->POWER THE SYSTER ON-->

RUN BIOS SETUP--> CHANGE BOOT PRIORITY TO DVD--> EXIT Select the install or updated existing system option Skip installation media checks Click next on welcome window Choose language Choose keyboard formate Select the instilation device type (basic or specific

storage drive) Specify host name if necessary

Partitioning , package selection and rebooting

Select network device and edit Click on connect automatically or on DNV or enter

manually Select network setting and apply Select time zone Type the password which is to be the root password and

confirm password and click next Select partition of the system as needed or customize Select the required package of software installation will start once done click on reboot Initialization is done now start using the system

File system of Linux

File system

• /bin- Common programs, shared by the system, the system administrator and the users.

• /boot- The startup files and the kernel, vmlinuz. In some recent distributions also grub data. Grub is the GRand Unified Boot loader and is an attempt to get rid of the many different boot-loaders we know today.

• /dev - Contains references to all the CPU peripheral hardware, which are represented as files with special properties.

• /etc - Most important system configuration files are in /etc

• /home - Home directories of the common users

• /initrd - (on some distributions) Information for booting.

• /lib- Library files, includes files for all kinds of programs needed by the system and the users.

• /lost+found- Files that were saved during failures are here.

• /misc- For miscellaneous purposes.• /mnt - Standard mount point for external file

systems,• /net - Standard mount point for entire remote file

systems• /opt - contains extra and third party software.

• /proc - containing information about system resources.

• /root - The administrative user's home directory.

• /sbin - Programs for use by the system and the system administrator.

• /tmp - Temporary space for use by the system, cleaned upon reboot

• /usr - Programs, libraries, documentation etc. for all user-related programs.

• /var -Storage for all variable files and temporary files created by users, such as log files, the mail queue

Linux File PermissionsThese read, write, and execute permissions are

defined for:• user - the user that owners the file• group - users in the files group

other - every other user There are also three other components when it comes to file mode bits, namely

• the setuid bit • the setgid bit• the sticky bit.

Read write executeThe repeated rwx sequences represent the notion of

read (r), write (w), and execute (x)

permissions for user, group, and other (in that order). The possible file types

• - = Regular File

• d = Directory

• l = Symbolic Link

• b = Block Special Device

• c = Character Device

• s = Unix Socket (local domain socket)

• p = Named Pipe

Special modesSetuid - Set User ID When the setuid bit is set for a

program, on execution the process's effective user ID gets set to that of the program file itself the lower case "s" where the "x" was. If however, the file didn't have the "x" permissions for the user, and then had the setuid bit set to S

Setgid - Set Group ID When the setgid bit is set for a program, on execution the process's effective group ID gets set to that of the program file the setgid bit is shown as either an "S" or "s".

Sticky Bit -When a directory has the sticky bit set, only root or the file's owner has permission to change files in that directory. The letter's "T" and "t" are used to indicate that the sticky bit is set. e.g. (So "t" vs "T" depends on whether the "other" category has "x" permissions set(t) or not (T)respectively).

Permissions: Octal Representation

• Permissions In Plain English Symbolic Octal

• read,write,and execute rwx 7

• read and write rw- 6

• read and execute r-x 5

• read r-- 4

• write and execute -wx 3

• write -w- 2

• execute --x 1

• no permissions --- 0

The command takes the general form: chmod MODE file There are two ways to represent the MODE:(1) Using symbolic modes (letters to indicate the categories and permission)(2) Using numeric modes (An octal (base 8) number that represents the mode)

In order to change the permissions of a file using symbolic permissions, use the command format: chmod SYMBOLIC/NUMERIC-MODE FILENAME

Chmod (changing permission)

NUMERICAL MODE

• chmod 400 file To protect a file against accidental overwriting.

• chmod 500 directory To protect yourself from accidentally removing, renaming or moving files from this directory.

• chmod 600 file A private file only changeable by the user who entered this command.

• chmod 644 file A publicly readable file that can only be changed by the issuing user.

• chmod 660 file Users belonging to your group can change this file, others don't have any access to it at all.

• chmod 700 file Protects a file against any access from other users, while the issuing user still has full access.

• chmod 755 directory For files that should be readable and executable by others, but only changeable by the issuing user.

• chmod 775 file Standard file sharing mode for a group.

• chmod 777 file Everybody can do everything to this file.

SYMBOLIC MODE• chmod a=rwx filename the a means all and rwx means set

read,write, and execute. chmod ugo=rwx filename or chmod ugo+=rwx filenameRegarding just the symbolic mode part of the command, here are a few more examples:

• To add read permission for all:a+r To remove permissions for all:a-r

• To add execute permissions for all:a+x To remove execute permissions for all:a-x

• To remove execute permissions from group and other (i.e from all users except the file's owner): go-x To remove permissions to do anything from all users except the owner: go=

• The setuid bit can be set using: u+s The setuid bit can be removed using: u-s

• setgid can be set using: g+s and removed using: g-s

• The sticky bit can be set by using: +t and removed using: -t

• To assign read, write permissions only for user and group:ug=rw

• To add read, write permissions to user and group to the permissions that already exist:ug+=rw

• To remove execute permissions from group and other (i.e from all users except the file's owner):go-x

• To remove permissions for all: a-r To add execute permissions for all: a+x remove execute permissions for all: a-x

• To assign read, write permissions only for user and group: ug=rw To add read, write permissions to user and group to the permissions that already exist: ug+=rw To add read, write permissions to user and group to the permissions that already exist: ug+=rw

• To remove execute permissions from group and other (i.e from all users except the file's owner): go-x To remove permissions to do anything from all users except the owner: go=

• The setuid bit can be set using: u+S The setuid bit can be removed using: u-s

• setgid can be set using: g+s removed using: g-s

• set by using: +t removed using: -t

UNMASK• octal numbers are preceded by a 0 (in the same way

hex would be preceded by 0x), so the umask value itself is actually 002.

• This value is an octal (base 8, digits 0-7) value which is subtracted from a base value of 777 for directories, or subtracted from a base value of 666 for files.

• A umask of 002 basically means don't remove any permissions from the base value for "user" or "group", but "other" is not allowed write permission (write permission is octal 2, or binary 010 meaning -w-).

Chown and Chgrp command

• The chown command can be applied to change both user and group ownership of a file, while chgrp only changes group ownership. Of course the system will check if the user issuing one of these commands has sufficient permissions on the file(s) she wants to change.

• In order to only change the user ownership of a file, use this syntax:

chown/chgrp newuser file

Commands till now• bash -GNU shell program.• cat file(s)-Send content of file(s) to standard

output.• cd directory or root- Enter directory or cd is a

bash built-in command.• chgrp newgroup file(s)- Change the group

ownership of file(s) to newgroup• chmod mode file(s)- Change access permissions

on file(s)• chown newowner[:[newgroup]] file(s)-

Change file owner and group ownership.• df file-Reports on used disk space on the

partition containing file.

• fdisk-to know hard disk size• echo string-Display a line of text export Part of bash

that announces variables and their values to the system.• find path expression-find files in the file system

hierarchy• locate searchstring-Print all accessible files matching

the search pattern.• ls file(s)-Prints directory content.• man command-Format and display online (system)

manual pages for command.• Pwd -Print the present or current working directory.• umask [value] -Show or change new file creation

mode.