Monday, April 29, 2024
 Popular · Latest · Hot · Upcoming
4
rated 0 times [  4] [ 0]  / answers: 1 / hits: 2886  / 2 Years ago, wed, january 19, 2022, 6:50:36

On most of our servers, tab completion of service names after typing in the service command no longer works, as root. It works just fine as non-root. This is on Ubuntu 12.04. I'm not sure how to approach troubleshooting this.



Demonstrating:



Tab completion works as the normal user zachary, who pressed tab to list completions in the first image:



Tab completion works



But as user root, it doesn't list services as completions (only files):



Now it does not



Any help would be greatly appreciated.


More From » 12.04

 Answers
4

This is disabled by default on Ubuntu.



Read your /root/.bashrc:



# enable programmable completion features (you don't need to enable
# this, if it's already enabled in /etc/bash.bashrc and /etc/profile
# sources /etc/bash.bashrc).
#if [ -f /etc/bash_completion ] && ! shopt -oq posix; then
# . /etc/bash_completion
#fi


Bash completion is all commented out. Apparently there's a reason for it I'm not aware of (recovery single user mode perhaps?).



The reason for why it does work when you do sudo su, sudo -s, sudo bash is that it doesn't really run login to make you completely root. When running sudo su - or sudo -i it really does completely logs you in as that user. Here, by example of the environment variable $HOME, more of this difference:



gert@gert-laptop:~$ id
uid=1000(gert) gid=1000(gert) groups=1000(gert),4(adm),7(lp),24(cdrom),27(sudo),[...]
gert@gert-laptop:~$ echo $HOME
/home/gert
gert@gert-laptop:~$ sudo -s
root@gert-laptop:~# id
uid=0(root) gid=0(root) groups=0(root)
root@gert-laptop:~# echo $HOME
/home/gert
root@gert-laptop:~# exit
gert@gert-laptop:~$ sudo su -
root@gert-laptop:~# id
uid=0(root) gid=0(root) groups=0(root)
root@gert-laptop:~# echo $HOME
/root

[#33335] Thursday, January 20, 2022, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
ippalogu

Total Points: 215
Total Questions: 127
Total Answers: 146

Location: Denmark
Member since Tue, Jul 19, 2022
2 Years ago
;