Tech C**P
15 subscribers
161 photos
9 videos
59 files
304 links
مدرس و برنامه نویس پایتون و لینوکس @alirezastack
Download Telegram
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. 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 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 clone a database in MySQL?

mysqldump -u root db_name | mysql -u root new_db_name

NOTE: if it gets password provide -p to both commands.

#mysql #clone #copy #database #copy_database
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:

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