Command-line interpreters

Similar documents
System Administration

System Administration

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

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

Introduction: What is Unix?

Perl and R Scripting for Biologists

3/8/2017. Unix/Linux Introduction. In this part, we introduce. What does an OS do? Examples

Computer Systems and Architecture

Useful Unix Commands Cheat Sheet

Computer Systems and Architecture

CSCI 2132 Software Development. Lecture 5: File Permissions

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

Files and Directories

Lab 2: Linux/Unix shell

Introduction to Linux

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

EECS 2031E. Software Tools Prof. Mokhtar Aboelaze

Unix Processes. What is a Process?

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

Operating Systems. Copyleft 2005, Binnur Kurt

Operating Systems 3. Operating Systems. Content. What is an Operating System? What is an Operating System? Resource Abstraction and Sharing

CS370 Operating Systems

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

UNIX System Programming Lecture 3: BASH Programming

Introduction to Linux

Introduction to Linux Organizing Files

UNIX Quick Reference

Linux Command Line Primer. By: Scott Marshall

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

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

Linux Command Line Interface. December 27, 2017

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

UNIX Kernel. UNIX History

Chap2: Operating-System Structures

EECS2301. Lab 1 Winter 2016

CSC209H Lecture 1. Dan Zingaro. January 7, 2015

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

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

Introduction to UNIX Shell Exercises

Chapter 1 - Introduction. September 8, 2016

Shell Programming Systems Skills in C and Unix

Introduction to the shell Part II

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

Introduction to Linux

Unix Shells and Other Basic Concepts

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

bash, part 3 Chris GauthierDickey

Introduction to Unix: Fundamental Commands

Exercise 1: Basic Tools

Introduction to the Linux Command Line January Presentation Topics

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

Chapter 9. Shell and Kernel

CS246 Spring14 Programming Paradigm Notes on Linux

CSCI 2132 Software Development. Lecture 4: Files and Directories

The Unix Shell & Shell Scripts

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

Linux Kung Fu. Ross Ventresca UBNetDef, Fall 2017

CISC 220 fall 2011, set 1: Linux basics

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

5/20/2007. Touring Essential Programs

Linux & Shell Programming 2014

Introduction To. Barry Grant

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

Introduction. Let s start with the first set of slides

Part 1: Basic Commands/U3li3es

Basic UNIX commands. HORT Lab 2 Instructor: Kranthi Varala

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

Introduction to the Shell

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

CSE 391 Lecture 1. introduction to Linux/Unix environment

An Introduction to Unix Power Tools

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

Virtual Machine. Linux flavor : Debian. Everything (except slides) preinstalled for you.

Shells and Shell Programming

PROGRAMMAZIONE I A.A. 2015/2016

Working with Basic Linux. Daniel Balagué

Assignment clarifications

Linux shell scripting Getting started *

Sperimentazioni I LINUX commands tutorial - Part II

elinks, mail processes nice ps, pstree, top job control, jobs, fg, bg signals, kill, killall crontab, anacron, at

Unix Handouts. Shantanu N Kulkarni

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

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

INTRODUCTION TO LINUX

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

A Brief Introduction to the Linux Shell for Data Science

18-Sep CSCI 2132 Software Development Lecture 6: Links and Inodes. Faculty of Computer Science, Dalhousie University. Lecture 6 p.

CSE 390a Lecture 1. introduction to Linux/Unix environment

Lec 1 add-on: Linux Intro

CSE 391 Lecture 1. introduction to Linux/Unix environment

GNU/Linux Course Lesson 1. Puria Nafisi

Unix basics exercise MBV-INFX410

The UNIX Operating System. HORT Lecture 2 Instructor: Kranthi Varala

Introduction to Linux

CS197U: A Hands on Introduction to Unix

Week 5 Lesson 5 02/28/18

Processes. System tasks Campus-Booster ID : **XXXXX. Copyright SUPINFO. All rights reserved

Module 8 Pipes, Redirection and REGEX

Short Read Sequencing Analysis Workshop

Transcription:

Command-line interpreters shell Wiki: A command-line interface (CLI) is a means of interaction with a computer program where the user (or client) issues commands to the program in the form of successive lines of text (command lines). sh, ksh, csh, zsh, tcsh, bash bash is default shell In GNU/Linux 29/50

Command line General form: ~$ command -options parameters Options alternate or specify the command behavior Parameters provide the input data by values, or by giving the path to the file. Parameter values may also alternate command behavior 30/50

Command line ~$ head vpn_manual.txt Manual for SA13 Configuration on GNU/Linux Configuring the OpenVPN * in this manual "username" refers to your username in this course (in class 123) To configure your openvpn you need certificates generated in first practical session. 1. First you need to install openvpn package. Install version not newer than 2.2 as 2.3 has a bug. For that either use command # apt-get install openvpn... ~$ head -n 1 vpn_manual.txt Manual for SA13 Configuration on GNU/Linux 31/50

Command Line Help option -h or --help Gives brief description of command usage ~$ tail --help Usage: tail [OPTION]... [FILE]... Print the last 10 lines of each FILE to standard output. With more than one FILE, precede each with a header giving the file name. With no FILE, or when FILE is -, read standard input. Mandatory arguments to long options are mandatory for short options too. -c, --bytes=k output the last K bytes; alternatively, use -c +K to output bytes starting with the Kth of each file. 32/50

