1 / 13

File and Directory Permissions

File and Directory Permissions. Basic UNIX Commands Lesson 2 – Part 5. Permissions. File and Directory Permissions. This section: Explains how to change permissions of a file Lists chmod number commands Explains how to change ownership of a file

Download Presentation

File and Directory Permissions

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. File and Directory Permissions Basic UNIX Commands Lesson 2 – Part 5

  2. Permissions File and Directory Permissions • This section: • Explains how to change permissions of a file • Lists chmod number commands • Explains how to change ownership of a file • Explains how to change group ownership of a file • Describes how to change user passwords

  3. Permissions Changing Permissions of a File To change certain permissions you must either own the file or be a UNIX super user or the system will display errors: NOTE: If changing permissions is not done correctly, you can cause the software to function incorrectly and possibly cause serious problems within the system.

  4. Permissions Changing File Ownership and File Group Ownership Use the chown command to change the ownership of a file. To change the ownership of a file you must be a UNIX super user or own the file. Action Step: To change ownership of a file, use the following format: #chownnew owner filename Use the chgrp command to change the group ownership of a file. To change the group ownership of a file you must be a UNIX super user. Action Step: To change group ownership of a file, use the following format: #chgrpnew group filename

  5. Permissions Changing Permissions of a File Use the chmod command to change permissions of a file. The chmod command uses the following format to assign permissions: chmod764 filename. This example would change permissions for owner (7), group (6), and world (4) to rwxrw_r__. Key: r Read the file w Write or edit the file x Execute the file Chmod Number Commands: 7 = rwx (read, write, execute) 3 = _wx (write, execute) 6 = rw_ (read, write) 2 = _w_ (write) 5 = r_x (read, execute) 1 = __x (execute) 4 = r__ (read) 0 = ___ (no access)

  6. Permissions Changing Permissions of a File Example The following screen displays the files example4 and example3 before and after their permissions have been changed. Note that example4 is changed to 777 (rwxrwxrwx) and example3 is changed to 764 (rwxrw_r__).

  7. Permissions Chmod Number Commands $ chmod 400 filename Only you can read the filename, and no one can write or remove it $ chmod 444 filename Everyone can read the filename, no one can write to it. $ chmod 600 filename Only you can read from, write to, or remove the filename. $ chmod 644 filename Only you can write or remove the filename, but everyone can read it. $ chmod 666 filename Everyone can read from, write to, and remove the filename. $ chmod 744 directory Allows other users to list the files in the directory, but not create or remove files from it. $ chmod 777 directory Allows other users to list, create, and remove files in the directory. $ chmod 700 directory Allows only yourself to list, create, and remove files in the directory.

  8. Permissions Changing Passwords Use the passwd command to change user passwords. As a UNIX super user you do not have to follow the password policy. Action Step: To change a password, use the following format: #passwdusername. The system will then prompt you for a new password. NOTE: In some systems, the user will be forced to change their password to a new assigned password after logging in. If the password is changed by a super user, you may be forced to change the password at login. With Sun servers, you have to add a -f to force a password change at the next login.

  9. Permissions Practical Exercises • Change to the directory you created, stuff, and display the current working directory. • Display the files with the user and group, which own them. • Change owner of all files in your directory to another person in class, then list the contents of your directory. • Change the owner of the files back to your login name. • Change the group for all files in your directory to the group staff. • Change all the group files in your directory back to the group they were in. • 7. For your files only, change the permissions so that anyone can read them, but no one else can write to or execute them.

  10. Permissions Practical Exercises • For your files only, change permission so that anyone can read them, but no one else can write or execute them. • For your files only, change the permissions so that everyone can read, write, and execute them.

  11. Permissions Check Your Answers • 1. sh • cd stuff • pwd • 2. ls -l • 3. chownusername* • ls -l • 4. chownusername* • 5. chgrpnewgroup* • 6. chgrpgroupname* • 7. chmod 744*

  12. Permissions Check Your Answers • 8. chmod 666* • 9. chmod 777*

  13. This concludes Lesson 2: Basic UNIX Commands Please continue to Lesson 3:Visual Interface

More Related