Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
RH033
Red Hat Linux Essentials
Objectives
Day 2
File Editing using vi editor Advanced usage of vi editor Users and Groups Management Understanding Permissions Linux File system Inodes Links Mounting Media Archives Compression Using GUI shells ( GNOME & KDE)
2
vi networknuts
Enter insert mode <i> and <CR> Enter <ESC> return to command mode Navigate the cursor h move cursor left j moves cursor down k moves cursor up l moves cursor right
Commands
G = go to last line in file 1G = go to first line in file H = go to first line on screen M = go to middle line on screen L = go to last line on screen z<Enter> = make current line first line on screen z= make current line last line on screen !!date = Inserts the current date and time in to file !}sort = Sorts the data of your file !}fmt -66 = formats the data of your file in to 66 column width Ex mode : Search and Replace command :%s/big/small :%s/big/small/g
What is Group ?
Is a collection of users which make easy for administrators to perform the task of administration level when they need to apply permissions and restrictions with same level to many of the users, then such permission and restrictions can be applied to related group.
10
11
Creating Users
useradd options user - Creates a new user. -c Assigns full name to user. -d Uses to define home folders location. -s Uses to define user's shell. (Use /sbin/nologin for users you wish to restrict from having shell access). -g Add user to group ( Primary Group ) -G Add user to group ( Secondary Group ) usermod options user - Modifies user account Same options as useradd. userdel options user - Deletes user account. -r : Remove user's home directory. passwd user - Changes the password of the specified user. If no user is specified, will change the password of the current user.
12
Creating Groups
groupadd group - Creates a group. groupmod options group - Modifies a group.
-n : Rename group
13
Configuration Files
/etc/passwd /etc/shadow /etc/group /etc/gshadow = = = = file contains user database file contains user password database file contains group database file contains group password database
14
15
16
Understanding Permissions
17
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.
18
19
r w x -
Permission to read a file or list a directorys contents Permission to write to a file or create and remove files from a directory 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 )
20
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 )
21
4 2 1 0
Permission to read a file or list a directorys contents Permission to write to a file or create and remove files from a directory Permission to execute a program or change into a directory and do a long listing of the directory no permission ( in place of the 4, 2, or 1 )
22
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 )
23
24
Permissions
r w x r Owner has read Owner has write Owner has execute Group has read Group does not have write
x
r x
25
26
27
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:
28
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
29
Using Links
Two types of links can be created Symbolic ( Soft ) Hard
30
Commands to unmount media umount /media/floppy = umount /media/cdrom = umount /media/Device ID = Unmounts floppy drive to your computer Unmounts cdrom drive to your computer Unmounts usb disk to your computer
31
Archive Files
Archiving places many files into one target file Easier to back up, store, and transfer tar Standard Linux archiving command
32
33
File Compression
Results in smaller file size Text files can be compressed over 75% tar archives are often compressed
34
Compression Utilities
gzip, gunzip
bzip2, bunzip2
Newer Linux compression utility Generally achieves better compression than gzip
35
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
36
37
38
39
?
Questions
Archives
Compression
?
Questions