How to Copy / Move / File or Directory in Linux using SSH Print

  • 3

Please Rate us 
Copy File

 

Below are steps on how to copy a single file from one directory to another directory as well as how to copy multiple files from one directory to another directory.

Copying a single file from one location to another.

 

 

  1. Using the cd command, move to the directory that contains the file you wish to copy.
  2. Type a command similar to the below command.

    cp myfile.txt /usr/bin

    In the above example, you would substitute "myfile.txt" with the name of the file you wish to copy, and "/usr/bin" with the directory you're copying to.

Copying multiple files to another location

  1. Using the cd command, move to the directory that contains the files you wish to copy.
  2. Once in the directory that contains the files you wish to copy, type a command similar to one of the below commands.

    cp *.* /usr/bin

    In the above example, the command would copy every file in the current directory to the "/usr/bin" directory.

    cp *.txt /usr/bin

    In the above example, the command would copy every txt, or text file, in the current directory into the "/usr/bin" directory.

 

Copy Directory

 

 

To copy a directory with all subdirectories and files use the Linux / Unix cp command. Below is an example command of how you would use the cp command to copy files. Additional information about this command and other examples can also be found in the above cp link.

cp -r /home/hope/files/* /home/hope/backup

In the above example the cp command would copy all files, directories, and subdirectories in the /home/hope/files directory to the /home/hope/backup directory.

 

 


Was this answer helpful?

« Back