Link to home
Start Free TrialLog in
Avatar of shurengyla
shurengyla

asked on

ls

What stands the "total" for in the ls command
and why do I get different results
when typing ls -l and ls -la ?
ASKER CERTIFIED SOLUTION
Avatar of christg
christg

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of braveheart
braveheart

If you read the manual page (type "man ls") it will tell you all about the different options for ls.

-l gives the long listing which tells you information about access and ownership, file size and last modified time, as well as the name of the file.

-a includes any files in the specified (or current) directory which begin with the "." character. These include "." which is a link in every directory to itself and ".." which is a link to the parent of every directory. The "." self-link is useful in case you have a file beginning with "-" which would otherwise be difficult to perform any operations on the file unless you prefixed it by "./". Special files in your home directory such as initialisation scripts and X resource files also typically begin with dot.

The total at the end of "ls -l" shows the total size (sum) of all the files in that directory, although the units may not be consistent from machine to machine.
if you want to know the size of a directory, better use du -s *
Hi shurengyla,

The answer to your questions are of two parts.

1) What stands the "total" for in the ls command?
    total stands for the total number of blocks occupied by the files listed using either 'ls -l' or 'ls -la'

2) why do I get different results when typing ls -l and ls -la ?
   'ls -l' lists the files in a particular directory. But when u  use 'ls -la' it lists all the files in that directory including the hidden files i.e) dot files like .login, any file which start with a dot (.). Whereas when u use 'ls -l' the hidden files will not be listed. So if u have hidden files in your directory, u will get different "totals" for 'ls -l' and 'ls -la"


Hope the above points answered your questions. Have a good day/night.

Thanks,
Ravi.
Hey, rmgopal, you seem to be making a habit of just rewording my answers. Don't you have any original thoughts, or do you just not read the question history before answering.