Questions tagged [chmod]

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 sticky bits.

Change the file modes.

External reference

chmod specification (The Open Group Base Specifications Issue 7, 2018 edition)

594 questions
172
votes
10 answers

How to chmod without /usr/bin/chmod?

Today I was told a tale by a Unix trainer 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 recover chmod in this case and make it executable again? Let's…
Sundar R
  • 1,578
  • 2
  • 10
  • 7
163
votes
4 answers

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.
stefan.at.kotlin
  • 3,007
  • 7
  • 32
  • 35
94
votes
6 answers

Understanding UNIX permissions and file types

I've never really got how chmod worked up until today. I followed a tutorial that explained a big deal to me. For example, I've read that you've got three different permission groups: owner (u) group (g) everyone (o) Based on these three groups,…
Peter
  • 1,011
  • 1
  • 10
  • 18
88
votes
5 answers

'chmod g+s' command

Hello I want to understand the role of the chmod g+s command in Unix. I also would like to know what it does in this particular context: cd /home/canard; touch un; chgrp canard .; chmod g+s .; touch deux ; I understand all the commands roles except…
otus
  • 981
  • 1
  • 6
  • 3
79
votes
6 answers

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-- ?
cnd
  • 1,893
  • 5
  • 18
  • 28
69
votes
5 answers

How to create a Samba share that is writable from Windows without 777 permissions?

I have a path on a Linux machine (Debian 8) which I want to share with Samba 4 to Windows computers (Win7 and 8 in a domain). In my smb.conf I did the following: [myshare] path = /path/to/share writeable = yes browseable = yes guest ok = yes public…
Foo Bar
  • 3,462
  • 7
  • 21
  • 28
64
votes
4 answers

Change permissions for a symbolic link

I have a symlink with these permissions: lrwxrwxrwx 1 myuser myuser 38 Aug 18 00:36 npm -> ../lib/node_modules/npm/bin/npm-cli.js* The symlink is located in a .tar.gz archive. Now when I unpack the tar.gz archive using maven the symlink is no…
u123
  • 951
  • 2
  • 10
  • 17
63
votes
3 answers

Create file in folder: permission denied

I have a problem copying files to a directory on Ubuntu 12.04. I create a directory in the home directory so that the path where I want to copy to is: /home/sixven/camp_sms/inputs But when ini run the following command in the terminal to create a…
franvergara66
  • 1,119
  • 3
  • 10
  • 10
63
votes
3 answers

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 access file.txt : no such file or directory So I add…
user58412
60
votes
1 answer

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 chmod 2777?
prosseek
  • 8,418
  • 16
  • 47
  • 43
47
votes
1 answer

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, everything under /path/to/parentdir # Permissions…
Matthew
  • 1,041
  • 2
  • 11
  • 16
41
votes
3 answers

How to set the permission drwxr-xr-x to other folders?

I have few directores inside a folder like below - teckapp@machineA:/opt/keeper$ ls -ltrh total 8.0K drwxr-xr-x 10 teckapp cloudmgr 4.0K Feb 9 10:22 keeper-3.4.6 drwxr-xr-x 3 teckapp cloudmgr 4.0K Feb 12 01:44 data I have some other folder as…
user1950349
  • 771
  • 2
  • 9
  • 16
40
votes
5 answers

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. I have attempted to restart into recovery mode,…
jett
  • 575
  • 2
  • 5
  • 8
38
votes
9 answers

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 chmod u=rw,go=r ...? PS: I'm not looking for an…
l0b0
  • 50,672
  • 41
  • 197
  • 360
33
votes
2 answers

Difference between chmod vs ACL

I understand chmod and chown and how the permission bits work, but there is another permission system inside Linux, ACL with setfacl and getfacl, so this makes me wonder. What's the difference between those two permission control systems? Do they…
mFeinstein
  • 513
  • 2
  • 7
  • 12
1
2 3
39 40