In Linux operating system, most users especially administrators perform tasks and operations using command- line shell, despite GUI (graphical user interface) has gaining popularity. The actual fact is that the commands in Linux is much more powerful, which usually can get the jobs done quickly.
Sometimes, Linux users may need to make a full copy or exact duplicate of an entire whole directory (folder), including all sub-directories. For example, to do a backup of all files and directories inside a folder. Copy entire directory at one go is easy in Linux, with just a simple cp command.
cp -r -a sourcedir targetdir
Where sourcedir is the origin directory, and targetdir is the next directory to copy to. “-r” is the switch parameter to instruct cp command to copy objects recursively to include all subdirectories, while “-a” flag preserves ownerships and permissions.
cp -r -a /home/user/files /home/user/backup
Above command will copy and duplicate /home/user/files directory as /home/user/backup directory, with all its contents.
cp -r * /home/user/backup
Above command will copy all files and subdirectories of current directory to /home/user/backup folder.
Share This Post
- Able2Extract Professional 11 Review – A Powerful PDF Tool
- How to Install Windows 10 & Windows 8.1 with Local Account (Bypass Microsoft Account Sign In)
- How to Upgrade CentOS/Red Hat/Fedora Linux Kernel (cPanel WHM)
- How to Install Popcorn Time Movies & TV Shows Streaming App on iOS (iPhone & iPad) With No Jailbreak
- Stream & Watch Free Torrent Movies & TV Series on iOS with Movie Box (No Jailbreak)
- Steganos Privacy Suite Free Download With Genuine License Series Key Code
- Windows 10 Insider Preview Build 18262 Released To Insiders in the Fast Ring and Skip Ahead
- Windows 10 Insider Preview Build 18267 – What’s New, Improved, Fixed, and Known issues
- O&O DiskImage Free Download With Genuine License Key Code
- Avira Prime Free 3-Months All-in-One Premium Services – Avira Antivirus Pro, Avira Phantom VPN Pro, Avira Identity Scanner Pro, Avira System Speedup Pro, Avira Software Updater Pro, Password Manager Pro