APPLIED INFORMATICS Processes. Bash characteristics. Command type. Aliases.

Similar documents
System Calls and Signals: Communication with the OS. System Call. strace./hello. Kernel. Context Switch

Signals. Joseph Cordina

Fortran Signal Handling

System Calls & Signals. CS449 Spring 2016

Operating Systems. Threads and Signals. Amir Ghavam Winter Winter Amir Ghavam

Princeton University. Computer Science 217: Introduction to Programming Systems. Signals

Signals. Goals of this Lecture. Help you learn about: Sending signals Handling signals

System Programming. Signals I

COSC243 Part 2: Operating Systems

Chapter 4 Multithreaded Programming

Technical Document Series. POSIX Signal Handling in Java

So far, we know how to create processes. How do we communicate with them? Primary mechanism: signals

Chapter 1 Introduction

Process Management forks, bombs, zombies, and daemons! Lecture 5, Hands-On Unix System Administration DeCal

Operating Systems Grado en Informática. Course

Signals! Goals of this Lecture! Help you learn about:" Sending signals" Handling signals"

Goals of this Lecture

Signals! Goals of this Lecture! Help you learn about:" Sending signals" Handling signals"

Preview. Process Termination. wait and waitpid() System Call. wait and waitpid() System Call. waitpid() System Call 10/23/2018

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

Table of Contents. Unix Systems: Some more useful commands

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

ECE 650 Systems Programming & Engineering. Spring 2018

Process management. What s in a process? What is a process? The OS s process namespace. A process s address space (idealized)

CSE 451: Operating Systems Winter Module 4 Processes. Mark Zbikowski Allen Center 476

signals Communicating with the OS System call (last lecture) Signal (this lecture) User Process Operating System

CSE 410: Computer Systems Spring Processes. John Zahorjan Allen Center 534

PVPSIDDHARTHA INSTITUTE OF TECHNOLOGY

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

COMP 2400 UNIX Tools

Review of Fundamentals

Process Control. Philipp Koehn. 23 April 2018

Advanced Unix Concepts. Satyajit Rai

Acontecimentos assíncronos (POSIX signals) Sincronização com múltiplos acontecimentos

Linux System Administration

Chapter 4: Threads. Operating System Concepts 9 th Edition

Introduction to Operating Systems Prof. Chester Rebeiro Department of Computer Science and Engineering Indian Institute of Technology, Madras

Lesson 3. The func procedure allows a user to choose the action upon receipt of a signal.

CSE 421: Introduction to Operating Systems

KING FAHD UNIVERSITY OF PETROLEUM AND MINERALS Information and Computer Science Department ICS 431 Operating Systems Lab # 6

CST Algonquin College 2

Processes. CS439: Principles of Computer Systems January 24, 2018

Processes. CS439: Principles of Computer Systems January 30, 2019

bash, part 3 Chris GauthierDickey

系統程式 郭大維教授 / 施吉昇教授臺灣大學資訊工程系

Linux 系统介绍 (III) 袁华

Introduction to Linux

void (*)(int) NAME signal: signal.h - description of signals SYNOPSIS #include <signal.h>

Command-line interpreters

gaffer Documentation Release Author

Linux System Administration. Paul Cobbaut

Embedded Systems Programming

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

NETWORK PROGRAMMING TOTAL = 45

Chapter 4 Controlling Processes

EECS Software Tools. Lab 2 Tutorial: Introduction to UNIX/Linux. Tilemachos Pechlivanoglou

Introduction to Linux

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

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

Computer Science & Engineering Department I. I. T. Kharagpur. Operating System: CS rd Year CSE: 5th Semester (Autumn ) Lecture VII

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

Introduction to Linux

System Administration

The GNU PIES Manual. version 1.3, 16 July Sergey Poznyakoff.

St. MARTIN S ENGINEERING COLLEGE Dhulapally,Secunderabad DEPARTMENT OF INFORMATION TECHNOLOGY Academic year

Concurrency Problems Signals & Synchronization Semaphore Mutual Exclusion Critical Section Monitors

More Scripting Todd Kelley CST8207 Todd Kelley 1

Managing Processes Process: A running program

Lab 2: Linux/Unix shell

Review of Fundamentals. Todd Kelley CST8207 Todd Kelley 1

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

Introduction to Linux. Woo-Yeong Jeong Computer Systems Laboratory Sungkyunkwan University

Computer Systems and Architecture

Advanced Unix/Linux System Program. Instructor: William W.Y. Hsu

The Unix Shell & Shell Scripts

CS 307: UNIX PROGRAMMING ENVIRONMENT REVIEW FOR EXAM 2

THE HONG KONG POLYTECHNIC UNIVERSITY Department of Electronic and Information Engineering

Review of Fundamentals. Todd Kelley CST8207 Todd Kelley 1

Linux Kung Fu. Ross Ventresca UBNetDef, Fall 2017

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

Process. Signal #8. Signals are software interrupts from unexpected events. a power failure. an alarm clock. the death of a child process

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

Linux System Administration. Paul Cobbaut

