LFCS 5.2: Environment profiles
Setting variables, PATH entries and aliases in the right startup files: for everyone, for one user, and for users created later.
Before you start
The lab creates users erin and frank (password Lab-Pass-1, shell
bash) and a directory /opt/tools/bin with a small tool in it. So that
le-lab check can test ssh sessions, it puts a lab key in their
~/.ssh/authorized_keys. Reset puts /etc/skel, /etc/profile.d,
/etc/environment, the system bashrc and root's own startup files back as
they were.
Tasks
- Set
COMPANY=examplefor every user's login shell, without editing/etc/profile. Test it withsudo -iu erin printenv COMPANY. - Give every new user an alias
lt='ls -ltr'and aREADMEfile in their home directory. Test it withuseradd -m testuser, thensudo -iu testuser bash -ic 'alias lt'andls /home/testuser; removetestuseragain afterwards. - Add
/opt/tools/bintoerin'sPATHpermanently, and only to hers:frank'sPATHmust not have it. - Set
HTTP_PROXY=http://proxy.example.org:3128for every session, includingssh host command. Test it withssh erin@localhost printenv HTTP_PROXY.
Hints
/etc/profile.d/*.sh; check withsudo -iu USER printenv./etc/skeland the.bashrcin it;useradd -m.~/.bash_profile(RHEL family) or~/.profile(Debian, Ubuntu)./etc/environment, read bypam_env; noexport, no$VARIABLES.