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. 

facebookShare on Facebook
TwitterTweet

Leave a Reply Cancel reply

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

Full text search

Recent Posts

  • Dumping AWS Organization tree
  • Free is the most expensive
  • Terraform conditional resource and blocks
  • Upgrade Ubuntu 16.04 to latest release
  • Inspect and control network traffic on AWS
  • aws (8)
  • coffee (1)
  • headfi (1)
  • linux (7)
  • others (55)
  • security (2)
  • tech (36)
  • wordpress (2)

apache aws awscli azure backup cloud coffee coreos distributed filesystem docker ec2 EL8 elasticcache etckeeper featured heartbleed kernel linux mail meltdown mysql php pine python rdp rds Redhat Red Hat RHEL RHEL7 rpm Ryzen snapshot spectre SSL systemd tech terraform ubuntu ubuntu upgrade vector vpn wordpress xtreemfs yum

©2022 blog.headdesk.me | Powered by SuperbThemes & WordPress