-2

I am using Kali as root user. I did setup an atftp server in a folder (created and owned by root) and gave 666 permission on that folder. But I noticed users get permission denied error while uploading into atftp. Same was happening with FTP server. So to perform some tests, I created a temporary directory, assigned it 666 permission, tried to create a file using unpriviledged user and I got 'Permission denied'. Then I changed the permission to 777 and repeated the same process. This time file got created.

Case 1: 666 permission

root@kali:~/temp# chmod 666 .
root@kali:~/temp# ls -la
total 8
drw-rw-rw-  2 root root 4096 May  7 00:32 .
drwxr-xr-x 21 root root 4096 May  7 00:32 ..
root@kali:~/temp# su temp
$ touch a
touch: cannot touch 'a': Permission denied

Case 2: 777 permission

root@kali:~/temp# chmod 777 .
root@kali:~/temp# ls -la
total 8
drwxrwxrwx  2 root root 4096 May  7 00:32 .
drwxr-xr-x 21 root root 4096 May  7 00:32 ..
root@kali:~/temp# su temp
$ touch a
$ ls -la
total 8
drwxrwxrwx  2 root root 4096 May  7 00:32 .
drwxr-xr-x 21 root root 4096 May  7 00:32 ..
-rw-r--r--  1 temp temp    0 May  7 00:32 a
$

How come adding additional x permission is helping with writing files even when folder had w in both cases?

eckes
  • 845
  • 9
  • 21

1 Answers1

3

Execute bit on directories grant permission to enter into it, see this answer

The execute bit (x) allows the affected user to enter the directory, and access files and directories inside

666 has no execute bit whereas 777 does.

Petter H
  • 3,443
  • 1
  • 16
  • 19