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?
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 onext3andext4.
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