Command Line Interface The basics

Similar documents
Mills HPC Tutorial Series. Linux Basics I

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

Introduction to Linux

Carnegie Mellon. Linux Boot Camp. Jack, Matthew, Nishad, Stanley 6 Sep 2016

Introduction. File System. Note. Achtung!

Lab Working with Linux Command Line

Essential Linux Shell Commands

FILE MAINTENANCE COMMANDS

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

DATA 301 Introduction to Data Analytics Command Line. Dr. Ramon Lawrence University of British Columbia Okanagan

Why learn the Command Line? The command line is the text interface to the computer. DATA 301 Introduction to Data Analytics Command Line

Tutorial 1: Unix Basics

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

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

Linux Command Line Primer. By: Scott Marshall

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

Lec 1 add-on: Linux Intro

COMS 6100 Class Notes 3

Introduction to Linux Workshop 1

CS 143A. Principles of Operating Systems. Instructor : Prof. Anton Burtsev

Chapter 4. Unix Tutorial. Unix Shell

Part I. UNIX Workshop Series: Quick-Start

Connecting to ICS Server, Shell, Vim CS238P Operating Systems fall 18

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

Linux Bootcamp Fall 2015

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 File System. Learning command-line navigation of the file system is essential for efficient system usage

15-122: Principles of Imperative Computation

Getting Started With UNIX Lab Exercises

Intro to Linux. this will open up a new terminal window for you is super convenient on the computers in the lab

Introduction: What is Unix?

Introduction to the UNIX command line

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

Week Overview. Unix file system File types and file naming Basic file system commands: pwd,cd,ls,mkdir,rmdir,mv,cp,rm man pages

Physics REU Unix Tutorial

Introduction to Unix

Introduction to Linux Part 1. Anita Orendt and Wim Cardoen Center for High Performance Computing 24 May 2017

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

Working with Basic Linux. Daniel Balagué

Unix Tutorial Haverford Astronomy 2014/2015

CS CS Tutorial 2 2 Winter 2018

Week 2 Lecture 3. Unix

Refresher workshop in programming for polytechnic graduates General Java Program Compilation Guide

History. Terminology. Opening a Terminal. Introduction to the Unix command line GNOME

Linux Introduction Martin Dahlö Valentin Georgiev

The Directory Structure

Helsinki 19 Jan Practical course in genome bioinformatics DAY 0

Unix basics exercise MBV-INFX410

Short Read Sequencing Analysis Workshop

Lab 2: Linux/Unix shell

Advanced Linux Commands & Shell Scripting

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

Table Of Contents. 1. Zoo Information a. Logging in b. Transferring files 2. Unix Basics 3. Homework Commands

THE HONG KONG POLYTECHNIC UNIVERSITY Department of Electronic and Information Engineering

CS101 Linux Shell Handout

Helpful Tips for Labs. CS140, Spring 2015

LAB #7 Linux Tutorial

This lab exercise is to be submitted at the end of the lab session! passwd [That is the command to change your current password to a new one]

Exploring UNIX: Session 3

Introduction of Linux

Introduction to Unix and Linux. Workshop 1: Directories and Files

Introduction to Linux for BlueBEAR. January

Using the Zoo Workstations

Linux Kung Fu. Ross Ventresca UBNetDef, Fall 2017

Scripting Languages Course 1. Diana Trandabăț

Practical Session 0 Introduction to Linux

This is Lab Worksheet 3 - not an Assignment

Unix/Linux Primer. Taras V. Pogorelov and Mike Hallock School of Chemical Sciences, University of Illinois

PDS Lab Section 16 Autumn Tutorial 1. Unix Commands pwd The pwd command displays the full pathname of the current directory.

CSE Linux VM. For Microsoft Windows. Based on opensuse Leap 42.2

Operating System Interaction via bash

Introduction to UNIX command-line II

Linux Systems Administration Getting Started with Linux

Introduction to UNIX command-line

Intermediate Programming, Spring Misha Kazhdan

Linux and Git Boot Camp

Basic UNIX Commands BASIC UNIX COMMANDS. 1. cat command. This command is used to create a file in unix. Syntax: $ cat filename

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

Introduction to Unix - Lab Exercise 0

Perl and R Scripting for Biologists

The Unix Shell & Shell Scripts

