0

I'm setting up a new Mac running Monterrey 12.4.

I've used the standard method of the following terminal command:

defaults write com.apple.Finder AppleShowAllFiles true; killall Finder

This doesn't allow me to see hidden files in terminal, only in Finder.

How can I always show hidden files when I use ls in the terminal?

1
  • 4
    The fine man page for ls(1) describes the '-a' and '-A' options. Jul 14, 2022 at 2:37

3 Answers 3

3

How can I always show hidden files when I use ls in the terminal?

You could add something like alias ls='ls -a' to one of your startup scripts. Be careful though, changing the 'meaning' of ls might confuse more than it helps, so alias lsa='ls -a' might be preferable.

1

To see the hidden files in the finder you can also use cmd + shift + . (period)

and to check it on the terminal ls -a -a stands for all the files.

1

If you want to make this behavior permanent and always show hidden files by default, you can create an alias for the ls command that includes the -a option. Add the following line to your shell configuration file (e.g., ~/.bash_profile for Bash):

alias ls='ls -a'

After adding this line, restart your Terminal or run source ~/.bash_profile to apply the changes. Now, every time you type ls, it will automatically include the -a option, showing hidden files.

2
  • 1
    Your answer is already covered by an existing answer to this question. Check the help centre for more information on how to write good answers. Oct 18, 2023 at 14:24
  • Also many if not most mac users will not be using bash now as the default is zsh and the bash version is 15 years old
    – mmmmmm
    Oct 18, 2023 at 17:32

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .