-1

I am not very familiar with Linux. I have got root access of a server. When I run the command "ls" then it displays nothing. No error no information nothing. When I run "ls -l" it displays "total 0"

How do I list all files and directories?

MDMarra
  • 100,734
  • 32
  • 197
  • 329
Ali
  • 251
  • 1
  • 2
  • 9
  • 3
    This is a site for professional systems administrators. I'd hope that if you're administering Linux in a professional environment, you know how `ls` works. – MDMarra Mar 22 '12 at 11:26

3 Answers3

1

The command ls lists the files and directories. If you have hidden files and folders, you can list them using:

$ ls -a

Adding the option -l gives a detailed list. You can see man ls for more options.

Khaled
  • 36,533
  • 8
  • 72
  • 99
  • This actually did the trick. But strange thing is when I logged out of server and logged in again as root then this command didn't work. Then I tried "dir" and it worked which was previously not working. Weird! – Ali Mar 22 '12 at 11:34
  • Are you sure you are listing the contents of same folder after re-login? If so, check the system logs `/var/log/messages` and `/var/log/syslog`. – Khaled Mar 22 '12 at 11:46
1

It is actually possible that the directory you're in has been deleted from another shell/application/...

This would result in ls -la displaying total 0

Using cd, change again to the directory you want to list and retry.

Atmocreations
  • 179
  • 3
  • 10
0

When you login as root, you are most likely in /root (root's home) which is often empty. Try "ls /" or "ls -lah /" to see the contents of the root of the filesystem tree.

DerekC
  • 106
  • 5