Go Back   DaemonForums > Miscellaneous > Guides

Guides All Guides and HOWTO's.

Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1   (View Single Post)  
Old 5th June 2008
BSDfan666 BSDfan666 is offline
Real Name: N/A, this is the interweb.
Helpful companion
Join Date: Apr 2008
Location: Ontario, Canada
Posts: 2,223
Red face Semi-brief introduction to file permissions,

Often you may see someone setting permissions using octal values, this may be confusing at first, but I'll try to help you out.

First, let's say someone sets the permission 666 on a file, you may have a chill run up your spine if you're religious, but it's honestly a very liberal number..

Octal, or base 8, has 8 possible values.. 0 through 7.
Binary, or base 2, has 2 possible values.. 0 and 1.

Binary is important in computing because it represents 2 universal states, ying and yang, right and wrong.. on and off.

1 is the equivalent of true.
0 is the equivalent of false.

So, 6 octal is 110 binary..

The first 2 binary digits of 6(110) represent the read and write permissions of the file, the last digit represents execute.

So, When you see "666", the first digit represents the owners permissions, the second digit represents the group permissions, the last digit represents "everyones" permissions.

In this case, everyone can read and write.. but nobody can execute the file.

Here is a basic reference:
  • 0 octal or 000 binary, no permissions.
  • 1 octal or 001 binary, execute only.
  • 2 octal or 010 binary, write only
  • 3 octal or 011 binary, write and execute
  • 4 octal or 100 binary, read only
  • 5 octal or 101 binary, read and execute
  • 6 octal or 110 binary, read and write
  • 7 octal or 111 binary, read/write and execute
Read chmod(1) for a more thorough introduction..

I should note, occasionally you may see permissions set as 4 digit octals..

For example:
$ chmod 0666 public_doc.txt
  • 0666(The same as 666)
  • 1666(sticky(8) bit)
  • 2666(setuid(2) bit)
  • 4666(setgid(2) bit)
  • 6666(setuid+setgid bits)
  • 7666(setuid+setgid+sticky bits)
This high order octal value represents some additional functionality on modern Unix systems, some are scary and are often abused..

I hope I helped somebody out, take care, feel free to post if you have questions.

Last edited by BSDfan666; 5th June 2008 at 01:03 AM.
Reply With Quote

binary, chmod, octal, permissions, unix

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Permissions error J05HYYY NetBSD Package System (pkgsrc) 1 7th October 2009 11:05 PM
Permissions for zzz / acpiconf Mantazz FreeBSD General 0 15th September 2009 10:43 PM
permissions and FTP/HTTP Yuka FreeBSD General 0 20th October 2008 10:32 PM
Designing BSD Rootkits: An Introduction to Kernel Hacking cajunman4life Book reviews 2 21st June 2008 03:27 PM

All times are GMT. The time now is 12:43 PM.

Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.
Content copyright © 2007-2010, the authors
Daemon image copyright ©1988, Marshall Kirk McKusick