What is the Command Line Interface? [Tutorial] - Green-Biome-Institute/AWS GitHub Wiki

In order to work with assembly software and the AWS EC2 instances, we need to have proficiency with using the "Command Line." Before diving into examples I want to make a note about what it is and why having an understanding of the command line is a practical skill to have in the sciences.


First, what is it?

The command line interface (also referred to as the CLI, command line, or command prompt) is a way to you can interface with the computer itself (like you do with your mouse or touchpad). Instead of using clicks (like when you double click on a document or file to open it), you will type commands and enter them for the computer to read and react to! Just like opening up a finder or file manager, you are able to navigate around the directories of your computer (the file-organizers, a folder is an example of a "directory" which contains other files or more folders), move files around, copy and paste them, edit them, etc.


Here are a couple reasons why it a practical skill you should pick up:

  1. While there are many softwares that have graphical user interfaces (a visual representation of the software with buttons, images, etc.), many must be operated from the command line. Therefore in order to actually use the breadth of open-source software that is out there, you must be familiar with using the command line.
  2. Gaining a familiarity of the command line will give you a better appreciation for how processes run on your computer and will allow you to look at science problems with a new perspective. Even just the simple understanding of knowing how to navigate around your computer using the command line (save, open, and edit files, connect with other computers to send and receive information from them, etc.) is fairly fundamental to most fields of science that require analysis of lots of data.
  3. Not only will you be able to better visualize the pipeline from "I produced a bunch of data!" to "Look what my data says!", you will also be able to troubleshoot issues that arise on the way. Those issues might come in the form of trying to find out where a software saved an important file or piece of information or through the writing of simple piece of code to make your experiments more efficient (this would be called writing a "shell script", which can just be one line!).

For this tutorial, we will go through a couple examples of building complexity.

Here's a list of the contents of this tutorial:

  1. First, we have to open up the command line! From here we will explore the syntax is of basic command prompts, navigate around your computer, understand what certain words mean (what is a "directory"?), and find out how to get more information if we have a question about a command prompt.
  2. I don't want to bog you down with too much information. But with step 1 done, we do need to explore some of the important ideas of the command line interface before moving forward. This includes environment variables, permissions, and some prompts related to them. Don't worry we won't get too into the weeds!
  3. Here we will be making, viewing, editing/manipulating, copying, renaming, and deleting files and folders.
  4. Next, let's start interacting with other computers and operating software from the command line! These examples will show you how to download files from the internet (from Github for example), copy them from another computer, and escape from mistakes you might have made.
  5. Finally, we will go over the implementation of 3rd party softwares (like genome assemblers!) and using a terminal multiplexer (tmux or screen). This includes the process of installing software that you might need, running it in the background (so you can leave a program running in the cloud and exit that computer), and will overlap a bit with the tutorial on doing genome assembly.
  6. Now that we have an understanding of the command line interface, how to navigate around it, make and modify files, use command prompts and 3rd party software, we will jump into the very basics of bash scripting. Here we will link together command prompts into a compilation of multiple commands, so that we can make our experiments better documented, customizable, and useful!

1. Finding our way around

  1. First, let's open up the command line. In Linux, like on MacOS, it is also known a Terminal. In your applications, search for and click on the terminal, or use the keyboard shortcut ctrl+alt+T. This will open up the terminal, which is the graphical interface that runs what is known as a bash shell. The bash shell is the actual program that you enter commands into, which processes them and returns an output.

Now that you have the terminal open, you can see on the left side of the screen there is the name of the user of the computer (this might be an ip address or the username you are using to log in). This shows where you are on the computer. What this means is that at any point in time the terminal is pointing to a specific location in your computer, and can only see what is in that place. This is the same as when you are going clicking through folders on your computer. When you double-click a folder, it opens up what is inside of that folder, giving you access to those further files and folders. Same thing here, wherever the terminal is currently looking at is what it can immediately access.

To show what this means, type the following When you type, you will see the letters write out to the right of

Vocabulary: Terminal - The program that runs a shell, which for our purpose is Bash. Bash - The program that processes things you write and enter and returns and output.


Resources

https://launchschool.com/books/command_line/read/introduction https://linuxhint.com/path_in_bash/ https://www.learnenough.com/command-line-tutorial/inspecting_files