sudo command doesn't autocomplete anymore on files
Ubuntu 16.04.1 LTS
I don't know what I did, everything was working fine, but since today my bash doesn't autocomplete anymore when I use sudo.
I can use the autocompletion as normal user, I can use autocompletion as root, I can use autocompletion for directories with sudo, but I can't use autocompletion for files if I use sudo.
If I write:
$sudo vim /etc/ssm[TAB]
it will autocomplete to:
$sudo vim /etc/ssmtp/
but then if I hit [TAB] again, even twice like I was used to list the files in the directory, nothing happens.
I already checked and I have the autocompletion enabled in the user .bashrc and also in /etc/bash.bashrc
bash auto-completion
add a comment |
Ubuntu 16.04.1 LTS
I don't know what I did, everything was working fine, but since today my bash doesn't autocomplete anymore when I use sudo.
I can use the autocompletion as normal user, I can use autocompletion as root, I can use autocompletion for directories with sudo, but I can't use autocompletion for files if I use sudo.
If I write:
$sudo vim /etc/ssm[TAB]
it will autocomplete to:
$sudo vim /etc/ssmtp/
but then if I hit [TAB] again, even twice like I was used to list the files in the directory, nothing happens.
I already checked and I have the autocompletion enabled in the user .bashrc and also in /etc/bash.bashrc
bash auto-completion
add a comment |
Ubuntu 16.04.1 LTS
I don't know what I did, everything was working fine, but since today my bash doesn't autocomplete anymore when I use sudo.
I can use the autocompletion as normal user, I can use autocompletion as root, I can use autocompletion for directories with sudo, but I can't use autocompletion for files if I use sudo.
If I write:
$sudo vim /etc/ssm[TAB]
it will autocomplete to:
$sudo vim /etc/ssmtp/
but then if I hit [TAB] again, even twice like I was used to list the files in the directory, nothing happens.
I already checked and I have the autocompletion enabled in the user .bashrc and also in /etc/bash.bashrc
bash auto-completion
Ubuntu 16.04.1 LTS
I don't know what I did, everything was working fine, but since today my bash doesn't autocomplete anymore when I use sudo.
I can use the autocompletion as normal user, I can use autocompletion as root, I can use autocompletion for directories with sudo, but I can't use autocompletion for files if I use sudo.
If I write:
$sudo vim /etc/ssm[TAB]
it will autocomplete to:
$sudo vim /etc/ssmtp/
but then if I hit [TAB] again, even twice like I was used to list the files in the directory, nothing happens.
I already checked and I have the autocompletion enabled in the user .bashrc and also in /etc/bash.bashrc
bash auto-completion
bash auto-completion
asked Jan 20 '17 at 14:23
effemmeffeeffemmeffe
168417
168417
add a comment |
add a comment |
3 Answers
3
active
oldest
votes
Try firstly reinstalling the bash-completion package with:
sudo apt-get install --reinstall bash-completion
Then backing up your .bashrc file:
mv ~/.bashrc ~/.bashrc.bak
Finally, replace your .bashrc file with the default from /etc/skel/.bashrc
by using:
cp /etc/skel/.bashrc ~/
This will ensure the following 'complete' config is restored within the file:
# 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 ! shopt -oq posix; then
if [ -f /usr/share/bash-completion/bash_completion ]; then
. /usr/share/bash-completion/bash_completion
elif [ -f /etc/bash_completion ]; then
. /etc/bash_completion
fi
fi
Also check both the containing folder and file permissions of /etc/bash.bashrc
and ~/.bashrc
- ownership should be root:root and yourusername:yourusergroup respectively. The permissions of the files are important as the shell only uses your own privilege level to auto-complete commands. Elevated permissions such as when sudo is invoked are only used after the command is committed by pressing enter.
Done. The problem is still there.
– effemmeffe
Jan 20 '17 at 19:46
It still appears you have some problem with bash-completion. Maybe try uninstalling with the 'purge' option. As a workaround and test, you can use the native completion of bash with alt + / rather than tab, which should complete file names for you.
– Sapient Saxon Saboo
Jan 21 '17 at 10:01
I already purged and reinstalled. The strange thing is that I can use autocomplete as user and as root, but not as user using sudo.
– effemmeffe
Jan 21 '17 at 13:19
@effemmeffe I have updated the answer to include your solution to give a fully rounded answer.
– Sapient Saxon Saboo
Jan 25 '17 at 7:47
I think that you could also add the comment from user596137 about the fact that sudo doesn't autocomplete because it uses user permission before pressing enter.
– effemmeffe
Jan 25 '17 at 11:17
|
show 1 more comment
I find out that the problem wasn't about autocomplete, but just a matter of permissions.
The folder is own by root:mail instead of root:root as most of the directories in /etc and my user wasn't in the mail group.
Once I added the user to the right group it worked.
I just don't understand why the command with sudo in front of it didn't superseded the group...
1
Because elevated permission from sudo start to work only after you press enter, before pressing enter shell uses just your permissions.
– marosg
Jan 25 '17 at 8:01
add a comment |
Add
complete -cf sudo
to your .bashrc
and .bash_profile
. Autocompletion will work on next login
New contributor
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "89"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f874179%2fsudo-command-doesnt-autocomplete-anymore-on-files%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
Try firstly reinstalling the bash-completion package with:
sudo apt-get install --reinstall bash-completion
Then backing up your .bashrc file:
mv ~/.bashrc ~/.bashrc.bak
Finally, replace your .bashrc file with the default from /etc/skel/.bashrc
by using:
cp /etc/skel/.bashrc ~/
This will ensure the following 'complete' config is restored within the file:
# 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 ! shopt -oq posix; then
if [ -f /usr/share/bash-completion/bash_completion ]; then
. /usr/share/bash-completion/bash_completion
elif [ -f /etc/bash_completion ]; then
. /etc/bash_completion
fi
fi
Also check both the containing folder and file permissions of /etc/bash.bashrc
and ~/.bashrc
- ownership should be root:root and yourusername:yourusergroup respectively. The permissions of the files are important as the shell only uses your own privilege level to auto-complete commands. Elevated permissions such as when sudo is invoked are only used after the command is committed by pressing enter.
Done. The problem is still there.
– effemmeffe
Jan 20 '17 at 19:46
It still appears you have some problem with bash-completion. Maybe try uninstalling with the 'purge' option. As a workaround and test, you can use the native completion of bash with alt + / rather than tab, which should complete file names for you.
– Sapient Saxon Saboo
Jan 21 '17 at 10:01
I already purged and reinstalled. The strange thing is that I can use autocomplete as user and as root, but not as user using sudo.
– effemmeffe
Jan 21 '17 at 13:19
@effemmeffe I have updated the answer to include your solution to give a fully rounded answer.
– Sapient Saxon Saboo
Jan 25 '17 at 7:47
I think that you could also add the comment from user596137 about the fact that sudo doesn't autocomplete because it uses user permission before pressing enter.
– effemmeffe
Jan 25 '17 at 11:17
|
show 1 more comment
Try firstly reinstalling the bash-completion package with:
sudo apt-get install --reinstall bash-completion
Then backing up your .bashrc file:
mv ~/.bashrc ~/.bashrc.bak
Finally, replace your .bashrc file with the default from /etc/skel/.bashrc
by using:
cp /etc/skel/.bashrc ~/
This will ensure the following 'complete' config is restored within the file:
# 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 ! shopt -oq posix; then
if [ -f /usr/share/bash-completion/bash_completion ]; then
. /usr/share/bash-completion/bash_completion
elif [ -f /etc/bash_completion ]; then
. /etc/bash_completion
fi
fi
Also check both the containing folder and file permissions of /etc/bash.bashrc
and ~/.bashrc
- ownership should be root:root and yourusername:yourusergroup respectively. The permissions of the files are important as the shell only uses your own privilege level to auto-complete commands. Elevated permissions such as when sudo is invoked are only used after the command is committed by pressing enter.
Done. The problem is still there.
– effemmeffe
Jan 20 '17 at 19:46
It still appears you have some problem with bash-completion. Maybe try uninstalling with the 'purge' option. As a workaround and test, you can use the native completion of bash with alt + / rather than tab, which should complete file names for you.
– Sapient Saxon Saboo
Jan 21 '17 at 10:01
I already purged and reinstalled. The strange thing is that I can use autocomplete as user and as root, but not as user using sudo.
– effemmeffe
Jan 21 '17 at 13:19
@effemmeffe I have updated the answer to include your solution to give a fully rounded answer.
– Sapient Saxon Saboo
Jan 25 '17 at 7:47
I think that you could also add the comment from user596137 about the fact that sudo doesn't autocomplete because it uses user permission before pressing enter.
– effemmeffe
Jan 25 '17 at 11:17
|
show 1 more comment
Try firstly reinstalling the bash-completion package with:
sudo apt-get install --reinstall bash-completion
Then backing up your .bashrc file:
mv ~/.bashrc ~/.bashrc.bak
Finally, replace your .bashrc file with the default from /etc/skel/.bashrc
by using:
cp /etc/skel/.bashrc ~/
This will ensure the following 'complete' config is restored within the file:
# 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 ! shopt -oq posix; then
if [ -f /usr/share/bash-completion/bash_completion ]; then
. /usr/share/bash-completion/bash_completion
elif [ -f /etc/bash_completion ]; then
. /etc/bash_completion
fi
fi
Also check both the containing folder and file permissions of /etc/bash.bashrc
and ~/.bashrc
- ownership should be root:root and yourusername:yourusergroup respectively. The permissions of the files are important as the shell only uses your own privilege level to auto-complete commands. Elevated permissions such as when sudo is invoked are only used after the command is committed by pressing enter.
Try firstly reinstalling the bash-completion package with:
sudo apt-get install --reinstall bash-completion
Then backing up your .bashrc file:
mv ~/.bashrc ~/.bashrc.bak
Finally, replace your .bashrc file with the default from /etc/skel/.bashrc
by using:
cp /etc/skel/.bashrc ~/
This will ensure the following 'complete' config is restored within the file:
# 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 ! shopt -oq posix; then
if [ -f /usr/share/bash-completion/bash_completion ]; then
. /usr/share/bash-completion/bash_completion
elif [ -f /etc/bash_completion ]; then
. /etc/bash_completion
fi
fi
Also check both the containing folder and file permissions of /etc/bash.bashrc
and ~/.bashrc
- ownership should be root:root and yourusername:yourusergroup respectively. The permissions of the files are important as the shell only uses your own privilege level to auto-complete commands. Elevated permissions such as when sudo is invoked are only used after the command is committed by pressing enter.
edited Jan 25 '17 at 17:34
answered Jan 20 '17 at 14:59
Sapient Saxon SabooSapient Saxon Saboo
683411
683411
Done. The problem is still there.
– effemmeffe
Jan 20 '17 at 19:46
It still appears you have some problem with bash-completion. Maybe try uninstalling with the 'purge' option. As a workaround and test, you can use the native completion of bash with alt + / rather than tab, which should complete file names for you.
– Sapient Saxon Saboo
Jan 21 '17 at 10:01
I already purged and reinstalled. The strange thing is that I can use autocomplete as user and as root, but not as user using sudo.
– effemmeffe
Jan 21 '17 at 13:19
@effemmeffe I have updated the answer to include your solution to give a fully rounded answer.
– Sapient Saxon Saboo
Jan 25 '17 at 7:47
I think that you could also add the comment from user596137 about the fact that sudo doesn't autocomplete because it uses user permission before pressing enter.
– effemmeffe
Jan 25 '17 at 11:17
|
show 1 more comment
Done. The problem is still there.
– effemmeffe
Jan 20 '17 at 19:46
It still appears you have some problem with bash-completion. Maybe try uninstalling with the 'purge' option. As a workaround and test, you can use the native completion of bash with alt + / rather than tab, which should complete file names for you.
– Sapient Saxon Saboo
Jan 21 '17 at 10:01
I already purged and reinstalled. The strange thing is that I can use autocomplete as user and as root, but not as user using sudo.
– effemmeffe
Jan 21 '17 at 13:19
@effemmeffe I have updated the answer to include your solution to give a fully rounded answer.
– Sapient Saxon Saboo
Jan 25 '17 at 7:47
I think that you could also add the comment from user596137 about the fact that sudo doesn't autocomplete because it uses user permission before pressing enter.
– effemmeffe
Jan 25 '17 at 11:17
Done. The problem is still there.
– effemmeffe
Jan 20 '17 at 19:46
Done. The problem is still there.
– effemmeffe
Jan 20 '17 at 19:46
It still appears you have some problem with bash-completion. Maybe try uninstalling with the 'purge' option. As a workaround and test, you can use the native completion of bash with alt + / rather than tab, which should complete file names for you.
– Sapient Saxon Saboo
Jan 21 '17 at 10:01
It still appears you have some problem with bash-completion. Maybe try uninstalling with the 'purge' option. As a workaround and test, you can use the native completion of bash with alt + / rather than tab, which should complete file names for you.
– Sapient Saxon Saboo
Jan 21 '17 at 10:01
I already purged and reinstalled. The strange thing is that I can use autocomplete as user and as root, but not as user using sudo.
– effemmeffe
Jan 21 '17 at 13:19
I already purged and reinstalled. The strange thing is that I can use autocomplete as user and as root, but not as user using sudo.
– effemmeffe
Jan 21 '17 at 13:19
@effemmeffe I have updated the answer to include your solution to give a fully rounded answer.
– Sapient Saxon Saboo
Jan 25 '17 at 7:47
@effemmeffe I have updated the answer to include your solution to give a fully rounded answer.
– Sapient Saxon Saboo
Jan 25 '17 at 7:47
I think that you could also add the comment from user596137 about the fact that sudo doesn't autocomplete because it uses user permission before pressing enter.
– effemmeffe
Jan 25 '17 at 11:17
I think that you could also add the comment from user596137 about the fact that sudo doesn't autocomplete because it uses user permission before pressing enter.
– effemmeffe
Jan 25 '17 at 11:17
|
show 1 more comment
I find out that the problem wasn't about autocomplete, but just a matter of permissions.
The folder is own by root:mail instead of root:root as most of the directories in /etc and my user wasn't in the mail group.
Once I added the user to the right group it worked.
I just don't understand why the command with sudo in front of it didn't superseded the group...
1
Because elevated permission from sudo start to work only after you press enter, before pressing enter shell uses just your permissions.
– marosg
Jan 25 '17 at 8:01
add a comment |
I find out that the problem wasn't about autocomplete, but just a matter of permissions.
The folder is own by root:mail instead of root:root as most of the directories in /etc and my user wasn't in the mail group.
Once I added the user to the right group it worked.
I just don't understand why the command with sudo in front of it didn't superseded the group...
1
Because elevated permission from sudo start to work only after you press enter, before pressing enter shell uses just your permissions.
– marosg
Jan 25 '17 at 8:01
add a comment |
I find out that the problem wasn't about autocomplete, but just a matter of permissions.
The folder is own by root:mail instead of root:root as most of the directories in /etc and my user wasn't in the mail group.
Once I added the user to the right group it worked.
I just don't understand why the command with sudo in front of it didn't superseded the group...
I find out that the problem wasn't about autocomplete, but just a matter of permissions.
The folder is own by root:mail instead of root:root as most of the directories in /etc and my user wasn't in the mail group.
Once I added the user to the right group it worked.
I just don't understand why the command with sudo in front of it didn't superseded the group...
answered Jan 23 '17 at 19:10
effemmeffeeffemmeffe
168417
168417
1
Because elevated permission from sudo start to work only after you press enter, before pressing enter shell uses just your permissions.
– marosg
Jan 25 '17 at 8:01
add a comment |
1
Because elevated permission from sudo start to work only after you press enter, before pressing enter shell uses just your permissions.
– marosg
Jan 25 '17 at 8:01
1
1
Because elevated permission from sudo start to work only after you press enter, before pressing enter shell uses just your permissions.
– marosg
Jan 25 '17 at 8:01
Because elevated permission from sudo start to work only after you press enter, before pressing enter shell uses just your permissions.
– marosg
Jan 25 '17 at 8:01
add a comment |
Add
complete -cf sudo
to your .bashrc
and .bash_profile
. Autocompletion will work on next login
New contributor
add a comment |
Add
complete -cf sudo
to your .bashrc
and .bash_profile
. Autocompletion will work on next login
New contributor
add a comment |
Add
complete -cf sudo
to your .bashrc
and .bash_profile
. Autocompletion will work on next login
New contributor
Add
complete -cf sudo
to your .bashrc
and .bash_profile
. Autocompletion will work on next login
New contributor
edited Jan 7 at 5:49
Pablo Bianchi
2,4251529
2,4251529
New contributor
answered Jan 7 at 2:57
guestguest
1
1
New contributor
New contributor
add a comment |
add a comment |
Thanks for contributing an answer to Ask Ubuntu!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f874179%2fsudo-command-doesnt-autocomplete-anymore-on-files%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown