0

The command chmod -x filename doesn't work for me.

When I execute the command like this:

chmod -r filename
chmod -w filename
chmod -x filename

They complete without any error. But the permission of the files doesn't get affected.

3
  • 1
    Is your file on ntfs partition ?
    – g_p
    Oct 3, 2014 at 12:19
  • We need more information. Most common a NTFS or FAT partition, but there can be other reasons. File systems can be mounted noexec for example. What file, what file system, and what mount options?
    – Panther
    Oct 3, 2014 at 12:25
  • 1
    You've not specified a user target and: If none of these are given, the effect is as if a were given, but bits that are set in the umask are not affected. (man chmod). Try chmod u+x filename instead.
    – Pyrophorus
    Oct 3, 2014 at 12:29

2 Answers 2

1

I think you're confusing - with +. One adds a permission, the other removes it. Here's a silly little test with a new file that starts with global rwx (aka 0777):

$ install -m 777 <(echo) test; ls -l test
-rwxrwxrwx 1 oli oli 1 Oct  3 13:34 test

Let's remove read permissions with -r:

$ chmod -r test; ls -l test
--wx-wx-wx 1 oli oli 1 Oct  3 13:34 test

And add them back with +r:

$ chmod +r test; ls -l test
-rwxrwxrwx 1 oli oli 1 Oct  3 13:34 test
-1

Try executing your commands in sudo mode.

sudo chmod -r /path/to/file/filename
sudo chmod -w /path/to/file/filename
sudo chmod -x /path/to/file/filename

And make sure the account you are using has the right permissions to change those properties.

4
  • The command would fail if sudo was needed.
    – Pyrophorus
    Oct 3, 2014 at 12:31
  • You are wrong. I had several times that I didn't got any error without using sudo
    – Bram
    Oct 3, 2014 at 12:33
  • This answer is probably best posted as a comment as we do not have sufficient information to answer the question yet.
    – Panther
    Oct 3, 2014 at 12:35
  • laurent@Hoedic-U14:~$ chmod u+w /etc/wgetrc chmod: changing permissions of ‘/etc/wgetrc’: Operation not permitted
    – Pyrophorus
    Oct 3, 2014 at 12:42

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .