Linux Mint

How To List only Directories in Linux Mint 20.3

You can use different commands in Linux to display all the contents of a particular directory. However, sometimes, you are only interested in the list of directories of your system. Therefore, in this guide, we will learn some methods of listing only the directories on a Linux Mint 20.3 system.

Methods of Listing only Directories in Linux Mint 20.3

For listing only the directories of your Linux Mint 20.3 system, you can use any of the following five methods. Although each of these five methods will display the intended output in a different format, the main goal of all these methods is the same.

Method 1: Using the “ls” Command

For using the “ls” command for listing the directories of your system, you have to run it in the manner shown below:

$ ls –d */

All the directories of our system are shown in the following image:

Method 2: Pairing the “ls” Command With the “grep” Command

In this method, we will pair the “ls” command with the “grep” command for displaying all the directories of our system in the following manner:

$ ls –l grep ‘^d’

The directories of our system, along with their access permissions, are shown in the following image:

Method 3: Using the “find” Command

This method will use the “find” command to list down all the directories of the Linux Mint 20.3 system. You simply need to run the following command:

$ find . –maxdepth 1type d

All the directories of our system are shown in the following image:

Method 4: Using the “echo” Command

Now, we will use the “echo” command in the following manner for displaying all the directories of our Linux Mint 20.3 system on the terminal:

$ echo */

The following image displays all the directories of our system:

Method 5: Using the “printf” Command

Finally, we will be using the “printf” command in the following manner for displaying all the directories of our system:

$ printf%s\n’ */

All the directories of our Linux Mint 20.3 system are shown in the following image:

Conclusion

This article discussed some methods of listing only the directories of a Linux Mint 20.3 system. We shared with you five methods you can use easily. You can pick any of these methods and follow them to display only the directories of your Linux Mint 20.3 system.

About the author

Karim Buzdar

Karim Buzdar holds a degree in telecommunication engineering and holds several sysadmin certifications. As an IT engineer and technical author, he writes for various web sites. He blogs at LinuxWays.