New user: bashrc error code

excellent. thank you!

Not quite. If you define alias sudo='sudo ' then when running sudo abc the word “abc” is also expanded as an alias. I you do not define the alias for sudo, then the word “abc” isn’t expanded even if it is a valid alias name.

See man bash and search for the section named “ALIASES”. It is complicated and bash is full of nasty details like that.

I expect that is probably, at least in part, because sudo actually changes the environment to obtain super user privileges. I have never encountered that situation since I do not use sudo with any of the aliases I have defined. (If the command within the alias requires sudo privileges then sudo is used within the alias definition and not while launching the alias.)

It has nothing to do with sudo per se. You can do the same with any other alias, which is perhaps not useful, but you can do it.

sudo doesn’t change the environment of the current shell. It creates a new process with a new shell with a new environment.

It’s not a matter of personal preference. The names of the files in ~/.bashrc.d must not start with a dot, otherwise the glob expansion in ~/.bashrc will skip them: for rc in ~/.bashrc.d/*; do. Hidden files are not glob-expanded.

The mystery aliases seems to come from https://blog.christophersmart.com/2020/04/18/making-dnf-on-fedora-silverblue-a-little-easier-with-bash-aliases/.

Yes, that was the original set of instructions I tried to follow…

You can restore the original .bashrc

cp /etc/skel/.bashrc ~/.bashrc

And if you run the script exactly as it was stated like

cat >> ~/.bashrc << EOF
alias sudo="sudo "
alias dnf="bash -c '#skip_sudo'; toolbox -y create 2>/dev/null; toolbox run sudo dnf"
EOF

it would have worked. But only run it once.