Skip to main content
14 of 27
edited tags
Peter
  • 1.1k
  • 2
  • 11
  • 18

Understanding UNIX/Linux permissions and chmod

I've never really got how chmod worked up until today. I followed a tutorial that explained that you've got three different permission groups:

  • owner (u)
  • group ((g)
  • everyone (o)

Based on these three groups, I now know that:

  • If the file is owned by the user, the user permissions determine the access.
  • If the group of the file is the same as the user's group, the group permisson determien the access.
  • If the user is not the file owner, and is not in the group, then the other permission is used.

I've also learned that you've got the following permissions:

  • read (r)
  • write (w)
  • execute (x)

I created a directory to test my newly aqcuired knowledge:

mkdir test

Then I did some tests:

chmod u+rwx test/
# drwx------
chmod g+rx test/
# drwxr-x---
chmod u-x test/
# drw-r-x---

After fooling around for some time I think I finally got the hang of chmod and the way you set permission using this cmmand.


But...

I still have a few questions:

  • What does the d at the start stand for?
  • What's the name and use of the containing slot and what other values can it hold?
  • How can I set and unset it?
  • What is the value for this d? (As you only have 7=4+2+1 7=4+2+1 7=4+2+1)
  • Why do people sometimes use 0777 instead of 777 to set their permissions?

But as I shouldn't be asking multiple questions, I'll try to ask it in one question.

In UNIX/Linux file permissions, what does the first part (d) stand for and what's the use for this part of the permissions?


I would like to add that I am new to the whole unix/linux platform and if this is a stupid question, please excuse me for asking.

Peter
  • 1.1k
  • 2
  • 11
  • 18