The Linux Equivalent of the Windows DIR Command and How to Use It


In law to glance the information Abroad the documents in a listing, you could Apply the dir propound. The default manner of the dir propound is to listing the facts of the genuine listing. If neither -cftuvSUX nor –put In order alternatives are used, the gadgets are taken care of alphabetically.

What Will We Talk About?

In this disabuse., we demise glance the way to Apply the dir propound to listing the facts Abroad a given listing and detect Abroad the dissimilar alternatives to put In order the gadgets Center it.

Syntax of the Dir Command

The dir propound has the aback fashionable syntax:

$ dir <OPTION><FILE>

Use of the Dir Command with Examples

The dir propound is most usually used to mien a listing’s contents in fashionable alphabetical law.

By default, the dir propound lists the documents Center the genuine operating listing if no illiberal listing is designated.

How to List the Files and Directories in a Given Path

If you craving a authoritative listing of the contents of a listing, strict name the listing’s admission to the scope of the propound. For instance, the contents of the House listing of the consumer LinuxSuggestion listing are exact argumentative consideration follows:

If you best craving to show one record in keeping with type, Apply the -1 parameter argumentative consideration proven inside the aback:

How to List the Hidden Files and Directories

The -a parole. makes the listing list encompass the real documents (.) in Arrival to the Continuous record names. Additionally, with the -l parole., the output is supplied in a listing layout:


How to List the Directory Entries

The -d parole. is used to mien strict the listing entries instead of the contents of a listing. The consumer House listing’s contents are proven inside the aback output with the -d parole..

The listing’s proprietor, workforce proprietor, and permissions are all proven in an in depth list whilst -dl is used.

$ dir -d /House/linuxhint


$ dir -d -l /House/linuxhint

How to List the Index Number of Files

The index node is cited by means of the “inode” acronym. An inode is a completely unique integer this is assigned to complete record and listing in a filesystem.

A filesystem’s mass inode investigate is ready whilst it’s far created and might’t be changed dynamically. Consequently, it’s important to frequently Prove the inode utilization to make imperative it complies with the set obstacles.

We can win the index/inode reckon of every record the use of the -i parole.:

How to Sort the Files Based on Size

We can glance the bigness of Segregation documents the use of the -s parole.. Furthermore, we also can deportment the record sizes in a always intuitive semblance the use of the -h parole.:

As we will glance from the output, the record sizes are in Kilobytes (glance the primary column). Also, to put In order the documents by means of bigness, we will genuinely name the -S parole.:

How to Sort the Files Based on Modification Time

Interestingly, we also can law our documents in line with once they have been Conserve changed, with the maximum currently up to date ones ostensible Knowledge the pinnacle. The -t transfer is available in artist in this place:

How to List the Files beyond Owners

You can Apply the -g transfer love -l to listing the documents however beyond their proprietors. Also, the -G transfer may be used to listing the documents beyond printing the workforce names.

$ dir -ahgG /House/linuxhint

It is Absolve from the stated whole that neither the record proprietor nor the workforce proprietor is displayed. Additionally, the –writer parole. presentations the record’s writer:

$ dir -al –author /House/linuxhint

Also, we ought to Apply the -l parole. in this place to glance the writer’s import.

How to List the Directories Before Any File

If you craving to listing the directories previous to some other documents, Apply the –group-directories-first substance:

$ dir -l –group-directories-first

You can glance that the directories are proven Onwards the Continuous documents. Also, accompanying directories, the “d” prefix is used, while “-“ is used accompanying Continuous documents. Using the -R parole., you could listing the subdirectories in a recursive semblance:

$ dir -R -l –group-directories-first

How to List the Files with the User and Group IDs

You might also Apply the -n parole. in law to glance the consumer and workforce IDs. Let’s exhibition Knowledge how the output differs with and beyond -n:

Without the -n parole.:

With the -n parole.:

How to List the Files Separated by means of Commas

The -m parole. lets in you to listing the documents disjoined by means of commas.

Use the –aid parole. to win always facts Abroad dir, and the –model flag to glance dir’s model facts.

$ dir –help


$ dir –model


These are strict some times of the way the dir propound may be used. There are a Wrong Assortment of additive alternatives useful. To detect always Abroad the dir propound, glance dir documentation from the person pages.

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More