In this appendix, we start with some of the basic Linux commands so that Windows users feel comfortable working with the OpenShift Linux Shell. After that, we show how to copy files from the PC to OpenShift Linux server using secure copy feature of SSH.

Note

To go through this Appendix, we have to complete the RHC (OpenShift Client Tools) installation. To work from a Windows system, we also require PuTTY. Refer OpenShift RHC Client Tools to know about RHC, PuTTY and OpenShift Shell.

To run the commands, Windows users have to use the command prompt. Open command prompt using StartRun and enter cmd and click OK. Linux users have to use console.

Create Directory in OpenShift

For some tasks, we may a new directory in OpenShift. To create a directory, log in to OpenShift Shell using RHC (Linux users) or PuTTY (Windows users).

In OpenShift Shell, app-root/data is the designated directory for application data and create directories under it. For example, to create a directory called test execute the following command.

> mkdir app-root/data/test

Change directories

In Linux, we use the cd command to change directories. To change to a directory use:

> cd app-root/data/test

To come backup to our home directory use:

> cd

To view our current location in the server use:

> pwd

Listing a directory

In Linux, we use ls command to list files in a directory.

> ls

Following ls command lists files in app-root/data directory in long form (l), in reverse chronological order(rt).

> ls -lrt app-root/data
 
 

Copy files to OpenShift Linux

OpenShift does not support FTP file transfers. To copy files, we need to use SSH copy also known as secured copy. In WordPress Tutorial - Backup chapter, we need to copy backup files to OpenShift.

For SSH copy, we require SSH string of our OpenShift application. To know SSH string, run following command from the command prompt (in PC).

C:> rhc apps
OpenShift Linux Primer - RHC apps output

RHC contacts and authenticates with OpenShift and shows details about applications configured in our account. In the output, SSH: line shows the SSH string of the app. Components of SSH line are:

OpenShift Linux Primer - OpenShift SSH String example

Copy SSH line to the clipboard and we need that in the next step. To securely copy files to OpenShift server, use the following commands.

Replace <file to copy> and <directory name> with the filename or directory we wish to copy to the server. Replace example SSH string with the real SSH string !!!

To copy single file:

---- Windows users ----

C:sample dir> pscp <file to copy> 5482222abca4620007e8@quickstart-wordpressguide.rhcloud.com:app-root/data/


---- Linux users ----

$ scp <file to copy> 5482222abca4620007e8@quickstart-wordpressguide.rhcloud.com:app-root/data/

To recursively copy a directory, use -r switch.

---- Windows users ----

C:sample dir> pscp -r <directory name> 5482222abca4620007e8@quickstart-wordpressguide.rhcloud.com:app-root/data/


---- Linux users ----

$ scp -r <directory name> 5482222abca4620007e8@quickstart-wordpressguide.rhcloud.com:app-root/data/