How to view hidden files in mac osx

there are three ways we can show hidden files in mac os x

1st approach:-
run below command in terminal 
defaults write com.apple.finder AppleShowAllFiles YES
above command will show the hidden files 
If you want to hide them again use the below code
defaults write com.apple.finder AppleShowAllFiles NO

2nd approach:-
Create a .bash_profile.
  1. In Terminal, paste the following: sudo nano ~/.bash_profile
  2. Enter your Mac’s administration password if required, then hit return
  3. At the bottom of the open .bash_profile file, paste the following: alias showfiles='defaults write com.apple.finder AppleShowAllFiles YES; killall Finder /System/Library/CoreServices/Finder.app'
  4. Below that, paste the following: alias hidefiles='defaults write com.apple.finder AppleShowAllFiles NO; killall Finder /System/Library/CoreServices/Finder.app'
  5. Press ctrl + O and hit return to save the file
  6. Press ctrl + X to exit the file and return to the command line
  7. In Terminal, paste the following: source ~/.bash_profile to refresh your profile and make the aliases available.
Simply type showfiles  in the terminal window to show hidden files and hidefiles to revert the earlier action.  

3rd approach:-
Create a .profile.
  1. In Terminal, paste the following: sudo nano ~/.profile
  2. Enter your Mac’s administration password if required, then hit return
  3. At the bottom of the open .bash_profile file, paste the following: alias showfiles='defaults write com.apple.finder AppleShowAllFiles YES; killall Finder /System/Library/CoreServices/Finder.app'
  4. Below that, paste the following: alias hidefiles='defaults write com.apple.finder AppleShowAllFiles NO; killall Finder /System/Library/CoreServices/Finder.app'
  5. Press ctrl + O and hit return to save the file
  6. Press ctrl + X to exit the file and return to the command line
  7. In Terminal, paste the following: source ~/.profile to refresh your profile and make the aliases available.
Simply type showfiles  in the terminal window to show hidden files and hidefiles to revert the earlier action.  

Note
Don't keep .bash_profile and .profile both in your home directory it can cause some problems therefore use either .bash_profile or .profile. Don't keep both of them in your file directory.

Conclusion
If you use 1st way user have to keep the whole command in mind and use whenever it needed but 2nd and 3rd ways are so simple because you need to just type showfiles in the terminal to unhide hidden files and hidefiles to hide them back.


Comments