CS 31: Intro to Systems Processes. Kevin Webb Swarthmore College March 31, 2016

Unix Introduction to UNIX

Working with Basic Linux. Daniel Balagué

Perl and R Scripting for Biologists

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

Operating Systems. Copyleft 2005, Binnur Kurt

Unix System Architecture, File System, and Shell Commands

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

Section 1: Tools. Contents CS162. January 19, Make More details about Make Git Commands to know... 3

Multitasking. Programmer s model of multitasking. fork() spawns new process. exit() terminates own process

Processes & Signals. System Runs Many Processes Concurrently. State consists of memory image + register values + program counter

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 COMMANDS AND SHELLS. UNIX Programming 2015 Fall by Euiseong Seo

Course 144 Supplementary Materials. UNIX Fundamentals

Chap2: Operating-System Structures

Outline. Cgroup hierarchies

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

Transcription:

Lab 3 APPLIED INFORMATICS Processes. Bash characteristics. Command type. Aliases.

Today... /proc /run 1. PROCESSES 2. BASH CHARACTERISTICS 3. COMMAND TYPES 4. ALIASES $$ $PPID pidof ps pgrep kill killall pkill ps -C ps ax /proc/cpuinfo sleep top /run 2

FILE SYSTEM HIERARCHY 3

FILE SYSTEM HIERARCHY 4

/proc a means of interaction with the kernel cata@debian:~$ ls /proc 5

/proc files in /proc are continuously updated cata@debian:~$ date cata@debian:~$ ls al /proc after a while: cata@debian:~$ ls al /proc 6

/proc size 0 is displayed for lots of non-empty files in /proc cata@debian:~$ ls al /proc/cpuinfo cata@debian:~$ file /proc/cpuinfo cata@debian:~$ cat /proc/cpuinfo 7

/proc most files in /proc are read-only some ask for root permission some can be overwritten lots of files in /proc/sys can be overwritten 8

PROCESSES 9

Terms process: compiled source code running in the system PID: process ID (identifier) Each process has an ID. PPID: parent process ID Each process has a parent process. 10

init PID = 1 does not have a parent is started by the kernel is adoptive parent for all orphan processes 11

kill when the execution of a process is ended, it dies a process can be killed with the command kill 12

daemon processes being launched at start up run in background daemons never die 13

zombie when a process is killed and still appears as running in the system, then that process becomes a zombie. a zombie cannot be killed because it is already dead. 14

COMMANDS FOR PROCESSES 15

$$ & $PPID echo $$ returns the ID of the process associated to the bash cata@debian:~$ echo $$ echo $PPID returns the ID of the parent process of the process associated to the bash cata@debian:~$ echo $PPID cata@debian:~$ echo $$ $PPID 16

pidof pidof process_name returns the ID of the process specified by its name cata@debian:~$ pidof iceweasel cata@debian:~$ pidof init 17

The relationship parent/child cata@debian:~$ echo $$ $PPID cata@debian:~$ bash cata@debian:~$ echo $$ $PPID cata@debian:~$ bash cata@debian:~$ echo $$ $PPID cata@debian:~$ ps cata@debian:~$ exit cata@debian:~$ ps cata@debian:~$ exit 18

ps cata@debian:~$ ps displays the processes associated to the bash cata@debian:~$ ps ax displays all the processes in the system cata@debian:~$ ps C process_name displays details of a specified process 19

pstree displays the processes in the system under the form of a tree cata@debian:~$ pstree 20

pgrep pgrep process_name returns the process ID for all the processes containing the specified name cata@debian:~$ pgrep gnome 21

grep cata@debian:~$ ps ax grep gnome returns all the processes in the system containing gnome in their name 22

top returns all the processes in the system under the form of a list cata@debian:~$ top Press h (help) for help. You can sort the list according to various criteriae. 23

Starting a process processes can be started from the terminal: cata@debian:~$ iceweasel Troubles? cata@debian:~$ iceweasel & starts the process in the background (so the bash becomes active) 24

Starting a process cata@debian:~$ sleep 10s cata@debian:~$ sleep 10s & cata@debian:~$ ps ax cata@debian:~$ ps -C sleep cata@debian:~$ sleep 1000 &... 25

kill kill process_id comand used for stopping a process cata@debian:~$ kill 3380 26

