Sperimentazioni I LINUX commands tutorial - Part II

Size: px
Start display at page:

Download "Sperimentazioni I LINUX commands tutorial - Part II"

Transcription

1 Sperimentazioni I LINUX commands tutorial - Part II A. Garfagnini, M. Mazzocco Università degli studi di Padova 24 Ottobre 2012 Streams and I/O Redirection Pipelines Create, monitor and kill processes

2 The BASH I/O Streams All the UNIX shells use three standard I/O streams: stdout, the standard output stream which displays output from commands. stderr, the standard error stream which displays error output from streams. stdin, the standard input stream which provides input to commands. Stream File descriptor stdin 0 stdout 1 stderr 2 Input streams provide input to programs, usually from terminals. Output streams print text characters, usually to terminals. Redirecting output There are two ways to redirect output: n> redirects output from file descriptor n to a file. You must have write permission to the file. If the file does not exist, it is created. If the file exists, the existing content is lost without any warning. n >> redirects output from file descriptor n to a file. You must have write permission to the file. If the file does not exist, it is created. If the file exists, the output is appended to the existing file.

3 Redirecting output streams - examples No redirection $ ls a* z* /bin/ls: z*: No such file or directory a2 a3 a4 a5 a.out* a.ps stderr redirection $ ls a* z* 2>errori.txt a2 a3 a4 a5 a.out* a.ps $ cat errori.txt /bin/ls: z*: No such file or directory stdout redirection $ ls a* z* >stdout.txt /bin/ls: z*: No such file or directory $ cat stdout.txt a2 a3 a4 a5 a.out* a.ps both output streams redirected $ ls a* z* >stdout.txt 2>>errori.txt $ cat errori.txt /bin/ls: z*: No such file or directory /bin/ls: z*: No such file or directory Redirecting both streams to the same file Sometimes both output streams have to be redirected to one file The procedure is often used for automated processes or in background jobs. Three possibilities: 1. command 1> output.log 2> output.log 2. command > output.log 2>&1 3. command &> output.log To append output to a file, replace > with >> Q: How to ignore output streams? A: redirect the appropriate stream to /dev/null Ex: Ignoring error output stream $ ls a* z* 2>/dev/null a2 a3 a4 a5 a.out* a.ps

4 Input redirection stdin stream can be redirected from a file, using the < operator stdin/stdout redirect example $ ls -1 > list.out Redirect stdout to list.out $ cat list.out a2 a3 $ sort -r < list.out a3 a2 All entries in ascending order Process input from file with sort giving a reverse ordering The cat command The cat command, short for catenate, allows to display the contents of a file on stdout: $ cat list.out... a3 The cat command takes input from stdin if you do not specify a file name; it keeps reading from stdin until the end-of-file. (ctrl-d is used to signal end-of-file). Creating a file with cat $ cat >list2.out Ctrl-d is pressed... a3 $

5 Input redirection with here-document The here-document is another form of input redirection It uses the << along with a word, such as END for a marker to indicate the end of input. [agarfa]$ cat«end>ex-here.sh > cat «-EOF > apple > EOF > END [agarfa]$ cat ex-here.sh cat «-EOF apple pear EOF [agarfa]$. ex-here.sh apple pear source the script, i.e. run in the current shell context It is often used in script files where there is no other way to indicate which lines should be treated as input. Input redirection summary > file Direct standard output to file < file Take standard input from file >> file Direct standard output to file; append to file if it exists << label Here-document n> file Direct file descriptor n to file n< file Take file descriptor n from file n >> file Direct file descriptor n to file; append to file if it exists n>& Duplicate standard output to file descriptor n n<& Duplicate standard input from file descriptor n n>&m File descriptor n becomes a copy of the output file descriptor n<&m File descriptor n becomes copy of the input file descriptor &>file Directs standard output and standard error to file

6 Pipelines Text filtering is the process of taking an input stream of text and performing some conversion before sending it to an output stream Filtering is done constructing a pipeline of commands where the output from one command is piped or redirected as input to the next: command1 command2 [ command3...] [agarfa]$ ls *a *z sort /bin/ls: z*: No such file or directory a2 [agarfa]$ ls *a *z 2>&1 sort a2 /bin/ls: z*: No such file or directory N.B. pipelines only pipe stdout to stdin! if stderr has been redirected to stdout, both streams will be piped. One advantage of pipes on LINUX and UNIX is that there is no intermediate file involved: the stdout of the first command is sent directly to the second command. head or tail... and wc While cat allows to concatenate files and print them on the standard output head output the first part of files (10 lines by default) head -n K head -c B prints the first K lines of a file; prints the first B bytes of a file; tail output the last part of files (10 lines by default) tail -n K tail -c B prints the last K lines of a file; prints the last B bytes of a file; wc prints newline, word and byte counts for each file wc -c wc -l wc -w print the byte counts; print the newline counts; print the word counts;

