I'm using Devuan ASCII (which is more or less Debian 9, Stretch). Now, my /var/log/auth.log has a bunch of these entries:

Jan  6 09:45:01 mybox CRON[20951]: pam_env(cron:session): Unable to open env file: /etc/environment: No such file or directory
Jan  6 09:45:01 mybox CRON[20951]: pam_unix(cron:session): session opened for user root by (uid=0)

which apparently get generated when I su.

  1. Why is cron/pam_env/pam_unix trying to open that file in the first place, rather than checking whether it exists?
  2. If they legitimately expect it, why isn't it there?
  3. What should I do about this?

Answering all of your questions

  1. Why is cron/pam_env/pam_unix trying to open that file in the first place?

See BUG #646015. In some cases (like locale related stuff) this file is deprecated. But it is still used system-wide, and log is made whenever it is missing.

  1. If they legitimately expect it, why isn't it there?

Cause maybe the bug isn't fixed after all. Steve Langasek (BUG #646015) said it is, and new systems should create that file using postinst scripts the same way old systems being upgraded should already have that file.

  1. What should I do about this?
  • Run dpkg-reconfigure libpam-modules and see if it will create the file through its postinst script.
  • If that does not work, create the file manually with touch /etc/environment

It's also interesting to report your issue to the Devuan Project with details of the problem and your setup since this issue was resolved before the Debian/Devuan fork happened.

  • dpkg-reconfigure will not help, and nor will apt install --reinstall, because the file is only created on fresh install or upgrades from a very old version of libpam-modules. There is an alternative method, but considering how easy it is to create the file manually, and how critical PAM is to the working of the system, I think you may as well use the manual approach. – sourcejedi Jun 11 at 12:29
  • I got the error on a Debian system. /etc is tracked by etckeeper, but unfortunately I don't have any record of the file. OTOH a clean debootstrap --variant=minbase stretch does create etc/environment. So, I wonder if there is or was a problem with the installer somewhere. – sourcejedi Jun 11 at 12:37

An inelegant but perfectly valid solution is to give those modules what they want: As root, execute

touch /etc/environment

and to make sure the permissions are right, just in case:

chmod 644 /etc/environment
  • 2
    Note that this behavior is completely normal. The pam_env is expected to look for /etc/environment and that's the default way that the /etc/environment file is read, at least on Linux systems. – terdon Jan 7 at 11:37
  • I have it here: cat /etc/environment QT_QPA_PLATFORMTHEME=qt5ct – Rui F Ribeiro Jan 7 at 11:41
  • @terdon: Looking for it is fine, assuming it exists is not fine. It's either a bug in pam_env or an issue with Debian. – einpoklum Jan 7 at 12:04
  • Sounds more like a bug of the specific distro. That is a standard file and it exists in Debian. But is this actually a problem? Does it cause any issue other than a message in the log? – terdon Jan 7 at 12:06

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.