ls command doesn't show folder but I can't create it because folder already exists

I'm using Ubuntu 16.04.

Step 1) I logged into my root user account.

Step 2) I used cd to navigate to a different user account's home directory.

Step 3) I typed ls to examine the contents of that directory.

Step 4) The contents came back as empty.

Step 5) I typed mkdir .ssh to create a directory.

Result) mkdir: cannot create directory '.ssh': File exists

Question: Why is the directory listed as empty if an .ssh folder exists inside of it?

-- update --

I logged into root because this is a test server. I'm repeatedly creating and destroying it.


ls by itself does not show hidden directories (hidden directories and files are ones that start with a ., such as .ssh)

Try using ls -a in the directory.

From the ls manpage:

-a, --all

do not ignore entries starting with .

As noted in the comments, "hidden" directories and files are not technically a thing, there is just code built into a lot of common tools that treat . and .. with special meaning, the result being that . is usually considered "hidden" by most tools. The reason I used this term is because it's common to hear it referred to that way.

Additionally . and .. usually have special meaning to most filesystems, indicating current directory and parent directory, respectively.


In your step 3, type ls -a to list the contents of directory.

File or directory whose name starts with . will be ignored by ls.