Chapter 3 Some additional notes - PowerPoint PPT Presentation

1 / 10
About This Presentation
Title:

Chapter 3 Some additional notes

Description:

Available to three categories of users (user, group and others) ... Similarly, to make info.dat readable and writable to the group, we can say: ... – PowerPoint PPT presentation

Number of Views:49
Avg rating:3.0/5.0
Slides: 11
Provided by: kendra6
Learn more at: http://utdallas.edu
Category:

less

Transcript and Presenter's Notes

Title: Chapter 3 Some additional notes


1
Chapter 3 Some additional notes
  • File permissions
  • A file has three types of permissions (read,
    write and execute).
  • Available to three categories of users (user,
    group and others).
  • Can see the permission settings using ls l
  • apache/public_html/CS3375 ls -l
  • total 6428
  • -rw-r--r-- 1 kkhan cs 3961 Jan 29
    2058 3375.html
  • -rw-r--r-- 1 kkhan cs 70656 Jan 21
    0311 Syllabus_3375_sp08.doc
  • -rw-r--r-- 1 kkhan cs 763392 Jan 7
    1327 Your_UNIX_2e.ppt
  • -
    r-x - - - - - -
  • The total line tells how many blocks (usually
    1024 bytes per block) are contained in this
    directory.
  • Directory, followed by three sets of 3 bits
    indicating permissions
  • First set? Owner
  • Second set? Group

Owner can read and execute this file
2
Chapter 3 Some additional notes
  • Copying Permissions
  • As one other shortcut, its possible to tell
    chmod give users of one class the same
    permissions that some other class has.
  • Lets say we have these files
  • d------rwx joe acctg sales
  • -rw-r--r-- joe acctg info.dat
  • The other users have full permissions on the
    sales directory.
  • Wed like to say the user and group should be
    assigned () the permissions belonging to
    others. That translates to
  • chmod ugo
  • Similarly, to make info.dat readable and writable
    to the group, we can say
  • chmod gu info.dat (you can read this as the
    group is assigned () the permissions currently
    held by the user.)
  • You may also use and - to add and subtract the
    permissions that currently belong to a different
    class of user.
  • You cant mix the standard permissions (r, w, and
    x) with the coyping shortcuts. chmod will protest
    if you give it something like this
  • chmod gwu info.dat

3
Need to be able to change the file permissions
  • Why?
  • Protect files from accidental deletion or
    modification (archive)
  • Allow team members to read, modify, execute,
    possibly even delete a file without having to
    send them a copy
  • Setting up your webpage on unix have to make
    the html files accessible or no one will be able
    to see it!
  • Unix command is chmod
  • Command allows us to change the permission
    settings
  • Examples (can use relative or absolute
    permissions)
  • chmod orwx testfile1
  • -r-x---rwx 1 kkhan cs 24 Sep 7
    1041 testfile1
  • // o is for other, means add permission

4
Need to be able to change the file permissions
  • Examples cont.
  • Change it back?
  • chmod o-rwx testfile1
  • Results in
  • -r-x------ 1 kkhan cs 24 Sep 7
    1041 testfile1
  • // - means remove permission
  • Can also use absolute (binary) mode
  • chmod 507 testfile1
  • Results in
  • -r-x---rwx 1 kkhan cs 24 Sep 7
    1041 testfile1
  • 5 0 7
  • 101 000 111
  • r-x - - - rwx
  • (Bits are set or cleared)

5
Need to be able to change the file permissions
  • Access to files is not independent of the
    permissions on the directories
  • The directory is the parent permissions on the
    parent cannot be over-ridden by permissions on
    its files
  • Examples
  • Directory is set with no write access
  • Cannot add or delete a file in the directory no
    matter what its permissions are
  • Question could we edit a file in this directory?
  • Only if we have write permission for the file
  • Directory is set with no read or execute access
  • Question could we run an html file in this
    directory?
  • No (this is a common problem setting up webpages)

6
Need to be able to change the file permissions
  • Man chmod
  • chmod -fR absolute-mode file...
  • chmod -fR symbolic-mode-list file...
  • -f Force. chmod will not complain if it fails
    to change the mode of a file.
  • -R Recursively descends through directory
    arguments, setting the mode for each file as
    described above.
  • Problem Im building my website and I want to
    set all my files in the directory public_html so
    everyone can read and execute my html file
  • chmod R arx public_html
  • Review chmod Solves Problems http//catcode.com/t
    eachmod/no_prob.html

7
File Permission Exercise
  • Set the permissions as follows
  • testdir1 group
    other has no access
  • testfile1.html group other
    has no access
  • testfile2.html group other
    has read access
  • testfile3.html group other
    has write access
  • testfile4.html group other
    has execute access
  • testfile5.html group other
    has read and execute access
  • testfile6.html group other
    has read and write access
  • testfile7.html group other
    has write and execute access
  • testfile8.html group other
    has read, write, and execute access

8
File Permission Exercise
  • testdir2 group other
    has read access
  • // 8 files
  • testdir3 group other
    has write access
  • // 8 files
  • testdir4 group other
    has execute access
  • // 8 files
  • testdir5 group other
    has read and execute access
  • // 8 files
  • testdir6 group other
    has read and write access
  • // 8 files
  • testdir7 group other
    has write and execute access
  • // 8 files
  • testdir8 group other
    has read, write, and execute access

9
File Permission Exercise
  • Now, try to
  • display the contents of each directory
  • e.g., ls testdir1
  • display a long listing of each directory
  • e.g., ls l testdir1
  • why dont these two list commands behave the same
    way?
  • display the contents of each file in each
    subdirectory
  • e.g., more testfile1.html
  • change the contents of each file
  • e.g., echo trying to change the file gtgt
    testfile1.html
  • delete each file
  • e.g., rm testfile1.html

10
File Permission Exercise
  • To test the ability to load a .html file in a
    browser, you need to set up a softlink (aka
    symbolic link) under your public_html directory
  • cd
  • cd public_html
  • ln -s ltoriginalgt ltlink namegt
  • - creates a softlink (called link name), which
    points to the original subdirectory
  • e.g., ln s kkhan/public_html/testfiles
    testdir
  • cd ltlink namegt takes you to the original
    subdirectory
  • cd testdir
  • Now, in the browser (for example running on the
    pc) you can use the open file option to test
    loading the .html files
  • If the file loaded successfully, then there is a
    brief text displayed from the file
  • Try loading one that definitely should work
  • testdir8/testfile8.html
Write a Comment
User Comments (0)
About PowerShow.com