Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member

Setting permissions using alpha notation

From: Unix for Mac OS X Users

Video: Setting permissions using alpha notation

Now that we understand how permissions work, how do we go about changing them? Well, you remember with ownership, we used chown, change ownership. We are going to use chmod to change permissions. It stands for change mode and that's what Unix refers to the mode of these files is being what it calls to permissions. So chmod and then we are going to put in whatever the mode is. I am just going to write the word mode as placeholder, we will talk about what the mode is, followed by the file name and so we will just put file name. That's the format. chmod, whatever changes to the mode we want, and then the file name.

Setting permissions using alpha notation

Now that we understand how permissions work, how do we go about changing them? Well, you remember with ownership, we used chown, change ownership. We are going to use chmod to change permissions. It stands for change mode and that's what Unix refers to the mode of these files is being what it calls to permissions. So chmod and then we are going to put in whatever the mode is. I am just going to write the word mode as placeholder, we will talk about what the mode is, followed by the file name and so we will just put file name. That's the format. chmod, whatever changes to the mode we want, and then the file name.

So let's look at some example of what that mode might look like. So first, remember that we have three categories. We have user, group, and other. Notice the first letters of those. u, g, and o. We are going to be using those first letters to indicate where we want to make changes to, which category should get changes. Okay, so u, g, and o, r, w, and, x. So the first one I want to look at is going to be changing user, group, and other and setting them all equal to something. All right, so it can provide whatever three letters I want there. I am going to say r, w, and x. This is going to give all of them all three of those.

Now most of the time you don't want to do that. Most of the time you are trying to set different permissions for different people. So another way to write that out would be to say u= and give it whatever permission is for u, followed by a comma then the g= whatever permissions it should have and then o for other. User, group, and other. Commas separating them. That's a long thing to type and I don't know anyone who really types it out that way. Typically when you are changing the permissions, you know what the current permissions something are. what you want to do is change it to something slightly different.

You are like, oh, you know what, I wish that the user and group both had write permissions to this file. Well, to do that, you can just use the plus sign. Keep the existing permissions exactly like they are. All I am interested in is for user and group add the w permission. We can also do the same thing subtractively. We can say all right, I want to take away the write permission from other. So plus and minus, it's typically the way people work. Instead of spelling it all out for each one, typically you just say all right here are the changes that I want to make.

Now as I said, u, g, and o are how we define the three categories that we are targeting. There is one other shortcut I want to show you which is, is if you are trying to do something to all three of them and you are using ugo, you can also use a, so that's a shortcut. Those last two do the exact same thing. a means u, g, and o altogether. Let's try it out, so you can get the hang of it. Okay, I am going erase this line, because that's not going to do anything for us. Let's do ls -la so we can see the current permissions and I am going to really target everything on this ownership.txt. You can use any file you want. You can just create a new file.

You can see that the current permissions are read and write for the owner and just read for the group and other categories. So to begin, let's do chmod and let's do user group and other equals, so we can see what that looks like and let's say r and x. And we will do it to ownership.txt. So that's typically what a chmod statement looks like. chmod, then what we want to do to it, followed by the file name. So we are going to add essentially an x to the last two. ls -la and now you will see that the x has been added to those two.

You see that actually took the w away from the owner as well, because I set it to equals. So now let's try it slightly different. let's do chmod u=rwx and let's do group = rw and other. It's going to be equal to just r for ownership.txt. ls -la again. Now you can see how we changed it using that. All right so we broke it up using commas. We can also add to it, for example. Then we can say chmod user group and other, plus x for ownership, ls -la.

There we go, you see that it added the x to it and let's just do chmod a-x so you can see what that does. ls -la again. You can see that it took back away the x. So now that you have the hang of how we specify these, let's see what the actual practical affects are of these. Let's try chmod and let's do user group and other. Let's take away their read privileges. Okay, so now we don't have the ability to read anymore. We just clear the screen so you can see it. So there we are. We don't have read privileges anymore.

Let's try nano ownership.txt. And notice that it pop opened nano but look at the message that it gives us at the bottom, permission denied. So I am inside nano, but I can't do anything. I can type here, but I am not actually inside that file and when I say save, it's going to save to a new file. It's not actually reading the contents that file into the buffer for me to change. I am just essentially opening nano. So let's try now changing the ownership so that, say chmod, let's say user group and other ought to be equal to read for ownership.

All right, so now we only have read permissions. We don't have write permissions. Once again, let's try opening up nano ownership.txt. So it opened it up. It read it fine. There is nothing inside this file to begin with, but it did successfully open it. Let's say hello and now let's do exit, save buffer, yes. File name to write. Now I have the opportunity to provide a different file name but I am essentially now about to write on to this file, and I hit Return. It says, "Sorry, permission denied." So we can't write to it.

