It is fairly well known that cd /
in Bash/terminal takes you to your root directory, regardless of where you were before:
brian@brian-linux:~/redis-3.0.3$ cd /
brian@brian-linux:/$ pwd
/
brian@brian-linux:/$ ls
bin dev initrd.img.old libx32 opt sbin usr
boot etc lib lost+found proc srv var
cdrom home lib32 media root sys vmlinuz
data initrd.img lib64 mnt run tmp vmlinuz.old
brian@brian-linux:/$
I stumbled upon an interesting discovery today:
In Bash, cd //
takes you to directory //
, which is the same as the root directory, but is still described as //
:
brian@brian-linux:~/redis-3.0.3$ cd //
brian@brian-linux://$ ls
bin dev initrd.img.old libx32 opt sbin usr
boot etc lib lost+found proc srv var
cdrom home lib32 media root sys vmlinuz
data initrd.img lib64 mnt run tmp vmlinuz.old
brian@brian-linux://$ pwd
//
What's going on here, and why is this the case?
It's also worth noting that cd ///
or any number of /
greater than 2 will take you to the root directory /
. However, from the root directory, cd //
takes you to //
:
brian@brian-linux:/$ cd ///
brian@brian-linux:/$ cd //
brian@brian-linux://$