Linux – Ubuntu file permissions

linuxpermissionsUbuntu

I'm having some trouble with file permissions on an Ubuntu server. I'm using WinSCP to move files to the server. The server will work fine, and then after a while it appears that I no longer have permission to delete a file.

I'm connecting to the server using an account called svadmin, and the root directory of the Apache server is /var/www. Each website has it's own directory under this – i.e.

/var/www/site1
/var/www/site2

This is the output from the ls command…

cd /var/www
ls -al
drwxr-sr-x   4  svadmin  svadmin  4096 2009-06-12 14:45 .
drwxr-xr-x  15  root     root     4096 2009-05-05 15:47 ..
drwxr-sr-x   4  svadmin  svadmin  4096 2009-06-12 15:15  site1
drwxr-sr-x   4  svadmin  svadmin  4096 2009-06-12 15:15  site2

My understanding is that this mean the directory owner has read/write/execute? When I connect to the server using the svadmin account, shouldn't I be able to overwrite or delete files in /var/www/site1 or /var/www/site2?

I'm not very familiar with linux file/directory permissions, so have been struggling to work out what I should be doing. Any help would be greatly appreciated!

More info: (thanks for the quick replies!)

Output of ls -al for /var/www/site1

drwxr-sr-x 4 svadmin svadmin 4096 2009-06-12 15:15 .
drwxr-sr-x 4 svadmin svadmin 4096 2009-06-12 14:45 ..
-rw-r--r-- 1 svadmin svadmin 157  2009-05-12 13:23 error.php
-rw-r--r-- 1 svadmin svadmin 158  2009-05-12 13:23 .htaccess
-rw-r--r-- 1 svadmin svadmin 142  2009-05-12 13:23 index.php
drwxr-sr-x 2 svadmin svadmin 4096 2009-05-12 18:40 libraries

Error message When I try and delete the file:

rm admin.php
rm: cannot remove 'admin.php' : Read-only file system

Even more info
Just to add some possibly relevant information… everything was working until yesterday afternoon. At that point a coworker took out the SAN that the virtual machine file was on, and the web server had a less than graceful shutdown.

Best Answer

This isn't a permissions problem. The two clues are:

  • rm: cannot remove 'admin.php' : Read-only file system
  • everything was working until yesterday afternoon. At that point a coworker took out the SAN that the virtual machine file was on, and the web server had a less than graceful shutdown.

Somehow the filesystem containing /var/www dropped to "read only" probably when the SAN went away. The output of the mount command should identify this filesystem with a (ro) flag at the end.

The fix is to figure out why it happened, make sure it's corrected, and remount the filesystem rw with this command:

mount -oremount,rw $filesystem