HostOnNet Blog

SSH commands to List files and directories

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
404.html   Downloads           index.html  Public      Videos
Desktop    examples.desktop    Music       Templates
Documents  hs_err_pid5482.log  Pictures    Ubuntu One

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)

$ ls -a
.                   .gconf                          .mozilla
..                  .gimp-2.8                       Music
404.html            .gksu.lock                      .opera
.adobe              .gnome2                         Pictures
.apport-ignore.xml  .gnome2_private                 .pki
.arcot              .gnome-color-chooser            .profile
.aspell.en.prepl    .goutputstream-BT8DYW           Public
.aspell.en.pws      .goutputstream-JP29TW           .pulse
.bash_history       .goutputstream-M53BTW           .pulse-cookie
.bash_logout        .goutputstream-QVCI0W           .purple
.bashrc             .goutputstream-XL8AZW           .putty
.cache              .gphoto                         .remmina
.compiz             .gstreamer-0.10                 .speech-dispatcher
.config             .gtk-bookmarks                  .ssh
.dbus               .gtkrc-2.0-gnome-color-chooser  Templates
Desktop             .gvfs                           .thumbnails
.dmrc               hs_err_pid5482.log              .thunderbird
Documents           .ICEauthority                   Ubuntu One
Downloads           .icons                          Videos
examples.desktop    index.html                      .Xauthority
.filezilla          .java                           .xsession-errors
.fonts              .local                          .xsession-errors.old
.freerdp            .macromedia
.furiusisomount     .mission-control
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 -laR

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


About Vineesh Mohan

A Technical Support specialist with strong customer service and good communication skills. I live in the city of Cochin, which known as the Queen of Arabian Sea.
Posted in Linux