Multiple choice technology operating systems

Command to List all the list all directories from home directory?

  1. ls -ltr

  2. ls -ltr | grep "^d"

  3. ls -a | grep "^l"

  4. ls -ltr | grep "^l"

Reveal answer Fill a bubble to check yourself
B Correct answer
Explanation

The command ls -ltr | grep "^d" lists directory contents with long format, sorting by modification time in reverse order, and filters lines starting with d (which represents directories in Unix file permission strings). The other options filter by l (symbolic links) or do not filter for directories.