It has been set to my routine task to copy folder/files from my local host or a remote linux server to another server or vise versa.
The general command is:
The above command will copy a file from your local machine to a remote server. If you want to copy a folder to a remote machine user
You can also copy from your remote server to your local machine by changing the order in scp as below:
The above command will copy the remote file called
#linux #sysadmin #scp #copy
scp
linux command is used for this specific need.The general command is:
scp YOUR_LOCAL_FILE USERNAME@YOUR_SERVER:~
The above command will copy a file from your local machine to a remote server. If you want to copy a folder to a remote machine user
-r
to recursively copy the whole folder into the remote.You can also copy from your remote server to your local machine by changing the order in scp as below:
scp USERNAME@YOUR_SERVER:~/YOUR_REMOTE_FILE .
The above command will copy the remote file called
YOUR_REMOTE_FILE
from the home
directory to your current path (.). Instead of dot you can provide your full path.NOTE:
use man scp
and see tons of flags to master this command.#linux #sysadmin #scp #copy
If you want to make an exact copy of a table from another database into a target database in
The above command will create a table named
#mysql #database #create_table #table #copy_table
mySQL
you could do like below:create table new_table like target_database.target_table
The above command will create a table named
new_table
like target_table
from target_database
database.#mysql #database #create_table #table #copy_table
How to copy a file in the same path with a different name?
Well you just need to use curly braces, {}, to make it happen:
What you usually MIGHT do:
You can take the smart path btw:
NOTE: if suffix of both files are different you can put that inside of curly braces too.
#linux #sysadmin #cp #copy #trick
Well you just need to use curly braces, {}, to make it happen:
What you usually MIGHT do:
cp /usr/local/share/lib/sample.conf /usr/local/share/lib/settings.conf
You can take the smart path btw:
cp /usr/local/share/lib/{sample,settings}.conf
NOTE: if suffix of both files are different you can put that inside of curly braces too.
#linux #sysadmin #cp #copy #trick