-2

Never used Linux before and trying to understand the difference between

ls

and

ls / 

"ls /" gets all my dir (and more, but not .files - hidden files) as we can see it in this extensive list of commands.

What about the ls?

user2060451
  • 2,576
  • 3
  • 24
  • 31
  • Add '-a' (or '-A') flag to see "hidden" files. It's just a convention to not generally list entries whose name starts with a dot. – jno Aug 25 '18 at 15:48
  • 4
    Stack Overflow is a site for programming and development questions. This question appears to be off-topic because it is not about programming or development. See [What topics can I ask about here](http://stackoverflow.com/help/on-topic) in the Help Center. Perhaps [Super User](http://superuser.com/) or [Unix & Linux Stack Exchange](http://unix.stackexchange.com/) would be a better place to ask. – jww Aug 25 '18 at 15:49

2 Answers2

5

ls is standing for listing directories and files under a directory.

In your situation, ls (without a directory argument) is going to list directories and files under the current directory(pwd). The other command, ls / is going to list files and directories under the root directory which is /.

rfum
  • 358
  • 1
  • 3
  • 13
1

ls alone will print your current directory's contents; you can use ls with arguments to display other information. An example would be ls -a where -a is the option, and displays listing directories including those starting with a dot (.htaccess for instance). ls has several argument options; short ones begin with a dash (-) like those as mentioned above -a, and there are longer ones too that start with a double dash (--) like --all which is the long version of -a and does the same thing.

ls / is the listing directory (ls) command and / is folder structure that ls will act on. In this case, you are invoking a listing of the directory contents on the / folder which is the root directory. An example of the usage of ls and folder structures would be using ls /home to display the /home directory contents.

To put it all together; you can use ls with an option (-a) and a folder structure like in the example below:

ls -a /home

I hope this helps!

For an advanced way to view your ls results please see this stackoverflow answer.

Erick Gonzalez
  • 343
  • 3
  • 6