M BUZZ CRAZE NEWS
// general

Why after write command ls I can't see real folders?

By Emma Martinez

After user comments, I am going to edit this question trying to be accurate, even when pLumo gave the correct answer (thanks a lot!)

I open the terminal, to connect my remote server as root user:

shh root@myip

inside my server as a root user:

[root@servidor ~]

If type ls I get some files BUT I cannot see any folder as /home.

When I type /home, actually I access to /home directory so I can do ls and see everything inside this directory.

The question was, why from [root@servidor ~] I couldn't see everything in server?

If I do that, but in my laptop, when I run terminal I can see many folders, but like server case, If I do cd / to come to root directory, I see everything again.

When I start my terminal:

~ 

if I type ls:

Code Desktop Downloads Music pdf Public Videos
Descargas Documents Escritorio Pictures Templates

If I type pwd:

/home/mynameuser

If I type from ~ :

~ cd /

I can see every directory and files:

bin Documents lib Music run Templates vmlinuz
boot Downloads lib64 opt sbin timeshift vmlinuz.old
cdrom etc lost+found Pictures snap tmp
core home media proc srv usr
Desktop initrd.img mnt Public swapfile var
dev initrd.img.old mssql-cli root sys Videos

If I type from /:

/ cd home/mynameuser

I go to same ~ at beginning:

pwd =>

home/mynameuser

I think, I solve my own question after pLumo explanation.

When I start my terminal in my laptop, it opens inside /home/mynameuser.

When I start my ssh connection, It starts in /root directory, that it is not /home directory.

1

1 Answer

TL;DR:

With ls you see the contents of the current working dir. You are probably inside ~, not in /, that is why you cannot see /home.


The directory home is usually placed below /, the directory root. Running ls /home will show the content from anywhere, because path names starting with / are absolute paths.

When using ls you're searching for directories in your current working directory. Use pwd to reveal it. For a new ssh connection it is usually ~ (a.k.a. /home/$USER/ == the users home directory) .

Use ls / to see home inside the directory root or cd / to change your current working directory to the directory root.

0

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy