/etc/profile

QNX SDP8.0User's GuideUser

The login shell executes /etc/profile if this file exists and is readable. This file does the shell setup that applies to all users, so you'll be interested in it if you're the system administrator; you need to log in as root in order to edit it.

The /etc/profile file:

  • sets the HOSTNAME and SYSNAME environment variables if they aren't already set
  • adds the appropriate directories to the PATH environment variable (the root user's PATH includes directories such as /sbin that contain system executables)
  • sets up the file-permission mask (umask); see File ownership and permissions in Working with Files
  • displays the date you logged in, the message of the day (found in /etc/motd), and the date you last logged in
  • sets the TMPDIR environment variable to /tmp if it isn't already set
  • runs any scripts in the /etc/profile.d directory as dot files (i.e., instead of executing them as separate shells, the current shell loads their commands into itself). For more information about dot files, see . (dot) builtin command in the documentation for ksh in the Utilities Reference.

If you have a script that you want to run whenever anyone on the system runs a login shell, put it in the /etc/profile.d directory. You must have root-level privileges to add a file to this directory.

For example, if you need to set global environment variables or run certain tasks when anyone logs in, then this is the place to put a script to handle it. If you're using sh as your login shell, make sure that the script has a .sh extension.

Page updated: