Write a listing of all directories and files on the computer to a compressed file.

sudo ls -RFal / | gzip > all_files_list.txt.gz
This command is meant to be used to make a lightweight backup, for when you want to know which files might be missing or changed, but you don't care about their contents (because you have some way to recover them). Explanation of parts: "ls -RFal /" lists all files in and below the root directory, along with their permissions and some other metadata. I think sudo is necessary to allow ls to read the metadata of certain files. "| gzip" compresses the result, from 177 MB to 16 MB in my case. "> all_files_list.txt.gz" saves the result to a file in the current directory called all_files_list.txt.gz. This name can be changed, of course.
Sample Output
A ~16MB file called "all_files_list.txt.gz". The first few lines after decompression:

total 37108
drwxrwxr-x+  36 root       admin          1292 Dec 14 20:02 ./
drwxrwxr-x+  36 root       admin          1292 Dec 14 20:02 ../
-rw-r--r--@   1 roryokane  admin         15364 Dec 14 22:39 .DS_Store
-rwxrwxrwx@   1 roryokane  roryokane     15364 Sep 11 06:17 .DS_Store (from old Mac)*
drwx------    3 root       admin           102 Aug 15 00:45 .Spotlight-V100/
d-wx-wx-wt@   2 root       admin            68 Aug 15 01:10 .Trashes/
-rwxr-xr-x    1 roryokane  admin            82 Jul 25  2007 ._Network*
srwxrwxrwx    1 root       admin             0 Dec 14 20:02 .dbfseventsd=
----------    1 root       admin             0 Jun 23 09:19 .file
drwx------   64 _unknown   _unknown       2176 Dec 14 22:06 .fseventsd/
-rw-------@   1 root       wheel        262144 Nov 12 07:02 .hotfiles.btree
drwxrwxr-x    7 root       admin           238 Sep  2  2006 .svn/
drwxr-xr-x@   2 root       wheel            68 May 18  2009 .vol/

2
By: roryokane
2009-12-14 21:40:56

What do you think?

Any thoughts on this command? Does it work on your machine? Can you do the same thing with only 14 characters?

You must be signed in to comment.

What's this?

commandlinefu.com is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.

Share Your Commands



Stay in the loop…

Follow the Tweets.

Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.

» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10

Subscribe to the feeds.

Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):

Subscribe to the feed for: