Ad
Sponsored by Sir Tauqeer
CLICK HERE TO JOIN SIR TAUQUEER WHATSAPP GROUP
FOR PREPARATION CLASSES AND JOBS UPDATES
Join Now

Which command in Linux is used to list files in a directory?

A. dir
B. ls
C. list
D. cd
Correct Answer: B. ls

In Linux and other Unix-like operating systems, the command used to list files and directories within a specified directory is ls. This command is fundamental for navigating and understanding the file system structure. By default, `ls` lists the contents of the current directory. It also supports various options, such as `ls -l` for a detailed (long) listing, `ls -a` to show all files including hidden ones, and `ls -h` for human-readable file sizes.

  • dir is the command used in Windows (DOS/CMD) to list directory contents, not in Linux.
  • list is not a standard or recognized command for listing directory contents in Linux.
  • cd stands for 'change directory' and is used to navigate between different directories in the file system, not to display their contents.

Thus, `ls` is the correct and universally recognized command for listing files in Linux.

Leave a Comment

Join Our WhatsApp Channel ×
Scroll to Top