Directory Info vs Directory Contents
In bash when using the ls command to list the content of the filesystem the shell behaves in a quite annoying way: when specifying a directory to be shown, the command instead of showing information about the directory itself (permissions, timestamp info, etc) it shows the content of the directory.
For instance here we try to get the info about the '/var/log' directory:
# 'll' is an alias for 'ls -lah' # so feel free to use 'ls -lah /var/log' instead user@TC21:/$ ll /var/log total 332 drwxrwxr-x 1 root syslog 512 Jun 4 00:09 ./ drwxr-xr-x 1 root root 512 Jun 3 23:41 ../ -rw-r--r-- 1 root root 434 Jun 4 00:09 alternatives.log drwxr-xr-x 1 root root 512 Jun 4 00:09 apt/ -rw-rw---- 1 root utmp 0 Jun 3 23:41 btmp drwxr-xr-x 1 root root 512 May 14 01:38 dist-upgrade/ -rw-r--r-- 1 root root 41015 Jun 4 00:09 dpkg.log drwxr-sr-x 1 root systemd-journal 512 Jun 3 23:39 journal/ drwxr-xr-x 1 landscape landscape 512 Jun 28 18:21 landscape/ -rw-rw-r-- 1 root utmp 292292 Jun 28 18:21 lastlog drwxr-x--- 1 root adm 512 Jul 21 2020 unattended-upgrades/ -rw-rw-r-- 1 root utmp 0 Jun 3 23:41 wtmp user@TC21:/$
List Only the Directory Itself
To list information only about the directory in question (in our example /var/log), use the '-d' switch with the ls command
# List directory info user@TC21:/$ ll -d /var/log drwxrwxr-x 1 root syslog 512 Jun 4 00:09 /var/log # If the 'll' alias is not set for you, use the 'ls -lah' command itself instead user@TC21:/$ ls -lahd /var/log drwxrwxr-x 1 root syslog 512 Jun 4 00:09 /var/log
Comments