CS Unix Tools. Lecture 2 Fall Hussam Abu-Libdeh based on slides by David Slater. September 10, 2010

Lab 1 Introduction to UNIX and C

Basic UNIX Commands BASIC UNIX COMMANDS. 1. cat command. This command is used to create a file in unix. Syntax: $ cat filename

CENG 334 Computer Networks. Laboratory I Linux Tutorial

Introduction to UNIX. Introduction. Processes. ps command. The File System. Directory Structure. UNIX is an operating system (OS).

Introduction to UNIX. CSE 2031 Fall November 5, 2012

CHEM5302 Fall 2015: Introduction to Maestro and the command line

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.

Linux Training. for New Users of Cluster. Georgia Advanced Computing Resource Center University of Georgia Suchitra Pakala

A Brief Introduction to the Linux Shell for Data Science

CHE3935. Lecture 1. Introduction to Linux

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

Reading and manipulating files

213/513/613 Linux/Git Bootcamp. Cyrus, Eugene, Minji, Niko

The Command Line. Matthew Bender. September 10, CMSC Command Line Workshop. Matthew Bender (2015) The Command Line September 10, / 25

Linux Command Line Interface. December 27, 2017

Cloud Computing and Unix: An Introduction. Dr. Sophie Shaw University of Aberdeen, UK

Introduction to Unix

Introduction to the Linux Command Line

Transcription:

Command Line Interface The basics Marco Berghoff, SCC, KIT Steinbuch Centre for Computing (SCC) Funding: www.bwhpc-c5.de

Motivation In the Beginning was the Command Line by Neal Stephenson In contrast to graphical user interface (which can simplify the use of computer) a command-line interface (CLI) is often the most powerful and flexible way to interact with a computer. The user types commands that tell the computer to do specific things. These commands can be combined -> see tomorrow session. You can feel like a real hacker. Sources: https://www.learnenough.com/command-line-tutorial man bash and other manuals 2

What is this course about and what not? We will present the basics of the command line: simple commands navigating some usability features no special command no programming (what you can do inside of the command line) -> see tomorrow 3

The command line interface [projects]$ ls l foo.txt prompt [projects]$ command line ls l foo.txt command ls option l argument foo.txt cursor 4

The first command $ echo hello bwhpc hello bwhpc $ Echo the STRING(s) to standard output. $ echo hello bwhpc hello bwhpc $ Task: Please do all examples by yourself. Using up-arrow for the last command. Use double or single quote to mark strings. $ echo "hello bwhpc" hello bwhpc $ echo 'hello bwhpc' hello bwhpc $ 5

Getting out of trouble You can get in trouble by: unfinished typing of a command long or endless running command command expecting further input Solution: holding Ctrl-Key (Strg) and pressing C. Short written as Ctrl C or ^C (remember as 'cancel') If it is not working try Ctrl D (remember as 'end of transmission', 'end of input'), ESQ or just q. Task: Try and exit the following commands: $ echo "hello $ yes $ cat 6

Effect of single and double quotes Each variable begins with $. There are many variable set that defines the environment. Details will be present tomorrow. $ echo My home is $HOME My home is /home/kit/scc/ab1337 Task: Try out the different effects of quoting by print out the variable $HOME. 7

Getting help $man echo open the manual pages of the command echo. It uses less as a page viewer, where you can use the arrow keys to navigate. less basics: up & down arrow Move up or down one line spacebar Move forward one page q quit /<string> search file for <string>. n Move to next search result. N Move to previous search result. p goto beginning of the file h help Task: Find out how to print text without the newline at the end. 8

Summary echo <string> Prints string to screen. man <command> Displays manual page for command. ^C Get out of trouble. Up & down arrow Scrolls through previous command history. 9

Manipulating files Create files $ touch foobar $ touch foobaz redirecting standard output (stdout) to a file: redirect operator > (overwrites files) append operator >> $ echo "This is the first line." > foobar.txt $ echo "This is the second line." >> foobar.txt $ cat foobar.txt This is the first line. This is the second line. 10

Listing $ ls foobar foobar.txt foobaz Task: What does ls lha do? Try also t and r. Use different combinations. Note: For short flags you can combine the flags instead of using ls l h a. Long flags beginning with two dashes ls help 11

Make life easier (Tab completion) use the tab key $ cat f expands to $ cat fooba twice tab print possible matches $ cat fooba foobar foobar.txt foobaz $ cat foobar. Task: Print out foobar.txt without typing to much. How many keystrokes are needed? 12

Make life easier (copy and past by mouse) $ ls foobar foobar.txt foobaz $ cat Mark foobar.txt with mouse. Click middle mouse button to insert at cursor. Tasks: Print out foobar.txt. What will happen when you print out foobaz including the letter after z? 13

Make life easier (reverse search) Search the history. $ ^R echo (reverse i search)`echo': echo "This is the second line." >> foobar.txt ^C cancel ^R previous search Enter run command right arrow select command for editing Task: Insert a third line to foobar.txt. 14

Manipulating files: Rename, copy, delete Moving Moving a file will rename it. mv foobaz test $ ls foobar foobar.txt test 15

Manipulating files: Rename, copy, delete Copy from source to target cp foobar.txt test_text.txt $ ls foobar foobar.txt test test_text.txt 16

Manipulating files: Rename, copy, delete Remove. WARNING: It is deleted, really, no trash, nothing. rm foobar.txt $ ls foobar foobar.txt test test_text.txt 17

Editors (nano) A basic editor $ nano test_text.txt Help for some useful commands see bottom lines Try ^K^K^U^U to cut and uncut lines exit nano ^X exist and ask for save changes, type y, type filename or press enter for current filename. 18

Editors (vim) A much more powerful and very fast editor $ vim test_text.txt Press i to go to insert mode. Now you can type text. exit vim Press ESQ to go back to the normal (command) mode. Type :q to quit. If you change something you have to write and quit :wq or force quit :q!. <br> LEARN vim! $ vimtutor (-g language) It takes 25-30 min. You can start at the end of this course. 19

Summary > Redirect output to filename >> Append output to filename touch <file> Create an empty file cat <file> Print contents of file to screen ls List directory or file mv <old> <new> Rename (move) from old to new cp <old> <new> Copy from old to new rm <file> Delete (remove) file (no recovery!) Auto completion ^R Reverse search vimtutor Tutor for learning vim 20

Directories $ pwd /home/kit/scc/ab1337 Prints the current working path, starting with the root directory / followed by the directories home, kit, scc and ab1337. 21

Create directory $ mkdir text_files $ mkdir example This is relative. Paths are normally relative from the current working path. Absolute paths beginning with the root /. 22

Moving directories Move files to directories $ mv *.txt text_files/ $ ls text_files/ Use tabs! *.txt is a Wildcard matching all files ended on.txt. See tomorrow. 23

Moving directories Move (rename) directories $ mv example/ data $ ls 24

Changing directories (Navigation) $ cd text_files/ $ cd.. $ cd data cd.. goes one directory up. Task: Double check directories with pwd and ls. 25

Relative changing A path beginning with../ goes relative to the current working directory one directory layer for each../ up. Try $ cd../text_files/ Tab completion adds automatically a / at end of directory name. (Don't matter at the moment.) Task: create foo/bar/ at once. 26

Special navigation Moving to the last directory. $ cd Moving to the home directory. $ cd $ cd ~ $ cd $HOME $HOME is the already known variable for the home directory. See later courses for other path variables. 27

Copying directories Add r option for recursive $ cd $ mkdir foobar $ cd foobar/ $ cp r../text_files. $ ls text_files. is the current directory. Task: What happen if you add a / to the source directory../text_files/? $ cp r../text_files/. $ ls text_files text.txt Remember as../text_files is the directory and../text_files/ is already inside the directory. 28

Remove directories Add r option for recursive $ cd $ rm r foobar Warning: Again, there are no warning, it will be deleted, not trash, nothing. Task: Do not execute it! What are the options f and r are doing in rm? Why you should NEVER used rm rf /? 29

Summary mkdir <name> Make directory with name pwd Print working directory cd <dir> Change to <dir> cd ~/<dir> cd relative to home cd Change to home directory cd Change to previous directory. The current directory.. One directory up cp r <old> <new> Copy recursively rm r <dir> Remove dir and content 30

Find files Task: create some.txt files in different directories. $ find. name "*.txt" Search recursively for files beginning in the current directory., filter by name, only display files ending with.txt. $ grep r line Search recursively ( r) for files and print lines containing line. Task: Print line number of lines with 'first' using grep Print lines not containing 'first' using grep 31