You've successfully subscribed to Nuvotex Blog
Great! Next, complete checkout for full access to Nuvotex Blog
Welcome back! You've successfully signed in.
Success! Your account is fully activated, you now have access to all content.
Success! Your billing info is updated.
Billing info update failed.

sudo root shell with autocomplete

Switching user using sudo results in a limited shell without command completion. Using the right sudo command omits this limit and provides a fully fledged shell.

Daniel Nachtrub
Daniel Nachtrub

Working remote on linux systems you might connect using a low privilege user which is allowed to run some basic diagnostic and control commands. Requiring additional access sudo provides a good service.

If you're going deep on system diag and configuring many things, it's quite common to change user context to root. It's quite convenient to do this using sudo su - and this works.

Can i do better?

Yes! Working on recent bash versions you might like that bash supports command completion ( Running sudo su won't provide command completion.

The solution: sudo -Es or sudo -s (depending if you want to keep env)

Update: if you want a root session with "full setup" like $HOME path it's better to use sudo -i

This will provide a shell running as the given target user (if no user is passed, root will be selected).

Quite an easy way to get a real root shell with all features.


Daniel Nachtrub

Kind of likes computers. Linux foundation certified: LFCS / CKA / CKAD / CKS. Microsoft certified: Cybersecurity Architect Expert & Azure Solutions Architect Expert.