inode permissions

Post on 20-Jul-2016

220 Views

Category:

Documents

1 Downloads

Preview:

Click to see full reader

DESCRIPTION

linux

TRANSCRIPT

RH033

Red Hat Linux Essentials

Welcome!

2

Objectives Day 4

Understanding Permissions Linux File system

Inodes Links Mounting Media Archives Compression

Introduction to string processing String Processing with Regular Expressions Finding and Processing Files Investigating and Managing Processes

3

Understanding Permissions

4

What is Permission ?

Specifies what rights are you granting to users to access the resources are available in the computer, so that important resources such as files are protected from unauthorized users.

5

Methods of Implementing Permissions Symbolic Method Numeric Method

6

Permissions- Symbolic Method Four symbols are used when displaying and applying permissions

● r Permission to read a file or list a directory’s contents● w Permission to write to a file or create and remove files from a

directory● x Permission to execute a program or change into a directory

and do a long listing of the directory● - no permission ( in place of the r, w, or x )

7

Applying Permission with Symbolic Method

chmod command is used to change access modes Symbolic Method

● chmod u+w,go-w somefile file name

( Grants write access to owner but denies it to group and other. )

● chmod u=rw somefile file name

( Sets read and write permission to owner, with execute turned off, regardless of the current permission )

● chmod +r somefile file name

( Make the file world-readable )

[ Note : +, - and = are operators to add, remove or overwrite the permission ]

8

Four numbers are used when displaying or applying permissions

● 4 Permission to read a file or list a directory’s contents● 2 Permission to write to a file or create and remove files from a

directory● 1 Permission to execute a program or change into a directory

and do a long listing of the directory● 0 no permission ( in place of the 4, 2, or 1 )

Permissions- Numeric Method

9

Applying Permission with Numeric Method

chmod command is used to change access modes Numeric Method

● chmod 664 somefile file name

( Grants Read and Write access to owner and group but read only it to and other. )

● chmod 600 somefile file name( Sets read and write permission to owner, with execute turned off, with others and group have no permissions )

● chmod 444 somefile file name

( Make the file world-readable )

10

11

Others do not have write-

Others have readr

Group has executex

Group does not have write-

Group has readr

Owner has executex

Owner has writew

Others have execute

Owner has readr

x

Permissions

12

Understanding File System

13

Partition and File System Disk drives are divided into partitions Partition are formatted with file system, allows users to store data

● Default file system: ext3, the Third Extended Linux File System● Other common file systems:

● ext2 and vfat● iso9660 ( typically used for CDs)

14

Inodes

An inode table contains a list of all files in an ext2 or ext3 file system

Directories have inode numbers associated with files. inodes contain information about the file or directory,

including:● Owner, group, permissions, size, location on disk, file type (file or

directory)

One inode is associated with each file. The system uses inodes as the definition of a file.

The ls -il command displays the inode number:

80977 drwxr-x--- 1 user user4096 Mar 19 11:23

15

Links A link is a file that points to another file. “ln” creates a “link” from the original file to a new “file” in your directory. Most programs will access the link as if it was the file. This is similar to a “shortcut” in Windows. This allows for aliasing (when two or more names can exist for the

same object) Easy way to point to a really long absolute pathname or filename

16

Using Links Two types of links can be created

● Symbolic ( Soft )● Hard

ln -s main soft

( This will create an soft link of file “main” )

ln main hard

( This will create an hard link of file “main” )

17

Mounting the media “Mounting” means making a partition to access from an access point

typically a folder to store and access data from it.

Commands to mount media

mount /media/floppy = Mounts floppy drive to your computer

mount /media/cdrom = Mounts cdrom drive to your computer

mount /media/Device ID = Mounts usb disk to your computer

Commands to unmount media

umount /media/floppy = Unmounts floppy drive to your computer

umount /media/cdrom = Unmounts cdrom drive to your computer

umount /media/Device ID = Unmounts usb disk to your computer

18

Archive Files Archiving places many files into one target file Easier to back up, store, and transfer tar – Standard Linux archiving command

19

Using Archive files – tar command tar cvf archive_name files..

( To create archive file ) tar tvf archive_name files..

( To display files under archive file ) tar xvf archive_name files..

( To extract files from archive file ) tar rvf archive_name files..

( To append archive file )

20

File Compression Results in smaller file size Text files can be compressed over 75% tar archives are often compressed

21

Compression Utilities gzip, gunzip

● Standard Linux compression utility● Up to 75% compression for text files

bzip2, bunzip2

● Newer Linux compression utility● Generally achieves better compression than gzip

22

Using Compression gzip somefile

( To create compressed file ) gunzip somefile

( To uncompress a compressed file ) bzip2 somefile

( To create compressed file ) bunzip2 somefile

( To uncompress a compressed file )

Note: - We can use z for gzip and j for bzip2 type of compression with tar

23

Introduction to String Processing

24

Head and Tail

Head shows the first lines of a file● Try head /etc/somefile● Try head -n 5 /etc/somefile (shows the first 5 lines of the file)

Tail shows the last lines of a file● Try tail /etc/somefile● Try tail -n 5 /etc/somefile (shows the last 5 lines of the file)

25

wc, sort, uniq , cut and paste wc “Word Count”

● wc OPTIONS somefile ● Options ( -l , -w, -c )

sort “Sorting Order”● sort OPTIONS somefile● Options ( -r, -n )

uniq “Removes duplicate lines in a file”● -u to show only truly uniq● -d to show lines that are repeated in the input● -c to count lines

cut “ Display specific columns of the file data● cut –f3 –d: /etc/passwd

paste “Paste files together”● paste file1.txt file2.txt > file3

26

aspell, expand aspell “To check spelling in file “

● aspell somefile expand “Expand tabs into spaces”

● expand tabfile.txt > result.txt

27

String Processing with Regular Expressions

28

grep , sed and awk grep “ Prints lines of files where a pattern is matched

● grep amit /etc/passwd sed “ Stream Editor :- Reads a file ; writes out the data performe

search and replace “● sed ‘s/big/small/’ somefile● sed ‘s/big/small/g’ somefile

awk “ Programming language for editing text “● awk ‘ /bash/ { print } ‘ /etc/passwd

29

Finding and Processing Files

30

slocate and find slocate “ Search for files “

● slocate somefile find “ Search for files “

● find /home –name somefile● find /home –iname somefile [ case-insensitive search ]● find /home –user amit –group amit somefile● find /home –perm 755● find /home –size 1000kb

31

Investigating and Managing Processes

32

What is a Process? A process in an executing program with several components and

properties. A process is a shell command or a program in execution. When you log in, a process is created. This process is executing the

shell When you execute a shell command, a new process is created. When

the command terminates, the new process dies. A single user can have many processes executing at the same time

33

ps The command ps is used to determine the status of active processes.

The command returns the process id (PID) number and other information such as the amount of CPU time the process has used (TIME) and the command which invoked the process (CMD).

Options may be combined.

34

Top

The command top is used to show a real-time view of Linux tasks top can be used to display the CPU/memory usage of each task top

35

Terminate Processes

kill is used to terminate processes or to send signal to processes. Examples:

● kill PID ● Terminate the process with the process id (PID).

?Questions

What have we learnt ?

File Editing using vi editorAdvanced usage of vi editor Users and Groups ManagementUnderstanding PermissionsLinux File system

InodesLinksMounting MediaArchivesCompression

Using GUI shells ( GNOME & KDE)

?Questions

Day 2 Complete !!!

Thank You !!!

top related