Completion in Bash is a two-stage process - some parts are done by bash, and some are done by readline. In the case of filename completion, bash gets the list of directory entries, and then passes the filenames to readline, where we have:
mark-directories
If set to ‘on
’, completed directory names have a slash appended. The
default is ‘on
’.
Readline then stat
s the filenames to decide whether or not to append a slash. On some systems, with some filesystems, this information is already available when bash got the directory entries, but this may not always be the case.
In any case, a quick check of strace -o log bash
without and with set mark-directories off
in .inputrc
shows this is likely the main reason.
Without set mark-directories off
:
read(0, "\t", 1) = 1
openat(AT_FDCWD, "/", O_RDONLY|O_NONBLOCK|O_LARGEFILE|O_CLOEXEC|O_DIRECTORY) = 3
fstat64(3, {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
getdents64(3, /* 20 entries */, 32768) = 488
getdents64(3, /* 0 entries */, 32768) = 0
close(3) = 0
write(2, "\n", 1) = 1
stat64("/bin", {st_mode=S_IFDIR|0755, st_size=53248, ...}) = 0
stat64("/bin", {st_mode=S_IFDIR|0755, st_size=53248, ...}) = 0
stat64("/boot", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
stat64("/boot", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
write(2, "bin/ boot/ \n", 13) = 13
write(2, "bash-5.0$ ls /b", 15) = 15
With:
read(0, "\t", 1) = 1
openat(AT_FDCWD, "/", O_RDONLY|O_NONBLOCK|O_LARGEFILE|O_CLOEXEC|O_DIRECTORY) = 3
fstat64(3, {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
getdents64(3, /* 20 entries */, 32768) = 488
getdents64(3, /* 0 entries */, 32768) = 0
close(3) = 0
write(2, "\n", 1) = 1
write(2, "bin boot \n", 13) = 13
write(2, "bash-5.0$ ls /b", 15) = 15
Best Answer
It sounds like you've accidentally changed the permissions of
/etc/fstab
. You should be able to usesudo
because/var/run/sudo
is mounted on the/var/run
filesystem (or/run
for Oneiric and up).First, make the root partition writable again:
Next, restore the permissions:
After that, future boots should not make everything read-only.