Tips and Tricks

…to make lives easier!

Command line aliases

Command line commands can get lengthy and difficult to remember or annoying to type. Fortunately, we can make shortcut aliases to help with this. The steps to take depend on what operating system and, for Windows, what command line program is being used. We cover a couple options here.

The examples below demonstrate how to define viame-prod as an alias to log into the production VM. Once completed, you will only need to type viame-prod into your terminal of choice to connect to the VM.

Windows: Command Prompt or Google Cloud SDK Shell

These both work the same way behind the scenes, so the following steps will work for both applications. Note that Steps 1-4 only need to be completed once the first time you create an alias, but steps 5-7 will need to be completed for each alias you wish to create.

  1. Create a folder called C:\Aliases

  2. In the Windows search box, find and open “Edit environmental variables for your account”

  3. In the top “Users variables” box, select “Path” and click “Edit”

  4. In the box that opens, click “New” and type “C:” and hit enter. Click “Ok” on both of the windows.

  5. Create a viame-prod.bat file in C:\Aliases.1 Note that the filename (before the extension) is the alias and is what you will type to execute the command, so it can be anything you want but should be simple and must not contain spaces.

  6. In this file, enter the following:

    @echo off
    echo.
    gcloud compute ssh...[Redacted]

    where the last line is the full command from login Step 3.

  7. Restart your computer.

Windows: Git Bash, or cmder, or other Linux emulator

If you use Git Bash (which comes with Git), cmder, or another application designed to behave similarly to Linux, use the steps below to define aliases.

  1. Create a file called .bash_profile in C:\Users\<username>, where <username> is your active username.

  2. Add your aliases to this file, one per line:

    alias viame-prod='gcloud compute ssh...[Redacted]'

    using the full command from login Step 3.

  3. Save and restart your computer.

MacOS

Follow the same steps as for Windows: Git Bash, or cmder, or other Linux emulator except create the .bash_profile in /Users/<username>.

SSH into the Docker Container

There may be (probably rather rare) instances when one might need to log into the Docker container in which the VIAME Web instance is running. Examples might be to troubleshoot or kill a process or job, or to manually run data processing scripts. Getting into the container is straightforward.

Important

These steps will only work for admin users with Docker access priviledges.

Step 1: SSH into the Web VM

First, make sure the sefsc-viame-web-... VM is running. Then, in the table of VMs on the Cloud Dashboard, click the SSH button for sefsc-viame-web-.... (You might might need to scroll right if you cannot see the “Connect” column.) A new window will open and request authorization to connect. Click “Authorize”. This new window contains a Cloud terminal. The command prompt should display your username and the VM name:

your-username@sefsc-viame-web-...

This indicates that you have connected to the VM.

Step 2: SSH into the Docker container

Now we need to enter the Docker container itself. In the Cloud terminal, type

docker exec -it dive-girder-1 /bin/bash

dive-girder-1 is the name of the Docker container and should not change between VM reboots. The command prompt should now display root@xxxxxxxxxxxx, where xxxxxxxxxxxx is the container ID for the dive-girder-1 container, indicating that you are now inside the container. You can now navigate around as on any Linux machine. For example,

cd home/assetstore

will change directories into the VM persistent storage. This directory contains the VAIME-generated CSV files, but the folders and files are all computer-generated IDs rather than human-readable names.

Your Three Best Friends of Linux Command Line
  1. pwd displays the present working directory, where you current are.
  2. ls lists the contents of the current directory, both files and folders.
  3. cd DIRNAME to change directories into the folder DIRNAME. Use cd .. to go back one level.
Tip

Use docker ps when connected to the VM to display the running Docker containers and their corresponding IDs.

Footnotes

  1. You will need to create a separate .bat file for every alias you want. Follow this procedure each time and remember that the file name is what you will type to execute the command.↩︎