Pages

Thursday, June 29, 2017

Learn How to Use ‘dir’ Command with Different Options and Arguments in Linux

This article shows some examples of using the dir command to list the contents of a directory. The dircommand is not a commonly used command in Linux. Though it works more less like the ls command which most Linux users prefer to use. We’ll be discussing the dir command where we shall look at how to use different options and arguments.
dir Command Usage in Linux
dir Command Usage in Linux
The general syntax of the dir command is as follows.
# dir [OPTION] [FILE]
dir Command Syntax
dir Command Syntax

dir Command Usage with Examples

Simple output of the dir command

# dir /
dir Command Output
dir Command Output
Output of the dir command with the /etc directory file is as follows. As you can see from the output not all files in the /etc directory are listed.
# dir /etc
List /etc Directory
List /etc Directory
To list one file per line use -1 option as follows.
# dir
# dir -1
List Files per Line
List Files per Line

View all files in a directory including hidden files

To list all files in a directory including . (hidden) files, use the -a option. You can include the -l option to format output as a list.
# dir -a
# dir -al
List Hidden Files
List Hidden Files
Long List Hidden Files
Long List Hidden Files

View directory entries instead of content

When you need to list only directory entries instead of directory content, you can use the -d option. In the output below, the option -d lists entries for the /etc directory.
When you use -dl, it shows a long listing of the directory including owner, group owner, permissions.
      ▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬
                                                    ► Read more: http://adf.ly/1nBgFH
      ▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬

No comments:

Post a Comment