Manage files using the Command Line Interface (CLI)
After successfully connecting to Unity with OpenSSH, you can manage your Unity files using the Command Line Interface (CLI). The CLI is a program that allows you to interact with the computer operating system through inputting lines of texts called command-lines.
You can use the CLI to copy, or upload, files to your Unity home directory. The CLI also allows you to conveniently copy a whole directory. A directory is another word for a folder that holds files.
The instructions below will guide you through opening the CLI, navigating to a directory, and copying files to your Unity home directory using the commands scp
and rsync
.
unity
and copy files to your Unity home directory using scp
and rsync
, you must configure the OpenSSH config file to contain the information for host unity
.Open CLI
If you are unsure of how to access your computer’s CLI, go to your computer’s application search menu and search for “Terminal” or “Command prompt”. Once opened, the CLI typically looks like a plain window with a text area that is mostly empty besides one small line of text.
Navigate to a directory
Once you have your CLI open, navigate to the directory, or folder, where the files you want to upload are located. Experienced CLI users might choose to use absolute paths in their commands and skip this step.
To navigate to a directory, use the command cd
followed by the path to the directory:
# Windows
cd C:/Users/YOUR_NAME/Desktop
# Linux
cd /home/$USER/Desktop
# Mac
cd /Users/YOUR_NAME/Desktop
The code example above assumes that the files you want to upload are located in your desktop
directory. In the Windows case, the example assumes that the drive you want to copy from is the C drive
. If they are located somewhere else, you must change the path used above.
Copy files to your Unity home directory
There are multiple commands you can use to efficiently copy your files to your Unity home directory, including scp
and rsync
.
For a simple and straightforward copy, the scp
command can be used without installing anything. For recurring tasks and synchronizing files over a network, the rsync
command is a good option. To use rsync
, you must install the utility on your Linux or Mac.
SCP
OpenSSH comes with the scp
command, which is similar to cp
(copy) but with the added benefit of referencing the OpenSSH config file
(~/.ssh/config
).
The scp
command allows you to use unity
as part of the command because the OpenSSH config file contains the connection information for host unity
. If the OpenSSH config file does not contain the connection information for host unity
, you must configure the OpenSSH config file to have that information in order to use unity
in your commands.
The following code example shows how to use scp
to copy a single file or an entire directory into your Unity home directory:
# single file
scp FILE_NAME unity:~
# entire directory
scp -r DIRECTORY_NAME unity:~
You could also upload the files to a different location on the Unity filesystem as long as you have the correct permissions.
-r
in many commands is short for ‘recursive,’ which means that the command will apply to all files and subdirectories under that directory to ensure that all contained files
are accounted for.~
in the terminal is a shortcut for your home directory path.
Your home directory path, or ~
, is:
C:/Users/YOUR_NAME
in Windows/home/YOUR_NAME
in Linux/Users/YOUR_NAME
in Mac.
RSYNC
Linux and Mac users can install and use the command rsync
to copy their files.
Similarly to scp
, the rsync
command references the OpenSSH config file. If the OpenSSH config file does not contain the connection information for host unity
, you must configure the OpenSSH config file to have that information in order to use unity
in your commands.
The rsync
command also comes with many useful options. For example, using the -tlp
flags ensures that timestamps, relative links, and permissions are preserved, respectively.
The following code example shows how to use rsync
to copy a single file or an entire directory into your Unity home directory:
# single file
rsync -tlp FILE_NAME unity:~
# entire directory
rsync -rtlp DIRECTORY_NAME unity:~