LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   unable to change file permissions!! (https://www.linuxquestions.org/questions/linux-general-1/unable-to-change-file-permissions-286390/)

dcdbutler 02-04-2005 08:00 PM

unable to change file permissions!!
 
Hi all,
I'm using KDE 3.2 on Mandrake 10.1 official, it's been installed for less than a week. Things were working fine, until I did a yum update. Then things were still mostly fine except that I couldn't get access to my partitions and devices with the default mount options in the /fstab file (I was able to before). I was able to change that with some basic editing of the /fstab file. However, when I to do this command on an unmounted partition;
# chmod 777 /mnt/[partition]
and then I mount it and try to access the directory /mnt/[partition] through Konqueror, or Rox, it says that access is denied. When I look at the file permissions again, they've all been changed back to their previous settings, as though the system is overriding the root command. I've been messing about with UID and GID a bit as root in KDE (the red splash screen scares me), but they get changed back to default again as well.
I'm a bit stuck here, don't want to break anything and could do with some help.
Thanks for any advice!
Dave

Ace07 02-04-2005 08:57 PM

You can log into root via the console using the su command:

su <username>

Then enter the password and you can change the permissions of the /mnt folder by using the following commands:

chown -R <your username> /mnt
chmod -R 777 /mnt

(first one changes owner)
(second one changes permissions to readwrite)

That should make you able to access them with your regular user account. It is generally NOT recommended that you log into the root account from the login screen. Use "su root" via the command line whenever you need to change something like this.

If you need any more help, don't hesitate to ask...

jschiwal 02-04-2005 09:11 PM

You need to perform the 'chmod' command on mounted partitions. If the partition is vfat or ntfs, then you need to use the 'uid=' and 'gid=' options in fstab or the mount command.

dcdbutler 02-04-2005 09:25 PM

Ah, ok, I didn't realise (or had forgotten) that the partitions had to be mounted for the chmod command to work.
I managed to change the permissions ok with chown and chmod this time.

So the new mount option line in /fstab should read something like
auto,user,gui=0,uid=0
for the vfat and ntfs partitions?
Also, inadvertantly, when I was messing around with Konqueror logged in as root, I somehow managed to make a couple of my partition folders into "Locked Folders" in the properties dialog box. What's the easiest way to set these back to regular folders again? It'll take me all night to figure it out unless you guys can point me in the right direction.
Many thanks for you help!
Cheers!

Ace07 02-04-2005 09:30 PM

Quote:

Originally posted by dcdbutler
Ah, ok, I didn't realise (or had forgotten) that the partitions had to be mounted for the chmod command to work.
I managed to change the permissions ok with chown and chmod this time.

So the new mount option line in /fstab should read something like
auto,user,gui=0,uid=0
for the vfat and ntfs partitions?
Also, inadvertantly, when I was messing around with Konqueror logged in as root, I somehow managed to make a couple of my partition folders into "Locked Folders" in the properties dialog box. What's the easiest way to set these back to regular folders again? It'll take me all night to figure it out unless you guys can point me in the right direction.
Many thanks for you help!
Cheers!

Locked folders as in owned by root? Or is it simply that your regular user can't read or write to them?

Most of those folders can be changed using (assuming you want readwrite for the particular folder):

chmod 777 <folder>

Use:
chmod -R 777 <folder>

to recursively change permissions. This changes the permissions of the folder and every folder/file underneath it.

And...make sure you are logged in as root of course.

dcdbutler 02-04-2005 09:48 PM

No, it's strange.
On the mounted partition I do;
# chown -R dave /mnt/[partitionname]
# chmod 777 /mnt/[partitionname]

Then I go into Konqueror to open the directory, but there's a padlock on the icon (like the /root directory has) and access is denied to the directory contents - This was something I must have done previously while logged into the console as root (which I'm not doing anymore).
It must be quite easy to remedy, I just don't know the answer.

Thanks again, when I get this sorted out, I'm gonna get drunk!

dcdbutler 02-04-2005 10:11 PM

Actually, I can't even access the folder /mnt through Konqueror now. It's got a padlock on iit as well. I can still access the directory and all contents through the terminal as root, but I'd love get rid of those padlocks.........

dcdbutler 02-04-2005 11:34 PM

OK, sorry to harp on about this - The padlocks have disappeared after a reboot (whew). I now get this.........

# ls -al /mnt
total 44
drwxr-x--- 9 dave dave 4096 Jan 31 20:53 ./
drwxr-xr-x 18 root root 4096 Feb 4 23:30 ../
drwxrwx--- 2 dave root 4096 Jan 30 17:21 cdrom/
drwxrwxrwx 0 root root 0 Feb 4 23:30 floppy/
drwxrwxrwx 2 dave root 4096 Jan 30 17:20 music/
drwxrwxrwx 2 dave root 4096 Jan 30 17:20 storage/
drwxrwx--- 2 dave root 4096 Jan 30 17:20 win98/
drwxrwx--- 2 dave root 4096 Jan 30 17:20 win_c/
drwxrwx--- 2 dave root 4096 Jan 30 17:20 win_c2/
# mount /mnt/music
# mount /mnt/storage
# ls -al /mnt
total 56
drwxr-x--- 9 dave dave 4096 Jan 31 20:53 ./
drwxr-xr-x 18 root root 4096 Feb 4 23:30 ../
drwxrwx--- 2 dave root 4096 Jan 30 17:21 cdrom/
drwxrwxrwx 0 root root 0 Feb 4 23:30 floppy/
drwxr--r-- 7 root root 16384 Dec 31 1969 music/
drwxr--r-- 5 root root 16384 Dec 31 1969 storage/
drwxrwx--- 2 dave root 4096 Jan 30 17:20 win98/
drwxrwx--- 2 dave root 4096 Jan 30 17:20 win_c/
drwxrwx--- 2 dave root 4096 Jan 30 17:20 win_c2/

