To list files in a directory in Linux, you can use the ls command. Here are some common usages:
Basic Command
- List Files:
This command will display the names of files and directories in your current working directory.ls
Detailed Listing
- List with Details:
Thels -la-loption provides a detailed listing, showing file permissions, number of links, owner, group, size, and modification date. The-aoption includes hidden files (those starting with a dot).
Listing Files in a Specific Directory
- Specify a Directory:
Replacels /path/to/directory/path/to/directorywith the actual path of the directory you want to list. For example:ls /home/labex/project
Example
If you want to list all files, including hidden ones, in your home directory, you would run:
ls -la ~
Additional Options
Sort by Modification Time:
ls -ltThis lists files sorted by the time they were last modified, with the most recently modified files first.
Human-Readable Sizes:
ls -lhThis option shows file sizes in a human-readable format (e.g., KB, MB).
Feel free to try these commands in your terminal, and let me know if you have any questions or need further assistance!
