chmod is used to change the commonly used read, write, and execute permissions on files. It can change these permission bits for the file owner, the file's group owner, and everyone else. It can also change the more esoteric ‘permissions’ (attributes, reall) like set-user-ID, set-group-ID, and ...

learn more… | top users | synonyms

99
votes
6answers
6k views

How to chmod without /usr/bin/chmod?

Today I was told a tale by a Unix trainer, a tale where the root password got leaked to the students, and one of the fellas removed the execute permission from /usr/bin/chmod itself. How do you ...
27
votes
4answers
3k views

How to recover from a chmod -R 000 /bin?

And now I am unable to chmod it back.. or use any of my other system programs. Luckily this is on a VM I've been toying with, but is there any way to resolve this? The system is Ubuntu Server 12.10. ...
22
votes
9answers
4k views

Why use `chmod 644` instead of `chmod u=rw,go=r,…`?

I've been working on *nix for a few years now, and one of the things I just can't get used to is octal permissions in code. Is there some other reason than line length to prefer chmod 644 ... over ...
17
votes
1answer
260 views

Why does chmod require disk space? Not-in-place algorithm?

I try to chmod some files and I get the error "disk quota exceeded": It's true that I don't have that much space remaining in the filesystem where I use chmod, ...
16
votes
1answer
5k views

What is the first chmod octal digit in a four-digit value for?

Sometimes I see chmod commands that use four octal digits instead of three -- what is the optional first digit for? For example, chmod 777 is equivalent to chmod a+rwx; what's the same command for ...
16
votes
2answers
2k views

How to apply recursively chmod directories without affecting files?

After I apply chmod -R to a directory, permissions are changed for everything within (files and directories). How can I add execute/search (x) permissions to directories without modifying the files?
13
votes
2answers
7k views

Get the chmod numerical value for a file

In FreeBSD and also in Linux, how can I get the numerical chmod value of a file? For example, 644 instead of -rw-r--r--? I need an automatic way for a Bash script.
13
votes
3answers
2k views

I accidentally chmod -R +x on a directory. How do I restore the correct permissions?

Well, to be specific, it was chmod -R 755. Now every file is executable, which I don't want. I am thinking that I should look at the first two bytes of each file for the #!, but will this cover ...
12
votes
3answers
4k views

Wrongly set chmod / 777. Problems?

I was trying to run chmod -R 777 ./ but ended up typing chmod -R 777 / and set 777 on my entire machine. What can go wrong? How can I fix it?
9
votes
4answers
6k views

Is there a web based converter between rwx and the octal version?

I can never remember what the conversion is from something like rw-r--r-- to 644. Is there a simple web based converter between the 2?
9
votes
3answers
5k views

How to get permission number by string : -rw-r--r--

I need to set the same chmod, how to get number for -rw-r--r-- ?
8
votes
5answers
2k views

Can't apply chmod to a file

I have a file on my HDD, cd /media/celebisait/5AC69788C6976355 There is my file called myFile.tar.gz. I do als -l, -rw------- 2 celebisait celebisait 1387745311 Jun 6 2013 myFile.tar.gz ...
8
votes
1answer
218 views

Make group permissions same as user permissions

I want to set the group permissions for all files and subdirectories within a certain parent directory to whatever the user permission setting for that specific file or directory is. For example, ...
8
votes
3answers
21k views

Recursive chmod only folders or only files via script or nautilus menu?

This has been discussed before here. What I'd like to know is how to turn these: Recursive chmod only files within this folder: find . -type f -exec chmod 0600 {} \; Recursive chmod only folders ...
7
votes
2answers
653 views

How are file permissions calculated?

Using chmod I could set the permissions for a file, but if the parent ( .. ) directory had conflicting permissions, what would happen? And if I create a new file, using touch or something similiar, ...
6
votes
1answer
3k views

Is NTFS under linux able to save a linux file, with its chown and chmod settings?

I'm having some doubts about how to install and allow linux to correctly read/write to a NTFS formated harddrive used as backup of various machines (windows included, that's how I need NTFS). For now ...
6
votes
4answers
2k views

