Invisible Dot Files Revealed!

Use the Terminal to list all files, even those that are hidden because their name starts with a dot.

 

Invisible Dot Files Revealed!
Mac Tip #363, 05 November 2008

The Finder hides files whose name begins with a dot.

The Finder hides files whose name begins with a dot.

In the last Tip, The Invisible Magic of the Dot File, you created a file named .atest.txt and saved it on the Desktop. You won’t find it though: because the filename begins with a dot the system hides it from you.

So, how can we see these invisible files?

Use the Terminal to list Files

One way is to use the Terminal. Mac Tip #126/05-Nov-2003, A Historic Terminal provided a very brief introduction to this piece of software. Mac Tip #349, 30 July 2008, List Applications and More showed one way to list the files in a folder.

Use Terminal to list files. With the right command the hidden files are visible.

Use Terminal to list files. With the right command the hidden files are visible.

To recap — open Terminal and type the following command to list the content of the Desktop folder: ls ~/Desktop .

Notes:

  1. The command begins with ls (ell ess) and a space
  2. the ~ key is known as tilde. On most keyboards you find it to the left of the 1 key, and you’ll need to press Shift.

The problem is, that if you do that, you still can’t see the invisible file. I keep my Desktop clean, so the only thing that showed up in my list was test.txt. The file .atest.txt was missing.

So, I tried again, with a slightly different command:

ls -A ~/Desktop

Note: this time I typed ls (ell ess) space -A (hyphen capital A).

Here’s what this command showed me:

.DS_Store   .atest.txt   .localized   test.txt  

The .DS_Store file holds information about the folder, such as whether to use List View or Icon View. The .localized file handles folder names for different languages, such as English, Japanese etc.

I can also now see both my test.txt file and the invisible .atest.txt .

Why are these files hidden?

The Operating System hides some files because most users don’t need to know about them. Many are essential to the functioning of your computer, while a few can be safely trashed or edited.

BBEdit has an Open Hidden command that shows hidden files.

BBEdit has an Open Hidden command that shows hidden files.

There’s an important rule though: trashing a hidden file could break your operating system and make your computer unusable. If you don’t know what a hidden file is and does then don’t touch it.

Other ways to see hidden files

Pathfinder, a Finder replacement, can hide or show hidden files.

Pathfinder, a Finder replacement, can hide or show hidden files.

Sometimes hidden files show up when you use certain programs. For example, I do most of my writing work with software called BBEdit. It has a menu option to ‘Open Hidden…’ because web designers often need to work with a hidden file called .htaccess.

I also use software called Pathfinder that replaces the built-in Finder. It offers many advantages, including a menu item to show and hide invisible files.

A clean sweep

The next Tip will tell you about software to track what’s using space on your computer. You may be surprised by large files hiding from you. When I did a sweep of my MacBook Pro recently I recovered 10 gigabytes of space lost to some unexpected hidden files.

Thanks for reading. Remember to tell your friends about MacTips. Subscribe for regular Tips.

Clip to Evernote

Tell us what you think.
Note: your comment is not published straight away. I check and approve all comments, otherwise the spammers get a free rein. I usually check comments within 24 hours.

* 2 comments… read them below and tell us what you think.

Jenna M 29 July 2009 at 09:40:19

I am self-taught in all of this so I found this tip incredibly helpful. I was able to view my files via the Terminal but how do I open them? I’m trying to find an htaccess file so I can upload it to MODx, a WYSIWYG program. I want to avoid having to pay for Path Finder. Grateful for any advice you can offer on this subject!

Reply

Miraz Jordan 29 July 2009 at 10:31:44

Excellent question Jenna.

the trick for web developers is to change the filename once the file hits the server. So: create a file on your own computer called htaccess (without the dot), upload it to the server and change the filename there to .htaccess.

Meanwhile:

1] on your Mac open Terminal and change directory to where the file is on your Mac. For example, on my Mac I have a file called .htaccess inside the Sites folder in my User directory.

I’d type this:

cd /Users/miraz/Sites

Now if you type ls -la you should see the .htaccess file listed.

2] Now *move* the file to the same directory but with a different name. The new name does not have the dot. Like this:

mv .htaccess htaccess

3] Now you can see the file in the normal way, without having to mess around with the Terminal. Open it with your usual text editor (NOT MS Word).

Extra TIP: the easy way to change directory in terminal:

1] open a Terminal window and type cd [space]
2] open the Finder window you want to cd to
3] drag the proxy icon (the wee folder) from the title bar of the Finder window into the Terminal window. This inserts the path to that folder
4] in Terminal press Return

I hope that helps.

Cheers,

Miraz

Reply

Add your Comment

Take Control ebooks (affiliate link) are superb.
I do some of my best learning from them. Buy through my link so I can make more and better Tips.

Take Control of Using Lion.   Buy Take Control of iCloud.  Macworld iPhone 4S Superguide   Take Control of iTunes 10: The FAQ, Second Edition