Linux / Unix: scp Copy All Hidden Dot Files

I‘m using scp command to copy files from one server to another server. The problem is that I’m unable to copy all hidden files (such as .bash_history). How do I copy hidden files using the scp command under Unix like operating systems?

The scp command copies files between servers (computers) on a network. It uses ssh for data transfer, and uses the same authentication and provides the same security as ssh.

scp Command

The correct syntax is as follows to copy all files including hidden dot files:
$ scp -rp /path/to/source/. user@server2:/path/to/dest/

  • -r : Recursively copy entire directories. Note that scp follows symbolic links encountered in the tree trave
  • -p : Preserves modification times, access times, and modes from the original file.
  • /path/to/source/. : Appending a dot (.) symbol is very important when you specify /path/to/source as a source path. If you skip dot in path it will only copy normal files and scp will skip all hidden files.

rsync Command

I recommend that you use rsync command to copy files between Unix / Linux based servers and workstations.
$ rsync -avzP /path/to/source/ user@server2:/path/to/dest/
$ rsync -avzP /path/to/source/ user@

🐧 Get the latest tutorials on Linux, Open Source & DevOps via RSS feed or Weekly email newsletter.

🐧 4 comments so far... add one

CategoryList of Unix and Linux commands
Disk space analyzersdf ncdu pydf
File Managementcat cp mkdir tree
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Network UtilitiesNetHogs dig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg jobs killall kill pidof pstree pwdx time
Searchinggrep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNAlpine CentOS 8 Debian 10 Firewall Ubuntu 20.04
4 comments… add one
  • satish Apr 14, 2012 @ 5:25

    it’s good & thanks

  • santosh Apr 19, 2012 @ 16:25

    please can you provide about copy related information, i am copying facing problems.

    suppose i have 700GB data is there in my external harddisk, i want copy that amount of data to server, i am using “cp” command but some files are exsiting in server how to overwrite the files with using cp command or else fast copy tools there in linux.

    and also provide fast copying tools are there in linux or commands.

    please provide me.
    thanks’ to “vivek”.

  • Aditya Jun 17, 2015 @ 11:40

    scp -rp
    will fail for copying the system files like .profile .bash_profile etc

    how to copy all those ?

  • teja Sep 10, 2015 @ 14:36

    thanks for rsync

Leave a Reply

Your email address will not be published.

Use HTML <pre>...</pre> for code samples. Still have questions? Post it on our forum