When does chmod fail?

Under what circumstances will chmod fail? I looked at the man page but it only specifies usage and doesn't go into details about what circumstances it won't work in. I'd assume chmod will work if: ...
5
votes
4answers
977 views

recursively chmod

I was trying to chmod folders and files with: find . -type d -exec chmod 755 {} \; find . -type f -exec chmod 644 {} \; But I was wondering: How to do it in one line using find and excluding the ...
5
votes
3answers
2k views

Write access without read access

Is it possible for a user to have a write access to a file and not be able to read it? How is it possible? I tried the following commands: debianbox@debian:~/posix/io$ touch filetest ...
5
votes
4answers
766 views

chmod recursive permission on thousands of files

This is a more general question about 'chmoding' recursively. I have this script which at some point needs to change the permissions recursively in a folder which has a few hundred thousand files. ...
5
votes
2answers
2k views

If I change permissions on a tar file, will that apply to the files inside it?

I have a script that runs regularly via cron, that creates a tar.gz file for the purpose of backing up a directory. For reasons beyond my control, the only user who can execute the script via cron is ...
5
votes
1answer
2k views

what is the difference between “chmod 775” and “chmod 2755”?

Question What is the difference between "chmod 775" and "chmod 2755" ?
5
votes
3answers
459 views

Unix users, groups, and permissions

I don't understand unix users, groups, permissions, etc. For example, things managed by the chmod, chgrp, usermod, groupadd, etc. commands. How do all these things work?
5
votes
2answers
469 views

vim: create file with +x bit

Is there any way to set +x bit on script while creating? For example I run: vim -some_option_to_make_file_executable script.sh and after saving I can run file without any additional movings. ps. ...
5
votes
2answers
271 views

Is it possible to represent the +X symbolic permission with an octal value?

Is it possible to represent the +X symbolic permission with an octal value? The chmod(1) man page says: execute/search only if the file is a directory or already has execute permission for some ...
5
votes
2answers
2k views

recursively change file permission but not directories?

I was doing a mass recursive change of permissions of some files that I had migrated to a unix system. I changed them to ug+rw, but then I found that I could not traverse subdirectories. I looked at ...
5
votes
2answers
61 views

Is there a flag corresponding to x/X, but for s with chmod on Linux?

When using chmod (in my case part of coreutils 8.12), and recursively setting the x bit, there exists the convenient X (uppercase letter x), to set the bit only on directories. So if you wanted to ...
5
votes
1answer
713 views

Can't get directory listing of folder I have permissions to

I was having some permission problems and used the following command on directory Media: chmod -R ugo+r Media It didn't help so then I did: chmod -R 775 Media Now I get this error when I try to ...
4
votes
4answers
2k views

Is chmod behavior wrong for symlinks?

Recently we had a problem on a Red Hat Linux box with many users: the /usr/bin/sudo binary has lost its sticky bit. Work was blocked until root user fix it (we need sudo for deploying and testing). ...
4
votes
2answers
2k views

Why can't I run programs on another partition in Linux?

So for convenience, I store all my data on my Windows partition so that I can access my data easily from both Linux and Windows. However, I tried compiling a C++ program with g++, and found out that I ...
4
votes
1answer
8k views

chmod: What does the `+a` parameter mean?