7 Finding text in files The grep command print lines matching a pattern grep [OPTIONS] PATTERN [FILE...] grep searches the named input FILEs, or standard input if no files are named, for lines containing a match to the given PATTERN. grep -i grep -n input file. ignore case distinctions in both the PATTERN and the input files. prefix each line of output with the 1-based line number within its [agarfa]$ grep iostream *.cxx primo.cxx:#include <iostream> secondo.cxx:#include <iostream> [agarfa]$ grep -n iostream *.cxx primo.cxx:1:#include <iostream> secondo.cxx:1:#include <iostream> [agarfa]$ ls -l grep cxx -rw-r-r- 1 agarfa fisica 100 Oct 21 12:27 primo.cxx -rw-r-r- 1 agarfa fisica 100 Oct 19 22:54 secondo.cxx Foregroud and background jobs When you run a command in a terminal window, you are running it in the foreground. The Bash shell has a suspend key, Ctrl-z. Pressing this key combination, you get the terminal prompt again. The clock is still on your destop but has stopped running. It can be restarted with the fg command fg brings the job right back to the foreground, but you no longer have a shell prompt. The bg command continues running your job in backgorund and giving back the terminal prompt [agarfa]$ xclock -d -update 1 [2]+ Stopped xclock -d -update 1 [agarfa]$ fg %2 xclock -d -update 1 [1]+ Stopped xclock -d -update 1 [agarfa]$ bg %1 [1]+ xclock -d -update 1 &

8 Using & To start a new job in background, add a & character at the end of the command The message shows a job number and a process id (PID). With the jobs command is possible to find out what jobs are running The -l option prints PIDs and the plus sign (+) beside the job number indicates that is the current job [agarfa]$ xclock -d -update 2 & [1] [agarfa]$ jobs -l [1] Running xclock -d -update 1 & ps: inspecting process status information The ps command accepts zero or more PIDs as argument and displays the associated process status Using ps with no options will list all processes that have our terminal as their controlling terminal [agarfa]$ jobs -l [1] [agarfa]$ ps pts/6 S 0:00 xclock -d -update 1 [agarfa]$ ps PID TTY TIME CMD pts/6 00:00:00 bash pts/6 00:00:00 xclock pts/6 00:00:00 ps

9 More process status information Several options give control of how much information is displayed with the process status: -f : full -j : jobs -l : long --forest : display the commands in a tree hierarcy [agarfa]$ ps -l F S UID PID PPID C PRI NI ADDR SZ WCHAN TTY TIME CMD 0 S pts/1 00:00:00 bash 0 R pts/1 00:00:00 ps [agarfa]$ ps -j PID PGID SID TTY TIME CMD pts/6 00:00:00 ps pts/6 00:00:00 bash [agarfa]$ ps --forest PID TTY TIME CMD 422 pts/1 00:00:00 bash 764 pts/1 00:00:00 \_ ps Displaying other processes The -x option displays processes without a controlling terminal The -e option displays dinformation for every process Many options possible, get a brief summary with ps --help [agarfa]$ ps afx # Use BSD syntax 2? S< 0:00 [kthreadd]... 1? Ss 0:01 /sbin/init ? Ss 0:00 /usr/sbin/gdm 5855? S 0:00 \_ /usr/sbin/gdm 8057 tty7 SLs+ 24:26 \_ /usr/bin/x :0 -br -audit 0 -auth /var/lib/gdm/:0.xauth -nolisten tc 8087? Ss 0:00 \_ /bin/sh /etc/xdg/xfce4/xinitrc -- /etc/x11/xinit/xserverrc 8175? Ss 0:00 \_ /usr/bin/seahorse-agent --execute startxfce4 8191? S 0:50 \_ xscreensaver -no-splash 8196? Sl 0:35 \_ /usr/bin/xfce4-session 8253? S 0:02 \_ /usr/lib/xfce4/[...] socket_i 8479? Ssl 0:27 \_ gnome-terminal 8485? S 0:00 \_ gnome-pty-helper pts/4 Ss 0:00 \_ bash

