If everything else is working, but just certain filename completion (autocomplete) attempts fail, it might be that you lack permission to search a directory that is a component of the path.
Suppose you want the listing for some other user's .bash_profile
file. The following ls
command will work; because sudo
runs the ls
command with the required permission.
$ sudo ls -al /home/someone_else/.bash_profile
However, if you try to use filename completion, the tab completion does nothing.
$ sudo ls -al /home/someone_else/.bash_pr<tab> # does not complete
That is because the bash
completion is operating before sudo
gets invoked. The command might as well be:
$ ls -al /home/someone_else/.bash_pr<tab>
Because permission to search that directory is lacking, the command completion does nothing.
To temporarily run with greater permissions, you can start a new shell with sudo
.
$ sudo bash
The ls
command can now be run without the sudo
predicate, and autocomplete works. (Note that the prompt switches from $
to #
.)
# ls -al /home/someone_else/.bash_pr<tab>
Just make sure you kill the shell when your task is completed; a shell with this much power is dangerous.
# exit
unity
to run the Unity shellsudo chsh -s /bin/bash root
works for me