Normally ls doesn't print filenames that start with a dot. With -a, it does, but that includes . and .., which exist in all directories, and hence aren't very interesting. With -A it prints everything but those two.

$ touch normal .hidden
$ ls
normal
$ ls -a
./  ../  .hidden  normal
$ ls -A
.hidden  normal

In that if-statement, the command substitution $( .. ) captures the output of ls, and [[ -z ... ]] tests if it's the empty string. That is, that there's no files in the directory.

Usually, reading the output of ls is not a good idea, if you want to loop over files in the shell, you can just use *. Here, it should work, though, except for the fact that if the given directory name contains whitespace (or filename glob characters), they'll be expanded on the command line of ls, which may mess up the results.

See:

  • https://mywiki.wooledge.org/ParsingLs
  • When is double-quoting necessary?
Answer from ilkkachu on Stack Exchange
🌐
Fresh2Refresh
fresh2refresh.com › home › unix tutorial › learn advanced unix commands online › ls command in unix
LS command in UNIX | Learn UNIX Online | Fresh2Refresh.com
June 12, 2018 - Learn ls command in UNIX - ls -l ,ls -r, ls -t etc. There are many options available in ls command. You can get to know each option using man command.
🌐
Xah Lee
xahlee.info › linux › linux_file_dir.html
Linux: List Files
ls -al | grep word · list files whose name match regular expression word · Linux: Navigate Directory · Linux: List Files · Linux: Walk Dir. find, xargs · Linux: View Directory as Tree · Linux: Copy File · Linux: Move or Rename File · Linux: Create New File ·
🌐
YouTube
youtube.com › shorts › LYUqBZkVKjA
Linux: ls command #linux #linuxtutorials - YouTube
Here is how to use the ls command in linux
Published   September 18, 2024
🌐
Pluralsight
pluralsight.com › tech insights & how-to guides › cloud
Linux Commands for Beginners: LS | Pluralsight
But if you're new to Linux or just ... in any directory or anywhere on the command line, all it does is list the contents of your current working directory....
🌐
Linux Foundation
refspecs.linuxfoundation.org › LSB_1.1.0 › gLSB › ls.html
ls
ls is as specified in the SUS, but with differences listed below · displays the *, @, and | characters for executables, links, and FIFOs, respectively (in addition to the slash declared by the SUS)
🌐
Ethz
compenv.phys.ethz.ch › linux › basics_1 › 60_basic_commands
Basic shell commands — Basics of Computing Environments for Scientists
ls - List files · top - Interactive view of system resources and processes · man - View documentation ·
🌐
LinuxTeck
linuxteck.com › basic-ls-command-in-linux-with-examples
The Most 17 Useful 'ls' Command In Linux With Examples | LinuxTeck
December 28, 2025 - Note: 'ls -a' will list all the hidden files started with (DOT '.') format along with the normal files. In Unix/Linux all hidden files begin with the dot '.' the formats are marked hidden.
Find elsewhere
🌐
freeCodeCamp
freecodecamp.org › news › the-linux-ls-command-how-to-list-files-in-a-directory-with-options
The Linux LS Command – How to List Files in a Directory + Option Flags
September 10, 2024 - Type the ls -a command to list files or directories including hidden files or directories. In Linux, anything that begins with a .
🌐
LabEx
labex.io › questions › how-to-interpret-ls-la-output-628765
How to interpret ls -la output? | LabEx
October 30, 2025 - Learn how to interpret the ls -la output to understand file permissions, ownership, and modification dates for effective file management in Linux.
Top answer
1 of 2
40

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.

Then:

  • the first character describes wether it is a directory (d) or a file (-) (or some other file type, see the docs for a complete listing)

File permissions:

  • the permissions in a nine-character section (3x3 for owner / group / other users)

Links

  • The number of links is the number of hard links to the file. For a directory, the number of hard links is the number of (immediate) subdirectories plus the parent directory and itself.

Owner

  • name of the owner
  • name of the (owner) group

File size

  • You see many files with the size of 4096, which is the minimum size for a directory on ext3 and ext4.
2 of 2
4

ls - list directory contents

You have 76 directories in /home/blog

drwxrwxr-x - These are the permissions for each one

The number after the permissions is the number of file/folders/links in this folder

After that the current user

After that the folders owner

Next is the group ID for the group the file belongs too.

Next is date and time the file was modified

The far right entery is the name of the folder

You can append ls with other commands for example

ls -a

Displays hidden files (starting with .)

You can find all the commands here

🌐
Hostinger
hostinger.com › home › tutorials › how to use the linux ls command
How to use the ls command in Linux?
December 22, 2025 - This output shows that example.txt is owned by the root user, belongs to the developers group, is 2635 bytes in size, and was last modified on January 15 at 00:46. To display hidden files in Linux, run the ls -a command. This reveals all files ...
🌐
Hostman
hostman.com › tutorials › the ls command in linux
The ls Command in Linux | Hostman
December 15, 2025 - A relative path specifies the location of objects relative to the current position (current directory). In the beginning of the address line, you might see: ... The Linux ls command displays information about directories and files located in folders.
Price   $
Address   1999 Harrison St 1800 9079, 94612, Oakland
🌐
Linux.org
linux.org › docs › man1 › ls.html
ls - list directory contents at Linux.org
control characters specially) -o like -l, but do not list group information -p, --indicator-style=slash append / indicator to directories -q, --hide-control-chars print ? instead of nongraphic characters --show-control-chars show nongraphic characters as-is (the default, unless program is 'ls' and output is a terminal) -s, --size print the allocated size of each file, in blocks -S sort by file size --sort=WORD sort by WORD instead of name: none (-U), size (-S), time (-t), version (-v), extension (-X) --time=WORD with -l, show time as WORD instead of default modification time: atime or access o
🌐
RapidTables
rapidtables.com › code › linux › ls › ls-la.html
ls -la | Linux/Unix command 11M
Linux commands pages. The code was tested with Ubuntu 13.04. ... This website uses cookies to improve your experience, analyze traffic and display ads.
🌐
GeeksforGeeks
geeksforgeeks.org › linux-unix › list-one-filename-per-line-in-linux
List One Filename Per Line in Linux - GeeksforGeeks
July 23, 2025 - To list one filename per line, we use the ls option -1, so run the following command to list down the items:- ... To list hidden files also, we use the -a flag or option in the command.
🌐
Vultr
docs.vultr.com › how-to-use-the-ls-command-in-linux
How to Use the ls Command in Linux: Essential Guide | Vultr Docs
August 16, 2024 - The above command finds all files modified in the last 7 days and lists them in long format. ... You have used the ls command in Linux to list directory contents, navigate the file systems, and manage files and directories.