Understanding ‘ls -la’: A Guide to the Command-Line Listing Command
By Brent Cohen July 18, 2023 July 18, 2023

In the world of Linux and Unix-like operating systems, the command-line interface (CLI) is a powerful tool that provides a direct way to interact with the system. One of the most frequently used commands is ls , which stands for list. In this article, we will delve deeper into a specific variant of the ls command, ls -la .
The ls -la command is used to list all the contents of a directory, including hidden files, in a long listing format.
What is ‘ls -la’?
The ls -la command is used to list all the contents of a directory, including hidden files, in a long listing format. This command is a combination of two options -l and -a with the ls command.
- ls : The list command used to list directory contents.
- -l : This option displays the directory contents in a long listing format.
- -a : This option shows all the files in the directory, including hidden files (those whose names start with . ).
Understanding the Output of ‘ls -la’
When you run the ls -la command, it produces several columns of information. Let’s break down what each column represents:
- File Type and Permissions: The first column indicates the file type and the permissions for the owner, group, and others. The first character represents the file type ( d for directory, — for regular files). The next nine characters show the permissions in sets of three (read r , write w , execute x ) for the owner, group, and others respectively.
- Number of Links: The second column shows the number of hard links to the file or directory.
- Owner: The third column displays the name of the file or directory’s owner.
- Group: The fourth column shows the name of the group that owns the file or directory.
- Size: The fifth column indicates the file size in bytes.
- Last Modification Time: The sixth column displays the date and time of the last modification.
- File or Directory Name: The seventh column shows the name of the file or directory.
Practical Examples
Let’s consider an example. When you run ls -la in your home directory, you might see something like this:
In the output above, the first line represents the current directory (denoted by . ), the second line represents the parent directory (denoted by .. ), and the rest of the lines represent files and directories in the current directory.
Conclusion
The ls -la command is a powerful tool for viewing detailed information about files and directories in a Linux or Unix-like system. Understanding how to read its output can greatly enhance your proficiency in system administration tasks. For more information about the ls command and its options, you can refer to the man ls command or the ls man page.
No, the ls -la command is specific to Linux and Unix-like operating systems. On Windows, you can use the dir /a command to achieve a similar result.
To sort the output by file size, you can use the -S option with the ls -la command. So the command would be ls -laS .
To list only directories, you can use the -d option with the ls -la command. So the command would be ls -lad .
To display file sizes in human-readable format (e.g., in kilobytes, megabytes, etc.), you can use the -h option with the ls -la command. So the command would be ls -lah .
Yes, you can use wildcards with the ls -la command. For example, ls -la *.txt will list all files with a .txt extension in the current directory.
To list files and directories in a specific directory, you can provide the directory path as an argument to the ls -la command. For example, ls -la /path/to/directory .
To view hidden files and directories separately, you can use the -A option with the ls -la command. This option excludes the . and .. entries. So the command would be ls -laA .
Что делает "ls -la"?
Когда я вошел в -al Атрибут с помощью команды ls, я получил следующее:
Что означает каждый столбец и что означает total 76 обозначать здесь?
2 ответа
ls -al команда представляет собой комбинацию ls -l (используйте формат длинного списка) и ls -a (не игнорируйте записи, начинающиеся с.)
Результатом является длинный список ( ls -l часть) с (слева направо):
- тип файла
- права доступа к файлу
- количество ссылок
- имя владельца
- группа владельцев
- размер файла
- время последней модификации
- имя файла или каталога
в то время как ls -a означает, что скрытые файлы также перечислены.
смотрите также man ls (как всегда man является первым источником информации), и эта ссылка.
Еще немного объяснения того, что вы видите
Вывод начинается с количества дисковых блоков, используемых каталогом (в вашем случае 76). Из документации GNU:
Для каждого каталога, который указан в списке, предварите файлы строкой «Всего блоков», где «блоки» — это общее дисковое пространство для всех файлов в этом каталоге. Размер блока в настоящее время по умолчанию составляет 1024 байта, но это может быть переопределено.
Everything behind the ls -la * .c command.
![]()
The shell is a command interpreter that provides a user interface for accessing operating system services. The shell interprets certain commands that provide a function to the user to do certain specific processes.
very simple, welcome to the shell!
A shell works with an infinite loop, where it will be waiting for a command to be entered to proceed with the execution, this evaluates whether the command entered is valid or not, being negative this statement skips an error in the standard output, if it is positive it processes the execution and executes the command process entered.
the shell when the exit command is detected, closes the execution process with an output of 127; another way to close this process is with the ctrl + D key combination.
We will start by giving a quick definition of what “ls” is; is a basic command that lists the contents of directories alphabetically. Generally, the commands can receive more options if we look for more specific results, to add other options to any command, in this case “ls” we simply need to write the command followed by the minus sign “-” and the specific option we need, these options can be find in the man of each command, we can access this by typing man followed by the command, for example in this case it would be “man ls” and there we find the options that we can use together with our desired command, the following is to learn about wildcards, in this case “*” which are parameters that we can also pass to our commands and will be interpreted by the shell, this “*” is used to search for a specified file in the current directory, in this case by putting “* .c” that it will find all the files that match that instruction, now after all this is clear, we can understand what the command “ls” -la * .c does “
First there is ls that together with the option “l” which is to list with long format and “a” so as not to ignore those files that start with “.” and ending with the wildcard that will only list the files that match * .c, as a result we will obtain a detailed list of all the .c files that are in our current directory with date, creation, execution permissions, user and owner.
But that’s not all, that’s just a small part of what happens when entering this command or any other
When the user enters the command “ls -la * .c”, this is stored in a memory space to enter the infinite loop, it is read word by word, checking the options and wildcards, if it is valid, the shell starts a search in the path, which is where all the directories with executable files are found, if it does not find the executable file, it will show us an error message and it will be ready to repeat this with each command entered.
And all this is a very basic review on how the shell works as a command interpreter and everything behind it, explained in a very simple way and omitting things that are too technical.
What does 'ls -la' do?
When I entered the -al attribute with the ls command, I got the following:
What does each column mean, and what does the total 76 signify here?
![]()
![]()
2 Answers 2
The ls -al command is a combination of ls -l (use a long listing format) and ls -a (do not ignore entries starting with .)
The result is a long list (the ls -l part) with (from left to right):
- filetype
- file permissions
- number of links
- owner name
- owner group
- file size
- time of last modification
- the name of the file or directory
while the ls -a means that hidden files are listed as well.
see also man ls (as always man is the first source of information), and this link.
A little more explanation on what you see
The output starts with the number of disc blocks, used by the directory (in your case 76). From the GNU docs:
For each directory that is listed, preface the files with a line ‘total blocks’, where blocks is the total disk allocation for all files in that directory. The block size currently defaults to 1024 bytes, but this can be overridden.