Introduction: Copy Hidden Files and Hidden Directories ONLY in /home Using Command Line

I spend an hour trying to copy hidden files and directories under /home directory using the much loved 'cp' command. What is so hard about copying? It's chicken feet! But not when it comes to copying hidden files and directories under /home directory. So this instructable is more of a reminder to me than me wanting to teach.

Hidden files and hidden directories under /home directories are important in controlling the preferences of the applications installed in the system. Therefore backing up hidden files and directories is an important task.

My backup requirement:

  • First-level hidden directories will be copied.
  • First-level hidden files will be copied.
  • Hidden directories of type Symlinks will not be copied
  • Hidden files of type Symlinks will not be copied
  • First-level directories that are not hidden but contains hidden files will not be copied

Step 1: Find and Copy Hidden Files and Hidden Directories ONLY

Decide your source directory to copy from. For example /home/john_doe

Decide your destination directory to copy to. For example /media/usb_drive

Open Terminal Emulator

Enter the following command:

find -H /home/john_doe -maxdepth 1 -name '.??*' -a \( -type d -o -type f \) -exec cp '{}' -R /media/usb_drive \; 


find -H /home/john_doe -maxdepth 1 -path './.*' -exec cp '{}' -R /media/usb_drive \;


Uncle Kudzu made it! (author)2015-09-03

I don't recall ever trying to do this, but now I'll know how. Thanks for sharing.

About This Instructable



Bio: Systems Administrator and Software Programmer.
More by mirza irwan osman:Install Modem USB Device in Raspberry PiMake the Volume Knob of Sound Blaster X-Fi Surround 5.1 Pro Sound Card Work in Raspberry PiCreate a Volume Control for USB Sound Card in Raspberry Pi
Add instructable to: