How to list files in a different directory?

QuestionsQuestions8 SkillsProDec, 21 2025
098

That's a great question! To list files in a different directory, you simply provide the path to that directory as an argument after the ls command.

Here is the general syntax:

ls /path/to/directory

Here are a few practical examples you can try right now in your terminal:

  1. List the Root directory:
    The root directory / is the very top of the Linux file system.

    ls /
  2. List the /etc directory:
    This is a standard Linux directory where system configuration files are stored.

    ls /etc
  3. List a specific folder inside your home directory:
    Since you know you have a Desktop folder in your home directory (~), you can peek inside it like this:

    ls ~/Desktop

Pro Tip: You can also list multiple directories at once by putting a space between them:

ls /home/labex/project /etc

By adding the path after ls, you can explore any part of the system without having to move there first! Do you want to try navigating into one of those folders next?

0 Comments

no data
Be the first to share your comment!