It is commonly known that for some script being executed after logging in, one must write path to the script in /etc/rc.local
.
No, that's false and is not commonly known at all. Aside from the fact that /etc/rc.local
is a double backwards compatibility mechanism for a bootstrap system that has been superseded twice over, or even three times over, on most current operating systems, that one should really forget about; there's also the detail that /etc/rc.local
does not execute after logging in. /etc/rc.local
is not even executed connected to a terminal with some operating systems' backwards compatibility mechanisms.
What executes after TUI login varies according to what shell you are using, and in what mode you are using it. The Bourne Again and Z shells source a whole bunch of profile scripts, varying according to what compatibility modes that are invoked in. The Korn and Debian Almquist shells source /etc/profile
and $HOME/.profile
. For the C shells, it is /etc/csh.login
, $HOME/.login
, et al..
But although you could put a clear
somewhere in there, those aren't really what you want; because that does not clear the terminal before displaying the login prompt, leaving you with a clear terminal that has the login prompt at the top ready for you to log on.
Ironically, the world wants you to clean your screen and tries quite hard to force you to do so. Your system has gone to some length to turn all this off. For starters: You must have used non-default options to stop, for example, mingetty
from clearing the terminal before it issues the login prompt, which is its default behaviour. You must have turned off the systemd settings that reset and deallocate the terminal devices for terminal log-on services, too.
So the easiest path to what you want is to turn at least one of those back on again. Take out the --noclear
option to mingetty
. Use TTYReset=yes
. ☺
Further reading
rc.local
is more analogous to theautoexec.bat
on old windows/dos system - it is the last thing run during the initialization/boot process. – ivanivan Jul 20 '17 at 13:40