List files and directories using SSH

In order to list all files and directories using an SSH client, you would need to execute the appropriate command. The command name, in this case, is ls and it accepts various parameters.

When using the command alone (without arguments):

ls

the output will be all visible files and folders without additional formatting or information.

In order to view more information about the files (such as their permissions, ownership, last modified date, etc) and at the same time to list the files and directories, you would need to supply additional arguments to the command. The most common arguments are as follows:

ls –a
(Short from –all) Lists all files and folders including hidden (starting with a dot) files and directories.

ls –R
(Short from –Recursive) Lists recursively (i.e follows subfolders as well) all files and folders under the current directory.

ls -l 
(Short from –long) Lists all files and folders, each on a separate line, and provides additional information about them (permissions, ownership and modified date)
The arguments, as is with most Unix based commands, can be combined. For example:

ls –alR
will list all files (even the hidden files starting with dot), provide more information about them and will continue recursively into each subfolder.


  • 39 Users Found This Useful
Was this answer helpful?

Related Articles

Create/Edit files and folders using SSH cmd line

There are various ways you can create a new file using the SSH command line.The easiest and most...

Move and copy files using SSH

Often you will need to move one or more files/folders or copy them to a different location. You...

Deleting files and folders via SSH

Sometimes you would need to remove a file or a folder from the system. To do so using SSH, you...

Extracting and creating archive files via SSH

Sometimes you would need to extract or create an archive file (i.e to install a script, you would...

Searching for files/text using SSH

In some cases you would need to find the location of a given file or to search for a certain text...