You are not logged in.
Pages: 1
I aliased systemctl with `alias sc='systemctl'` in .bashrc. If i run `sudo sc ...` alias doesn't work anymore. I understand this is due to sudo spawning a new process.
I tried editing /root/.bashrc and few other things but nothing works. Is there a way to alias systemctl when using sudo?
Last edited by notadaughter (2025-05-02 20:07:21)
Offline
not a direct fix, but more the way I do it ...
I have these alias:
systemctl="sudo systemctl"
userctl="systemctl --user"
I have never need to un-alias systemctl
Why I run Arch? To "BTW I run Arch" the guy one grade younger.
And to let my siblings and cousins laugh at Arsch Linux...
Offline
systemctl will use polkit to leverage credentials when necessary anyway?
You can simply skip sudo'ing it.
Offline
systemctl will use polkit to leverage credentials when necessary anyway?
You can simply skip sudo'ing it.
doesn't that require typing in a password?
I use passwordless sudo (bad idea, I know, but fuck it, I already do autologin)
Last edited by jl2 (2025-04-26 16:59:53)
Why I run Arch? To "BTW I run Arch" the guy one grade younger.
And to let my siblings and cousins laugh at Arsch Linux...
Offline
systemctl will use polkit to leverage credentials when necessary anyway?
You can simply skip sudo'ing it.
Some commands require elevated rights before. E.g. systemctl edit ...
Offline
@jl2, polkit allows you to configure yourself into a CVE, too
@mithrial, indeed - looks like a straight up systemd bug, though.
You cannot sudo some_alias because sudoe executes executables, not aliases.
You could simply symlink systemctl to sc, but since systemctl inspects it args[0], that could run you into probles.
=> possibly a wrapper script that also parses the commandline and automagically involves sudo when necessary?
Offline
im confused on why you need to alias or unalias systemctl can you explain more on what your trying to do to give a solution
Offline
echo sc | wc
echo systemctl | wc
cp, rm, mv, dd, …
http://blog.xkcd.com/2007/08/14/mirror … -the-lazy/
IT'S BECAUSE WE'RE LAZY!
Offline
sudo your-alias
This one will not work. Instead do this
In your .bashrc, you add this line for example, to turn on bluetooth every time it starts, should the systemctl enable command does not work as nicely as it wanted
alias turnonbt='sudo systemctl start bluetooth'
But I don't recommend setting an alias in order to skip typing the word sudo in any way. I think it's just best practice. Unless I am entirely sure that I won't do anything stupid at all. Moreover if you had type sudo for your last commands (time limit for sudo), the alias you set will happily execute your sudo command without even asking you
Last edited by lvsl (2025-04-27 06:16:18)
Offline
cp, rm, mv, dd, …
http://blog.xkcd.com/2007/08/14/mirror … -the-lazy/IT'S BECAUSE WE'RE LAZY!
Wait there's a blog too for xkcd?
Also, randal is a complete genious.
@jl2, polkit allows you to configure yourself into a CVE, too
Good to know thanks
Last edited by jl2 (2025-04-27 06:32:19)
Why I run Arch? To "BTW I run Arch" the guy one grade younger.
And to let my siblings and cousins laugh at Arsch Linux...
Offline
No, but there's a blag.
I don't know who that randal is, but Randall is certainly on the list I've submitted to Apophis to keep around if he doesn't want to get whacked again.
Offline
No, but there's a blag.
I don't know who that randal is, but Randall is certainly on the list I've submitted to Apophis to keep around if he doesn't want to get whacked again.
Sogar die Gross/Kleinschreibung falsch (meine grösste Deutsch-Grammatik-Schwäche, wird mir immer mal wieder zum Verhängnis)
That exceeds my very limited ancient egyptan knowledge and the capacity to read Wikipedia ...
(Only found a image of Seth stabing him, is it a reference to that? [Even though everybody seemed to bash him in some way] Also, if Apophis was the god of darkness, was he the god of death too?)
Edit: I'm steering far into the offtopic part once again, feel free to steer back ...
Edit2: fixed english capitalisation
Last edited by jl2 (2025-04-27 07:52:46)
Why I run Arch? To "BTW I run Arch" the guy one grade younger.
And to let my siblings and cousins laugh at Arsch Linux...
Offline
Apophis is not so much a god "of" - he *is* darkness, chaos and death.
And yes, the famous episode is where was about to tank the sunbark and everyone started to panic and freeze, so I rolled my eyes, picked my spear and whacked him over the head so the sun could rise again.
I btw. do that every night, you're welcome
Offline
I btw. do that every night, you're welcome
Thank you for your service
The egyptains must really have hated snakes.
Anyway, you pulled out the most german way of saying something between "He's awesome" and "He's the absolute fucking goat". (He would've said "nicht schlecht" if he thought he was less than that )
Last edited by jl2 (2025-04-27 11:42:43)
Why I run Arch? To "BTW I run Arch" the guy one grade younger.
And to let my siblings and cousins laugh at Arsch Linux...
Offline
after multiple attempts aliasing systemctl in .bashrc, i came up with the following:
exec /usr/bin/systemctl "$@"
put this under /usr/local/bin/sc
this allows running both `sudo sc ...` and `sc ...`
Offline
Pages: 1