I was following a tutorial and it told me to run sudo chmod +a "SOME_PARAMS" some/dir I was surprised to see that fail telling me chmod: invalid mode: `+a' So I wonder: What does the +a mode ...
4
votes
2answers
409 views

Directory special permission problem

When I write: chmod g=rws,u=rwx,o=rx folder_name I get: drwxrwSr-x But S is not the same as s, right?
4
votes
1answer
227 views

chmod does not change permissions of certain directories

System file: ext4 I changed the owner of files to apache: with the command: chown -R apache: wp.localhost Then, I could not change the permissions of directories in wp.localhost nor the ...
4
votes
3answers
172 views

restrict student account permissions, give faculty access

I have set up two user groups, students and faculty on Ubuntu 12.04 and created a number of students and faculty accounts. The problem is a student can currently see & read all of the files of a ...
4
votes
1answer
426 views

Clear setuid permission using numeric mode

On an Ubuntu Linux I have a directory with the setuid bit set (drwsr-xr-x) which I want to unset. Neither chmod 755 nor chmod 0755 nor chmod 00755 (I though maybe the first 0 is interpreted as just ...
4
votes
1answer
1k views

copying device nodes

I'm trying to transfer a working Linux installation to a new larger disk, so I've attached the new disk on a USB port, partitioned it and created filesystems. While copying all the files over I hit a ...
4
votes
1answer
110 views

chmod doesn't work on folder 'd — — ---' permissions

In /var/www I've got a folder: d--------- 2 www-data www-data 4096 May 20 2012 update reported by ls -la. I'm logged in as root, but I can't change permissions or ownership. chown and chmod ...
3
votes
2answers
3k views

Why does “chmod 1777” and “chmod 3777” both set the sticky bit?

To set the sticky bit on a directory, why do the commands chmod 1777 and chmod 3777 both work?
3
votes
4answers
324 views

Run a given command on every subpath of a long path

Say I have a long path such as: /a/b/c/d/e/f I would like to run a command only on each of the subpaths of the path: e.g. If my command is cmd, I am looking for a one-liner that can do (perhaps ...
3
votes
3answers
1k views

How can I revert a chmod on the etc directory?

I accidentally executed the following command on the etc directory: sudo chmod -R 700 /etc I know that I have done something very wrong. My terminal now prints: I have no name!@ubuntu: /$ How ...
3
votes
2answers
554 views

How to make a folder request root password to view execute?

I am running Ubuntu 10.04 LTS. I want to use my laptop to play music in a party. MY screensaver does not need a password to deactivate. I would like to allow people to use my computer to play the ...
3
votes
2answers
105 views

Accidentaly changed the permissions in / [duplicate]

Accidentally did : chmod -R 777 / Now, RHEL 6 is not booting up. What do I do? I have a DVD and can go into rescue mode. Can someone explain how do I reset all the permissions ? Update ...
3
votes
4answers
1k views

permissions 755 on /home/<user>/

I am wondering why by default my directory /home/<user>/ has permissions set to 755. This allows other users to enter into directories and read files in my home. Is there any legitimate reason ...
3
votes
1answer
120 views

What is chmod 6050 good for

Recently I came across to command: chmod -R 6050 /usr/lib/hadoop-yarn/bin/container-executor I don't know what that mean? I know file permissions like 777 etc. in a mode rwx for owner group others. ...
3
votes
2answers
421 views

Chmod by Letters Vs Numbers

I was recently asked by a colleague to use chmod with letters instead of numbers. Apart from the obvious readability advantage is there any particular reason to use letters over numbers ?
3
votes
1answer
168 views

How to create a folder which will change its contents’ ownership to what the folder has?

In a GNU/Linux OS there is no way to change ownership of a file until you are root. But what if I want to hide my system’s username e.g. before sending a file to someone, because some things like tar ...
3
votes
1answer
285 views

chmod + silent mode + how force exit code 0 in spite of error

Is it possible execute chmod and ignore error from command Example ( remark file.txt not exsist to show the example ) When I type chmod 777 file.txt I get error on the output chmod: cannot ...
3
votes
1answer
170 views

How to let a user execute a script owned by root? Setuid doesn't seem to work anymore [duplicate]

I have some bash scripts that I use with the user 'root' to manage iptable rules. The problem is that I want these things at the same time: The script must be owned by root Permissions must be 700 ...
3
votes
1answer
838 views

Giving SSH users read-only access to a directory

I'm running Fedora 17 and I want to give several users access to files on my secondary hard drives on /run/media/haukur/. This is what I initially did: chmod -R 755 /run/media/ But every time I ...
3
votes
1answer
363 views

Vanishing permission on device file (RHEL 6.1)

I want to set world read/write permissions on a raw block device file (yeah, I know). I can set the permission to 666, but it goes back to 660 immediately after I touch it or write to it. Why? ...