Menu
blog.headdesk.me
blog.headdesk.me

Copy directory in linux

Posted on 2016/05/042016/08/24

Back to 101, copy a directory. This sounds trivial but there are subtle differences that can make a huge difference.

I used to run this as it makes sense to me syntactically

rsync -av source/* dest/

It works well BUT all the hidden directories right below source/ will not be copied.

If I do any of the followings, source will end up being a subdirectories under dest:

rsync -av source dest

cp -ap source dest

cp -ap source/ dest

So what’s the correct way to do it? There may be a number of ways but this one works:

rsync -av source/ dest

Simple command, copies everything and preserve ownerships, permissions, and dates. 

Loading

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Full text search

Recent Posts

  • Generate secure password
  • AWS Compute Savings Plans
  • AWS Zonal Shift
  • Coffee break…
  • Prevent private key from being committed to git
  • aws (14)
  • coffee (2)
  • headfi (1)
  • linux (9)
  • others (61)
  • security (2)
  • tech (41)
  • terraform (3)
  • wordpress (2)

Loading

apache aws awscli azure backup boot cloud coffee docker ec2 EL8 ElasticBeanstalk espresso featured git kernel lelit linux lvm meltdown MFA nat gateway php power proliant python rdp Redhat RHEL rpm Ryzen scp security smartarray smart switch snapshot spectre tech terraform ubuntu ubuntu upgrade vpn windows wordpress workspace

©2026 blog.headdesk.me | Powered by SuperbThemes