Home
/
SSH Tutorials
/
List Files and Directories using SSH

List Files and Directories using SSH

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.

user@servername [~/path/to/current/folder]# ls
./  ../  1.txt  image.png  test  test123.txt

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

The above command lists all files and folders including hidden (starting with a dot) files and directories.

ls –R

Lists recursively (i.e follows subfolders as well) all files and folders under the current directory.

ls -l

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 a dot), provide more information about them and will continue recursively into each subfolder.

Share This Article