Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I use Git Bash as my terminal on Windows. When I ls in my Home directory, I see some NTUSER.DAT entries, which I assume are system files. They don't appear when I run dir in the default Windows Prompt.

What can I do so the ls command ignore these entries in the Git Bash as well?

Screenshot: http://i.stack.imgur.com/hDYbz.png

share|improve this question

3 Answers 3

After some digging, I found a way around it. I put the script below in my .bashrc file, so these settings load automatically with Git Bash. This piece of code was based on a dotfiles project.

LS_COMMON="$LS_COMMON --color=auto"
LS_COMMON="$LS_COMMON -I NTUSER.DAT\* -I ntuser.dat\*"

test -n "$LS_COMMON" &&
alias ls="command ls $LS_COMMON"
alias ll="ls -l"
alias la="ls -a"
alias lal="ll -a"
share|improve this answer

I added some folder patterns to the great (!) solution of thalesmello. Those folders were disturbing me on Windows 7. Now, my home-folder in git bash is completely empty. This is it!

# refers to http://superuser.com/questions/650322/ignore-ntuser-dat-files-when-ls-on-git-bash
# --color : On Windows7 this produces permission errors, e.g. for Music folder:
# LS_COMMON="$LS_COMMON --color=auto"
LS_COMMON="$LS_COMMON -I NTUSER.DAT\* -I ntuser.dat\*"
LS_COMMON="$LS_COMMON -I Pictures\*"
LS_COMMON="$LS_COMMON -I Start\ Menu\*"
LS_COMMON="$LS_COMMON -I Application\ Data\*"
LS_COMMON="$LS_COMMON -I Local\ Settings\*"
LS_COMMON="$LS_COMMON -I ntuser.ini"
LS_COMMON="$LS_COMMON -I ntuser.pol"
LS_COMMON="$LS_COMMON -I Favorites\*"
LS_COMMON="$LS_COMMON -I Searches\*"
alias ls="command ls $LS_COMMON"
alias ll="ls -l"
alias la="ls -al"
share|improve this answer

Thanks to previous answers, a Windows 8.1 version:

Add your alias: alias ls=ls_filter.bat $*.
Save the following as ls_filter.bat somewhere along your %PATH%:

@REM Runs ls with a filter to exclude some Windows folders, but only when run from the user's home folder.
@if "%CD%" == "%USERPROFILE%" (
    ls --color^
        -I "AppData" -I "Contacts" -I "Favorites" -I "Links"^
        -I "Music" -I "My Documents" -I "Pictures" -I "Videos" -I "Saved Games" -I "Start Menu" -I "OneDrive"^
        -I "NTUSER.*" -I "ntuser.*" -I "thumbs.db" -I "Thumbs.db" -I "desktop.ini"^
        -I "Application Data" -I "Cookies" -I "NetHood" -I "PrintHood" -I "Local Settings"^
        -I "Recent" -I "Searches" -I "SendTo" -I "Templates" %*
) else (
    ls --color -I "NTUSER.*" -I "ntuser.*" -I "thumbs.db" -I "Thumbs.db" -I "desktop.ini" %*

This makes it so the filter only applies when you're in your home directory. When in other directories, folders like Music and Videos won't be filtered out.

All of these filters make ls a little slow for me (I'm using Cmder), so I've substituted my ls for a faster version which takes the same arguments.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.