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

About: Systems Administrator and Software Programmer.

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

Teacher Notes

Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.

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 \;

Be the First to Share


    • Made with Math Contest

      Made with Math Contest
    • Multi-Discipline Contest

      Multi-Discipline Contest
    • Robotics Contest

      Robotics Contest


    Uncle Kudzu

    4 years ago on Introduction

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