I always enjoy using Linux and working just sitting on my desk and manage all from just one command line interface; i found myself moving virtually in my network :) just feel it, you will enjoy too..;)!
Anyway let’s come to the point So this tutorials will guide you, how to copy and paste files/directories Locally or on Remote linux box.
In Linux shell, cp command is used to copy files/directories and directories locally from one directory to other. In this guide you will also learn the use of scp command for copying files and directories remote Linux box.
Copy file locally
Usage of cp command will be same like mv command, you need to provide source and destination directory.
See Syntax of cp command:
$ cp [options] source dest
I list my current directory using ls -l command and Copy one file called copyme.txt to /tmp/ directory.
-rw——-. 1 root root 1183 Dec 23 21:10 anaconda-ks.cfg
-rw-r--r-- 1 root root 66 Dec 24 13:13 commmand.txt
-rw-r--r-- 1 root root 0 Dec 27 20:10 copyme.txt
cp copyme.txt /tmp
Copy all files from current working directory.
cp * /tmp
Copy all files including directories and sub directories by using options â€“f forcefully and â€“r recursively.
cp â€“fr * /tmp
Copy files remotely:
So now I will be going to show you how to copy file remotely from one Linux box to other.
So while performing task on Linux, as system admin we need to move files and folders between two or more Linux machines over the network. Here you will use scp command to copy files & directories remotely.
For instance you have one file called backup.sh file and you want to move it to other Linux box:
As I mentioned above I have one machine called lx2.broexperts.com and I want to copy backup.sh file to this machine:
Remote Copy command will be
scp backup.sh Lx2.broexperts.com:/tmp
Once you hit enter you will prompt to enter password of remote machines. Provide password and hit enter again.
Next: Vim Text Editor Basics
If you have any question please leave comment and donâ€™t forget to say thanks, as itâ€™s free.:)