photon icon indicating copy to clipboard operation
photon copied to clipboard

Unable to autocomplete commands when I use the sudo command

Open vndroid opened this issue 3 years ago • 11 comments

Describe the bug

Unable to autocomplete commands when I use the sudo command, such as

sudo tdnf ...

and so on. I can not find out the solutions.

Reproduction steps

1. add a new user.
2. add the new user to the sudo list.
3. switch to the new user's account.
4. can not use the bash_completion and the root account also can not use the sudo autocomplete.

Expected behavior

when I use the sudo command, I can use TAB to auto complete the command.

Additional context

OS version: PhotonOS 4.0 Rev2

vndroid avatar Aug 19 '22 08:08 vndroid

/cc @oliverkurth

ssahani avatar Aug 19 '22 09:08 ssahani

After logging into the regular user account, run the following command:

complete -F _root_command sudo

You can add this to your .bash_profile / .bashrc, and all bash completions work smoothly. I tested this on my Ph4 vm, working as expected.

sshedi avatar Aug 22 '22 09:08 sshedi

Thanks, it works. Will this issue be fixed in the future?

vndroid avatar Aug 23 '22 02:08 vndroid

I have made the necessary changes in our bash spec, fixed rpm will be released soon. Thanks.

sshedi avatar Aug 24 '22 10:08 sshedi

Fixed in https://github.com/vmware/photon/commit/49769c1c48dcd947cb40711c6e7f7495c9d80092 Please close this bug.

sshedi avatar Sep 05 '22 06:09 sshedi

Good day, where in the

After logging into the regular user account, run the following command:

complete -F _root_command sudo

You can add this to your .bash_profile / .bashrc, and all bash completions work smoothly. I tested this on my Ph4 vm, working as expected.

Good day, where in the .bashrc file to add that line? under which line or before which line ?

Whiteoakrum avatar Apr 19 '23 11:04 Whiteoakrum

No need to do add it anywhere, it's fixed in upstream already.

If at all you want to add it yourself, you can add it anywhere in your bashrc

sshedi avatar Apr 19 '23 12:04 sshedi

This issue still exists in PhotonOS 5.0. I hope it can be dealt with as soon as possible.

vndroid avatar Sep 18 '25 17:09 vndroid

Thanks for reporting this issue. Changes made in https://github.com/vmware/photon/commit/49769c1c48dcd947cb40711c6e7f7495c9d80092 was undone by https://github.com/vmware/photon/commit/2386008a951b39340a2c3964b621798b3fa40a64, I'm addressing it.

If you need a quick solution, please modify the file/usr/share/bash-completion/bash_completion Change

complete -F _comp_root_command fakeroot gksu gksudo kdesudo really

to

complete -F _comp_root_command fakeroot gksu gksudo kdesudo really sudo

sshedi avatar Sep 19 '25 11:09 sshedi

Thanks for reporting this issue. Changes made in 49769c1 was undone by 2386008, I'm addressing it.

If you need a quick solution, please modify the file/usr/share/bash-completion/bash_completion Change

complete -F _comp_root_command fakeroot gksu gksudo kdesudo really

to

complete -F _comp_root_command fakeroot gksu gksudo kdesudo really sudo

Thanks a lot, it works.

vndroid avatar Sep 19 '25 12:09 vndroid

Fixed by: https://github.com/vmware/photon/commit/51d64cdd5a8d5bd27802c813e49a2c9041ee5820

sshedi avatar Oct 01 '25 09:10 sshedi