This article explains using the
ls command to list files and directories in Ubuntu Linux.
In Ubuntu Linux, the
ls command is mostly used to list files and directories in a directory. It provides a detailed view of the contents of the current directory, including file permissions, symbolic links, and more.
By default, it lists only the names of the files and directories in the current directory. However, it provides several options that can be used to customize the output of the command.
To use the
ls command, open the terminal on your Ubuntu system, and follow the examples below:
- List files and directories in the current directory:
- List files and directories in a specific directory:
- List files and directories with detailed information:
- List files and directories in a “human-readable” format:
- List all files, including hidden files:
- List files and directories sorted by modification time:
- List files and directories sorted by size:
ls The command provides several options to customize the listing output. Here are some additional options you can use:
--recursive: List files and directories recursively.
--sort=time: Sort files and directories by modification time.
--reverse: Reverse the order of the sort.
--inode: Display the index number (inode) of each file or directory.
--directory: List directories themselves, not their contents.
--classify: Append indicators to entries to indicate file types.
--no-group: Inhibit display of group information.
--human-readable: Display file sizes in human-readable format.
--version: Display the version information and exit.
--help: Display help information and exit.
Remember, you can combine multiple options to suit your needs. For example,
ls -lhtr will sort files and directories by modification time in reverse order and display their sizes in a human-readable format.
That should do it!
This post showed you how to use the ls command on Ubuntu Linux. Please use the comments form below if you find errors or have something to add.