You can copy the contents of a folder /source to another existing folder /dest with the command:

cp -a /source/. /dest/

The -a option is an improved recursive option, that preserves all file attributes and symlinks.

The . at end of the source path is a specific cp syntax that copies all files and folders, including hidden ones.

Answer from enzotib on askubuntu.com
🌐
Opensource.com
opensource.com › article › 21 › 8 › copy-files-linux-terminal
Copy files in the Linux terminal | Opensource.com
To copy a file in a terminal, you use the cp command, which works exactly like the mv command, except that it duplicates the contents of a file rather than moving them from one location to another.
Discussions

windows - How to copy specific files from one folder to another from the command prompt - Stack Overflow
I have a large folder of pictures (thousands), and I have a long list of files, by exact file name, that I need to copy to another folder using Windows commands, through cmd prompt only. I use Wind... More on stackoverflow.com
🌐 stackoverflow.com
linux - Copying All Files Between Directories in Terminal (Mac) - Stack Overflow
When I try to copy files from one directory to another on Mac, I use the following command: sudo cp -r dir1/* dir2/ At first glance, it seems that it works well. However, it always skips the files More on stackoverflow.com
🌐 stackoverflow.com
Using terminal, how to copy paste a folder, like you would from finder? - Ask Different
I want to right click, copy. Change directory, right click paste. But using the terminal. Thing is pbcopy More on apple.stackexchange.com
🌐 apple.stackexchange.com
How to copy all files in a folder to another folder in the terminal?
I need to copy all files from **/home/antranig/downloads/fonts to *usr/share/wine/font * **I did this command in the terminal: ** *antranig@linux-plfp:~> su **Password: * ***linux-plfp:/home/antranig # *** *cp -r /home/antranig/downloads/fonts usr/share/wine/fonts * **But the terminal shown ... More on forums.opensuse.org
🌐 forums.opensuse.org
0
0
March 1, 2015
🌐
freeCodeCamp
freecodecamp.org › news › the-linux-cp-command-how-to-copy-files-in-linux
The Linux cp Command – How to Copy Files in Linux
June 6, 2022 - In this article, I'll explain what the cp command is and show you how to copy and paste files and directories in Linux using the terminal. You use the cp command for copying files from one location to another.
🌐
Quora
quora.com › How-do-I-copy-a-file-from-one-directory-to-another-in-a-Mac-terminal
How to copy a file from one directory to another in a Mac terminal - Quora
Answer (1 of 3): “How do I copy a file from one directory to another in a Mac terminal?” Use the basic Unix command: cp (more (Unix) — Wikipédia) cp dir1/file1.xxx dir2/file2.xxx dir1 and dir2 are the source and target directories file1 and file2 are the source and target files (yes, you can ...
🌐
Built In
builtin.com › articles › linux-cp-command
Linux cp Command: How to Copy a File or Directory | Built In
To copy a directory and all of its contents, use the -R (recursive) option: cp -r /path/to/source_directory /path/to/destination/ This command copies the entire source_directory and all its subdirectories and files to the specified destination ...
Find elsewhere
Top answer
1 of 1
7

I don't want to know every path of everything so I refuse to do anything like...

Most of us don't remember long and complex paths either, so this is very relatable. For example, there is an excellent command tool called "Airport Utility" (airport) but it is not found in the PATH. Using find or locate will get you an ungodly path of

/System/Library/PrivateFrameworks/Apple80211.framework/Versions/A/Resources/airport

This is impossible to remember, but it’s just one example (I use an alias for this command, by the way). There is no expectation that anyone will remember every directory path. However, we have a number of tools which we can use to make life just a bit simpler. Following is just a sampling of the tools that I use.

Drag and Drop from Finder to Terminal

If you already have the file/folder pulled up, you don't have to remember the entire path. Simply start your command as approprite (copying a folder in this example) cp -R then drag the folder from Finder to Terminal and the path will be automatically populated.

Then continue the command as needed. Here I'm copying to my current directory so I use a period or dot . but I could drag another file/folder from Finder as the destination.

Using Shell Builtins

We have several from which to use:

  • Tab Completion. This is availabe in both Bash (default for Mojave and earlier) and Zsh shells (default for Catalina and later). when you are entering a file or folder, simply start with the first few characters, press ⇨Tab and it will automatically complete the rest of the line for you. For example:

     cp - R /Users/al<⇨Tab>
    

    Will automatically fill in the rest of the folder until it needs more input from you to continue:

     cp -R /Users/allan/Desk<⇨Tab>  ← and so on and so on...
    

You can use this for both source and destination. Just tab complete your way through each directory

  • pwd → Outputs the present (current) working directory. It's also available as a variable, $PWD. For example, assuming you're deep into some obscure folder, and want to copy something like a single file or folder to a folder on your Desktop, just issue the command

    cp -R $PWD/folder_to_copy ~/Desktop/destination_folder
    
  • Tilde ~ Expansion → This is the shortcut to your home folder which is also conveniently referenced by the shell variable $HOME. If you wanted to copy all of your Documents to a USB drive, you could simply issue the Terminal command:

    cp -R $HOME/Documents /Volumes/My_Backup_USB/Documents
    

    or equally valid

    cp -R ~/Documents /Volumes/My_Backup_USB/Documents
    

  • pushd, popd, and dirs → Allow you to push directories onto, pop off of and list the contents of the directory stack that is LIFO or Last In/Fist Out. (Think of a stack like a stack of pancakes; you always put the newest on top and take the top one off when eating one).

    • dirs will list all of the directories on your stack (dirs -p shows one entry per line). The first value is always the current working directory. This will remain so, until you "push" some entries onto the stack. Here's an example of a directory stack:

       dirs -lp
      
       /Users/allan/Desktop/Email to Process
       /Users/allan/Desktop/Saved Images to Process
       /Users/allan/Desktop/eBooks to Process
       /Users/allan/Desktop
       /Users/allan
       /Users/allan/Desktop
      

      (Desktop is on there twice because I accidentally pushed it twice, but illustrates this function perfectly)

    • pushd will "push" the present directory or a directory you specify onto the stack. This is how I populated the stack for the previous bullet point. Examples:

       `pushd` 
       `pushd ~/Desktop/My_Folder`
      
    • popd will "pop off" the latest directory entry or the one you specify (can be determined with the dirs command) For example, we can use some command expansion to get the 3rd directory in our stack with the command popd +3 (3rd item from the top) or popd -3 (for 3rd item from the bottom)

      So, once you know where your directories are in the stack, you can use those with command expansion:

       cp -R `popd` ~/Desktop     ← Will copy whatever folder from top of stack to present working directory
      
       cp -R `popd` `popd`        ← Will copy the first folder on the stack to second folder on the stack
      
       cp -R `popd +2` `popd -4`  ← Will copy the 2nd from top to 4th from bottom
      

    Please keep in mind that this is not a comprehensive tutorial on pushd, popd, and dirs. There are many options (flags) that you can use with each to better work with the directory stack.

🌐
Red Hat
redhat.com › en › blog › move-copy-files-linux
Linux fundamentals: How to copy, move, and rename files and directories
November 20, 2025 - The cp command copies both files and directories. This command has many options, but the basic syntax is simple. Run cp {source} {destination} to copy from one place (source) to another (destination).
🌐
How-To Geek
howtogeek.com › home › linux › how to copy files and directories in the linux terminal
How to Copy Files and Directories in the Linux Terminal
October 18, 2023 - But you can save time by copying those files in the Terminal. Here's how. The cp command is the native copying tool built into Linux. cp stands for copy and is, you guessed it, used to copy files and directories in Linux.
🌐
Linode
linode.com › docs › guides › how-to-copy-files-and-directories-in-linux
How to Copy Files and Directories in Linux | Linode Docs
July 18, 2022 - The cp command is used to copy one or more files on a Linux system to a new location. It is similar to the mv command, except it does not move or remove the original file, which remains in place.
🌐
GeeksforGeeks
geeksforgeeks.org › linux-unix › cp-command-linux-examples
cp Command in Linux - GeeksforGeeks
4 days ago - The cp command has a flexible syntax depending on whether you are copying a single file, multiple files, or directories. cp [options] <source> <destination> cp [options] <source1> <source2> ... <destination_directory> ... When the cp command ...
🌐
openSUSE Forums
forums.opensuse.org › english › applications
How to copy all files in a folder to another folder in the terminal? - Applications - openSUSE Forums
March 1, 2015 - I need to copy all files from **/home/antranig/downloads/fonts to *usr/share/wine/font * **I did this command in the terminal: ** *antranig@linux-plfp:~> su **Password: * ***linux-plfp:/home/antranig # *** *cp -r /ho…
🌐
Red Hat
ftp.kh.edu.tw › Linux › Redhat › en_6.2 › doc › gsg › s1-managing-working-with-files.htm
Copying, Moving and Renaming Files and Directories
Don't want to overwrite the file? Now is the time to press N and Enter. To move files, use the mv command (man mv), which is similar to the cp command, except that with mv the file is physically moved from one place to another, instead of being duplicated, as with cp.
Top answer
1 of 3
2518

The option you're looking for is -R.

cp -R path_to_source path_to_destination/
  • If destination doesn't exist, it will be created.
  • -R means copy directories recursively. You can also use -r since it's case-insensitive.
  • To copy everything inside the source folder (symlinks, hidden files) without copying the source folder itself use -a flag along with trailing /. in the source (as per @muni764's / @Anton Krug's comment):
cp -a path_to_source/. path_to_destination/
2 of 3
393

You are looking for the cp command. You need to change directories so that you are outside of the directory you are trying to copy.

If the directory you're copying is called dir1 and you want to copy it to your /home/Pictures folder:

cp -r dir1/ ~/Pictures/

Linux is case-sensitive and also needs the / after each directory to know that it isn't a file. ~ is a special character in the terminal that automatically evaluates to the current user's home directory. If you need to know what directory you are in, use the command pwd.

When you don't know how to use a Linux command, there is a manual page that you can refer to by typing:

man [insert command here]

at a terminal prompt.

Also, to auto complete long file paths when typing in the terminal, you can hit Tab after you've started typing the path and you will either be presented with choices, or it will insert the remaining part of the path.

There is an important distinction between Linux and Unix in the answer because for Linux (GNU and BusyBox) -R, -r, and --recursive are all equivalent, as mentioned in this answer. For portability, i.e. POSIX compliance, you would want to use -R because of some implementation-dependent differences with -r. It's important to read the man pages to know any idiosyncrasies that may arise (this is a good use case to show why POSIX standards are useful).