ls - List providers, buckets, or objects

ls - List providers, buckets, or objects


gsutil ls [-a] [-b] [-d] [-l] [-L] [-r] [-p proj_id] url...

Listing Providers, Buckets, Subdirectories, And Objects

If you run gsutil ls without URLs, it lists all of the Google Cloud Storage buckets under your default project ID:

gsutil ls

(For details about projects, see gsutil help projects and also the -p option in the OPTIONS section below.)

If you specify one or more provider URLs, gsutil ls will list buckets at each listed provider:

gsutil ls gs://

If you specify bucket URLs, gsutil ls will list objects at the top level of each bucket, along with the names of each subdirectory. For example:

gsutil ls gs://bucket

might produce output like:


The "/" at the end of the last 2 URLs tells you they are subdirectories, which you can list using:

gsutil ls gs://bucket/images*

If you specify object URLs, gsutil ls will list the specified objects. For example:

gsutil ls gs://bucket/*.txt

will list all files whose name matches the above wildcard at the top level of the bucket.

See gsutil help wildcards for more details on working with wildcards.

Directory By Directory, Flat, And Recursive Listings

Listing a bucket or subdirectory (as illustrated near the end of the previous section) only shows the objects and names of subdirectories it contains. You can list all objects in a bucket by using the -r option. For example:

gsutil ls -r gs://bucket

will list the top-level objects and buckets, then the objects and buckets under gs://bucket/images1, then those under gs://bucket/images2, etc.

If you want to see all objects in the bucket in one "flat" listing use the recursive ("**") wildcard, like:

gsutil ls -r gs://bucket/**

or, for a flat listing of a subdirectory:

gsutil ls -r gs://bucket/dir/**

If you want to see only the subdirectory itself, use the -d option:

gsutil ls -d gs://bucket/dir

Listing Object Details

If you specify the -l option, gsutil will output additional information about each matching provider, bucket, subdirectory, or object. For example:

gsutil ls -l gs://bucket/*.txt

will print the object size, creation time stamp, and name of each matching object, along with the total count and sum of sizes of all matching objects:

   2276224  2017-03-02T19:25:17Z  gs://bucket/obj1
   3914624  2017-03-02T19:30:27Z  gs://bucket/obj2
TOTAL: 2 objects, 6190848 bytes (5.9 MiB)

Note that the total listed in parentheses above is in mebibytes (or gibibytes, tebibytes, etc.), which corresponds to the unit of billing measurement for Google Cloud Storage.

You can get a listing of all the objects in the top-level bucket directory (along with the total count and sum of sizes) using a command like:

gsutil ls -l gs://bucket

To print additional detail about objects and buckets use the gsutil ls -L option. For example:

gsutil ls -L gs://bucket/obj1

will print something like:

        Creation time:                    Fri, 26 May 2017 22:55:44 GMT
        Update time:                      Tue, 18 Jul 2017 12:31:18 GMT
        Storage class:                    MULTI_REGIONAL
        Content-Length:                   60183
        Content-Type:                     image/jpeg
        Hash (crc32c):                    zlUhtg==
        Hash (md5):                       Bv86IAzFzrD1Z2io/c7yqA==
        ETag:                             5ca67960a586723b7344afffc81
        Generation:                       1378862725952000
        Metageneration:                   1
        ACL:                              [
    "entity": "project-owners-867484910061",
    "projectTeam": {
      "projectNumber": "867484910061",
      "team": "owners"
    "role": "OWNER"
    "email": "",
    "entity": "",
    "role": "OWNER"
TOTAL: 1 objects, 60183 bytes (58.77 KiB)

Note that results may contain additional fields, such as custom metadata or a storage class update time, if they are applicable to the object.

Also note that some fields, such as update time, are not available with the (non-default) XML API.

See also gsutil help acl for getting a more readable version of the ACL.

Listing Bucket Details

If you want to see information about the bucket itself, use the -b option. For example:

gsutil ls -L -b gs://bucket

will print something like:

gs://bucket/ :
        Storage class:                MULTI_REGIONAL
        Location constraint:          US
        Versioning enabled:           False
        Logging configuration:        None
        Website configuration:        None
        CORS configuration:           None
        Lifecycle configuration:      None
        Labels:                       None
        Time created:                 Thu, 14 Jan 2016 19:25:17 GMT
        Time updated:                 Thu, 08 Jun 2017 21:17:59 GMT
        Metageneration:               1
    "entity": "project-owners-867489160491",
    "projectTeam": {
      "projectNumber": "867489160491",
      "team": "owners"
    "role": "OWNER"
        Default ACL:
    "entity": "project-owners-867489160491",
    "projectTeam": {
      "projectNumber": "867489160491",
      "team": "owners"
    "role": "OWNER"

Note that some fields above (time created, time updated, metageneration) are not available with the (non-default) XML API.


-l Prints long listing (owner, length).
-L Prints even more detail than -l. Note: If you use this option with the (non-default) XML API it will generate an additional request per object being listed, which makes the -L option run much more slowly (and cost more) using the XML API than the default JSON API.
-d List matching subdirectory names instead of contents, and do not recurse into matching subdirectories even if the -R option is specified.
-b Prints info about the bucket when used with a bucket URL.
-h When used with -l, prints object sizes in human readable format (e.g., 1 KiB, 234 MiB, 2 GiB, etc.)
-p proj_id Specifies the project ID to use for listing buckets.
-R, -r Requests a recursive listing, performing at least one listing operation per subdirectory. If you have a large number of subdirectories and do not require recursive-style output ordering, you may be able to instead use wildcards to perform a flat listing, e.g. gsutil ls gs://mybucket/**, which generally performs fewer listing operations.
-a Includes non-current object versions / generations in the listing (only useful with a versioning-enabled bucket). If combined with -l option also prints metageneration for each listed object.
-e Include ETag in long listing (-l) output.

Monitor your resources on the go

Get the Google Cloud Console app to help you manage your projects.

Send feedback about...

Cloud Storage Documentation