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.
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.
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/ firstname.lastname@example.org:/path/to/dest/
- 30 Cool Open Source Software I Discovered in 2013
- 30 Handy Bash Shell Aliases For Linux / Unix / Mac OS X
- Top 30 Nmap Command Examples For Sys/Network Admins
- 25 PHP Security Best Practices For Sys Admins
- 20 Linux System Monitoring Tools Every SysAdmin Should Know
- 20 Linux Server Hardening Security Tips
- Linux: 20 Iptables Examples For New SysAdmins
- Top 20 OpenSSH Server Best Security Practices
- Top 20 Nginx WebServer Best Security Practices
- 20 Examples: Make Sure Unix / Linux Configuration Files Are Free From Syntax Errors
- 15 Greatest Open Source Terminal Applications Of 2012
- My 10 UNIX Command Line Mistakes
- Top 10 Open Source Web-Based Project Management Software
- Top 5 Email Client For Linux, Mac OS X, and Windows Users
- The Novice Guide To Buying A Linux Laptop