0

I'm doing OverTheWire and looking for a password hidden somewhere on the server. I did ls -a to view the hidden contents inside the current directory and received this as the output:

.    ..    .bash_logout    .bashrc    .profile

I checked the file type of . and it says it's a directory:

bandit6@bandit: file ./.
./.: directory

I then tried to cd into this directory but I didn't have any success, it accepted the command but I just stayed in the same directory.

I'm not sure if the syntax is wrong or if the . and .. directories refer to the current and parent directory respectively.

Sorry if this is painfully obvious, but I am new to the command line.

peterh
  • 9,731
fnalkj
  • 11

1 Answers1

4

As per comment, . is your local dir.

It is mainly use in command where you need to specify a directory, like copying file

cp /etc/hosts .

(It will copy /etc/hosts to local dir.) Of course cd . will stay on same directory, this can be useful in shell:

#!/bin/bash
# stuff before
cd "$1"
# other stuff after

You can call either

my-bash /data/foo

or

my-bash .

Another rare usecase is if the current directory was renamed by another session or process. Then, pwd returns the old directory name. To update this, just execute cd ..

rexkogitans
  • 1,329
Archemar
  • 31,554