Linux Basics: Understanding File Ownership And PermissionsMarch 24th, 2008 · No Comments
As many web servers out there are running on Linux while most workstations are running on Windows, mastering Linux administration concepts can be confusing at first. Today we’re going to see the basics of file and directory ownership and permissions.
File & Directory OwnershipFile ownership on Linux is quite different (and simpler) than on Windows. A file or directory is only owned by a user and a group. It can’t owned by more than a single user and a single group at a time. In a command shell, issue this command to get a detailed file list:
Here is an example of a directory listing:
The third and fourth columns respectively show the user and the group owners. Here we see that the “apache” user and the “web2″ user group owns the file index.html. In this case, the “apache” user is the account under which the web server process is running. In order to change the ownership of a file, you must have a shell access as it has to be done through command lines:
To recursively change the ownership of a directory, use:
Unfortunately this can’t be done through FTP. There might be some web-based file managers that can do this though. File & Directory PermissionsA file or directory can only have three different permissions: read, write and execute. These file permissions are applied to:
Let’s look at our previous directory listing:
Starting by the first character of the first column, here’s what it means:
So for the above listing, we know that the “error” directory has:
For the above listing also, we know that the “index.html” file has:
Using The Command Line To Adjust PermissionsIf you have a shell access, you can set file and directory permissions using the command line. This is done using the chmod command. There two syntaxes possible:
or
The first syntax is a bit more friendly but you might have to issue several commands to set all the permissions on a file or directory. Let’s see how it works:
The second syntax is more difficult to remember but it’s much faster. The first number is the permission for user, the second is for group and the third is for others. Here are the possible numeric values:
Let’s look at a few examples done both ways.
You can see that the second syntax is faster than the first one. Using FTP To Adjust PermissionsYou can also use a FTP client to set permissions. Pretty much any FTP software can do this. Using Filezilla for example, you can set the permissions by right-clicking on the file or folder and selecting File Attributes.
The downside to using an FTP client is that you can’t set permissions recursively. Changing the permission on a folder will not affect its content whatsoever. Keep It Secure!Sometimes it’s too easy to give all permissions to everyone to make things work. Unfortunately this is a big security hole and you’re putting your web server at risk. It’s always better to set the lowest level of permission possible. There are some script installer that will require you to set the permissions to 777 while the application is being installed. Don’t forget to set the permissions back to their original state if possible. Related Posts |
Popular PostsLatest PostsLatest Deals & Coupons
Recent Comments
Recent WebmastersTag Cloud
1and1
apache
centos
cheap web hosting
control panel
coupon code
coupons
coupons codes
cpanel
dreamhost
godaddy
godaddy vs 1and1
green web hosting
hostdime
hostgator
hostpapa
iis
inmotion hosting
knownhost
linux
mysql
openads
openx
php
reseller hosting
security
shared hosting
system administration
vps
web hosting
web hosting comparison
Web Hosting Comparisons
whm
windows
windows 2008
|
|||||||||
0 responses so far ↓
There are no comments yet...Kick things off by filling out the form below.
Leave a Comment