LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Chmod is acting strange (https://www.linuxquestions.org/questions/linux-newbie-8/chmod-is-acting-strange-839996/)

sungchoiok 10-23-2010 11:06 AM

Chmod is acting strange
 
I'm trying to change the restrictions to some normal text files and their result is not what is expected.

For example, when I put:

chmod 000 testfile.txt

on a file that is

-rwxrwxrwx,

it instead becomes

-r--r--r--.

It doesn't matter whether I do it with a root or the owner of the file, the result is the same.

Also, putting

chmod u-rwx testfile

results in the file becoming, again,

-r--r--r--.

Also, some doesn't have any effect, such as

chmod o-r testfile.

Even if I do this, the result is the same -rwxrwxrwx.


What is happening?

Thank you in advance...

eSelix 10-23-2010 11:21 AM

This file is probably on filesystem that does not support chmod. Chmod work only on ext2/3/4, etc. You can check your filesystem by "mount" command.

smoker 10-23-2010 01:12 PM

Why are you trying to give a file permissions that mean no-one can read it, not even the creator or root ? I think that chmod is behaving correctly here.

eSelix 10-23-2010 05:51 PM

That was only example. He even can't do "chmod o-r testfile". And, at least on Ubuntu, removing all permissions is allowed, root bypasses checking them. He definitely can't remove read permission from this file and permissions for user, group and others depend on each.

@sungchoiok:
Check if this behavior also concern other files in this directory. And as I suggested earlier check type of filesystem.

sungchoiok 10-23-2010 09:36 PM

Reply
 
Thank you for the generous replies..
At least, knowing that I'm not doing something completely stupid is comforting :)



There are five mounts, which are hda1, hda2, hda3, hda5, and sda1.
The first two 'hda's have my Windows 7 OS and the type is NTFS, so my DSL (Damn Small Linux) cannot even write to it.

The hda5 and sda1 is FAT. One is FAT32 and one is FAT, in my belief; I'm not at my computer right now, so I don't exactly know. Anyhow, I tried the same commands (and various others which I have not mentioned) and the results are more or less the same... either the files becoming, with some combinations, -r--r--r-- or with others, -rwxrwxrwx.


It's not a particulary important function, since I'm the only one using the computer and the members of my family (who are distrustful, lol) would gasp at a monitor filled with colorful text and no GUI, but nonetheless, it would be better to have them for practice, because I want to know more about Linux!


Once again, thank you!

John VV 10-24-2010 02:22 AM

the very very old fat ( 16 bit for win95 )
or the newer ( 1998) fat32 DO NOT support file permissions
NOR dose the ntfs partition format
there is no way to change them because they DO NOT have any permissions !!

eSelix 10-24-2010 11:11 AM

You can't change permission on FAT or NTFS with chmod, but during mounting you can choose owner, group and permissions for all files on given partition. Read proper section of "man mount".

John VV 10-24-2010 04:14 PM

there is no mount options on a "live" dsl cd

however a good question would be WHY are there fat and fat32 partitions on a windows7 ( 64 bit) os default on new hardware
or 32 bit on a vista upgrade

a very small HP or dell"recovery" partition yes but....

and why is the OP using dsl on a machine that has win 7 on it

replacing windows98 with DSL is onething

sungchoiok 10-25-2010 04:23 PM

Hmm. I take that you are "comdemming" me for installing Windows 7 on a FAT partition, but I never claimed that I did such a thing; the disk that has my Windows OS is NTFS.

Also, the FAT32 hard drive is the 5 GB partition that I made that is used by the Linux, not Windows.

Also, I decided to use the CD-booting Linux since I felt not ready to use a "full-scale" one.. any better alternatives you give me will be welcomed!



"You can't change permission on FAT or NTFS with chmod"... so what file system?


Thank you~

eSelix 10-25-2010 07:49 PM

Linux mainly use ext2, ext3 or ext4. If you have no data on that 5GB FAT32 partition you can reformat it by 'mkfs.ext2' Double check if you set proper device name, to not destroy your Windows.

chrism01 10-26-2010 01:12 AM

Linux & MS use different file permissions models. Don't try to use Linux chmod on any MS formatted disk ie FAT, NTFS.
Ususally on Linux the current default FS type is ext3, so the cmd

mkfs.ext3

would be used.
Some of the distros are now on ext4.
http://linux.die.net/man/8/mkfs.ext3


All times are GMT -5. The time now is 09:01 PM.