Introduction to Linux

BCH 519
Spring 2021

Andrew E. Bruno

Video Recordings

Videos for BCH519 Unit 2 can be found at:

Outline for this lecture

  • What is Linux?
  • CCR OnDemand
  • Command Line Boot Camp
  • Edit files

An operating system is a collection of software that manages computer resources

Operating Systems

  • Linux
  • Windows
  • macOS, iOS, watchOS
  • Android, Chromium OS
  • Orbis OS

A very brief history of UNIX…


  • Originally developed in 1969 at AT&T Bell Labs
  • First ran on the PDP-11/20 16-bit minicomputer
  • Widely adopted in academia


UNIX Features

  • Multi-user, multi-tasking, time-sharing
  • Large number of users to interact concurrently with a single computer
  • Consists of many utility programs or commands
  • Master control program called the kernel
  • Use plain text for storing data
  • Hierarchical file system

UNIX Philosophy

  • Write programs that do one thing and do it well
  • Write programs to work together
  • Write programs to handle text streams, because that is a universal interface

UNIX has many descendents..




  • A “UNIX-Like” operating system
  • GNU Project started in 1983 by Richard Stallman, to create “complete UNIX-compatable software system” composed entirely of free software
  • Linux kernel first developed by Linus Torvolds in 1991
  • Together they make the GNU/Linux operating system
  • Free and open source

Many flavors of Linux

Linux on the Desktop

Linux in the Data Center


Linux is Everywhere


Why Linux for this Course?

  • Many research centers run Linux
  • Popular in Bioinformatics
  • Includes many programming languages and environments
  • CCR operates a data center with hundreds of Linux computers
  • To run jobs at CCR, you need to be familiar with Linux

Getting started with Linux

  • Install Linux on your Desktop/Laptop (Local)
  • Run Linux off Live USB
  • Connect to remote Linux server (Remote)

Linux - Remote Login

  • Connect to remote Linux server
  • We use SSH: Secure SHell
  • Allows us to connect to remote Linux server using encrypted network channel
    • MobaXTerm (Windows)
    • OpenSSH (Linux/Mac OS X)
    • CCR OnDemand (Web based)

CCR OnDemand

CCR OnDemand Shell Access

CCR OnDemand Shell Access

Operating systems have user interfaces

  • GUI - Graphical User Interface
  • CLI - Command Line Interface

CLI - Command Line Interface

  • Control the computer with commands
  • “Shell” - a program that accepts commands and performs operating system functions
  • We’ll be using a shell called BASH

Anatomy of the shell

  • There’s a prompt: [aebruno2@vortex1:~]$
  • You type in commands
  • Shell executes the commands
  • Prints output to the screen
  • Repeat

How to read the SHELL

Anatomy of a command

  • Basic form: command options arguments
  • command = name of the command
  • options = modify the behavior of the command
  • arguments = expression or filename
  • Commands can be simple: echo, date
  • More complex: find . -type f -name \*.py

Command Line Boot Camp

Simple Commands

Print todays date

$ date
Mon Jan 28 13:24:03 EST 2019

Echo a string

$ echo "Hello World"
Hello World

Simple Commands

What’s my username?

$ whoami

What computer am I logged into?

$ hostname --fqdn

Getting Help

  • man page (short for manual page)
  • Usage: man [command name]
$ man echo
$ man grep

Download and print!

GNU Coreutils Cheat Sheet

Files, Directories, and Paths

  • Basic unit is a File
  • Files are organized in directories (folders)
  • Navigate filesystem using paths

Hierarchical Filesystem


Moving around

  • Print the current working directory: pwd
  • List all files: ls
  • Change working directory: cd
  • Move up a directory (go back): cd ..
$ pwd
$ ls
projects bch519 docs hello-world.txt
$ cd bch519
$ pwd
$ ls README.txt
$ cd ..
$ pwd

File Basics

  • Create a file: touch
  • Copy files: cp
  • Rename files: mv
  • Remove files: rm
  • View files: cat,less,more
$ touch hello-world.txt
$ ls
$ cp hello-world.txt goodbye-world.txt
$ ls
hello-world.txt goodbye-world.txt
$ mv goodbye-world.txt new-file.txt
$ rm goodbye-world.txt
$ cat hello-world.txt
Hello World!

Text Manipulation

  • Search for patterns in file: grep
  • Print first/last n lines: head, tail
  • Count lines, words, characters: wc
  • Print selected parts of file: cut
  • Sort file: sort
$ grep "pattern" my_file
$ head -n 20 my_file
$ tail -n 20 my_file
$ wc -l my_file
$ cut -f 1,3 my_file
$ sort my_file

Input/Output redirection

  • > takes output from command and writes it to file
  • >> takes output from command and appends it to file
  • < takes input from file and sends it to command
$ echo "Hello World" > hello.txt
$ cat hello.txt
Hello World
$ echo "Goodbye" >> hello.txt
$ cat < hello.txt
Hello World
$ grep "Hello" hello.txt > results.txt
$ cut -f 1,3 output.txt > columns-1-3.txt


  • Allows you to “chain” commands together
  • | = pipe
  • | take output from command on left and send as intput to command on right
$ cat my_file.txt | wc -l
$ cat my_file.txt | grep -i "hello"
$ echo "Hello World" | wc -c > num-chars.txt
$ echo "1234" | rev

Editing Files

  • Editor: A program for editing text files
  • Most important tool for programmers
  • We will use an editor to author Python programs



GNU nano

  • Simple text editor
  • Controlled using the control key (Ctrl)
  • Documentation:

GNU nano basics

  • Start: nano <filename>
  • ^ = Ctrl key
  • Save file: ^O
  • Quit: ^X
  • Search: ^W
  • Help: ^G

GNU nano

Homework #1

Due: 2021-02-16 09:00:00