What is the difference between the following su commands?
su -m
su -p
I know that both flags are used to preserve the current environment but I don’t know the differences if there are any.
There are no differences, they are just different options for the same behaviour. They probably come from different older versions of su
that implemented one of these options with the same behaviour.
From the man page:
-m, -p, --preserve-environment
Preserve the current environment, except for:
$PATH
reset according to the /etc/login.defs options ENV_PATH or
ENV_SUPATH (see below);
$IFS
reset to “<space><tab><newline>”, if it was set.
If the target user has a restricted shell, this option has no
effect (unless su is called by root).
su --help
give an difference for the two? – Anthon Jun 11 '13 at 19:33