Getting Started UNIX InKwan Yu Topics Unix Commands Unix System calls C function calls.

Slides:



Advertisements
Similar presentations
CMPT 471 Networking II Linux Primer 1© Janice Regan, 2013.
Advertisements

Learning Unix/Linux Bioinformatics Orientation 2008 Eric Bishop.
Second edition Your UNIX: The Ultimate Guide Das © 2006 The McGraw-Hill Companies, Inc. All rights reserved. UNIX – The Process The Process A process is.
Introduction to UNIX CSE 2031 Fall May 2015.
Lesson 10-Controlling User Processes. Overview Managing and processing processes. Managing jobs. Exiting/quitting when jobs have been stopped.
1 Introduction to UNIX Ke Liu
©Colin Jamison 2004 Introduction to Linux Colin Jamison.
1 Introduction to UNIX 2 Ke Liu
CS 497C – Introduction to UNIX Lecture 26: - The Process Chin-Chih Chang
THE UNIX SYSTEM Ashish Gupta TA, Intro to Networking Jan Recital 2 Introduction to Networking, Instructor: Prof. Yan Chen.
More Shell Basics CS465 - Unix. Unix shells User’s default shell - specified in /etc/passwd file To show which shell you are currently using: $ echo $SHELL.
1 Basics of Linux On linux machine: Login at your home directory Open a “shell” or “terminal” or “xterm” workspace (4) On windows machine Intall linux.
Unix Basics. Systems Programming: Unix Basics 2 Unix Basics  Unix directories  Important Unix file commands  File and Directory Access Rights through.
UNIX Utilities Learning Objectives: 1. To understand the some basic utilities of UNIX File 2. To compare UNIX shell and popular shell 3. To learn Input/Output.
Introduction to Linux/UNIX. History UNIX beginnings in 1969 (Linus Torvalds is born!) AT & T Bell Laboratories (Ken Thompson & Dennis Richie) Working.
1 SEEM3460 Tutorial Unix Introduction. 2 Introduction What is Unix? An operation system (OS), similar to Windows, MacOS X Why learn Unix? Greatest Software.
Linux Commands LINUX COMMANDS.
CS 141 Labs are mandatory. Attendance will be taken in each lab. Make account on moodle. Projects will be submitted via moodle.
Using Macs and Unix Nancy Griffeth January 6, 2014 Funding for this workshop was provided by the program “Computational Modeling and Analysis of Complex.
Systems Programming Concepts
Introduction to Linux Workshop February Introduction Rob Lane & The HPC Support Team Research Computing Services CUIT.
Learning basic Unix command IT 325 operating system.
Welcome to CSE  Name: Di Cao   Classroom: DL357  Class Time: T 8:30am - 9:18am  Office.
Unix Primer. Unix Shell The shell is a command programming language that provides an interface to the UNIX operating system. The shell is a “regular”
CHAPTER 1 UNIX FOR NONPROGRAMMERS By U ğ ur Halıcı.
Lesson 1. PC vs. Multi-user System  Personal Computer – each user gets his/her own processor (or multicore processor).  Multi-user system – The processor,
An Introduction to UNIX System --- Cosc513 Presentation n Instructor: Morteza Anvari n Author: Yonghong Pan n ID#: n Date: Jan.29, 2001.
Introduction to Computer Organization & Systems Topics: Intro to UNIX COMP John Barr.
File Permissions. What are the three categories of users that apply to file permissions? Owner (or user) Group All others (public, world, others)
Introduction to Unix – CS 21 Lecture 9. Lecture Overview Shell description Shell choices History Aliases Topic review.
Introduction to Linux Azzam Mourad COEN 346.
Chapter 4 UNIX Common Shells Commands By C. Shing ITEC Dept Radford University.
The UNIX development environment CS 400/600 – Data Structures.
Linux overview. Architecture Kernel File system Shell: Korn, Bourne, C, Bash X Windows: Motif, Open Look, X.OrgX.Org Desktop: Gnome, KDE,etc.
CS 6560 Operating System Design Lecture 3:Tour of GNU/Linux.
System Administration Introduction to Unix Session 2 – Fri 02 Nov 2007 Reference:  chapter 1, The Unix Programming Environment, Kernighan & Pike, ISBN.
Session 2 Wharton Summer Tech Camp Basic Unix. Agenda Cover basic UNIX commands and useful functions.
UNIX Commands. Why UNIX Commands Are Noninteractive Command may take input from the output of another command (filters). May be scheduled to run at specific.
1 Week 2 The Crunchy Shell to the Soft and Chewy Kernel… Sarah Diesburg 8/3/2010 COP4610 / CGS5765.
UNIX/LINUX SHELLS.  “A Unix shell is a command-line interpreter or shell that provides a traditional user interface for the Unix operating system and.
Unix/Linux cs3353. The Shell The shell is a program that acts as the interface between the user and the kernel. –The shell is fully programmable and will.
Lesson 2-Touring Essential Programs. Overview Development of UNIX and Linux. Commands to execute utilities. Communicating instructions to the shell. Navigating.
L&T Infotech1 UNIX – Getting Started - Aneesh Ramani.
UNIX Commands COMP 1090 Introduction to Unix Fall
Introduction to Programming Using C An Introduction to Operating Systems.
CSC414 “Introduction to UNIX/ Linux” Lecture 5. Schedule 1. Introduction to Unix/ Linux 2. Kernel Structure and Device Drivers. 3. System and Storage.
Linux Commands C151 Multi-User Operating Systems.
1 CS3695/M6-109 – Network Vulnerability Assessment & Risk Mitigation – Introduction to Unix & Linux.
THE UNIX SYSTEM Jan Recitation 2 Introduction to Networking.
A gentle introduction to LINUX at the command prompt.
Linux A practical introduction. 1)Background and Getting Started Linux is an operating system with multiple providers Red Hat/CentOS (our version) Ubuntu.
1 Introduction to Unix. 2 What is UNIX?  UNIX is an Operating System (OS).  An operating system is a control program that helps the user communicate.
 Last lesson, the Windows Operating System was discussed along with the Windows command shell  Unix is a computer operating system, that similarly manages.
