How to Use the Equivalent of the “ls” Command in Windows?

Linux users are very familiar with the ls command which is used to list files and folders. When migrating to Windows or using Windows they really question the “ls” command equivalent in Windows operating system. Windows operating systems provide alternatives via the MS-DOS and PowerShell command prompts.

Linux “ls” Command

The Linux provides “ls” command in order to list files and folders and describes the ls command with the following statement.

List information about the FILEs (the current directory by default)

The ls command provides a lot of options and parameters to list items in different ways like according to size, creation date, and type with different coloring.

$ ls

Windows “dir” Command is “ls” Command Equivalent

Windows MS-DOS and PowerShell command-line interface provide the dir command in order to list files and folders. By default without any option, the dir command lists files and folders. The dir command provides similar output to the ls command except for the owner and permissions information. The dir command lists the creation date, type, size of file, file, or folder name.

The help information about the dir command can be listed by using the /? .

> dir /?
dir Command Help

List files and folders for the specified path using the dir command.

> dir C:\Users

PowerShell “ls” Command Alias

PowerShell is the next-generation command-line interface for the Windows operating systems. PowerShell tries to mimic some commands and features of the Linux operating system and as a result, it provides the ls command. PowerShell “ls” command is just an alias but provides very similar usage and output like below.

> ls
PowerShell “ls” Command Alias

“‘ls’ is not recognized as an internal or external command” Error

If you try to run the ls command in Windows MS-DOS command prompt you will get the following error message.

'ls' is not recognized as an internal or external command,
operable program or batch file.
See also  How To Create Local User In Windows 10?

Leave a Comment