Contents
- Secure Copy Protocol Linux Securely Transfer Files with EC2
- Linux – move file and directory
- Get or set host name
Secure Copy Protocol Linux Securely Transfer Files with EC2
SCP(secure copy) is Securely Transfer Files. This command allows securely transfer files between a source server and target server.
Download files from Amazon EC2 server
$ scp -r -i ~/Desktop/aws-keys/key.pem ubuntu@ecx-xx-xxx-xxx-xxx.ap-northeast-2.compute.amazonaws.com:/home/app ~/Desktop
-r
for the copy directory without-r
flag download file.-i
for flag specifies the private key- Pem location: ~/Desktop/aws-keys/key.pem
- Source directory to copy: /home/app at EC2 Target directory: ~/Desktop
Linux – move file and directory
the mv utility renames the file named by the source operand to the destination path named by the target operand. This form is assumed when the last operand does not name an already existing directory.
SYNOPSIS
mv [-f | -i | -n] [-v] source target
mv [-f | -i | -n] [-v] source … directory
Create a new file for testing command on Mac
$ touch ~/Downloads/old-v1.txt
- named old-v1.txt file is created.
$ mv ~/Downloads/old-v1.txt ~/Desktop/new-v2.txt
- text file named old-v1.txt in Downloads will move to Desktop with the changed file name new-v2.txt.
Create a new directory for testing command on Mac
$ mkdir ~/Downloads/old-v1
- named old-v1 directory is created.
Move directory & change directory name
$ mv ~/Downloads/old-v1 ~/Desktop/new-v2
- Directory named old-v1 in Downloads will move to Desktop with the changed directory name new-v2.
Get or set hostname
$ sudo hostname main
root@main