Linux chmod not changing permissions

Changing File Permissions Linux

The chmod command is used to change the permissions of a file or directory. To use it, you specify the desired permission settings and the file or files that you wish to modify. There are two ways to specify the permissions, but I am only going to teach one way.

It is easy to think of the permission settings as a series of bits (which is how the computer thinks about them). Here’s how it works:

rwx rwx rwx = 111 111 111 rw- rw- rw- = 110 110 110 rwx --- --- = 111 000 000 
rwx = 111 in binary = 7 rw- = 110 in binary = 6 r-x = 101 in binary = 5 r-- = 100 in binary = 4 

(rwxrwxrwx) No restrictions on permissions. Anybody may do anything. Generally not a desirable setting.

(rwxr-xr-x) The file’s owner may read, write, and execute the file. All others may read and execute the file. This setting is common for programs that are used by all users.

(rwx——) The file’s owner may read, write, and execute the file. Nobody else has any rights. This setting is useful for programs that only the owner may use and must be kept private from others.

(rw-rw-rw-) All users may read and write the file.

(rw-r—r—) The owner may read and write a file, while all others may only read the file. A common setting for data files that everybody may read, but only the owner may change.

(rw——-) The owner may read and write a file. All others have no rights. A common setting for data files that the owner wants to keep private.

Directory permissions

The chmod command can also be used to control the access permissions for directories. In most ways, the permissions scheme for directories works the same way as they do with files. However, the execution permission is used in a different way. It provides control for access to file listing and other things. Here are some useful settings for directories:

(rwxrwxrwx) No restrictions on permissions. Anybody may list files, create new files in the directory and delete files in the directory. Generally not a good setting.

(rwxr-xr-x) The directory owner has full access. All others may list the directory, but cannot create files nor delete them. This setting is common for directories that you wish to share with other users.

Читайте также:  Снизить чувствительность мыши linux

(rwx——) The directory owner has full access. Nobody else has any rights. This setting is useful for directories that only the owner may use and must be kept private from others.

Use this command on terminal

to grant all access (Read, Write, Execute).

If you don’t need execution access and need only right access then

In general, chmod commands take the form:

chmod options permissions filename 

If no options are specified, chmod modifies the permissions of the file specified by filename to the permissions specified by permissions.

permissions defines the permissions for the owner of the file (the user ), members of the group who owns the file (the group ), and anyone else ( others ). There are two ways to represent these permissions: with symbols (alphanumeric characters), or with octal numbers (the digits 0 through 7).

Here the digits 7, 5, and 4 each individually represent the permissions for the user, group, and others, in that order. Each digit is a combination of the numbers 4, 2, 1, and 0:

  • 4 stands for «read»,
  • 2 stands for «write»,
  • 1 stands for «execute», and
  • 0 stands for «no permission.»

So 7 is the combination of permissions 4+2+1 (read, write, and execute), 5 is 4+0+1 (read, no write, and execute), and 4 is 4+0+0 (read, no write, and no execute).

enter image description here

I think, you got the idea. For more detail read man entry of chmod (this page).

Use chmod command, as a example ;

To change the owner of the file use chown as in

Old post, but maybe somebody will still find useful my answer.

If you want to give access to all users (or «other than owner» — meaning last digit ) you can run next command:

 cd sudo find . -perm 750 -exec chmod 757 <> +; 

It will find all files with permission 750 (read + write + execute for owner user / read + execute for group owner / nothing for other users) and by changing just last digit, you give the same permission as owner, to all other users. (last 7 meaning read + write + execute for other users)

Of course, you can run the command with different digits, but just replace last digit with the value of first on. For example, run next commands to ensure that all file that are read + write + executable for owner , will have the same right access for ‘other’:

sudo find . -perm 700 -exec chmod 707 <> +; sudo find . -perm 701 -exec chmod 707 <> +; sudo find . -perm 702 -exec chmod 707 <> +; sudo find . -perm 703 -exec chmod 707 <> +; sudo find . -perm 704 -exec chmod 707 <> +; sudo find . -perm 705 -exec chmod 707 <> +; sudo find . -perm 706 -exec chmod 707 <> +; 

If you will continue in this way (having one line for every combination 7xx), you will end up running 77 commands. Which is a bit too much. right?

Читайте также:  Check crontab status linux

Luckily, there can be done a trick. You can use «-» in front of the number that meaning that the file has «at least» that number. For example, running:

will return all files that have permission 775, 776 and 777. Another example is running:

that will return files with permision 770, 771 . 777.

In our case, we are care only about first digit and we want to change last digit with its value, so there can used:

sudo find . -perm 700 -exec chmod 777 <> +; 

**> This will work only for files on which owner has read + write +

execute. If you will try above command with 600 instead of 700, keep in mind that it will return also files with permission 6xx and files with permission 7xx.**

Источник

Unable to change the permission of a file using chmod

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?

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.

2 Answers 2

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):

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 
$ chmod +r test; ls -l test -rwxrwxrwx 1 oli oli 1 Oct 3 13:34 test 

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.

This answer is probably best posted as a comment as we do not have sufficient information to answer the question yet.

laurent@Hoedic-U14:~$ chmod u+w /etc/wgetrc chmod: changing permissions of ‘/etc/wgetrc’: Operation not permitted

