Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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?

share|improve this question

closed as off topic by MDMarra, cjc, Jeff Ferland, Lucas Kauffman, Kyle Smith Mar 22 '12 at 13:37

Questions on Server Fault are expected to relate to professional server, networking, or related infrastructure administration within the scope defined by the community. Consider editing the question or leaving comments for improvement if you believe the question can be reworded to fit within the scope. Read more about reopening questions here.If this question can be reworded to fit the rules in the help center, please edit the question.

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 Answers 3

up vote 1 down vote accepted

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.

share|improve this answer
    
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

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.

share|improve this answer

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.

share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.