I tried to delete a folder that contained tons of localization folders and waited for a very long time, since I was using FTP client and it was very slow during deleting and copying folders with massive amount of subfolders and files. That is why I decided to find another way to delete and copy files faster to the remote server from my local computer.
Secure copy or SCP is a means of securely transferring computer files between a local host and a remote host or between two remote hosts. It is based on the Secure Shell (SSH) protocol.
SCP is more secure that plain FTP. It also allows to copy directly to the given folder on server, if permissions granted. FTP allows to copy only to the FTP folder.
These are the commands.
To copy files from server to your local machine:
1 |
scp -r root@lovecakes.ru:/root/www/ladby.ru . |
To copy files from your local machine to the server:
1 |
scp wordpress-4.0.zip root@lovecakes.ru:/root/www/test.ladby.ru |
To go to the folder with a folder, that will be copied (in my case it is common-app-server folder):
1 |
$ cd ~/Documents |
To archive a folder, so that not to include Mac OS X system files like .DS_Store
1 |
~/Documents: $ zip common-app-server.zip common-app-server/ -x "*.DS_Store" |
To remove a folder from server before copying a new version:
1 |
# rm -rf common-app-server |
To copy zip file using SCP:
1 |
$ scp common-app-server.zip root@lovecakes.ru:/var/www/den.ladby.ru/public |
Here root is a user name, that has permission to write to the destination folder.
lovecakes.ru – server name
/var/www/den.ladby.ru/public – destination folder
To install zip on server:
1 |
# sudo apt-get install unzip |
To unzip copied folder on server:
1 |
# unzip common-app-server.zip -d |
To remove MACOSX folder:
1 |
# rm -rf __MACOSX |
To remove zip file on server and local machine after unzipping:
1 |
# rm common-app-server.zip |
To copy a folder without archiving:
1 |
$ scp -r common-app-server root@lovecakes.ru:/var/www/den.ladby.ru/public |