In Ubuntu 18.04, I can create a file as one user in /tmp, and write to it as user root (despite the sticky bit being set on /tmp).

In Ubuntu 20.04, I get a Permission Denied error as user root.

Ubuntu 18.04:

# As user "ubuntu":
touch /tmp/tmplock

# As user "root":
echo "foo" > /tmp/tmplock

cat /tmp/tmplock
# Outputs "foo"

ls -lah /tmp
drwxrwxrwt 32 root   root    20K Jun 16 18:36 .
-rw-rw-r--  1 ubuntu ubuntu    4 Jun 16 18:36 tmplock

Ubuntu 20.04:

# As user "ubuntu":
touch /tmp/tmplock

# As user "root":
echo "foo" > /tmp/tmplock
# Outputs: bash: /tmp/tmplock: Permission denied

ls -lah /tmp
drwxrwxrwt 12 root   root   4.0K Jun 16 18:15 .
-rw-rw-r--  1 ubuntu ubuntu    0 Jun 16 18:14 tmplock

I can't find any information on if this is related to the sticky bit, or an underlying Linux kernel change, or anything.

Does anyone know what can explain the change in behavior?

2 Answers 2


To change the behavior back to the 18.04 default:

sudo sysctl fs.protected_regular=0  

See the accepted answer to


Sigh, sometimes the cure is worse than the disease.

  • Thanks for this. Beyond running that command on every login, is there a way to make the setting permanent? Seems it goes back to 2 every time I reboot.
    – IpsRich
    Aug 3, 2021 at 11:01
  • @IpsRich See the other answer for a permanent change to this new system default. It's a security issue, so you should understand the consequences of the change.
    – ubfan1
    Aug 3, 2021 at 15:43
  • Thanks @ubfan1 - don't know how I missed that! I've decided to try to avoid /tmp where I can instead, and use the TMPDIR environment variable to tell things like tmpfile to use e.g. ~/tmp instead.
    – IpsRich
    Aug 4, 2021 at 6:27

The root user should always be able to edit any and all files. The only correct response is to disable the sysctl fs.protected_regular setting until it gets fixed (i.e. so that root can edit anything on the system).

The other answer has a temporary solution that doesn't stick between reboots.

If you want to make the fs.protected_regular=0 change permanent between reboots, edit the /usr/lib/sysctl.d/protect-links.conf file.

Make the above change, then save and reboot to verify that it is working as expected.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.