Understanding File or Folder Permissions in Linux
In Linux nothing is taken for granted. Linux is secure and it will always continue to be. What are file/folder permissions in Linux?
It becomes very boring when you can’t even open, delete or modify your own files and folders on Linux as a beginner. When I started using Ubuntu and doesn’t know about file/folder permissions I only allow these stubborn secured files and folders to just have their way on my computer.
Most people have gone through this before, where files and folders become immutable to them due to file permissions. Is file or folder permission setting necessary at all? YES. Want to know why, continue reading.
Today am going to show what file and folder permissions is all about.
Let’s get started.
The command that will help us solve this is known as chmod.
chmod command is used to set the permission of a file or folder. chmod command uses three digits as a parameter to assign permissions to files or folders. chmod changes the file mode bits of each given file according to mode, which can be either a symbolic representation of changes to make, or an octal number representing the bit pattern for the new mode bits.
$ sudo chmod XXX file/folder name
Understanding the example above,
The XXX in the command are the digits used in manipulating of bits to change permissions.
The first X represents the Owner (current user)
The second X represents Group (set by owner)
The third X represents anyone else
Here we dealing with 3-bits xxx where one of the 3-bits is set to 1 it means you are permitted to do something, when set to 0 you are not.
for these bits xxx, they stand for x-Read, x- Write and x-Execute (in their respective order).
The list below shows the Decimals, Bits and Meanings
0 = 000 = No permission, this person can neither read, write nor execute
1 = 001 = Execute only (because last bit set to 1)
2 = 010 = Write only (because middle bit set to 1)
3 = 011 = Write and Execute only (because last 2 bits set to 1)
4 = 100 = Read only (because first bit set to 1)
5 = 101 = Read and Execute only (because first and last bits set to 1)
6 = 110 = Read and Write only (because first and second bits set to 1)
7 = 111 = Read, Write and Execute (because all bits set to 1)
Now let’s try our hands on a real file. Using ls -l to list files and folders in a directory displays the permission of files with
- r (Read)
- w (Write)
- x (Execute)
The first, second and third part corresponds Owner, Group and anyone permissions.
Looking at the codes below, only the Owner have permission to the file.
enock@enock-pc:~/unixmen$ ls -l total 0 -rwx------ 1 enock enock 0 Aug 25 18:05 unixmen.txt
Looking at the codes below, only the owner and anyone have permission to the file.
enock@enock-pc:~/unixmen$ chmod 707 unixmen.txt enock@enock-pc:~/unixmen$ ls -l total 0 -rwx---rwx 1 enock enock 0 Aug 25 18:05 unixmen.txt
Looking at the codes below, everybody have permissions to the file.
enock@enock-pc:~/unixmen$ chmod 777 unixmen.txt enock@enock-pc:~/unixmen$ ls -l total 0 -rwxrwxrwx 1 enock enock 0 Aug 25 18:05 unixmen.txt
Now you can change the permission of files or folders.
NOTE: It is not good to set permission of confidential files or folders to 777.
Like us on Facebook
We need your assistance to stay live
This week Top Posts
- Top Things To Do After Installing Ubuntu 13.10 'Saucy Salamander' : Ubuntu 13.10 Saucy Salamander will be released on coming October 17th with many new salient featur...0 comments |
- How To Upgrade From Ubuntu 13.04 Raring To Ubuntu 13.10 Saucy Salamander : Ubuntu 13.10 Saucy will be released on October 17th. Hope it will come with lot of improvements and ...0 comments |
- Wow! Linux Foundation To Offer Free Linux Course This Summer Worth $2,400 on EdX : Wow! Early last week it was all over the internet, if you haven't heard it yet then this is the t...0 comments |
- Install LAMP Server (Apache, MySQL or MariaDB, PHP) On Ubuntu 13.10 : Updated January 12, 2014 LAMP is a combination of operating system and open-source software stack. ...0 comments |
- DNS Server Installation Step by Step Using CentOS 6.5/6.4/6.3 : DNS, Domain Name System, translates hostnames or URLs into IP addresses. For example if we type www....0 comments |
- Install lamp with 1 command in Ubuntu 12.10, 13.04 Raring Ringtail & LinuxMint13 : Updated: 10/09/2012 :LAMP (Linux, Apache, MySQL and PHP) is an open source Web development platform ...0 comments |
- How To “Fix E: Could not open file /var/lib/dpkg/status”
- Wow! Linux Foundation To Offer Free Linux Course This Summer Worth $2,400 on EdX
- Fedora 21 Scheduled For Release In October
- Install Uget Download Manager In Ubuntu, Fedora, Debian
- Download Elementary OS ‘Luna’ Official Wallpapers
- Install Power Commands 0.1.5 On Ubuntu 14.04/13.10/12.10/12.04
- 5 Android Apps that’s Going to Make Running Your Business Less Stressful
- Puppet agent Install Using Script
- Install Corosync and Pacemaker On CentOS 6.5
- Install Fail2Ban On Ubuntu Server 13.04/13.10
This work by unixmen.com is licensed under a Creative Commons Attribution-NonCommercial-NoDerivs 3.0 Unported License.
Copyright © 2008-2013 Unixmen.com .