[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: How to run automatically a script as soon root login



On Mon 13 May 2024 at 21:18:30 (+0200), Mario Marietto wrote:
> On Mon, May 13, 2024 at 9:05 PM Greg Wooledge <greg@wooledge.org> wrote:
> > On Mon, May 13, 2024 at 06:06:37PM +0200, Hans wrote:
> > > Am Montag, 13. Mai 2024, 13:24:17 CEST schrieb Greg Wooledge:
> > > > On Mon, May 13, 2024 at 07:36:07AM +0200, Richard wrote:
> > > > > .profile
> > >
> > > Sorry, dumb question: Depending of the shell, the user is using (let's
> > say, he
> > > will use bash), can the script not be added into ~/.bashrc?
> >
> > The context has been snipped out.  The context for this was "OP is trying
> > to run a command when root logs in".  The method of login was not stated.
> > First responder said ".profile works for every method of login".  I said
> > that this is incorrect: it doesn't work for many GUI login setups.
> >
> > In those same GUI login setups, .bashrc is *also* not read when the
> > user logs in.  None of the shell startup files are read at all.
> >
> > All of this is a tangent to the actual problem, though.
> >
> > > If yes, second dumb question: Coiuld it be ANY script or command?
> > > (also running as non-rootuser, like adding "runuser -u myuser
> > > command_whatever").
> >
> > We're several layers deep into an X-Y problem here.  The *actual* problem
> > is that the system's networking configuration is not correct/complete.
> >
> > The *workaround* is that the OP is logging in and running commands to
> > change the networking configuration temporarily.
> >
> > The question resulting from the workaround (the Y in the X-Y) was "How
> > can I automate these commands that I keep having to type?"
> >
> > The proper question should have been "How can I fix my system's networking
> > configuration permanently?"
> > 
> ---> The context has been snipped out....
> 
> nope. Read well what I said on my first post :
> 
> 
> *[Forgot to say that I switched boot target to text with this command :*
> 
> *sudo systemctl set-default multi-user.target]*
> 
> What does this mean for you ?

To me, it means just one more change while trying to get your
networking to work. Your OP finished with "It does not work and anyway
it does not seem to be what I want..." and "I suspect that the
solution is easier than what I'm trying to do...". Again, to me,
that suggests that after settling on a better, permanent solution
to your problem, you would roll back the other changes that you
made along the way.

> The context is that I was not using any
> desktop manager.

My understanding of this statement is that "the context" is what
is described in your OP. As you said you "switched boot target to
text", I would assume you originally had a different target, likely
a DM, and that you might revert back to it after solving the problem.

Cheers,
David.


Reply to: