Linux Command Line Interface. December 27, 2017

Similar documents
Introduction to UNIX Shell Exercises

Introduction to Linux

5/20/2007. Touring Essential Programs

Introduction To. Barry Grant

Introduction: What is Unix?

Processes. Shell Commands. a Command Line Interface accepts typed (textual) inputs and provides textual outputs. Synonyms:

Perl and R Scripting for Biologists

Lab 2: Linux/Unix shell

Introduction to Unix The Windows User perspective. Wes Frisby Kyle Horne Todd Johansen

Introduction to Linux Organizing Files

Unix/Linux Basics. Cpt S 223, Fall 2007 Copyright: Washington State University

Review of Fundamentals

Introduction to UNIX. Logging in. Basic System Architecture 10/7/10. most systems have graphical login on Linux machines

COMS 6100 Class Notes 3

Unix basics exercise MBV-INFX410

Unix. Examples: OS X and Ubuntu

Shells. A shell is a command line interpreter that is the interface between the user and the OS. The shell:

Unix Shells and Other Basic Concepts

Unix Processes. What is a Process?

CSE 390a Lecture 2. Exploring Shell Commands, Streams, Redirection, and Processes

Recap From Last Time:

Contents. Note: pay attention to where you are. Note: Plaintext version. Note: pay attention to where you are... 1 Note: Plaintext version...

BGGN 213 Working with UNIX Barry Grant

Introduction to remote command line Linux. Research Computing Team University of Birmingham

Linux for Beginners. Windows users should download putty or bitvise:

STATS Data Analysis using Python. Lecture 15: Advanced Command Line

CST Algonquin College 2

Introduction p. 1 Who Should Read This Book? p. 1 What You Need to Know Before Reading This Book p. 2 How This Book Is Organized p.

Command-line interpreters

Review of Fundamentals. Todd Kelley CST8207 Todd Kelley 1

Using LINUX a BCMB/CHEM 8190 Tutorial Updated (1/17/12)

Chapter 4. Unix Tutorial. Unix Shell

Introduction to Linux Workshop 1

unix intro Documentation

Recap From Last Time: Setup Checklist BGGN 213. Todays Menu. Introduction to UNIX.

Vi & Shell Scripting

Bioinformatics? Reads, assembly, annotation, comparative genomics and a bit of phylogeny.

UNIX. The Very 10 Short Howto for beginners. Soon-Hyung Yook. March 27, Soon-Hyung Yook UNIX March 27, / 29

The Unix Shell & Shell Scripts

The UNIX Shells. Computer Center, CS, NCTU. How shell works. Unix shells. Fetch command Analyze Execute

Linux Systems Administration Getting Started with Linux

When talking about how to launch commands and other things that is to be typed into the terminal, the following syntax is used:

Mills HPC Tutorial Series. Linux Basics I

Shells and Shell Programming

Introduction to the shell Part II

Lecture-4. Introduction to Unix: More Commands, Boot-up Actions and X Window

Introduction to the Linux Command Line January Presentation Topics

COMP 4/6262: Programming UNIX

An Introduction to Cluster Computing Using Newton

Lec 1 add-on: Linux Intro

Assignment clarifications

CSCI 2132 Software Development. Lecture 3: Unix Shells and Other Basic Concepts

EECS2301. Lab 1 Winter 2016

Exploring UNIX: Session 5 (optional)

Lecture 3. Unix. Question? b. The world s best restaurant. c. Being in the top three happiest countries in the world.

Table of contents. Our goal. Notes. Notes. Notes. Summer June 29, Our goal is to see how we can use Unix as a tool for developing programs

Unix Shell Environments. February 23rd, 2004 Class Meeting 6

Introduction to the Shell

Working With Unix. Scott A. Handley* September 15, *Adapted from UNIX introduction material created by Dr. Julian Catchen

Chapter 9. Shell and Kernel

1. What statistic did the wc -l command show? (do man wc to get the answer) A. The number of bytes B. The number of lines C. The number of words

M2PGER FORTRAN programming. General introduction. Virginie DURAND and Jean VIRIEUX 10/13/2013 M2PGER - ALGORITHME SCIENTIFIQUE

What is the Shell. Whenever you login to a Unix system you are placed in a program called the shell. All of your work is done within the shell.

Review of Fundamentals. Todd Kelley CST8207 Todd Kelley 1

Shells and Shell Programming

Scripting Languages Course 1. Diana Trandabăț

Answers to AWK problems. Shell-Programming. Future: Using loops to automate tasks. Download and Install: Python (Windows only.) R

Using UNIX. -rwxr--r-- 1 root sys Sep 5 14:15 good_program

CSE 303 Lecture 2. Introduction to bash shell. read Linux Pocket Guide pp , 58-59, 60, 65-70, 71-72, 77-80

Linux at the Command Line Don Johnson of BU IS&T

Lab #2 Physics 91SI Spring 2013

Linux shell scripting Getting started *

More Raspian. An editor Configuration files Shell scripts Shell variables System admin

Part 1: Basic Commands/U3li3es

27-Sep CSCI 2132 Software Development Lab 4: Exploring bash and C Compilation. Faculty of Computer Science, Dalhousie University

CISC 220 fall 2011, set 1: Linux basics

Exercise 1: Basic Tools

Essential Linux Shell Commands

UNIX COMMANDS AND SHELLS. UNIX Programming 2015 Fall by Euiseong Seo

ScazLab. Linux Scripting. Core Skills That Every Roboticist Must Have. Alex Litoiu Thursday, November 14, 13

Using the Zoo Workstations

Getting started with Hugs on Linux

UNIX System Programming Lecture 3: BASH Programming

Chap2: Operating-System Structures

Crash Course in Unix. For more info check out the Unix man pages -orhttp:// -or- Unix in a Nutshell (an O Reilly book).

First of all, these notes will cover only a small subset of the available commands and utilities, and will cover most of those in a shallow fashion.

BIOINFORMATICS POST-DIPLOMA PROGRAM SUBJECT OUTLINE Subject Title: OPERATING SYSTEMS AND PROJECT MANAGEMENT Subject Code: BIF713 Subject Description:

Unix tutorial. Thanks to Michael Wood-Vasey (UPitt) and Beth Willman (Haverford) for providing Unix tutorials on which this is based.

Chapter-3. Introduction to Unix: Fundamental Commands

XSEDE Scholars Program Introduction to the Linux Environment. Tips and Tricks for Linux Users John Lockman III June 5 th, 2012

Lab Working with Linux Command Line

CS197U: A Hands on Introduction to Unix

Command Line Interface Techniques

CS 3410 Intro to Unix, shell commands, etc... (slides from Hussam Abu-Libdeh and David Slater)

Advanced Linux Commands & Shell Scripting

Introduction to Unix: Fundamental Commands

CSC209H Lecture 1. Dan Zingaro. January 7, 2015

Introduction To Linux. Rob Thomas - ACRC

Practical Session 0 Introduction to Linux

Introduction to Shell Scripting

Transcription:

Linux Command Line Interface December 27, 2017

Foreword It is supposed to be a refresher (?!) If you are familiar with UNIX/Linux/MacOS X CLI, this is going to be boring... I will not talk about editors (vi, emacs...)

Basics (Computer) Terminal: Hardware device for data entry and display; Terminal Emulator (aka tty): An application program replacing a computer terminal. Many of those, OS dependent (cmd for DOS/Win; Terminal for OS X; xterm for Linux;...); The Terminal provides user access to the computer through the Command Line Interface (CLI) where the user issues commands. The CLI dialect is the Shell. In UNIX-like systems a lot of dialects exists: sh, bash, csh, tcsh, ksh, zsh... I will only use the bash shell.

Shell How to access a shell Logging in to your own Linux (virtual) box (CTRL-ALT-F1/CTRL-ALT-F7); Opening a graphic terminal (xterm...); SSHing into a server. To know which shell you use: echo $SHELL I use this font to denote commands SHELL is an environment variable echo is a command

Commands apropos: search the manual page names and descriptions man: manual page (try man apropos, man man) Almost every command, system program, or API has a man page man apropos, man fread, man pthreads, man 1 open, man 2 open Reading man pages is a very worthwhile activity Not everything is a command... type <cmd> type man (command), type echo (shell built-in), type ls (alias (well... on my system)) Commands take arguments (optional or mandatory); take input from the standard input (aka stdin); produce output on the standard output (stdout) or the standard error output (stderr). UNIX philosophy: Have a lot of programs; Each of them does only one thing but does it well.

First Commands Print the current working directory: pwd; List the files in the current directory: ls; Create a directory: mkdir <directoryname>; Change the current directory to <directoryname>: cd <directoryname>; Create an empty file: touch <filename>;

Wildcards List the files whose names start with a c: ls c*; List the files whose names end with a c: ls *c; List the files whose names contain a c: ls *c*; We could spend a whole session (and maybe more) on bash and the use of regular expressions (Look up bash regular expressions with your favorite search engine)

UNIX Philosophy (continued) - Pipes Expect the output of every program to become the input to another, as yet unknown, program. Don t clutter output with extraneous information. Avoid stringently columnar or binary input formats. Don t insist on interactive input grep: find a string in a file or a set of files; prompt> grep Prince TheLittlePrince.txt prompt> grep -i Prince TheLittlePrince.txt... [A lot] wc: count lines, words, characters prompt> wc TheLittlePrince.txt 2582 17297 91651 TheLittlePrince.txt lines words characters

UNIX Philosophy (continued) - Pipes : pipe (the output of the program at the left of the pipe becomes the input of the program at the right of the pipe) prompt> grep -i Prince TheLittlePrince.txt wc -l 195 and more... cat TheLittlePrince.txt sed s/becuase/because/g

Jobs Commands can be executed in the background thanks to the & symbol. find / -type f wc -l > /tmp/find.stdout 2> /tmp/find.stderr & The running command is called a job jobs is the command to look at running jobs Jobs can be accessed as %1, %2,... fg %2 brings the job #2 to the foreground If a job is already running, hitting CTRL-Z suspends the job and gives it a job id bg %4 resumes the suspended job in the background kill %7 attempts to terminate the job #7 gracefully kill -9 %7 kills the job unconditionally

Environment Variables printenv to get the list of environment variables; Sometimes you ll have to set/modify environment variables (PATH) (and you can mess things up badly); Setting a new environment variable (or overwriting another one): export NEWTHING="a:b/c" Adding to an environment variable: export NEWTHING="$NEWTHING hello"

Shell Customization You are supposed to always know what you are doing cp, rsync can be useful for backups chsh: Change the shell Edit.bashrc and/or.bash profile to add/modify aliases, environment variables... export PATH=$PATH:$HOME/bin Tip: Always add the old path (unless you know what you are doing) (Setting export PATH=foo is a bad idea... Why?) source $HOME/.bashrc is faster than logging out and back in.

Tricks and Tips Tab completion Up-arrow history and!<something>,!ls,!!,!23 CTRL-R... and others...

sudo / System Updates/System Upgrades sudo is dangerous (With great power comes great responsibility); Every now and then the system will tell you something like: 224 packages can be updated. 130 updates are security updates. New release 16.04.1 LTS available. Run do-release-upgrade to upgrade to it. DO NOT do-release-upgrade your Virtual Machine during the semester

Conclusion. Limits We ve barely scratched the surface... The CLI is very powerful But there are things it can t do (e.g., floating-point numbers) Knowing a scripting language is a good idea for your future (bash, Python, Ruby?, Perl?...) Allows you to avoid tedious by-hand work (e.g., see the first programming assignment ) There is a Scripting Languages course (ICS215)