You must log in to answer this question.

Hot Network Questions

Subscribe to RSS

To subscribe to this RSS feed, copy and paste this URL into your RSS reader.

Читайте также:  Права доступа ко всем файлам папки linux

Site design / logo © 2023 Stack Exchange Inc; user contributions licensed under CC BY-SA . rev 2023.7.14.43533

Ubuntu and the circle of friends logo are trade marks of Canonical Limited and are used under licence.

By clicking “Accept all cookies”, you agree Stack Exchange can store cookies on your device and disclose information in accordance with our Cookie Policy.

Источник

chmod 0775 is not changing permissions

I have an Ubuntu larval AWS instance running and I am trying to change some permissions: When I visit my IP address for my newly installed site I get this warning:

The /var/www/seekadventure.net directory is not writable. Please chmod this directory and its contents to 0775. 
ubuntu@ip-172-31-80-211:/var/www$ sudo chmod 0775 /var/www/seekadventure.net ubuntu@ip-172-31-80-211:/var/www$ ls -la total 20 drwxr-xr-x 5 root root 4096 Dec 14 05:32 . drwxr-xr-x 14 root root 4096 Feb 27 2018 .. drwxr-xr-x 12 www-data www-data 4096 Feb 28 2018 laravel5.6 drwxrwxr-x 5 root root 4096 Dec 14 05:34 seekadventure.net drwxr-xr-x 3 www-data www-data 4096 Nov 8 13:32 utility ubuntu@ip-172-31-80-211:/var/www$ 

And as you can see from the ls -la command its still root root Any ideas why the permissions are not changing? Update: While doing further investigation I saw the mount command could show more useful information:

ubuntu@ip-172-31-80-211:/var/www$ mount sysfs on /sys type sysfs (rw,nosuid,nodev,noexec,relatime) proc on /proc type proc (rw,nosuid,nodev,noexec,relatime) udev on /dev type devtmpfs (rw,nosuid,relatime,size=2014540k,nr_inodes=503635,mo de=755) devpts on /dev/pts type devpts (rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmod e=000) tmpfs on /run type tmpfs (rw,nosuid,noexec,relatime,size=404508k,mode=755) /dev/xvda1 on / type ext4 (rw,relatime,discard,data=ordered) securityfs on /sys/kernel/security type securityfs (rw,nosuid,nodev,noexec,relat ime) tmpfs on /dev/shm type tmpfs (rw,nosuid,nodev) tmpfs on /run/lock type tmpfs (rw,nosuid,nodev,noexec,relatime,size=5120k) tmpfs on /sys/fs/cgroup type tmpfs (ro,nosuid,nodev,noexec,mode=755) cgroup on /sys/fs/cgroup/systemd type cgroup (rw,nosuid,nodev,noexec,relatime,xa ttr,release_agent=/lib/systemd/systemd-cgroups-agent,name=systemd) pstore on /sys/fs/pstore type pstore (rw,nosuid,nodev,noexec,relatime) cgroup on /sys/fs/cgroup/cpuset type cgroup (rw,nosuid,nodev,noexec,relatime,cpu set) cgroup on /sys/fs/cgroup/hugetlb type cgroup (rw,nosuid,nodev,noexec,relatime,hu getlb) cgroup on /sys/fs/cgroup/cpu,cpuacct type cgroup (rw,nosuid,nodev,noexec,relatim e,cpu,cpuacct) cgroup on /sys/fs/cgroup/perf_event type cgroup (rw,nosuid,nodev,noexec,relatime ,perf_event) cgroup on /sys/fs/cgroup/memory type cgroup (rw,nosuid,nodev,noexec,relatime,mem ory) cgroup on /sys/fs/cgroup/pids type cgroup (rw,nosuid,nodev,noexec,relatime,pids) cgroup on /sys/fs/cgroup/freezer type cgroup (rw,nosuid,nodev,noexec,relatime,fr eezer) cgroup on /sys/fs/cgroup/net_cls,net_prio type cgroup (rw,nosuid,nodev,noexec,re latime,net_cls,net_prio) cgroup on /sys/fs/cgroup/devices type cgroup (rw,nosuid,nodev,noexec,relatime,de vices) cgroup on /sys/fs/cgroup/blkio type cgroup (rw,nosuid,nodev,noexec,relatime,blki o) systemd-1 on /proc/sys/fs/binfmt_misc type autofs (rw,relatime,fd=31,pgrp=1,time out=0,minproto=5,maxproto=5,direct) mqueue on /dev/mqueue type mqueue (rw,relatime) hugetlbfs on /dev/hugepages type hugetlbfs (rw,relatime) debugfs on /sys/kernel/debug type debugfs (rw,relatime) fusectl on /sys/fs/fuse/connections type fusectl (rw,relatime) lxcfs on /var/lib/lxcfs type fuse.lxcfs (rw,nosuid,nodev,relatime,user_id=0,grou p_id=0,allow_other) tmpfs on /run/user/1000 type tmpfs (rw,nosuid,nodev,relatime,size=404508k,mode=7 00,uid=1000,gid=1000) ubuntu@ip-172-31-80-211:/var/www$ 

Источник

Оцените статью
Adblock
detector