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

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.

 

 

  • 3 Users Found This Useful
Was this answer helpful?

Also Read

How to Unlock account locked due to brute force attack

Please Rate us 1. log into WHM2. Locate the SECURITY section3. ENTER the SECURITY CENTER4....

mysql user with the name already exists. how to delete

Please Rate us Solving an issue of Extracting tarball................... DoneExtracting...

How To Empty tmp Partion By rm -rf *

Please Rate us Make sure that you are in tmp folder # cd /tmp order # rm -rf *...

How to use a simple PHP script to determine your server's outgoing IP address.

Instructions Create a file named getIP.php with the following contents:...