ZSH: command not found: ls

ZSH: command not found: ls

If you are getting the error "zsh: command not found: ls", it means that your shell does not recognize the ls command. This can happen if the ls command is not included in the default path that your shell searches for executables or if the ls command has not been installed on your system.

To fix this error, you can try the following steps:

  1. Check if the ls command is installed on your system by running the which ls command. This should print the path to the ls executable if it is installed. If the which command returns nothing, it means that the ls command is not installed, and you will need to install it.

  2. Check if the ls command is in your default path by running the echo $PATH command. This will print a list of directories that your shell searches for executables. If the directory containing the ls executable is not in this list, you will need to add it to your path.

  3. If the ls command is installed but not in your default path, you can add it to your path by modifying your .zshrc file. To do this, open the .zshrc file in a text editor and add the following line at the end of the file:

export PATH="$PATH:/path/to/ls/executable"

Replace /path/to/ls/executable with the actual path to the ls executable. Then, save the .zshrc file and run the source ~/.zshrc command to reload the file and update your shell's environment.

  1. If the ls command is not installed on your system, you can install it using your system's package manager. For example, on Ubuntu or Debian, you can use the apt command to install the ls command:

sudo apt install coreutils

On CentOS or Fedora, you can use the yum or dnf command to install the ls command:

sudo yum install coreutils


sudo dnf install coreutils

After installing the ls command, you should be able to run it without getting the "command not found" error.

What 'ls' command does

The ls command is a command-line utility used to list the contents of a directory. When you run the ls command, it displays a list of files and directories in the current directory. You can also use the ls command to list the contents of other directories by providing the path to the directory as an argument.

For example, the following command will list the contents of the /usr/bin directory:

ls /usr/bin

The ls command has many options that you can use to control the information that is displayed and the format of the output. For example, the -l option will show a long listing with detailed information about each file, such as its permissions, owner, size, and modification time.

Here is an example of the ls command with the -l option:

ls -l

To learn more about the ls command and all of its options, you can use the man command to read the manual page for ls. For example:

man ls

You will see this:

LS(1)                            User Commands                           LS(1)

       ls - list directory contents

       ls [OPTION]... [FILE]...

       List  information  about  the FILEs (the current directory by default).  Sort
       entries alphabetically if none of -cftuvSUX nor --sort is specified.

       Mandatory  arguments  to  long options are mandatory for short options too.

As you can see, the manual page for ls provides detailed information about the command's usage, options, and behaviour. You can use this information to learn more about the ls command and how to use it effectively.

Useful links: