Understanding Users and File Systems - PowerPoint PPT Presentation

1 / 49
About This Presentation
Title:

Understanding Users and File Systems

Description:

etc/login.defs - Configuration control definitions for the login package. ... Not present as a default on Ubuntu. Types of User Accounts (continued) su command ... – PowerPoint PPT presentation

Number of Views:64
Avg rating:3.0/5.0
Slides: 50
Provided by: pbcc
Category:

less

Transcript and Presenter's Notes

Title: Understanding Users and File Systems


1
Understanding Users and File Systems
  • Chapter Four

2
Linux Users and Groups
  • Must first log in using valid user account name
    and password
  • More user accounts on Linux system
  • More work required to keep them running smoothly

3
/etc/login.defs
  • /etc/login.defs - Configuration control
    definitions for the login package. Three
    items must be defined MAIL_DIR, ENV_SUPATH, and
    ENV_PATH. If unspecified, some arbitrary (and
    possibly incorrect) value will be assumed. All
    other items are optional - if not specified
    then the described action or option will be
    inhibited. Comment lines (lines beginning
    with "") and blank lines are ignored.
    Modified for Linux. --marekm

4
Policy Settings
  • PASS_MAX_DAYS Maximum number of days a
    password may be used. PASS_MIN_DAYS Minimum
    number of days allowed between password
    changes. PASS_WARN_AGE Number of days warning
    given before a password expires.PASS_MAX_DAYS
    99999PASS_MIN_DAYS 0PASS_WARN_AGE 7
    Min/max values for automatic uid selection in
    useraddUID_MIN 1000UID_MAX 60000 Min/max
    values for automatic gid selection in
    groupaddGID_MIN 100GID_MAX 60000

5
Types of User Accounts
  • Preconfigured user accounts
  • Root
  • Administrative account
  • Also called superuser
  • Can perform any operation on Linux system
  • Do not log in as root for normal work
  • Change temporarily to root user
  • Not present as a default on Ubuntu

6
Types of User Accounts (continued)
  • su command
  • Temporarily changes access rights to those of
    another user
  • Without any parameters
  • Change to root account
  • Hyphen after su command
  • su - tsmith
  • Causes command to run login scripts
  • Places you in login directory of user

7
Types of User Accounts (continued)
  • Preconfigured user accounts
  • Regular user accounts
  • Users who log in at keyboard and use Linux system
  • Commonly associated with named individuals
  • Special user account
  • Used by Linux programs
  • Created during installation of Linux
  • Vary depending on services installed

8
Linux Groups
  • Group
  • Collection of user accounts
  • Can be collectively granted access to files and
    directories
  • Each user in Linux is assigned to primary group
  • /etc/group file
  • Lists members of each defined group

9
Linux Groups (continued)
10
User and Group Files
  • /etc/passwd
  • Stores user account information
  • Password information not stored in this file
  • Contents include
  • User account name
  • Password
  • User ID number (UID)
  • Group ID number (GID)
  • Users real name
  • Home directory
  • Default shell

11
User and Group Files (continued)
  • /etc/group file
  • Defines groups on Linux system
  • vigr command
  • Edit this file
  • Contents include
  • Name of group
  • Group password
  • GID number
  • Members of group

12
Shadow Passwords
  • /etc/shadow
  • Stores encrypted passwords
  • Can only be read by
  • Root user
  • Certain utilities
  • Shadow password suite
  • Collection of password-related programs
  • Have been modified to recognize /etc/shadow file

13
Changing User Passwords
  • Can change password of any user account on system
  • When logged in as root
  • Use passwd command
  • Standard procedure
  • System administrator assigns initial password to
    new account
  • User immediately selects new password

14
Changing User Passwords (continued)
  • To change users password
  • Use passwd without any parameters
  • Must enter current password

15
Changing User Passwords (continued)
  • Good password characteristics
  • At least eight characters long
  • Include digits or punctuation marks
  • Mix uppercase and lowercase letters
  • Easy for account owner to remember
  • Hard for anyone else to guess
  • Not created from simple manipulation of
  • Word found in dictionary
  • Name of person or place

16
User Information Commands
  • id command
  • Shows effective UID
  • logname command
  • View user name that you used to log in
  • whoami command
  • Shows user name of currently effective UID
  • groups command
  • Lists all groups you are a member of