We can write to a different file name if we want, we still have the ability to save our changes, but we can't overwrite ownership.txt because we don't have write privileges. So I will just say no to saving those changes and let's go ahead and just set it back to chmod and we will make user gain its write privileges back on ownership.txt. Let's take one last look at it and there we go. The other thing I just want to mention to you is that in addition to doing changes like this, if we have a directory and we want to change this to the directory, let's say that we want to do chmod, let's add the write attribute for group, and we will write that for test.1 for the test directory.

If we do this right now, it will change it just for that top level one, same as the ownership did. If we wanted to change it to everything that's inside of there, we have to also include the recursive flag. So that's the option -R and that will recursively change everything that's inside of there, directories and files all the way down the line. So I just want to make sure you know we have that recursive option available to us. That's important if you are trying to change everything that's inside of that directory to have the same permissions. That's really all you need to being able to manage permissions in Unix. You now understand what they are, you understand how to read the notation that it gives you there on the directory listing, and you now know how to manipulate them, how to enable and disable permissions for those three categories one way or another.

But before we move on, I wanted to take a look at how we can also specify these permissions using something called octal notation and we will do that in the next movie.

Show transcript

This video is part of

Image for Unix for Mac OS X Users
Unix for Mac OS X Users

82 video lessons · 26058 viewers

Kevin Skoglund
Author

 
Expand all | Collapse all
  1. 3m 57s
    1. Introduction
      1m 14s
    2. Using the exercise files
      2m 43s
  2. 32m 2s
    1. What is Unix?
      7m 27s
    2. The terminal application
      4m 23s
    3. Logging in and using the command prompt
      5m 19s
    4. Command structure
      5m 22s
    5. Kernel and shells
      5m 25s
    6. Unix manual pages
      4m 6s
  3. 15m 58s
    1. The working directory
      2m 49s
    2. Listing files and directories
      3m 59s
    3. Moving around the filesystem
      4m 58s
    4. Filesystem organization
      4m 12s
  4. 1h 4m
    1. Naming files
      5m 41s
    2. Creating files
      2m 19s
    3. Unix text editors
      6m 39s
    4. Reading files
      5m 35s
    5. Reading portions of files
      3m 27s
    6. Creating directories
      2m 40s
    7. Moving and renaming files and directories
      8m 32s
    8. Copying files and directories
      3m 7s
    9. Deleting files and directories
      3m 38s
    10. Finder aliases in Unix
      4m 10s
    11. Hard links
      5m 30s
    12. Symbolic links
      6m 36s
    13. Searching for files and directories
      6m 32s
  5. 34m 58s
    1. Who am I?
      4m 3s
    2. Unix groups
      1m 52s
    3. File and directory ownership
      6m 41s
    4. File and directory permissions
      4m 27s
    5. Setting permissions using alpha notation
      6m 49s
    6. Setting permissions using octal notation
      3m 49s
    7. The root user
      1m 57s
    8. sudo and sudoers
      5m 20s
  6. 52m 34s
    1. Command basics
      4m 4s
    2. The PATH variable
      4m 13s
    3. System information commands
      3m 40s
    4. Disk information commands
      6m 8s
    5. Viewing processes
      5m 0s
    6. Monitoring processes
      3m 36s
    7. Stopping processes
      3m 19s
    8. Text file helpers
      6m 50s
    9. Utility programs
      7m 28s
    10. Using the command history
      8m 16s
  7. 20m 39s
    1. Standard input and standard output
      1m 24s
    2. Directing output to a file
      4m 13s
    3. Appending to a file
      2m 44s
    4. Directing input from a file
      5m 28s
    5. Piping output to input
      4m 40s
    6. Suppressing output
      2m 10s
  8. 41m 28s
    1. Profile, login, and resource files
      9m 11s
    2. Setting command aliases
      6m 59s
    3. Setting and exporting environment variables
      4m 54s
    4. Setting the PATH variable
      6m 10s
    5. Configuring history with variables
      6m 17s
    6. Customizing the command prompt
      6m 5s
    7. Logout file
      1m 52s
  9. 1h 25m
    1. grep: Searching for matching expressions
      5m 21s
    2. grep: Multiple files, other input
      4m 28s
    3. grep: Coloring matched text
      2m 57s
    4. Introduction to regular expressions
      3m 22s
    5. Regular expressions: Basic syntax
      3m 19s
    6. Using regular expressions with grep
      5m 20s
    7. tr: Translating characters
      8m 17s
    8. tr: Deleting and squeezing characters
      5m 30s
    9. sed: Stream editor
      7m 45s
    10. sed: Regular expressions and back-references
      7m 8s
    11. cut: Cutting select text portions
      7m 42s
    12. diff: Comparing files
      4m 35s
    13. diff: Alternative formats
      4m 30s
    14. xargs: Passing argument lists to commands
      7m 25s
    15. xargs: Usage examples
      7m 59s
  10. 42m 25s
    1. Finder integration
      4m 45s
    2. Clipboard integration
      5m 5s
    3. Screen capture
      3m 42s
    4. Shut down, reboot, and sleep
      3m 34s
    5. Text to speech
      2m 36s
    6. Spotlight integration: Searching metadata
      3m 41s
    7. Spotlight integration: Metadata attributes
      4m 24s
    8. Using AppleScript
      5m 23s
    9. System configurations: Viewing and setting
      5m 51s
    10. System configurations: Examples
      3m 24s
  11. 1m 26s
    1. Conclusion
      1m 26s

