Skip to content

CLI basics for using Co-op Cloud

Introduction

There are many great resources for learning how to effectively wield the linux command line, but here I'm only going to introduce the concepts you need to run Abra, the Co-op Cloud command line interface (CLI), at a basic level.

There will be codeblocks in this tutorial, which will generally describe commands to be run in the terminal. Any line starting with '#', however, is a comment and describes the command, and won't do anything if run.

# this is a comment

Basic Concepts

Read the section "Opening a terminal" in the guide below, and follow along. Stop reading when you reach the end of "Relative and absolute paths":
https://ubuntu.com/desktop/docs/en/latest/tutorial/the-linux-command-line-for-beginners/#opening-a-terminal

We'll also want to understand how to use different options in our commands. These options modify how the commands work, and are passed into our commands as flags. Most utilities have a --help option, or -h for shorthand (most flags have a long and shorthand), so try the following:

# ls doesn't have a -h shorthand
ls --help
You should see the usage of this command described, and many other options. Let's try some of them
# ls with the --all flag shorthand
ls -a
# ls with the long listing format
ls -l
# ls with both -a and -l options, you could also do ls -l -a
ls -la
Notice how these change the output of our base command!

Root and Sudo

Generally, when you use the linux terminal, you'll be an unprivileged user. This means that certain directories, executables, and files will be inaccessible to you (in various ways). In order to perform these tasks, you'll need to be a superuser or root, which has the highest privileges to modify files, change configurations, or whatever else can be done.

It's generally not safe to use the terminal as root all the time, so instead, we'll use a command called sudo (or 'superuser do') to invoke superuser privileges when a command relies on it.

Try running the commands below normally and with sudo and see the difference. Probably, you'll need to type in your user's password to invoke sudo.

ls
sudo ls
pwd
sudo pwd
whoami
sudo whoami
Now, when you see sudo, you'll understand what importance that has for the command.

SSH

ssh or 'secure shell' is the command we'll use to connect to our server that will be running our services. When we execute ssh and connect to our server, our commands on the terminal will execute on the server's filesystem and not our own.

We should have given you an IP address for your server, and a password. Connect to that server with

# here, the -p flag describes the password we're entering
ssh root@<ip-address> -p <password>
after accepting the fingerprint, you should see a startup message and a different prompt, your shell is now running on a different machine.

Let's try some basic commands

whoami
pwd
ls
To exit the shell, we can just type exit into the command line, which will restore our local shell.

Editting Files

When using Co-op Cloud, we'll have to edit a few configuration files. You can do this through the command line with a few different utilities. For this tutorial, we'll use nano.

Let's try opening up a basic text file

# create a text file
touch example.txt
# open that text file using nano
nano example.txt
You should have the nano interface open. You'll have to use your keyboard to navigate around the interface. Edit the text file to say something like
This is a text file. 
This text file was editted using nano.

This is the end of the file.
To save the file, Ctrl+S, to close the file Ctrl+X.
Now try cat example.txt, this command will print the file to your terminal.