Signals for kill kill l (the letter l, not the digit 1!) cata@debian:~$ kill -l 1) SIGHUP 2) SIGINT 3) SIGQUIT 4) SIGILL 5) SIGTRAP 6) SIGABRT 7) SIGBUS 8) SIGFPE 9) SIGKILL 10) SIGUSR1 11) SIGSEGV 12) SIGUSR2 13) SIGPIPE 14) SIGALRM 15) SIGTERM 17) SIGCHLD 18) SIGCONT 19) SIGSTOP 20) SIGTSTP 21) SIGTTIN 22) SIGTTOU 23) SIGURG 24) SIGXCPU 25) SIGXFSZ 26) SIGVTALRM 27) SIGPROF 28) SIGWINCH 29) SIGIO 30) SIGPWR 31) SIGSYS 34) SIGRTMIN 35) SIGRTMIN+1 36) SIGRTMIN+2 37) SIGRTMIN+3 38) SIGRTMIN+4 39) SIGRTMIN+5 40) SIGRTMIN+6 41) SIGRTMIN+7 42) SIGRTMIN+8 43) SIGRTMIN+9 44) SIGRTMIN+10 45) SIGRTMIN+11 46) SIGRTMIN+12 47) SIGRTMIN+13 48) SIGRTMIN+14 49) SIGRTMIN+15 50) SIGRTMAX-14 51) SIGRTMAX-13 52) SIGRTMAX-12 53) SIGRTMAX-11 54) SIGRTMAX-10 55) SIGRTMAX-9 56) SIGRTMAX-8 57) SIGRTMAX-7 58) SIGRTMAX-6 59) SIGRTMAX-5 60) SIGRTMAX-4 61) SIGRTMAX-3 62) SIGRTMAX-2 63) SIGRTMAX-1 64) SIGRTMAX 27

kill -1 (SIGHUP) kill -1 process_id signal used to force a process to re-read its configuration file 1) SIGHUP cata@debian:~$ kill -1 1 Similarly: kill -HUP process_name 28

kill -15 (SIGTERM) kill -15 process_id command used to stop a process 15) SIGTERM cata@debian:~$ kill -15 3880 cata@debian:~$ kill 3880 29

kill -19 (SIGSTOP) kill -19 process_id suspends a process 19) SIGSTOP cata@debian:~$ kill -19 3880 30

kill -18 (SIGCONT) kill -18 process_id resumes a suspended process 18) SIGCONT cata@debian:~$ kill -18 3880 31

pkill/killall pkill process_name kills a process by its name (not process_id) cata@debian:~$ pkill iceweasel cata@debian:~$ kill 2242 cata@debian:~$ killall iceweasel 32

top You can also kill processes from the top list. cata@debian:~$ top Press k key to kill a process. Type in the process ID. Confirm the deletion. 33

BASH CHARACTERISTICS 34

Remember... echo displays the input received from the keyboard basic command in this lab: important command! Try: cata@debian:~$echo It is snowing outside! 35

Remember... Bash: Bourne Again Shell cata@debian:~$ command interface used in the most Linux systems command interpreter in this lab: bash characteristics 36

Bash characteristics a command we type in the terminal is processed (and modified) by the bash, then executed first step: the bash scans the command then: divides the commands in arguments to be modified 37

Arguments each piece of text separated by one or several spaces or by tab, is considered an argument the command is an argument too Argument 3 Argument 5 cata@debian:~$echo It is Argument 1 Argument 2 Argument 4 (the command) Separator 2 Separator 1 (1 tab) (1 space) snowing outside! Separator 3 (2x space) 38

Arguments echo returns the arguments separated by a single space, no matter what the separator is Try: cata@debian:~$echo It is snowing outside! cata@debian:~$echo It is snowing outside! cata@debian:~$echo It is snowing outside! cata@debian:~$ echo It is snowing outside! 39

echo & by using you can avoid deletion of extra spaces and tabs Try: cata@debian:~$echo It is(tab)snowing outside! cata@debian:~$echo (2xspace)It is snowing outside! 40

echo & by using you can avoid deletion of extra spaces and tabs Try: cata@debian:~$echo It is(tab)snowing outside! cata@debian:~$echo (2xspace)It is snowing outside! 41

echo e & / with e option, or, /n and /t you can insert new lines or tabs in the text you want to display Try: cata@debian:~$echo -e A line with \na newline cata@debian:~$echo -e A line with \na newline cata@debian:~$echo -e A line with \ta tab cata@debian:~$echo -e A line with \ta tab 42

COMMAND TYPE 43

Command type 1) External commands having their own binary file saved locally on the computer (most can be found in bin and in sbin) 2) Internal (builtin) commands are integrated in the shell 44

type returns the command type Try: cata@debian:~$type cd cata@debian:~$type cat 45

type some commands are both internal and external internal type has priority in order to execute an external command the path to the binary file must be specified cata@debian:~$type a echo cata@debian:~$/bin/echo 46

which displays the path to the binary folder corresponding to an external command cata@debian:~$which cp ls cd mkdir pwd 47

ALIASES 48

alias the shell enables the creation of aliases for commands aliases are created with the purpose of replacing a difficult to recall command name with an easy name Create the file count.txt in which you write: 1, 2, 3 on three different lines. Then, try: cata@debian:~$alias reversed=tac cata@debian:~$reversed count.txt 49

alias aliases can be created in order to substitute complex commands cata@debian:~$alias md= mkdir p ~/D1/D2/ D3/D4 50

alias in order to list all the existing aliases in the computer : cata@debian:~$alias Try: cata@debian:~$alias invers md cata@debian:~$which md 51

unalias in order to deallocate an alias: cata@debian:~$unalias reversed 52

That s all for today www.ace.catalinamancas.ro catalina.mancas@dcti.ucv.ro