大网数据广告活动
服务器运维问答

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

· 52CE 我爱测

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 ca…

问题原文

原帖链接 · DR01D · CC BY-SA 3.0

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.

已采纳解答

原帖链接 · Patrick · CC BY-SA 3.0

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.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2017-11-29)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。