My questions are:
1. Why have the file permissions and owner changed after mounting?
2. Why can't I open either /mnt/storage or /mnt/music with a graphical interface (or normal user at the terminal) after mounting?
3. Why has the date changed to Dec 31 1969 after mounting?

This is driving me nuts. Is it possible that another operating system has upset the balance here? I have edited files and folders in these partitions in another distro of Linux and Windows XP.

Thanks again!
Dave
I know I'll kick myself when I know the answer.

Ace07 02-05-2005 02:41 PM

To get certain users to be able to access those mount folders you need to edit your /etc/mtab or /etc/fstab file.

My fstab looks like this:
Code:

# This file is edited by fstab-sync - see 'man fstab-sync' for details
LABEL=/                /                      ext3    defaults        1 1
none                    /dev/pts                devpts  gid=5,mode=620  0 0
none                    /dev/shm                tmpfs  defaults        0 0
LABEL=/home            /home                  ext3    defaults        1 2
none                    /proc                  proc    defaults        0 0
none                    /sys                    sysfs  defaults        0 0
/dev/hda6              swap                    swap    defaults        0 0
/dev/hda1              /mnt/c                  ntfs    ro,uid=500      0 0
/dev/hdb1              /mnt/d                  ntfs    ro,uid=500      0 0

/dev/hdc                /media/cdrecorder      auto    pamconsole,ro,exec,noauto,managed 0 0
/dev/fd0                /media/floppy          auto    pamconsole,exec,noauto,managed 0 0

The bolded parts are what I use so that users (the user id) can access the drives. However, I have heard that just putting "users" instead of that 'uid=' stuff actually works better. But since I have one user...there is no reason to mess with it I don't think.

(gid= group id that can access it)

dcdbutler 02-05-2005 03:11 PM

I managed to get it working.......for a while. I did this by
#chown [user] /mnt
#chown [user] /mnt[partitions]
and I changed the permissions accordingly.
then I went to open my partitions through the GUI all was fine.
I went out to buy some beer.
When I came back, I found I could still mount my partitions through the GUI, however, when I try to open the partition, I get an error message "The file or folder /mnt/[partition] does not exist". Nor am I able to open the folder /mnt through ROX or Konqueror, because permission is denied. Incredulous, I check out the permissions again for /mnt - They are
drwxr-x--- 9 root root 4096 Jan 31 20:53 mnt/
The owner has changed back to root. Why? I have no idea. The ownership of the folders in /mnt has remained as I had set it though - to the 'user' - me. It must be something simple I have missed or am doing wrong.
I don't have fstab-sync, but I edit my /fstab file through kwrite. Maybe there is something wrong with this. I will include it below for reference, in case anyone can tell me if there is a glaring ommission or some detail that absolutely should be changed.

/dev/hda6 / ext3 defaults 1 1
/dev/hdc /mnt/cdrom auto,iso9660 noauto,user,exec 0 0
/dev/fd0 /mnt/floppy auto sync,noauto,user 0 0
/dev/hda1 /mnt/win_c ignore 0 0
/dev/hda3 /mnt/win_c2 ignore 0 0
/dev/hda5 /mnt/music vfat users,noauto 0 0
/dev/hdb4 /mnt/storage vfat users,noauto 0 0
/dev/hda2 /mnt/win98 vfat users,noauto 0 0
none /proc proc defaults 0 0
/dev/hda7 none swap defaults 0 0
/dev/hdb5 none swap defaults 0 0

Thanks for all your help and time!

dcdbutler 02-05-2005 07:16 PM

ok, the problem seems to lie somewhere with the /mnt directory. I change ownership of this to user (myself). Everything's ok for a while. Then for some reason, ownership changes back to root later. then when I try to access the /mnt directories through the GUI (ROX), it tells me that access is denied. When I try to access the directory through one of the disk icons on my desktop (after mounting) I get the error message "The file or folder /mnt/storage does not exist."
The process can be reversed by 'reowning' the /mnt directory to 'user', but it's a temporary fix which eventually gets overwritten by root.

I'm beginning to wonder if this is a Mandrake specific problem - when I goggled this phrase, all I got were a few Mandrake users links which were not much help.

Anyone got any ideas? I'm tearing my hair out and my knuckles are bleeding from punching the wall in frustration!

jschiwal 02-06-2005 09:58 AM

The permissions on the /mnt directory should be like this:
drwxr-xr-x 6 root root 4096 Jan 22 03:54 /mnt/
You could change the ownership of /mnt/c or /mnt/d (using mount options) but don't do that for /mnt.

In the fstab entry, you can use the user name in place of the uid or gid.

For example:
Quote:

/dev/hda1 /mnt/c ntfs ro,uid=ace007 0 0
Other options to use are 'fmask', 'dmask', 'users'. The 'users' option allows any user to unmount the drive. The 'fmask' option is like umask, but just for files.

Here is my NTFS paritions entry in my fstab file:
/dev/hda1 /mnt/win_c ntfs umask=0022,nls=iso8859-1,ro 0 0

Using 'fmask=0333,dmask=0222' may make more sense. For security reasons, you don't want to execute files on a storage paritition, or any partition with global write access.
Since the NTFS filesystem is read only anyway, I have the 'x' bit masked on files. But since the 'x' bit for directories allows entering them, the 'dmask' setting allows it.

I don't know about Red Hat and Fedora Core systems, but they may have a service such as 'msec' run by cron periodically to reset ownership and permissions of certain directories. If you have root's mail forwarded to yourself, you could monitor files on your system. For example, receiving warnings about world readable files.


All times are GMT -5. The time now is 10:11 PM.