10 top The top command displays a continuosly updated process list, along with useful summary information the -p option allows to control a single process [agarfa]$ top -p top - 18:58:50 up 10:32, 7 users, load average: 0.18, 0.28, 0.27 Tasks: 1 total, 0 running, 1 sleeping, 0 stopped, 0 zombie Cpu(s): 9.9%us, 1.8%sy, 0.2%ni, 87.2%id, 0.6%wa, 0.1%hi, 0.3%si, 0. Mem: k total, k used, 56140k free, 54776k buffers Swap: k total, 23580k used, k free, k cached PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND alberto S :03.36 xclock kill To Ctrl-c sequence terminates a running program. The sequence sends a SIGINT or interrupt signal to the process. The kill command sends a signal to a job or process. Type man kill to get a table of all available signals. The SIGTSTP and SIGCONT signals stop and resume a background job [agarfa]$ xcalc & [2] 6080 [agarfa]$ ps pts/6 S 0:00 xcalc [agarfa]$ kill -s SIGCONT 6215 [agarfa]$ ps pts/6 S 0:00 xcalc [agarfa$ kill -s SIGTSTP 6215 [2]+ Stopped xcalc [agarfa]$ ps pts/6 T 0:00 xcalc [agarfa]$ kill -s SIGINT 6215 [agarfa]$ ps 6215 [agarfa]$

Unix Processes. What is a Process?

Unix Processes. What is a Process? Unix Processes Process -- program in execution shell spawns a process for each command and terminates it when the command completes Many processes all multiplexed to a single processor (or a small number

More information

S E C T I O N O V E R V I E W

S E C T I O N O V E R V I E W INPUT, OUTPUT REDIRECTION, PIPING AND PROCESS CONTROL S E C T I O N O V E R V I E W In this section, we will learn about: input redirection; output redirection; piping; process control; 5.1 INPUT AND OUTPUT

More information

Most of the work is done in the context of the process rather than handled separately by the kernel

Most of the work is done in the context of the process rather than handled separately by the kernel Process Control Process Abstraction for a running program Manages program s use of memory, cpu time, and i/o resources Most of the work is done in the context of the process rather than handled separately

More information

Linux System Administration

Linux System Administration System Processes Objective At the conclusion of this module, the student will be able to: Describe and define a process Identify a process ID, the parent process and the child process Learn the PID for

More information

Introduction to UNIX Shell Exercises

Introduction to UNIX Shell Exercises Introduction to UNIX Shell Exercises Determining Your Shell Open a new window or use an existing window for this exercise. Observe your shell prompt - is it a $ or %? What does this tell you? Find out

More information

5/20/2007. Touring Essential Programs

5/20/2007. Touring Essential Programs Touring Essential Programs Employing fundamental utilities. Managing input and output. Using special characters in the command-line. Managing user environment. Surveying elements of a functioning system.

More information

CPSC 457 OPERATING SYSTEMS MIDTERM EXAM

CPSC 457 OPERATING SYSTEMS MIDTERM EXAM CPSC 457 OPERATING SYSTEMS MIDTERM EXAM Department of Computer Science University of Calgary Professor: Carey Williamson March 9, 2010 This is a CLOSED BOOK exam. Textbooks, notes, laptops, calculators,

More information

CRUK cluster practical sessions (SLURM) Part I processes & scripts

CRUK cluster practical sessions (SLURM) Part I processes & scripts CRUK cluster practical sessions (SLURM) Part I processes & scripts login Log in to the head node, clust1-headnode, using ssh and your usual user name & password. SSH Secure Shell 3.2.9 (Build 283) Copyright

More information

Exploring UNIX: Session 5 (optional)

Exploring UNIX: Session 5 (optional) Exploring UNIX: Session 5 (optional) Job Control UNIX is a multi- tasking operating system, meaning you can be running many programs simultaneously. In this session we will discuss the UNIX commands for

More information

Linux Tutorial #6. -rw-r csce_user csce_user 20 Jan 4 09:15 list1.txt -rw-r csce_user csce_user 26 Jan 4 09:16 list2.

Linux Tutorial #6. -rw-r csce_user csce_user 20 Jan 4 09:15 list1.txt -rw-r csce_user csce_user 26 Jan 4 09:16 list2. File system access rights Linux Tutorial #6 Linux provides file system security using a three- level system of access rights. These special codes control who can read/write/execute every file and directory

More information

07 - Processes and Jobs

07 - Processes and Jobs 07 - Processes and Jobs CS 2043: Unix Tools and Scripting, Spring 2016 [1] Stephen McDowell February 10th, 2016 Cornell University Table of contents 1. Processes Overview 2. Modifying Processes 3. Jobs

More information

Command-line interpreters

Command-line interpreters 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

More information

Managing Processes Process: A running program

Managing Processes Process: A running program Managing Processes Process: A running program User Process: The process initiated by a User while logged into a terminal (e.g. grep, find, ls) Daemon Process: These processes are usually initiated on system

More information

Programs. Program: Set of commands stored in a file Stored on disk Starting a program creates a process static Process: Program loaded in RAM dynamic

Programs. Program: Set of commands stored in a file Stored on disk Starting a program creates a process static Process: Program loaded in RAM dynamic Programs Program: Set of commands stored in a file Stored on disk Starting a program creates a process static Process: Program loaded in RAM dynamic Types of Processes 1. User process: Process started

More information

bash, part 3 Chris GauthierDickey

bash, part 3 Chris GauthierDickey bash, part 3 Chris GauthierDickey More redirection As you know, by default we have 3 standard streams: input, output, error How do we redirect more than one stream? This requires an introduction to file

More information

System Programming. Introduction to Unix

System Programming. Introduction to Unix Content : by Dr. B. Boufama School of Computer Science University of Windsor Instructor: Dr. A. Habed adlane@cs.uwindsor.ca http://cs.uwindsor.ca/ adlane/60-256 Content Content 1 Introduction 2 3 Introduction

More information

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

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 Summer 2010 Department of Computer Science and Engineering York University Toronto June 29, 2010 1 / 36 Table of contents 1 2 3 4 2 / 36 Our goal Our goal is to see how we can use Unix as a tool for developing

More information

The Unix Shell & Shell Scripts

The Unix Shell & Shell Scripts The Unix Shell & Shell Scripts You should do steps 1 to 7 before going to the lab. Use the Linux system you installed in the previous lab. In the lab do step 8, the TA may give you additional exercises

More information

Bamuengine.com. Chapter 7. The Process

Bamuengine.com. Chapter 7. The Process Chapter 7. The Process Introduction A process is an OS abstraction that enables us to look at files and programs as their time image. This chapter discusses processes, the mechanism of creating a process,

More information

System Administration

System Administration Süsteemihaldus MTAT.08.021 System Administration UNIX shell basics Name service DNS 1/69 Command Line Read detailed manual for specific command using UNIX online documentation or so called manual (man)

More information

HW 1: Shell. Contents CS 162. Due: September 18, Getting started 2. 2 Add support for cd and pwd 2. 3 Program execution 2. 4 Path resolution 3

HW 1: Shell. Contents CS 162. Due: September 18, Getting started 2. 2 Add support for cd and pwd 2. 3 Program execution 2. 4 Path resolution 3 CS 162 Due: September 18, 2017 Contents 1 Getting started 2 2 Add support for cd and pwd 2 3 Program execution 2 4 Path resolution 3 5 Input/Output Redirection 3 6 Signal Handling and Terminal Control

More information

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.

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. 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. 2 Conventions Used in This Book p. 2 Introduction to UNIX p. 5 An Overview

More information

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

M2PGER FORTRAN programming. General introduction. Virginie DURAND and Jean VIRIEUX 10/13/2013 M2PGER - ALGORITHME SCIENTIFIQUE M2PGER 2013-2014 FORTRAN programming General introduction Virginie DURAND and Jean VIRIEUX 1 Why learning programming??? 2 Why learning programming??? ACQUISITION numerical Recording on magnetic supports

More information

CSC UNIX System, Spring 2015

CSC UNIX System, Spring 2015 CSC 352 - UNIX System, Spring 2015 Study guide for the CSC352 midterm exam (20% of grade). Dr. Dale E. Parson, http://faculty.kutztown.edu/parson We will have a midterm on March 19 on material we have

More information

Shell. SSE2034: System Software Experiment 3, Fall 2018, Jinkyu Jeong

Shell. SSE2034: System Software Experiment 3, Fall 2018, Jinkyu Jeong Shell Prof. Jinkyu Jeong (Jinkyu@skku.edu) TA -- Minwoo Ahn (minwoo.ahn@csl.skku.edu) TA -- Donghyun Kim (donghyun.kim@csl.skku.edu) Computer Systems Laboratory Sungkyunkwan University http://csl.skku.edu

More information

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

Introduction to Unix The Windows User perspective. Wes Frisby Kyle Horne Todd Johansen Introduction to Unix The Windows User perspective Wes Frisby Kyle Horne Todd Johansen What is Unix? Portable, multi-tasking, and multi-user operating system Software development environment Hardware independent

More information

Week Overview. Simple filter commands: head, tail, cut, sort, tr, wc grep utility stdin, stdout, stderr Redirection and piping /dev/null file

Week Overview. Simple filter commands: head, tail, cut, sort, tr, wc grep utility stdin, stdout, stderr Redirection and piping /dev/null file ULI101 Week 05 Week Overview Simple filter commands: head, tail, cut, sort, tr, wc grep utility stdin, stdout, stderr Redirection and piping /dev/null file head and tail commands These commands display

More information

I/O and Shell Scripting

I/O and Shell Scripting I/O and Shell Scripting File Descriptors Redirecting Standard Error Shell Scripts Making a Shell Script Executable Specifying Which Shell Will Run a Script Comments in Shell Scripts File Descriptors Resources

More information

Advanced Unix Concepts. Satyajit Rai

Advanced Unix Concepts. Satyajit Rai Advanced Unix Concepts Advanced Unix Concepts Satyajit Rai March 17, 2003 March 22, 2003 KReSIT, IIT Bombay 1 Contents Contents Advanced Unix Concepts.......... 1 Contents.................. 2 Process Creation..............

More information

UNIX Essentials Featuring Solaris 10 Op System

UNIX Essentials Featuring Solaris 10 Op System A Active Window... 7:11 Application Development Tools... 7:7 Application Manager... 7:4 Architectures - Supported - UNIX... 1:13 Arithmetic Expansion... 9:10 B Background Processing... 3:14 Background

More information

Lab 2: Linux/Unix shell

Lab 2: Linux/Unix shell Lab 2: Linux/Unix shell Comp Sci 1585 Data Structures Lab: Tools for Computer Scientists Outline 1 2 3 4 5 6 7 What is a shell? What is a shell? login is a program that logs users in to a computer. When

More information

High Performance Computing Lecture 11. Matthew Jacob Indian Institute of Science

High Performance Computing Lecture 11. Matthew Jacob Indian Institute of Science High Performance Computing Lecture 11 Matthew Jacob Indian Institute of Science Agenda 1. Program execution: Compilation, Object files, Function call and return, Address space, Data & its representation

More information

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

CSE 390a Lecture 2. Exploring Shell Commands, Streams, Redirection, and Processes CSE 390a Lecture 2 Exploring Shell Commands, Streams, Redirection, and Processes slides created by Marty Stepp, modified by Jessica Miller & Ruth Anderson http://www.cs.washington.edu/390a/ 1 2 Lecture

More information

Linux Command Line Interface. December 27, 2017

Linux Command Line Interface. December 27, 2017 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

More information

Chapter 9: Process management. Chapter 9 Process management

Chapter 9: Process management. Chapter 9 Process management Chapter 9: Process management Chapter 9 Process management Last revised: 19/7/2004 Chapter 9 Outline In this chapter we will learn about: Processes and process concepts Examining processes Adjusting process

More information

Chap2: Operating-System Structures

Chap2: Operating-System Structures Chap2: Operating-System Structures Objectives: services OS provides to users, processes, and other systems structuring an operating system how operating systems are designed and customized and how they

More information

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.

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. 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. The shell is your interface to the operating system. It acts

More information

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

Processes. System tasks Campus-Booster ID : **XXXXX.  Copyright SUPINFO. All rights reserved Processes System tasks Campus-Booster ID : **XXXXX www.supinfo.com Copyright SUPINFO. All rights reserved Processes Your trainer Presenter s Name Title: **Enter title or job role. Accomplishments: **What

More information

Redirection and Pipes

Redirection and Pipes Redirection and Pipes Boris Veytsman July 26, 2001 This document contains lecture notes for informal Unix seminar for ITT AES employees (Reston, VA). No information in this document is either endorsed

More information

The Unix Shell. Job Control

The Unix Shell. Job Control The Unix Shell Copyright Software Carpentry 2010 This work is licensed under the Creative Commons Attribution License See http://software-carpentry.org/license.html for more information. shell shell $

More information

Lab 2: Implementing a Shell COMPSCI 310: Introduction to Operating Systems

Lab 2: Implementing a Shell COMPSCI 310: Introduction to Operating Systems Lab 2: Implementing a Shell COMPSCI 310: Introduction to Operating Systems 1 Shells are cool Unix [3] embraces the philosophy: Write programs that do one thing and do it well. Write programs to work together.

More information

Useful Unix Commands Cheat Sheet

Useful Unix Commands Cheat Sheet Useful Unix Commands Cheat Sheet The Chinese University of Hong Kong SIGSC Training (Fall 2016) FILE AND DIRECTORY pwd Return path to current directory. ls List directories and files here. ls dir List

More information

The Unix Shell. Job Control

The Unix Shell. Job Control The Unix Shell Copyright Software Carpentry 2010 This work is licensed under the Creative Commons Attribution License See http://software-carpentry.org/license.html for more information. shell shell $

More information

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

Shells. A shell is a command line interpreter that is the interface between the user and the OS. The shell: Shells A shell is a command line interpreter that is the interface between the user and the OS. The shell: analyzes each command determines what actions are to be performed performs the actions Example:

More information

Introduction to UNIX. Introduction EECS l UNIX is an operating system (OS). l Our goals:

Introduction to UNIX. Introduction EECS l UNIX is an operating system (OS). l Our goals: Introduction to UNIX EECS 2031 13 November 2017 Introduction l UNIX is an operating system (OS). l Our goals: Learn how to use UNIX OS. Use UNIX tools for developing programs/ software, specifically shell

More information

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

The UNIX Shells. Computer Center, CS, NCTU. How shell works. Unix shells. Fetch command Analyze Execute Shells The UNIX Shells How shell works Fetch command Analyze Execute Unix shells Shell Originator System Name Prompt Bourne Shell S. R. Bourne /bin/sh $ Csh Bill Joy /bin/csh % Tcsh Ken Greer /bin/tcsh

More information

Processes and Shells

Processes and Shells Shell ls pico httpd CPU Kernel Disk NIC Processes Processes are tasks run by you or the OS. Processes can be: shells commands programs daemons scripts Shells Processes operate in the context of a shell.

More information

Checking Resource Usage in Fedora (Linux)

Checking Resource Usage in Fedora (Linux) Lab 5C Checking Resource Usage in Fedora (Linux) Objective In this exercise, the student will learn how to check the resources on a Fedora system. This lab covers the following commands: df du top Equipment

More information

Assignment 1. Teaching Assistant: Michalis Pachilakis (

Assignment 1. Teaching Assistant: Michalis Pachilakis ( Assignment 1 Teaching Assistant: Michalis Pachilakis ( mipach@csd.uoc.gr) System Calls If a process is running a user program in user mode and needs a system service, such as reading data from a file,

More information

Shells and Processes. Bryce Boe 2012/08/08 CS32, Summer 2012 B

Shells and Processes. Bryce Boe 2012/08/08 CS32, Summer 2012 B Shells and Processes Bryce Boe 2012/08/08 CS32, Summer 2012 B Outline Opera>ng Systems and Linux Review Shells Project 1 Part 1 Overview Processes Overview for Monday (Sor>ng Presenta>ons) OS Review Opera>ng

More information

How to Implement a Web-based Terminal with Docker

How to Implement a Web-based Terminal with Docker How to Implement a Web-based Terminal with Docker 2015-03-14 Who am I 杜万 (Vangie Du) Full-Stack Web Developer Linux fans Working on Coding@Shanghai About Coding Project Management Source Code Management

More information

Module 8 Pipes, Redirection and REGEX

Module 8 Pipes, Redirection and REGEX Module 8 Pipes, Redirection and REGEX Exam Objective 3.2 Searching and Extracting Data from Files Objective Summary Piping and redirection Partial POSIX Command Line and Redirection Command Line Pipes

More information

Perl and R Scripting for Biologists

Perl and R Scripting for Biologists Perl and R Scripting for Biologists Lukas Mueller PLBR 4092 Course overview Linux basics (today) Linux advanced (Aure, next week) Why Linux? Free open source operating system based on UNIX specifications

More information

The input can also be taken from a file and similarly the output can be redirected to another file.

The input can also be taken from a file and similarly the output can be redirected to another file. Filter A filter is defined as a special program, which takes input from standard input device and sends output to standard output device. The input can also be taken from a file and similarly the output

More information

CS246 Spring14 Programming Paradigm Files, Pipes and Redirection

CS246 Spring14 Programming Paradigm Files, Pipes and Redirection 1 Files 1.1 File functions Opening Files : The function fopen opens a file and returns a FILE pointer. FILE *fopen( const char * filename, const char * mode ); The allowed modes for fopen are as follows

More information

Review of Fundamentals

Review of Fundamentals Review of Fundamentals 1 The shell vi General shell review 2 http://teaching.idallen.com/cst8207/14f/notes/120_shell_basics.html The shell is a program that is executed for us automatically when we log

More information

bash Args, Signals, Functions Administrative Shell Scripting COMP2101 Fall 2017

bash Args, Signals, Functions Administrative Shell Scripting COMP2101 Fall 2017 bash Args, Signals, Functions Administrative Shell Scripting COMP2101 Fall 2017 Positional Arguments It is quite common to allow the user of a script to specify what the script is to operate on (e.g. a

More information

Introduction to the Linux Command Line January Presentation Topics

Introduction to the Linux Command Line January Presentation Topics 1/22/13 Introduction to the Linux Command Line January 2013 Presented by Oralee Nudson ARSC User Consultant & Student Supervisor onudson@alaska.edu Presentation Topics Information Assurance and Security

More information

Utilities. September 8, 2015

Utilities. September 8, 2015 Utilities September 8, 2015 Useful ideas Listing files and display text and binary files Copy, move, and remove files Search, sort, print, compare files Using pipes Compression and archiving Your fellow

More information

Operating Systems. Lecture 07. System Calls, Input/Output and Error Redirection, Inter-process Communication in Unix/Linux

Operating Systems. Lecture 07. System Calls, Input/Output and Error Redirection, Inter-process Communication in Unix/Linux Operating Systems Lecture 07 System Calls, Input/Output and Error Redirection, Inter-process Communication in Unix/Linux March 11, 2013 Goals for Today Interprocess communication (IPC) Use of pipe in a

More information

File system Security (Access Rights)

File system Security (Access Rights) File system Security (Access Rights) In your home directory, type % ls -l (l for long listing!) You will see that you now get lots of details about the contents of your directory, similar to the example

More information

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

Processes. Shell Commands. a Command Line Interface accepts typed (textual) inputs and provides textual outputs. Synonyms: Processes The Operating System, Shells, and Python Shell Commands a Command Line Interface accepts typed (textual) inputs and provides textual outputs. Synonyms: - Command prompt - Shell - CLI Shell commands

More information

CST Algonquin College 2

CST Algonquin College 2 The Shell Kernel (briefly) Shell What happens when you hit [ENTER]? Output redirection and pipes Noclobber (not a typo) Shell prompts Aliases Filespecs History Displaying file contents CST8207 - Algonquin

More information

Operating Systems Lab 1 (Users, Groups, and Security)

Operating Systems Lab 1 (Users, Groups, and Security) Operating Systems Lab 1 (Users, Groups, and Security) Overview This chapter covers the most common commands related to users, groups, and security. It will also discuss topics like account creation/deletion,

More information

Introduction to Linux Organizing Files

Introduction to Linux Organizing Files Introduction to Linux Organizing Files Computational Science and Engineering North Carolina A&T State University Instructor: Dr. K. M. Flurchick Email: kmflurch@ncat.edu Arranging, Organizing, Packing

More information

UNIX Tutorial Five

UNIX Tutorial Five UNIX Tutorial Five 5.1 File system security (access rights) In your unixstuff directory, type % ls -l (l for long listing!) You will see that you now get lots of details about the contents of your directory,

More information

Introduction to Linux

Introduction to Linux Introduction to Linux Mukesh Pund Principal Scientist, NISCAIR, New Delhi, India History In 1969, a team of developers developed a new operating system called Unix which was written using C Linus Torvalds,

More information

6 Redirection. Standard Input, Output, And Error. 6 Redirection

6 Redirection. Standard Input, Output, And Error. 6 Redirection 6 Redirection In this lesson we are going to unleash what may be the coolest feature of the command line. It's called I/O redirection. The I/O stands for input/output and with this facility you can redirect

More information

Chapter 4 Controlling Processes

Chapter 4 Controlling Processes Chapter 4 Controlling Processes Program to Process Program is dead Just lie on disk grep is a program /usr/bin/grep % file /usr/bin/grep ELF 32-bit LSB executable When you execute it It becomes a process

More information

Common File System Commands

Common File System Commands Common File System Commands ls! List names of all files in current directory ls filenames! List only the named files ls -t! List in time order, most recent first ls -l! Long listing, more information.

More information

Review of Fundamentals. Todd Kelley CST8207 Todd Kelley 1

Review of Fundamentals. Todd Kelley CST8207 Todd Kelley 1 Review of Fundamentals Todd Kelley kelleyt@algonquincollege.com CST8207 Todd Kelley 1 GPL the shell SSH (secure shell) the Course Linux Server RTFM vi general shell review 2 These notes are available on

More information

Introduction: What is Unix?

Introduction: What is Unix? Introduction Introduction: What is Unix? An operating system Developed at AT&T Bell Labs in the 1960 s Command Line Interpreter GUIs (Window systems) are now available Introduction: Unix vs. Linux Unix

More information

Introduction to UNIX Part II

Introduction to UNIX Part II T H E U N I V E R S I T Y of T E X A S H E A L T H S C I E N C E C E N T E R A T H O U S T O N S C H O O L of H E A L T H I N F O R M A T I O N S C I E N C E S Introduction to UNIX Part II For students

More information

Introduction to Linux

Introduction to Linux Introduction to Linux January 2011 Don Bahls User Consultant (Group Leader) bahls@arsc.edu (907) 450-8674 Overview The shell Common Commands File System Organization Permissions Environment Variables I/O

More information

ACS Unix (Winter Term, ) Page 92

ACS Unix (Winter Term, ) Page 92 ACS-294-001 Unix (Winter Term, 2016-2017) Page 92 The Idea of a Link When Unix creates a file, it does two things: 1. Set space on a disk to store data in the file. 2. Create a structure called an inode

More information

CS 213, Fall 2001 Lab Assignment L5: Writing Your Own Unix Shell Assigned: Oct. 25, Due: Fri., Nov. 2, 11:59PM

CS 213, Fall 2001 Lab Assignment L5: Writing Your Own Unix Shell Assigned: Oct. 25, Due: Fri., Nov. 2, 11:59PM CS 213, Fall 2001 Lab Assignment L5: Writing Your Own Unix Shell Assigned: Oct. 25, Due: Fri., Nov. 2, 11:59PM Dave O Hallaron (droh@cs.cmu.edu) is the lead person for this assignment. Introduction The

More information

Removing files and directories, finding files and directories, controlling programs

Removing files and directories, finding files and directories, controlling programs Removing files and directories, finding files and directories, controlling programs Laboratory of Genomics & Bioinformatics in Parasitology Department of Parasitology, ICB, USP Removing files Files can

More information

sottotitolo A.A. 2016/17 Federico Reghenzani, Alessandro Barenghi

sottotitolo A.A. 2016/17 Federico Reghenzani, Alessandro Barenghi Titolo presentazione Piattaforme Software per la Rete sottotitolo BASH Scripting Milano, XX mese 20XX A.A. 2016/17, Alessandro Barenghi Outline 1) Introduction to BASH 2) Helper commands 3) Control Flow

More information

CS 4410, Fall 2017 Project 1: My First Shell Assigned: August 27, 2017 Due: Monday, September 11:59PM

CS 4410, Fall 2017 Project 1: My First Shell Assigned: August 27, 2017 Due: Monday, September 11:59PM CS 4410, Fall 2017 Project 1: My First Shell Assigned: August 27, 2017 Due: Monday, September 11th @ 11:59PM Introduction The purpose of this assignment is to become more familiar with the concepts of

More information

Part I. UNIX Workshop Series: Quick-Start

Part I. UNIX Workshop Series: Quick-Start Part I UNIX Workshop Series: Quick-Start Objectives Overview Connecting with ssh Command Window Anatomy Command Structure Command Examples Getting Help Files and Directories Wildcards, Redirection and

More information

Operating Systems. Copyleft 2005, Binnur Kurt

Operating Systems. Copyleft 2005, Binnur Kurt 3 Operating Systems Copyleft 2005, Binnur Kurt Content The concept of an operating system. The internal architecture of an operating system. The architecture of the Linux operating system in more detail.

More information

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

Operating Systems 3. Operating Systems. Content. What is an Operating System? What is an Operating System? Resource Abstraction and Sharing Content 3 Operating Systems The concept of an operating system. The internal architecture of an operating system. The architecture of the Linux operating system in more detail. How to log into (and out

More information

Mills HPC Tutorial Series. Linux Basics II

Mills HPC Tutorial Series. Linux Basics II Mills HPC Tutorial Series Linux Basics II Objectives Bash Shell Script Basics Script Project This project is based on using the Gnuplot program which reads a command file, a data file and writes an image

More information

Introduction to the Shell

Introduction to the Shell [Software Development] Introduction to the Shell Davide Balzarotti Eurecom Sophia Antipolis, France What a Linux Desktop Installation looks like What you need Few Words about the Graphic Interface Unlike

More information

Design Overview of the FreeBSD Kernel CIS 657

Design Overview of the FreeBSD Kernel CIS 657 Design Overview of the FreeBSD Kernel CIS 657 Organization of the Kernel Machine-independent 86% of the kernel (80% in 4.4BSD) C code Machine-dependent 14% of kernel Only 0.6% of kernel in assembler (2%

More information

Mid Term from Feb-2005 to Nov 2012 CS604- Operating System

Mid Term from Feb-2005 to Nov 2012 CS604- Operating System Mid Term from Feb-2005 to Nov 2012 CS604- Operating System Latest Solved from Mid term Papers Resource Person Hina 1-The problem with priority scheduling algorithm is. Deadlock Starvation (Page# 84) Aging

More information

UNIX Quick Reference

UNIX Quick Reference UNIX Quick Reference This card represents a brief summary of some of the more frequently used UNIX commands that all users should be at least somewhat familiar with. Some commands listed have much more

More information

Read the relevant material in Sobell! If you want to follow along with the examples that follow, and you do, open a Linux terminal.

Read the relevant material in Sobell! If you want to follow along with the examples that follow, and you do, open a Linux terminal. Warnings 1 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. Read the relevant material in Sobell! If

More information

Design Overview of the FreeBSD Kernel. Organization of the Kernel. What Code is Machine Independent?

Design Overview of the FreeBSD Kernel. Organization of the Kernel. What Code is Machine Independent? Design Overview of the FreeBSD Kernel CIS 657 Organization of the Kernel Machine-independent 86% of the kernel (80% in 4.4BSD) C C code Machine-dependent 14% of kernel Only 0.6% of kernel in assembler

More information

UNIX Kernel. UNIX History

UNIX Kernel. UNIX History UNIX History UNIX Kernel 1965-1969 Bell Labs participates in the Multics project. 1969 Ken Thomson develops the first UNIX version in assembly for an DEC PDP-7 1973 Dennis Ritchie helps to rewrite UNIX

More information

find starting-directory -name filename -user username

find starting-directory -name filename -user username Lab 7: Input and Output The goal of this lab is to gain proficiency in using I/O redirection to perform tasks on the system. You will combine commands you have learned in this course using shell redirection,

More information

Processes in linux. What s s a process? process? A dynamically executing instance of a program. David Morgan. David Morgan

Processes in linux. What s s a process? process? A dynamically executing instance of a program. David Morgan. David Morgan Processes in linux David Morgan What s s a process? process? A dynamically executing instance of a program 1 Constituents of a process its code data various attributes OS needs to manage it OS keeps track

More information

Introduction To. Barry Grant

Introduction To. Barry Grant Introduction To Barry Grant bjgrant@umich.edu http://thegrantlab.org Working with Unix How do we actually use Unix? Inspecting text files less - visualize a text file: use arrow keys page down/page up

More information

Software I: Utilities and Internals. What is UNIX?

Software I: Utilities and Internals. What is UNIX? Software I: Utilities and Internals Lecture 1 UNIX for Beginners What is UNIX? UNIX is a time-sharing operating system with userchosen shells (user interfaces) and one kernel (operating system core, which

More information

Processes. What s s a process? process? A dynamically executing instance of a program. David Morgan

Processes. What s s a process? process? A dynamically executing instance of a program. David Morgan Processes David Morgan What s s a process? process? A dynamically executing instance of a program 1 Constituents of a process its code data various attributes OS needs to manage it OS keeps track of all

More information

Computer Science 330 Operating Systems Siena College Spring Lab 5: Unix Systems Programming Due: 4:00 PM, Wednesday, February 29, 2012

Computer Science 330 Operating Systems Siena College Spring Lab 5: Unix Systems Programming Due: 4:00 PM, Wednesday, February 29, 2012 Computer Science 330 Operating Systems Siena College Spring 2012 Lab 5: Unix Systems Programming Due: 4:00 PM, Wednesday, February 29, 2012 Quote: UNIX system calls, reading about those can be about as

More information

QUESTION BANK ON UNIX & SHELL PROGRAMMING-502 (CORE PAPER-2)

QUESTION BANK ON UNIX & SHELL PROGRAMMING-502 (CORE PAPER-2) BANK ON & SHELL PROGRAMMING-502 (CORE PAPER-2) TOPIC 1: VI-EDITOR MARKS YEAR 1. Explain set command of vi editor 2 2011oct 2. Explain the modes of vi editor. 7 2013mar/ 2013 oct 3. Explain vi editor 5

More information

CSC209H Lecture 1. Dan Zingaro. January 7, 2015

CSC209H Lecture 1. Dan Zingaro. January 7, 2015 CSC209H Lecture 1 Dan Zingaro January 7, 2015 Welcome! Welcome to CSC209 Comments or questions during class? Let me know! Topics: shell and Unix, pipes and filters, C programming, processes, system calls,

More information

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

Lecture 3. Unix. Question? b. The world s best restaurant. c. Being in the top three happiest countries in the world. Lecture 3 Unix Question? Denmark is famous for? a. LEGO. b. The world s best restaurant. c. Being in the top three happiest countries in the world. d. Having the highest taxes in Europe (57%). e. All of

More information

CSC374, Spring 2010 Lab Assignment 1: Writing Your Own Unix Shell

CSC374, Spring 2010 Lab Assignment 1: Writing Your Own Unix Shell CSC374, Spring 2010 Lab Assignment 1: Writing Your Own Unix Shell Contact me (glancast@cs.depaul.edu) for questions, clarification, hints, etc. regarding this assignment. Introduction The purpose of this

More information