$ touch file && chmod a+x file
The explanations in other answers are superb. I want to add something that actually gives an answer to the question,
How can this be fixed?
with specific code. @Scott told how to do this,
you must create the file and then chmod
it.
The code in my answer shows how to do it and highlights it by putting it first.
More Explanation
To start out, for simplicity, I simply add to the touch
command given by the OP, specifically touch file
becomes touch file && chmod a+x file
.
someuser@someuser-MS-7816:/opt/lampp/htdocs/project$ touch file && chmod a+x file
someuser@someuser-MS-7816:/opt/lampp/htdocs/project$ mkdir dir
someuser@someuser-MS-7816:/opt/lampp/htdocs/project$ ls -l
total 4
drwxrwsrwx+ 2 someuser webs 4096 paź 31 13:35 dir
-rwxrwxrwx 1 someuser webs 0 paź 31 13:35 file
Here, I'll set up the same situation on my machine (Cygwin) to show that it works, then do the same on a virtual Ubuntu box to show the differences in the setup. (Note that the actual command for fixing things doesn't change, I simply want to show some differences that might come up with setfacl
, as well as to verify for myself that it works.)
$ uname -a | head -n 1
CYGWIN_NT-10.0 my_machine 2.10.0(0.325/5/3) 2018-02-02 15:16 x86_64 Cygwin
$ pwd
/home/me
$ mkdir user294034
$ setfacl -m u::rwx user294034/
$ setfacl -m d:u::rwx user294034/
$ setfacl -m g::rwX user294034/
setfacl: illegal acl entries
$ setfacl -m g::rws user294034/
setfacl: illegal acl entries
$ # I guess I don't know how to get the `flags: -s-` on Cygwin
$ setfacl -m g::rwx user294034/
$ setfacl -m d:g::rwx user294034/
$ setfacl -m o::rwx user294034/
$ setfacl -m d:o::rwx user294034/
$ cd user294034
$ getfacl .
# file: .
# owner: me
# group: my_group
user::rwx
group::rwx
other:rwx
default:user::rwx
default:group::rwx
default:other:rwx
$ # I admitted that I don't know how to get `# flags: -s-`
$ umask
0022
$ umask 0000
$ touch file
$ mkdir dir
$ # Here, we'll see the same problem
$ ls -l
total 0
drwxrwxrwx+ 1 me my_group 0 Sep 18 20:31 dir
-rw-rw-rw- 1 me my_group 0 Sep 18 20:31 file
$ # Here, we'll fix the problem
$ rm file
$ touch file && chmod a+x file
$ ls -l
total 0
drwxrwxrwx+ 1 me my_group 0 Sep 18 20:31 dir
-rwxrwxrwx 1 me my_group 0 Sep 18 20:32 file
user
,group
, andother
ACL entries. If you have default ACL entries for named users or groups, they'll be inherited as specified, right? – Barmar Oct 31 '14 at 20:26