Displays files and directories. There are many options as shown below, so it is impossible to learn them all. There are so many options that it is impossible to learn them.

     ls -- list directory contents

     ls [-ABCFGHLOPRSTUW@abcdefghiklmnopqrstuwx1] [file ...


  • The file in jupyter notebook format on github is here .

google colaboratory

  • To run it in google colaboratory here ls_nb.ipynb)


The author’s OS is macOS, and the options are different from those of Linux and Unix commands.

When you actually run the command, you should not use the leading ! and %%bash in the first line.

ProductName: Mac OS X
ProductVersion: 10.14.6
BuildVersion: 18G2022
!bash --version
GNU bash, version 3.2.57(1)-release (x86_64-apple-darwin18)
Copyright (C) 2007 Free Software Foundation, Inc.

Example usage

No options. Displays the files in the directory directly below.


The most commonly used is ls -al. This is an alias setting. It is in a list format and will also show you hidden files starting with a dot.

ls -al
total 24
drwxr-xr-x 6 hiroshi staff 192 7 3 18:50 [34m.[m[m/
drwxr-xr-x 24 hiroshi staff 768 7 3 18:36 [34m. [m[m/
drwxr-xr-x 3 hiroshi staff 96 6 24 19:46 [34m.ipynb_checkpoints[m[m/
-rw-r--r-- 1 hiroshi staff 2967 7 3 18:49 ls_nb.ipynb
-rw-r--r-- 1 hiroshi staff 1052 7 3 18:49
-rw-r--r-- 1 hiroshi staff 970 7 3 18:49

Typical options

  • a = all
  • l == list