Что делает "ls -la"?
Когда я вошел в -al Атрибут с помощью команды ls, я получил следующее:
Что означает каждый столбец и что означает total 76 обозначать здесь?
2 ответа
ls -al команда представляет собой комбинацию ls -l (используйте формат длинного списка) и ls -a (не игнорируйте записи, начинающиеся с.)
Результатом является длинный список ( ls -l часть) с (слева направо):
- тип файла
- права доступа к файлу
- количество ссылок
- имя владельца
- группа владельцев
- размер файла
- время последней модификации
- имя файла или каталога
в то время как ls -a означает, что скрытые файлы также перечислены.
смотрите также man ls (как всегда man является первым источником информации), и эта ссылка.
Еще немного объяснения того, что вы видите
Вывод начинается с количества дисковых блоков, используемых каталогом (в вашем случае 76). Из документации GNU:
Для каждого каталога, который указан в списке, предварите файлы строкой «Всего блоков», где «блоки» — это общее дисковое пространство для всех файлов в этом каталоге. Размер блока в настоящее время по умолчанию составляет 1024 байта, но это может быть переопределено.
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 .
A beginner’s guide to Linux command-line
![]()
Systems administration and ops are one of my biggest areas of technical weakness.
I used GUI applications almost exclusively during the entirety of my education and first years working professionally. It didn’t help that the IDEs I used for Java, Eclipse and Netbeans, were absolutely amazing tools: I felt I had no reason to switch to what I perceived was a more time consuming way of doing things. In fact, the only command-line tool I used extensively was git .
When I finally started using Ruby on Rails and other scripting languages (and eventually got a Mac), I was at first flabbergasted by the lack of robust GUI tooling available. It was like I had reverted back to using notepad to code. It forced me to start using the terminal and command-line more often.
After a while I realized the power of the command-line. These commands were the APIs to the programs I used and I could use them however I wanted! Better yet, by changing commands together, you could do far more things than you could using a UI.
The journey has been tough. It’s hard to learn all this stuff without a guide. There’s just so much out there, and day-to-day you’ll only end up using a handful of commands.
I’ve written this document to hopefully help others focus their initial search on some common things they’ll end up using on a regular basis. A lot of it has been simplified and it glosses over some important concepts that will come in handy later. However, this should be useful for beginners.
First, some important concepts…
You’ll see these terms referenced throughout the post.
Current Directory
This is the current directory / folder, and is the default context your command will be run in. You can always find your Current Directory by typing pwd .
Arguments
Many of these commands take multiple arguments. In a lot of cases, the required argument is the file the command is being run on. When you see a command like more file.txt , the file.txt is the argument and the file the command is being run on. Every program has different arguments — check the documentation!
Flags
Flags are a way to set options and pass in arguments to the commands you run. Commands you run will change their behavior based on what flags are set. You should read the documentation of each command to know what flags are available.
For example, running ls with the -l flag ( ls -l ) will include more information in the result and change the format of what is returned.
Relative Path
Relative Paths are the names / paths to folders and files relative to your current directory. A relative path of myfolder/myimage.png , will mean the myfolder/myimage.png in the current directory, not anywhere else. If I was in another folder, that relative path would not point to the same myfolder/myimage.png .
Absolute Path
Absolute Paths are the names / paths to folders and files that your current directory. An absolute path is valid regardless of your current directory. /myfolder/myimage.png , will mean the same /myfolder/myimage.png regardless of what your current directory is. Note the / in front of the name.
Navigation 101
The first thing to learn is how to move around the directory structure and various folders.
Show your current directory with: pwd
pwd will Print your current Working Directory. It’s great to figure out where you are.
List files in a directory with: ls
ls lists files and folders in the current directory.
There’s a few flags you can use to make the listing easier to read or more informative:
- ls -l list all the files in a single column, along with their permissions, sizes and timestamps.
- ls -a lists all files, including hidden files.
You can combine flags:
- ls -la for example, will list all files in a single column, including hidden files.
You can also pass in the name of a folder to view the contents of that folder:
- ls myfolder will list the contents of the folder myfolder in your current directory.
Change directory with: cd
cd changes the directory. By default, the path is relative to the current directory. That means if I type cd myfolder , it will only work if the current directory I am in has a folder called myfolder . You can specify an absolute path by entering / in front of the folder path. cd /myfolder will work only if the root level / has a folder called myfolder .
Manipulation 101
Now that you know how to move around the directory structure, you’ll probably want to start making changes to it.
Create a directory with: mkdir
mkdir will make a directory with the name you pass it. To create a new directory called myfolder in the current directory, you would type in mkdir myfolder .
Create a file with: touch
touch will create an empty file with the name you provide.
Move a file with:mv
mv will move a file from the source to the destination. You can actually use mv to rename a file.
mv file_to_move folder_name_here will move the file into the folder. However, if the second argument turns out to be a file, it will overwrite the file.
Copy a file with: cp
cp will copy a file. It takes two arguments — the name of the file you want to copy, and the new path to the copy (including the file name).
You can use the -r flag to copy a directory.
Delete a file with: rm
rm will remove a file from your system. If you want to delete a directory, you would use the -r flag (recursive).
Note that this is a rather dangerous command, so be careful with it — there are many horror stories of accidentally deleting important things with a single command (often in conjunction with -r and * wildcards).
Editing 101
Now that you know how to move around, you’ll probably want to learn how to read, edit, and change files.
Read file contents with: more and tail
more and tail are two commands you can use to read file contents.
more filename.txt will open a reader where you can navigate through the file. When in more , you’ll be able to use some additional commands:
- You can use space to scroll down a full screen.
- The up and down arrow keys will scroll up and down a line.
- Pressing g will enter the goto mode. You can then enter a line number to go directly to that line.
- Pressing / will enter search mode — type in text to find and it’ll scroll to wherever that text is found. Pressing n will go to the next instance of that found text.
tail filename.txt will print the last 10 lines of a text file. You can use the -f flag (eg. tail -f filename.txt ) to follow the file in realtime. Whenever the file changes, it will print the last lines. This is useful if you are watching a log file for an application, for example.
Search through contents for a specific word with: grep
grep lets you search through text, returning the full line for any matches.
grep "text to find" filename.txt will search for text to find in filename.txt .
Change the contents of a file with: vi or vim
vi / vim is a ridiculously complicated text-editor that’s often your only option if you are manipulating files on a server. I’ve only learned enough of the basic commands to make small changes, but that should serve you well enough for now.
vi filename will open the file you want to edit.
Note that the editor opens in a mode ( normal mode ) that doesn’t let you type anything. You’ll need to press the i key to go into insert mode .
After you are done making your changes changes, you’ll want to go back into the normal mode by pressing escape .
- To make changes to a file, enter insert mode with i and type away.
- To save your changes, you enter normal mode with escape and press :w to write your changes.
- To quit, you enter normal mode with escape and type in :q to quit. If you made changes, you’ll need to type :q! to force it to quit.
That’s about all I know about this editor.
Practicals 101
Now that you know the basics, you’ll want to have this additional information so you can start actually making use of all of this in a real environment.
Get help on a command or find out more about it with: man
man is a command that displays a help manual for the command you pass in as an argument. Not all commands have manuals, and sometimes the manuals are confusing.
For example, man ls will show the manual for the ls command.
If there isn’t a man ual for it, you can also try passing in a -help or —help flag. Some programs have a built-in help that will tell you how to use it.
Referencing the Current Directory with: .
. is a way to explicitly reference the current directory. You’ll often see commands like mv ./file.txt ./potato.txt . The first . in ./ is the current directory.
Specify a wildcard with: *
* often represents a wildcard in commands. This means that the command will be run on any file that matches. You can use it to perform actions in bulk, such as running a mv of all files of a specific type:
For example, mv *.png images will move all .png files into the images directory.
It’s very easy to accidentally perform commands on files you don’t want using wildcards, so be careful!
Redirect output to another program with: |
| , known as pipes, are a way to unlock the power of Linux by chaining commands together. It routes the output of the command on the left of the | and passes it to the command on the right of the | .
For example, suppose I want to find all of the running instances of a program called zsh . I could use ps to find the list of all of my processes. However, this list could be massive, and scrolling through it all would be a pain. I could combine it with grep to search through the results of ps and display only what I am looking for: ps | grep zsh .
Save the results of a command to a file with: > and >>
> and >> will let you run a command and save the results to a file. > will overwrite the file with the results of the command, while >> will append or add the results to the end of the file.
l, ls & la — what are the differences, and are there more of these commands?
So, through typing several commands I’ve found that there’s not only ls , but l and la too. There doesn’t appear to be any man entries on Ubuntu 12.14. They all appear to do similar things with minor differences:
Just as a bit of trivia, are there more of these and what do they do? Is here any place to find this out? Unfortunately, google searching these commands gets ignored because they’re so short.
3 Answers 3
Aliases
ls is a command, l and la are most likely aliases which make use of the command ls . If you run the command alias you can find all the aliases on your system.
This will return all the aliases that match the pattern l=. or la=. .
Debugging it further
You can also use the command type to see how a particular command is getting executed. Is it a command, an alias, or a function.
Example
On my system I have the command ls aliased so that it calls ls but also includes a bunch of extra switches, like so:
In the above output you can see that ls is aliases, but then also on my system’s $PATH in the directories /usr/bin and /bin .