Skip to content
Directory Listing (LIST/NLST)
step 1/5

Reading — step 1 of 5

Read

~1 min readFiles & Directories

Directory Listing (LIST/NLST)

LIST: detailed listing (Unix ls -l style):

-rw-r--r-- 1 alice users 1024 May 13 10:30 file.txt
drwxr-xr-x 2 alice users 4096 May 12 09:15 dir

NLST: names only:

file.txt
dir

LIST format is NOT standardized. Original RFC says "implementation defined". Common formats:

  • Unix: permissions links owner group size date name.
  • Windows: MM-DD-YY HH:MMxx <DIR>|<size> name.

Clients struggle to parse this reliably. Modern fix: MLST/MLSD (RFC 3659):

C: MLSD .
S: 150 Opening data connection
S: type=file;size=1024;modify=20240513103000;perm=adfr; file.txt
S: type=dir;size=4096;modify=20240512091500;perm=cpdmle; dir
S: 226 Transfer complete

Each fact is key=value;. Standardized parse.

Other related commands:

  • SIZE path: file size.
  • MDTM path: modification time.
  • STAT path: inline LIST without data channel.

Permissions:

  • perm= flags in MLSD: a (append), c (create), d (delete), e (cd), f (rename), l (list), m (mkdir), p (delete), r (retrieve), w (store).

Wildcards: NLST/LIST in many implementations support LIST *.txt, but not standardized.

Recursive listing: not in protocol; clients walk tree manually.

Path encoding: most servers use UTF-8 today. Old servers use ISO-8859-1. Client should detect via FEAT (UTF8 capability).

C: FEAT
S: 211-Features:
S:  UTF8
S:  MLST type*;size*;modify*;
S:  MLSD
S: 211 End

If UTF8 listed, client can use UTF-8 for paths via OPTS UTF8 ON.

Discussion

Ask a question, share an insight, or help someone who’s stuck.

Sign in to post a comment or reply.

Loading…