1 CS3695 – Network Vulnerability Assessment & Risk Mitigation – Introduction to Unix & Linux.
Learning Unix/Linux Based on slides from: Eric Bishop.
Learning Linux Shell. Outline Introduction to Linux Learning the Shell Writing Shell Scripts.
INTRODUCTION TO SHELL SCRIPTING By Byamukama Frank
Laboratory 1.2a1 First steps with Unix - Lab Boris Steipe Department of Biochemistry Department.
CS3695/M6-109 – Network Vulnerability Assessment & Risk Mitigation –
Andy Wang Object Oriented Programming in C++ COP 3330
Some Linux Commands.
C151 Multi-User Operating Systems
CS 60 Discussion Review.
Unix : Introduction and Commands
Introduction to Linux/UNIX
CHAPTER 13 Processes.
Andy Wang Object Oriented Programming in C++ COP 3330
Linux Commands LINUX COMMANDS.
Introduction to Linux Commands
Presentation transcript:

Getting Started UNIX InKwan Yu

Topics Unix Commands Unix System calls C function calls

What’s shell? A "shell" is a command interpreter that takes input from a person through the keyboard, issues requests on the user's behalf to the OS, receives the results, and displays them to the user.

How many Shells in Unix? zsh (Z Shell) bash (Bourne Again Shell) tcsh (Enhanced C Shell) used interactively csh (C Shell) the same to csh sh (Bourne Shell) used mostly for script exceution ksh (Korn Shell) the same to sh

How to find which shell you use? echo $SHELL or echo $shell whereis shell which shell

Editors in Unix pico emacs vi ed ……

Basic Emacs Commands KeystrokesDescription C-hEnter the online help system. C-x C-sSave the file. C-x C-c Exit emacs. C-x uUndo last edit (can be repeated). C-gGet out of current command operation. C-pUp/down/forward/back by line or character. C-n C-f C-b C-vForward/backward by one screen. M-v C-sSearch forward/backward for characters. C-r C-dDelete next/previous character. Del

Useful Unix Commands (1) chgrp - change group ownership chmod - change file permission kill process id - terminate a process pwd - display current working directory ls - list files mv - move or rename files rm file - delete files mkdir - create a directory

Useful Unix Commands (2) cd pathname - change working directory man –k man –s section name-in-question ps - check process status cp - copy files cat file - catenate and print

Unix files groups & permissions -rw-r--r-- 1 yuchen phd Oct calendar.xls drwx yuchen phd 4096 Jan 5 10:24 fa04/ -rw-r--r-- 1 yuchen phd Sep 30 13:30 in.htm -rw-r--r-- 1 yuchen phd 924 Jan 5 10:08 index.htm drwx--x--x 2 yuchen phd 4096 Aug 20 16:54 old/ There are three groups in Unix: owner, group & others For each group, it has three permissions: read (r), write (w) & execute (x) rwx (binary 770)

Unix processes rain:14% ps –u`whoami` -f UID PID PPID C STIME TTY TIME CMD yuchen :24:28 pts/44 0:00 tcsh yuchen :55:41 pts/44 0:00 -tcsh yuchen :55:41 ? 0:00 /usr/local/sbin/sshd yuchen :23:38 pts/44 0:00 ksh

Some tips (1) How to find the processes belonging to me? How to find the details for some system/function call? How to deal with some exception such as dead loop in Unix? How to debug my code in Unix?

Some tips (2) ps -ef|grep userid ps -u `whoami` -f ps -u userid -f man cmd man -s section cmd man -k key kill pid kill -9 -1

Some tips (3) ddd (require X window) gdb – with emacs will be useful gdb xxxxx core (“where” to look at the trace stack)

Unix System Calls System calls OS API to provide services to user processes C standard library wraps the system calls Why not normal function calls? User / Kernel mode to protect the critical OS resources. Trap or interrupt calls are necessary to go through the user/kernel barrier

Unix System Calls FD = OPEN(“FILE”, “RW”); FILE CREATION OPERATION TRAP USER MODE KERNEL MODEL Trap Call : User->Kernel Trap Return : Kernel->User

Unix System Calls fork() Create a child process with the same image of parent process Returns 0 for the child Returns child’s process ID for the parent After the call there are two processes in the system with same execution image

Unix System Calls fork() – who’s the parent? main() { int i; i = fork(); printf(“%d\n, i); } main() { int i; i = fork(); printf(“%d\n, i); } main() { int i; i = fork(); printf(“%d\n, i); } After fork()

Unix System Calls execvp() Load a program image (possibly with arguments) Replace the current process image with the newly loaded program Run the new image with the same process ID.

Unix System Calls execvp() Do you read “ok?” main() { execvp(“ls”, 0); printf(“ok?\n”); } execvp() After execvp() New execution image of “ls” starts to run New execution image of “ls” starts to run main() { execvp(“ls”, 0); printf(“ok?\n”); } Replace