Command Line Read detailed manual for specific command using UNIX online documentation or so called manual (man) pages. man - special command to view manual of specific command: ~$ man command ~$ man tail Gives detailed description of tail command Navigate with arrow keys, terminate with q key 33/50

Command Line (shell) Internal commands: shell built-in commands Examples: cd echo exit External commands: OS level programs, located in /bin and /usr/bin For exact location of the external program use which command: ~$ which ls /bin/ls returned the location of ls 34/50

Command Line (shell) Important meta symbols: File name patterns: * - any amount of any symbols? - exactly one symbol [symbols] exactly one symbol from the list \ -Escaping \( \) \$ \# `command` or $(command) in place execution Expression will be replace with the output of the command 35/50

File management commands pwd print current directory cd dir change directory cp -r dir1 dir2 directory copy cp file1 file2 filen directory copy files to directory mv source_file targe_file - move/rename file mv file1 file2 filen directory rm file1 file2 delete files rm -r directory delete directory 36/50

File permissions and ownership chmod change permissions Covered in slides 26-28 chown change ownership chown newuser.newgroup file1 file2 filen Change ownership of the files to newuser and newgroup chown -R newuser.newgroup directory Change ownership of the directory and all the files within recursively 37/50

Process Management ps view process table ps -e -view all (also detached and not owned) ps -f detailed table ps -u user view processes of user top,htop interactive process tables 38/50

Process Management It is possible to send the signals to process by process id (PID) kill -SIG PID (send signal) kill -l (view signals) kill -15 PID (SIGTERM) soft terminate kill -9 PID (SIGKILL) hard terminate And by process name pkill -15 xclock soft terminate xclock process In graphical environment xkill and the just select the window you want to terminate 39/50

Process Management Process priorities in UNIX Highest -20 Lowest 19 Default 10 Superuser permission required to set process priority below 0 nice -n N run process with N priority renice -n N change priority of running process 40/50

Process Management nohup run program detached (in background) Ctrl+C in runtime send SIGINT (2) signal Ctrl+Z in runtime suspend and detach process bg send detached process to background fg restore detached process from background 41/50

Disk management and quotas Disk Quota Limits user disk usage Number of files Soft quota Hard quota quota Amount used diskspace quota -v detailed quota info Class 123 quota is 50G per user 42/50

Disk management and quotas du Disc Usage information (sum of all files in current directory) du -sk *.??* sort -n sorted list of disc usage by individual files and directories df File system load information 43/50

Default Communication Channels STDIN (0) Standard Input STDOUT (1) Standard Output STDERR (2) error reports Each program apart from options and parameters can read from STDIN and write to STDOUT,STDERR STDIN comes by default from command line input Keyboard STDOUT, STDERR by default command line output Terminal application (command promt) 44/50

Default Communication Channels ~$ N=''; \ echo 'Say something :'; \ read N; \ echo 'You said: ' $N; Here we ask user to input some data, obviously read command will be expecting data from STDIN letting user type in some words. echo prints the corresponding messages to the STDOUT, so user can read the from command promt. N variable is only user to store the user input. Here we do not use STDERR 45/50

Input/Output Redirection command1 > fail1 Write output of the command1 to file1 command1 >> fail1 Append output of the command1 to file1 command1 < fail1 Command1 input from file1 2>&1 Redirect STDERR as well as the STDOUT 46/50

Input/Output Redirection ~$ echo 'Input some words, Enter to separate.' \ echo 'Ctrl+C to finish : '; \ cat > words.txt; Here we ask user to provide list of words (in several lines), and we write the word list int file words.txt. File writing occurs by redirecting output of cat command. ~$ echo 'Sorted list :'; \ sort < words.txt Now we show the alphabetically sorted list of words by providing the input to sort command from the file we just have written. 47/50

Command pipelines Powerful utility to combine simple utility Pipeline redirects the standard output of one command to the standard input of the next command. Commands in pipeline run parallel in separate processes No need for temporary files du -sk *.??* sort -n Do you remember this expression? 48/50

Command pipelines command1 command2 the pipe is one way synchronization Command2 waits if pipe is empty Command1 waits if pipe is full Command2 reads if pipe not empty Command1 writes if pipe not full possible errors pipe lock broken pipe 49/50

Some useful links http://www.thegeekstuff.com/2010/11/50-linux-commands/ http://www.ibm.com/developerworks/aix/library/au-badunixhabits.html http://www.thegeekstuff.com/2009/07/linux-ls-command-examples/ http://www.linuxnix.com/2012/07/23-awesome-less-known-linuxunix-command-chaining-examples.html http://www.linuxnix.com/2012/02/linuxunix-redirection-operatorsfile-descriptors-explained-examples.html http://www.linuxnix.com/2010/02/file-types-in-linux.html http://www.linuxnix.com/2011/12/chown-command-linuxunix-explained-examples.html http://www.linuxnix.com/2011/10/chmod-command-explained-linuxunix.html http://www.linuxnix.com/2012/07/abslute-path-vs-relative-path-in-linuxunix.html http://www.linuxnix.com/2012/03/how-to-rename-files-in-linux.html http://www.linuxnix.com/2012/02/linux-bash-shell-short-cuts.html http://www.linuxnix.com/2012/01/sticky-bit-set-linux.html http://www.linuxnix.com/2011/07/grep-command-usage-linux.html 50/50