17
User Information Commands (continued)
  • who command
  • Lists all regular users on system
  • Shows location where they are logged in
  • w command
  • Information from who command, plus
  • Time person logged in
  • Program they are running
  • Information about system resources user is
    consuming

18
File Permissions
  • Files and directories have
  • Owner
  • Group
  • Linux determines who can access file or directory
    based on
  • Who owner is
  • Which group is assigned to object
  • File permissions define access granted to file or
    directory
  • Permissions are cumulative for user and group

19
File Permissions (continued)
  • Access mode
  • Permissions
  • Read permission (r)
  • Write permission (w)
  • Execute permission (x)
  • Permissions can be assigned by
  • User permissions
  • Group permissions
  • Other permissions

20
File Permissions (continued)
21
Changing Ownership
  • chown command
  • Change user and group assigned to file or
    directory
  • Can only use when logged in as root
  • Example chown jtaylorManagers report.doc
  • Can use graphical file manager to change owner of
    file
  • chgrp command
  • Change group assigned to file or directory
  • Example chgrp managers report.doc
  • newgrp project
  • User is a member of the group project
  • Change group membership to project for all files
    or folders created during a session

22
Changing File Permissions
  • chmod (change mode) command
  • Change file permissions
  • Regular users can alter permissions assigned to
    any file or directory that you own
  • Example chmod ow reportDoc
  • Adds write permission to other
  • Example chmod urwx,grx,o reportDoc
  • Explicitly sets permissions for user, group, and
    other
  • System administrators normally use shortcut syntax

23
Changing File Permissions (continued)
  • Alternate syntax
  • Each of sets of three permissions is represented
    by number from 0 to 7
  • 24 22 20
  • 110 100 000
  • rw- r-- ---
  • Example chmod 640 report.doc
  • Graphical environment provides easy method of
    setting file permissions
  • Properties dialog box
  • Permissions tab

24
Changing File Permissions (continued)
25
Changing File Permissions (continued)
26
Special Permissions
  • SUID Set User ID
  • Allows user to temporarily become the owner of
    the file
  • SGID Set Group ID
  • Allows user to temporarily become a member of the
    group owner of the file
  • Sticky Bit
  • User with write permission may modify file, but
    not delete files that they do not own.
  • May delete their own files.

27
Default File Permissions
  • umask command
  • Defines mask to stop certain permissions from
    being granted by default when files created
  • Executed automatically when you log in to Linux
  • Uses same three-digit permission codes as chmod
    command
  • 24 22 20
  • 000 010 111
  • umask 027
  • Removes write permissions from group and all
    permissions from other, subtract from 777
  • rw-r----

28
Partitions and File Systems
  • Partition
  • Distinct area of hard disk
  • Has been prepared to store particular type of
    data
  • File system
  • Arrangement of information on device such as hard
    disk
  • df command
  • See status of all currently accessible file
    systems

29
Partitions and File Systems (continued)
  • Linux can access a number of file system types
  • Ext2 permissions
  • Ext3 permissions and journaling
  • Reiserfs many small files
  • Vfat - DOS
  • ISO-9660 CD ROM read only
  • Udf - DVD, CD-RW, CD-R
  • Ntfs read-only

30
Partitions and File Systems (continued)
31
Inodes and Links
  • inode
  • Hold information about files
  • Within ext2 or ext3 file system
  • Has associated number
  • Controls file to which it points
  • Does not contain file name
  • File record contains
  • File name
  • Inode number for file

32
Inodes and Links (continued)
  • Directory record contains list of files with
    corresponding inode numbers
  • Link allows two or more file records to refer to
    same physical data stored in file system
  • Symbolic link
  • File that refers to another file or directory,
    rather than containing data itself
  • Used when same data must be accessed from two
    locations in directory structure
  • Takes only a few bytes of hard disk space

33
Inodes and Links (continued)
  • ln command
  • Create symbolic link
  • Use -s option
  • Syntax ln -s be created
  • Hard link
  • File record that includes file name and inode
  • Just like regular file record
  • Refers to inode that already has file record
    pointing to it

34
Inodes and Links (continued)
35
Inodes and Links (continued)
36
File Types
  • Different types of files are used to perform
    different functions
  • stat command
  • Ties together file name with inode
  • Shows information about inode

