While building WebShell, I needed a reliable way to get file lists and metadata from ls. Here’s a note.
Command
ls -Al --time-style=full-iso
The output looks like:
total 190600
-rw-r--r-- 1 root root 1781 2023-07-24 09:56:56.520113036 +0800 cosfs.sh
drwxrwxrw- 3 root root 4096 2023-06-05 16:32:39.466006640 +0800 dir1
drwxrwxrw- 2 root root 4096 2023-05-27 20:46:06.219707419 +0800 dir2
lrwxrwxrwx 1 root root 4 2023-09-05 21:45:49.401943527 +0800 dir3 -> dir1
drwxr-xr-x 3 root root 4096 2023-05-06 06:57:38.000000000 +0800 docs
drwxr-xr-x 484 root root 20480 2023-05-06 15:42:58.494411265 +0800 node_modules
drwxr-xr-x 4 root root 4096 2023-08-29 11:07:33.162370076 +0800 .orca_term
-rw-r--r-- 1 root root 195132152 2023-06-14 19:04:12.167000570 +0800 test 2.zip
From this output, you can parse:
- Permissions
- Owner
- Group
- File size
- ISO time with timezone
- File name (and symlink target if
->)
Limitations / compatibility
time-style is not supported on all Linux distributions, and Unix-like systems may not support it either.
Examples:
- Alpine Linux does not support it and has no built-in equivalent.
- Unix-like systems such as FreeBSD do not support it.
Workarounds
- Install
coreutils. On FreeBSD:pkg install coreutils. On Alpine:apk add coreutils. - Avoid
time-styleand combinestatinstead. The downside is worse performance due to extra commands.
Final Thoughts
Linux has many distributions. Be careful about compatibility, which depends on command versions and Linux/Unix standards.

