It’s very easy to list the contents of the current directory, or by specifying, any given directory. You can also use the listing command, to certify yourself that a file is where you think it is.
Now, listing command is a easy one to remember and it goes like this:
ls [option] [directories or files]
it’s the normal Linux command syntax, which is command option target.
There are some important option switches that are useful to learn, and ill try to go trough a few of them.
I am currently in my home directory (/home/mgarces) and I do a simple ls command. The output is:

ls without any options or targets, lists the files and directory names in the current working directory. Pretty dull…
Now lets do a ls -a:

A few more things appear… What I did here, was to had the -a option switch, which outputs the “hidden” files and directories, whose names commence with a . (example: .bash_history).
Now that you can see all the files and directories, let’s go in detail:

This uses two different options flags, one you already know, the other makes the output of the ls command to be a more detailed long list.
You can observe the files/directories permissions, the owner and the group for the files/directories, and a bunch of other information, that later you’ll learn in detail.
Other options can be used in the ls command, and by reading the man page there are a few that I found important enough to put here:
-d List names of directories like other files, rather than listing their contents.
-i Precede the output for the file by the file serial number (i-node number).
-q Output non-printable characters in a filename as question marks.
-h Outputs human-readable format, in KB, MB and GB.
Go on and try different combinations of options. Surf trough the man page for ls, and learn what you can; get comfortable with different output options, so you can list and examine your files and directories easily. Don’t try to hard to memorize option flags, just use them, by having different things to accomplish with the list command. With time you retain the most important ones (this is valid for everything in Linux) and it will become your second nature.
Enjoy the power off listing =)
LINKS: man ls
   Share This


1 comment so far ↓
[...] the last articles, specially on the ls command one, you have seen examples of listing your files and directories. And if you paid attention, you [...]
Leave a Comment