Start learning today

Get unlimited access to all courses for just $25/month.

Become a member
Sometimes @lynda teaches me how to use a program and sometimes Lynda.com changes my life forever. @JosefShutter
@lynda lynda.com is an absolute life saver when it comes to learning todays software. Definitely recommend it! #higherlearning @Michael_Caraway
@lynda The best thing online! Your database of courses is great! To the mark and very helpful. Thanks! @ru22more
Got to create something yesterday I never thought I could do. #thanks @lynda @Ngventurella
I really do love @lynda as a learning platform. Never stop learning and developing, it’s probably our greatest gift as a species! @soundslikedavid
@lynda just subscribed to lynda.com all I can say its brilliant join now trust me @ButchSamurai
@lynda is an awesome resource. The membership is priceless if you take advantage of it. @diabetic_techie
One of the best decision I made this year. Buy a 1yr subscription to @lynda @cybercaptive
guys lynda.com (@lynda) is the best. So far I’ve learned Java, principles of OO programming, and now learning about MS project @lucasmitchell
Signed back up to @lynda dot com. I’ve missed it!! Proper geeking out right now! #timetolearn #geek @JayGodbold
Share a link to this course

What are exercise files?

Exercise files are the same files the author uses in the course. Save time by downloading the author's files instead of setting up your own files, and learn by following along with the instructor.

Can I take this course without the exercise files?

Yes! If you decide you would like the exercise files later, you can upgrade to a premium account any time.

Become a member Download sample files See plans and pricing

Please wait... please wait ...
Upgrade to get access to exercise files.

Exercise files video

How to use exercise files.

Learn by watching, listening, and doing, Exercise files are the same files the author uses in the course, so you can download them and follow along Premium memberships include access to all exercise files in the library.


Exercise files

Exercise files video

How to use exercise files.

For additional information on downloading and using exercise files, watch our instructional video or read the instructions in the FAQ.

This course includes free exercise files, so you can practice while you watch the course. To access all the exercise files in our library, become a Premium Member.

Join now "Already a member? Log in

Are you sure you want to mark all the videos in this course as unwatched?

This will not affect your course history, your reports, or your certificates of completion for this course.


Mark all as unwatched Cancel

Congratulations

You have completed Unix for Mac OS X Users.

Return to your organization's learning portal to continue training, or close this page.


OK
Become a member to add this course to a playlist

Join today and get unlimited access to the entire library of video courses—and create as many playlists as you like.

Get started

Already a member?

Become a member to like this course.

Join today and get unlimited access to the entire library of video courses.

Get started

Already a member?

Exercise files

Learn by watching, listening, and doing! Exercise files are the same files the author uses in the course, so you can download them and follow along. Exercise files are available with all Premium memberships. Learn more

Get started

Already a Premium member?

Exercise files video

How to use exercise files.

Ask a question

Thanks for contacting us.
You’ll hear from our Customer Service team within 24 hours.

Please enter the text shown below:

The classic layout automatically defaults to the latest Flash Player.

To choose a different player, hold the cursor over your name at the top right of any lynda.com page and choose Site preferencesfrom the dropdown menu.

Continue to classic layout Stay on new layout
Exercise files

Access exercise files from a button right under the course name.

Mark videos as unwatched

Remove icons showing you already watched videos if you want to start over.

Control your viewing experience

Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.

Interactive transcripts

Click on text in the transcript to jump to that spot in the video. As the video plays, the relevant spot in the transcript will be highlighted.

Are you sure you want to delete this note?

No

Your file was successfully uploaded.

Thanks for signing up.

We’ll send you a confirmation email shortly.


Sign up and receive emails about lynda.com and our online training library:

Here’s our privacy policy with more details about how we handle your information.

Keep up with news, tips, and latest courses with emails from lynda.com.

Sign up and receive emails about lynda.com and our online training library:

Here’s our privacy policy with more details about how we handle your information.

   
submit Lightbox submit clicked
Terms and conditions of use

We've updated our terms and conditions (now called terms of service).Go
Review and accept our updated terms of service.