+ All Categories
Home > Documents > RedHat Trainings Day3

RedHat Trainings Day3

Date post: 02-Apr-2018
Category:
Upload: sanjeev0132003
View: 233 times
Download: 1 times
Share this document with a friend

of 43

Transcript
  • 7/27/2019 RedHat Trainings Day3

    1/43

    RH033

    Red Hat Linux Essentials

    Welcome!

  • 7/27/2019 RedHat Trainings Day3

    2/43

    2

    Object ives 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)

  • 7/27/2019 RedHat Trainings Day3

    3/43

    3

    Using Linux File editing tool

  • 7/27/2019 RedHat Trainings Day3

    4/43

  • 7/27/2019 RedHat Trainings Day3

    5/43

    5

    Advanced Uses of the editor

    Position the cursor across a file or within a screen

    Insert into the file the output of a linux command

    Search for text and replace it

    Learn advanced reading and saving commands

    Configure vi and vim

  • 7/27/2019 RedHat Trainings Day3

    6/43

    6

    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 screenz = 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

  • 7/27/2019 RedHat Trainings Day3

    7/437

    Advanced Reading and Saving

    :r newfile = writes data from other file to current file

    :r !date = writes date to your file

    :1,5w xnewfile = writes line 1 to 5 to new file xnewfile

    :.,$w ynewfile = writes from current line to end in to new file ynewfile

    :1,5w >> xfile = append xfile with line 1 to 5:n = changes to next file

    :n! = abandoning changes

    :n# = jump to the previous file

    :set showmatch = shows the match

    :set textwidth=65 = sets the text width to 65 character

    :set number = sets the line numbers

    ( Note : You can use no with set command to unset changes you made )

    Ex. :set nonumber = will remove line numbers

  • 7/27/2019 RedHat Trainings Day3

    8/438

    Users and Groups Management

  • 7/27/2019 RedHat Trainings Day3

    9/43

    9

    What is User Account ?

    When a computer is used by many people it is usually necessary to

    differentiate between the users, for example, so that their private files

    can be kept private. This is important even if the computer can only be

    used by a single person at a time, as with most computers. Thus, each

    user is given a unique username, and that name is used to log in.

  • 7/27/2019 RedHat Trainings Day3

    10/43

    10

    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.

  • 7/27/2019 RedHat Trainings Day3

    11/43

    11

    The root user

    The root user: a special administrative account

    Same like Adminis t rator we called in Win*

    Sometimes called the superuser

    root has complete control over the system

    An unlimited capacity to damage the system!

  • 7/27/2019 RedHat Trainings Day3

    12/43

    12

    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.

  • 7/27/2019 RedHat Trainings Day3

    13/43

    13

    Creating Groups

    groupadd group - Creates a group.

    groupmod options group - Modifies a group. -n : Rename group

    groupdel group - Deletes the specified group.

  • 7/27/2019 RedHat Trainings Day3

    14/43

    14

    Configuration Files

    /etc/passwd = file contains user database

    /etc/shadow = file contains user password database

    /etc/group = file contains group database

    /etc/gshadow = file contains group password database

  • 7/27/2019 RedHat Trainings Day3

    15/43

    15

    User Information Commands

    Find out who you are

    whoami

    Find out what groups you belong to

    groups, id

    Find out who is logged in users, who, w

    Login/reboot history

    last

  • 7/27/2019 RedHat Trainings Day3

    16/43

    16

    User and Group ID Numbers

    User names map to user ID numbers

    Group names map to group ID number

    Data stored on the hard disk is stored numerically

  • 7/27/2019 RedHat Trainings Day3

    17/43

    17

    Understanding Permissions

  • 7/27/2019 RedHat Trainings Day3

    18/43

    18

    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.

  • 7/27/2019 RedHat Trainings Day3

    19/43

    19

    Methods of Implementing Permissions

    Symbolic Method

    Numeric Method

  • 7/27/2019 RedHat Trainings Day3

    20/43

    20

    Permissions- Symbolic Method

    Four symbols are used when displaying and applying permissions

    r Permission to read a file or list a directorys contents

    w Permission to write to a file or create and remove files from adirectory

    x Permission to execute a program or change into a directoryand do a long listing of the directory

    - no permission ( in place of the r, w, orx )

  • 7/27/2019 RedHat Trainings Day3

    21/43

    21

    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 thepermission ]

  • 7/27/2019 RedHat Trainings Day3

    22/43

    22

    Four numbers are used when displaying or applying permissions

    4 Permission to read a file or list a directorys contents

    2 Permission to write to a file or create and remove files from adirectory

    1 Permission to execute a program or change into a directoryand do a long listing of the directory

    0 no permission ( in place of the 4, 2, or1 )

    Permissions- Numeric Method

  • 7/27/2019 RedHat Trainings Day3

    23/43

    23

    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 onlyit 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 )

  • 7/27/2019 RedHat Trainings Day3

    24/43

    24

  • 7/27/2019 RedHat Trainings Day3

    25/43

    25

    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

  • 7/27/2019 RedHat Trainings Day3

    26/43

    26

    Understanding File System

  • 7/27/2019 RedHat Trainings Day3

    27/43

    27

    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)

  • 7/27/2019 RedHat Trainings Day3

    28/43

    28

    Inodes

    An inode table contains a list of all files in an ext2 or ext3file 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 ordirectory)

    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 user 4096 Mar 19 11:23

  • 7/27/2019 RedHat Trainings Day3

    29/43

    29

    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 thesame object)

    Easy way to point to a really long absolute pathname or filename

  • 7/27/2019 RedHat Trainings Day3

    30/43

    30

    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 )

  • 7/27/2019 RedHat Trainings Day3

    31/43

    31

    Mounting the media

    Mounting means making a partition to access from an access pointtypically 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

  • 7/27/2019 RedHat Trainings Day3

    32/43

    32

    Archive Files

    Archiving places many files into one target file

    Easier to back up, store, and transfer

    tar Standard Linux archiving command

  • 7/27/2019 RedHat Trainings Day3

    33/43

    33

    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 )

  • 7/27/2019 RedHat Trainings Day3

    34/43

    34

    File Compression

    Results in smaller file size

    Text files can be compressed over 75%

    tar archives are often compressed

  • 7/27/2019 RedHat Trainings Day3

    35/43

    35

    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

  • 7/27/2019 RedHat Trainings Day3

    36/43

    36

    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 andj for bzip2 type of compression with tar

  • 7/27/2019 RedHat Trainings Day3

    37/43

    37

    Using GUI shells ( GNOME & KDE)

  • 7/27/2019 RedHat Trainings Day3

    38/43

    38Simple view of GNOME Desktop

  • 7/27/2019 RedHat Trainings Day3

    39/43

    39Simple view of KDE Desktop

  • 7/27/2019 RedHat Trainings Day3

    40/43

    ?

    Questions

  • 7/27/2019 RedHat Trainings Day3

    41/43

    What have we learnt ?

    File Editing using vi editorAdvanced usage of vi editor

    Users and Groups ManagementUnderstanding PermissionsLinux File system

    Inodes

    Links

    Mounting MediaArchives

    CompressionUsing GUI shells ( GNOME & KDE)

  • 7/27/2019 RedHat Trainings Day3

    42/43

    ?

    Questions

    Day 2 Complete !!!

  • 7/27/2019 RedHat Trainings Day3

    43/43

    Thank You !!!


Recommended