To view a directory’s files and directories, use ls command in Linux. One of the most frequently used commands in Linux, it may be found in the majority of Linux distributions. The command’s fundamental syntax is as follows:
Use of Ls command Example SYNTAX
note : options are the available flags and directory is the path where you want to list the contentsls [options] [directory]
The command will show the files and directories in the current working directory if you run it without specifying any parameters or a directory.
Common Flags to use
- -a : Using this option, all files, even hidden files and folders (files that begin with a dot), are displayed (.)
- -l : With the -l option, you may see information about the files and directories, including their size, last modification time, owner, group, and rights.
- -t : With the newest files displayed first, the -t option sorts files and folders according to when they were last modified.
- -r : Using the -r option, you can see the files and directories in reverse.
- -h : File sizes are shown with the -h option in a format that is understandable by humans.
- -R : When using the -R option, you can list files and directories recursively, which includes listing the contents of all subdirectories
To get the desired outcome, you can also combine several alternatives. For instance,
ls -ltr [directory]
The command above will show the files and directories in long format. Furthermore, the result will be arranged by the time of last modification, and in the opposite direction.
A very potent tool that can be used to list files and directories in various ways is the ls command. When working with several files and directories and when you need to locate particular files quickly, it is helpful.
Also have a look at this post which help you create new users using Linux terminal commands.
https://offsecpath.com/how-to-create-a-new-user-on-linux/