37
File Types (continued)
38
Accessing Removable Media
  • To use any file system
  • Must be mounted
  • mount command
  • Instruct Linux how to access file system
  • Mount point
  • Path in directory structure where you access data
    in file system
  • umount command
  • unmount media
  • umount /dev/fd0

39
Accessing Removable Media (continued)
  • fdformat command
  • Format 3.5-inch disk
  • fdformat /dev/fd0
  • /dev/fd0
  • Device name for 3.5-inch disk drive
  • sudo mkdir /media/floppy
  • sudo mount t vfat /dev/fd0 /media/floppy
  • cd /media/floppy to access disk
  • sudo gedit /etc/fstab
  • Modify mount points when logging on.
  • Displays partition numbers to mount points.
  • /dev/fd0 /media/floppy vfat rw,user,noauto 0 0

40
Accessing Removable Media (continued)
  • Mounting a CD ROM
  • mount -t iso9660 /dev/cdrom /media/cdrom
  • Mounting a zip disk
  • mkdir /media/zip
  • Add to /etc/fstab
  • /dev/sda1 /media/zip vfat noauto,rw,user,nosuid,sy
    nc
  • mount /media/zip
  • cd /media/zip

41
Mounting Windows Partition
  • sudo mkdir /media/win1
  • sudo gedit /etc/fstab
  • /dev/hda1 /media/win1 vfat rw,user,umask000 0 0
  • Partition number, mount point, file system,
    allows all users to read and write, 0 -
    filesystem does not need to be dumped, 0 - file
    system does not need to be checked (1 - reserved
    for root filesystem, 2 - all other drives to be
    checked sequentially)

42
Using find
  • find command
  • Helps find objects matching exact search criteria
  • Doesnt use prebuilt index
  • Recursively search from starting directory
  • find /home -name "report.doc"
  • Find file matching name
  • find /home -user horvathe
  • Find all files owned by horvathe
  • find /home -size 2048M
  • Find files larger than 2 Gbytes

43
Using find
  • Other options
  • mtime - modified time
  • Example find /home atime -1
  • -1 less than one day
  • 3 more than three days
  • mmin - modified minutes
  • -15 less than fifteen minutes
  • 30 more than thirty minutes
  • atime - access time
  • amin access minutes
  • See http//www.ss64.com/bash/find.html

44
Managing File Archives
  • System administrators often work with files that
    include
  • Compressed data
  • Multiple files in archival format

45
Compressing Files
  • Compressing files
  • Useful way to use less space for rarely accessed
    data
  • Makes files smaller before transmitting them over
    network
  • gzip command
  • Compress any file best compression 60-70 of
    original size
  • Lempel-Ziv Compression
  • gzip v sample sample.gz
  • -v verbose option
  • zcat sample.gz to view compressed file contents
  • gunzip command
  • Uncompresses file compressed using gzip
  • gunzip v sample.gz

46
Compressing Files
  • bzip2 command
  • Compress any file
  • bzip2 v sample sample.bz2
  • -v verbose option
  • bzcat sample.bz2 to view compressed file contents
  • bunzip2 command
  • Uncompresses file compressed using gzip
  • bunzip2 v sample.bz2

47
Using tar and cpio for Archiving Files
  • tar archive
  • Tape Archive
  • Single file that can contain other files and
    directory structure
  • tar command
  • Create tar archive
  • Specify files to be included in backup archive on
    command line
  • Writes data to file name or device

48
Using tar for Archiving Files
  • tar and compress an entire directorys contents
  • tar zcvf backup.tar.gz
  • View contents of archive
  • tar ztvf backup.tar.gz
  • tar to a tape device
  • tar cvf /dev/st0
  • Extract and uncompress
  • tar zxvf backup.tar.gz
  • Extract from a tape device
  • tar xvf /dev/st0
  • Tarball archive and compressed
  • .tar.gz or .tgz

49
Using tar and cpio for Archiving Files (continued)
  • cpio command
  • Copy in and out
  • Similar to tar
  • Reads from STDIN channel for file names
  • Writes data back to STDOUT
  • Examples
  • Archive
  • find /home u horvathe cpio vocB O
    horvathe.cpio
  • Extract
  • cpio vicB I horvathe.cpio
  • tar and cpio
  • Help create incremental or multilevel backup
Write a Comment
User Comments (0)
About PowerShow.com