How to Copy Directory in Linux


In this post, we are going to see how to copy directory in Linux. Linux is an open source operating system that has many distributions and platforms. Most of the people use Windows as their operating system as it is user friendly and compatible to almost all the software. Unlike Windows, Ubuntu and Linux based operating systems are not user friendly. A beginner or a newbie will face many difficulties in using a Linux based operating system like Ubuntu. Ubuntu is the best platform for Linux and we can easily show and make a copy of directory in Ubuntu. There are two methods. They are as follows –

Methods to Copy Directory in Linux –

  1. Command Line Method
  2. Graphical User Interface Method


copy directory in linux
how to copy a directory in linux


Command Line Method –


For example, if we want to copy a folder, you need to use sudo command.


“SUDO” is a command to get the administrative privileges. Fire up a terminal using the combination of buttons- “CONTROL + ALT + T“.


If you want to copy a directory, the command you must use is “sudo cp“.


If you are going to copy a folder named “Downloads” to another folder, you must specify the path where the Downloads directory is located and then the path where the Downloads directory has to be copied. Let us assume the Downloads directory has to be copied to the Desktop.


cp -a /user/local/Downloads /user/local/Desktop – This is the command you must use to copy the Downloads directory to Desktop directory.


sudo cp -a /user/local/Downloads /user/Desktop – This is the command you can execute with the administrator privileges. -a command is used to improve the recursive option and to preserve all the attributes.


sudo cp -av /user/local/Downloads /user/Desktop – With this option, the process will be clearly visualised in the terminal.


sudo cp -avr /user/local/Downloads /user/Desktop – With this option, the process will be clearly visualised in the terminal and will be copied recursively.

Graphical User Interface Method-


Open the directory you want to copy. For example, if you want to copy the Downloads folder to Desktop, got to the location where the Downloads folder is available.


Right click on the Downloads folder and select copy (CONTROL+C).


Go to the location where it has to be pasted. Right click and select paste (CONTROL+V).

The graphical method is simple and is very popular where as the command line method is a bit complex to understand the commands.

Things you need to keep in mind while using Command Line Method –

  1. Use correct form of alphabets. If the folder name is a mix of capital and small letters, use them as it is.
  2. Never try to use 2 or more commands in the same line as it may cause confusion and some errors.
  3. All the Linux based operating systems uses Linux terminal commands. Windows and Mac systems have their own type of commands and does not match with the Linux commands.

Also check the following link

How to Remove Directory in Linux