Copying files using scp

Copying files between different linux, MacOSX or UNIX servers can be done with the scp command. Thus you can use scp to transport data between CSC and your local environment or between different file systems at CSC.

The basic syntax for copying data from a local machine to a remote machine is:

scp /path/to/file
And correspondingly the syntax to copy files from a remote machine to a local machine is:

scp /path/to/local/destination

The command to copy a local file data.txt from the current directory to Puhti the user bob:s home directory would be:

scp data.txt
The special symbol ~ points to the users home directory.

To copy complete directories you should use scp command with option -r.

scp -r /path/to/data_directory 
The above command will copy the directory with all its content to Puhti. The directory will be created in /scratch/project#####_.

Copying the data from CSC environment to local computer is done in the same way:

scp .
The . symbol points to the current local directory. Use the csc-workspaces command on Puhti to show available disk areas.

In the commands above, files and directories have been copied one at a time. However, scp can copy several files at a time:

scp data1.txt data2.txt data3.txt

You can also use wild cards when defining the files to be copied. For example to copy all files with extension .txt in the current directory to Puhti, you could use the command:

scp *.txt
By default the copied files are treated as new files, but if you add option -p to the scp command, then the copied file will inherit the date and access mode information from the original file.

Last update: January 21, 2020