Introduction to Linux

BCH 519
Spring 2018

Andrew E. Bruno

BCH519 Students

Please pick up a USB Key!

    USB Key


Outline for this lecture

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

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

Operating systems

  • Windows
  • Mac OS X
  • UNIX
  • Linux

A very brief history of UNIX...


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

UNIX has many descendents..

Unix History Img Source:




  • 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: RedHat, Debian, Ubuntu, Porteus..

Why Linux?

  • Center for Computational Research (CCR)
  • Leading academic supercomputing facility
  • Operates a datacenter with hundreds of Linux computers
  • To run jobs at CCR, you need to be familiar with Linux

Let's boot into Linux!

    Slax instructions

Operating systems have user interfaces

  1. GUI - Graphical User Interface
  2. CLI - Command Line Interface
In the Beginning..Was the Command Line
-- Neal Stephenson
Porteus desktop

CLI - Command Line Interface

  • Control the computer with commands
  • "Shell" - a program that accepts commands and performs operation system functions
  • We'll be using a shell called BASH

Anatomy of the shell

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

How to read the SHELL

Example grep command

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
    Tue Dec 11 14:42:04 EST 2012
  • 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


Linux File System

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
  • Find differences between files: diff
  • 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
$ diff -u file1 file2
$ 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


Img Source:

GNU nano

GNU nano basics

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

GNU nano

GNU nano

Accessing computers remotely

  • Login to server
  • Run programs, execute commands, etc.
  • We use SSH: Secure SHell
  • Allows us to connect to remote Linux server using encrypted network channel

How to login to CCR

  • Open terminal program (shell)
  • Run: ssh username@host
  • Enter in password when prompted

$ ssh

Copy files to rush

  • Use command: scp
  • Usage: scp [LOCAL file] [REMOTE file]
  • Enter in password when prompted

$ scp

Homework #1

  • Due: 2018-02-13 09:00:00