File system links. Week Overview. Hard and symbolic links Process management

Similar documents
File system Security (Access Rights)

ACS Unix (Winter Term, ) Page 92

UNIX Tutorial Five

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

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.

CPSC 341 OS & Networks. Processes. Dr. Yingwu Zhu

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

CS 153 Design of Operating Systems

The UNIX File System

The UNIX File System

Computer Systems and Architecture

Unix Internal Assessment-2 solution. Ans:There are two ways of starting a job in the background with the shell s & operator and the nohup command.

Unix Processes. What is a Process?

Getting started with Hugs on Linux

INSE Lab 1 Introduction to UNIX Fall 2017

Introduction to the Linux Command Line January Presentation Topics

File permission u owner of file/directory (user) g group of the file/directory o other a all

System Administration

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

CSC209H Lecture 1. Dan Zingaro. January 7, 2015

PESIT Bangalore South Campus

Lecture 5: Jobs and Processes

Getting started with Hugs on Linux

Working with Basic Linux. Daniel Balagué

Introduction to Linux

Process a program in execution; process execution must progress in sequential fashion. Operating Systems

Computer Systems and Architecture

Part 1: Basic Commands/U3li3es

Introduction to Linux

Welcome to Linux. Lecture 1.1

CST8207: GNU/Linux Operating Systems I Lab Six Linux File System Permissions. Linux File System Permissions (modes) - Part 1

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

Each terminal window has a process group associated with it this defines the current foreground process group. Keyboard-generated signals are sent to

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

Linux System Administration

Command-line interpreters

Systems Programming/ C and UNIX

Perl and R Scripting for Biologists

Chap2: Operating-System Structures

The Unix Shell. Job Control

! The Process Control Block (PCB) " is included in the context,

ADVANCED OPERATING SYSTEMS

Oxford University Computing Services. Getting Started with Unix

Files and File Systems

Introduction to UNIX/Linux

Advanced Unix Concepts. Satyajit Rai

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

Bamuengine.com. Chapter 7. The Process

Chap 4, 5: Process. Dongkun Shin, SKKU

5/8/2012. Creating and Changing Directories Chapter 7

Operating Systems. Lecture 05

Unix Basics. Systems Programming Concepts

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

5/8/2012. Controlling User Processes Chapter 10

ECE 550D Fundamentals of Computer Systems and Engineering. Fall 2017

bash, part 3 Chris GauthierDickey

IMPORTANT: Logging Off LOGGING IN

Roadmap. Tevfik Ko!ar. CSC Operating Systems Fall Lecture - III Processes. Louisiana State University. Processes. September 1 st, 2009

Introduction to UNIX Shell Exercises

Killing Zombies, Working, Sleeping, and Spawning Children

Getting to know you. Anatomy of a Process. Processes. Of Programs and Processes

Programming Assignment #1: A Simple Shell

Linux & Shell Programming 2014

Files and File Systems

CSCB09: Software Tools and Systems Programming. Bianca Schroeder IC 460

REVIEW OF COMMONLY USED DATA STRUCTURES IN OS

The Unix Shell & Shell Scripts

. Fill in the Blank: A directory named mydir has just been... Points:10. Add Question Success: 64 questions added as a copy.

PROCESS CONTROL: PROCESS CREATION: UNIT-VI PROCESS CONTROL III-II R

(MCQZ-CS604 Operating Systems)

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

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

CS 307: UNIX PROGRAMMING ENVIRONMENT REVIEW FOR EXAM 2

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

Unix Filesystem. January 26 th, 2004 Class Meeting 2

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.

Introduction to Linux Organizing Files

Roadmap. Tevfik Ko!ar. CSC Operating Systems Spring Lecture - III Processes. Louisiana State University. Virtual Machines Processes

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

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

Processes. Dr. Yingwu Zhu

Introduction to Linux

Processes. Process Concept

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

CISC 220 fall 2011, set 1: Linux basics

CS 471 Operating Systems. Yue Cheng. George Mason University Fall 2017

Self-test Linux/UNIX fundamentals

CS370 Operating Systems

Hitchhiker s Guide to VLSI Design with Cadence & Synopsys

07 - Processes and Jobs

PROCESS CONTROL BLOCK TWO-STATE MODEL (CONT D)

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

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

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

Introduction to Computer Security

Assignment clarifications

This lecture is covered in Section 4.1 of the textbook.

CSC 539: Operating Systems Structure and Design. Spring 2006

Assume that username is cse. The user s home directory will be /home/cse. You may remember what the relative pathname for users home directory is: ~

UNIX File System. UNIX File System. The UNIX file system has a hierarchical tree structure with the top in root.

Transcription:

ULI101 Week 08

File system links Week Overview Hard and symbolic links Process management

What is a file system Link? A link is a pointer to a file. This pointer associates a file name with a number called an i-node number An i-node is the control structure for a file (on a UNIX/Linux file system) If two file names have the same i-node number, they are links to the same file

What is a file system Link? Use the command ls -i to print i-node numbers of each file: [ray@localhost week8]$ ls -i 32764 lab3a.html 37745 lab3b.html 37740 lab3.zip Use the command ls -il for a long listing [ray@localhost week8]$ ls -il total 40 32764 -rw-r--r-- 1 ray ray 1097 Sep 13 08:53 lab3a.html 37745 -rw-r--r-- 1 ray ray 6582 Sep 13 08:53 lab3b.html 37740 -rw-rw-r-- 1 ray ray 6218 Sep 14 00:05 lab3.zip inode

What is a file system Link? There are two kinds of links: 1. Hard Links 2. Soft or Symbolic Links

Hard Links Hard link is a reference to the physical data on a file system More than one hard link can be associated with the same physical data Hard links can only refer to data that exists on the same file system Hard links cannot be created to a directory When a file has more than one link, you can remove any one link and still be able to access the file through the remaining links

Hard Links Example: Assume you used "vi" to create a new file, you create the first hard link (vi myfile) To Create the 2 nd, 3 rd, etc. hard links, use the command: ln myfile link-name

Display Hard Link Info Create a new file called myfile Run the command ls -il to display the i- node number and link counter 38753 -rw-rw-r-- ^ -- inode # 1 uli uli 29 Oct 29 08:47 myfile ^ -- link counter (one link)

Display Hard Link Info Create a 2 nd link to the same data: ln myfile mylink Run the command ls -il : 38753 -rw-rw-r-- 2 uli uli 29 Oct 29 08:47 myfile 38753 -rw-rw-r-- 2 uli uli 29 Oct 29 08:47 mylink ^ ^ -- inode # --link counter (2 links)

Add the 3 rd Link Create a 3 rd link to the same data: ln myfile newlink Run the command ls -il : 38753 -rw-rw-r-- 3 uli uli 29 Oct 29 08:47 myfile 38753 -rw-rw-r-- 3 uli uli 29 Oct 29 08:47 mylink 38753 -rw-rw-r-- 3 uli uli 29 Oct 29 08:47 newlink ^ ^ -- inode # --link counter (3 links)

Symbolic Links Also known as soft links or symlinks A Symbolic Link is an indirect pointer to a file a pointer to the hard link to the file You can create a symbolic link to a directory A symbolic link can point to a file on a different file system A symbolic link can point to a nonexistent file (referred to as a "broken link")

Symbolic Links To create a symbolic link to the file myfile, use ln -s myfile symlink [uli@seneca courses] ls -li myfile 44418 -rw-rw-r-- 1 uli uli 49 Oct 29 14:33 myfile [uli@seneca courses] ln -s myfile symlink [uli@seneca courses] ls -li myfile symlink 44418 -rw-rw-r-- 1 uli uli 49 Oct 29 14:33 myfile 44420 lrwxrwxrwx 1 uli uli 6 Oct 29 14:33 symlink -> myfile Different inode File type: (symbolic link) Link counter: (1 link)

Properties of Symbolic Links The i-node number is different from the pointed-to file The link counter of the new symbolic link file is "1" A Symbolic link file does not affect the link counter of the pointed-to file The type field of symbolic file contains the letter "l" The symbolic link file and the pointed-to file have different status information (file size, last modification time, etc.) chmod on the link applies to the actual file, the permissions on the link stay the same

Create Symbolic Link Directory The syntax is the same as linking to a file: ln -s target_directory link_directory [uli@seneca week8]$ ls -li 38766 drwxrwxr-x 7 uli uli 168 Oct 29 13:32 courses [uli@seneca week8]$ ln courses mydir ln: `courses': hard link not allowed for directory [uli@seneca week8]$ ln -s courses mydir [uli@seneca week8]$ ls -li 38766 drwxrwxr-x 7 uli uli 168 Oct 29 13:32 courses 44417 lrwxrwxrwx 1 uli uli 7 Oct 29 15:41 mydir -> courses

Directory Listing To display the contents in a directory, we usually use the command ls -l directory_name Compare the following two commands: [uli@seneca lrwxrwxrwx week8]$ ls 1 uli uli -l mydir 7 Oct 29 15:41 mydir -> courses [uli@seneca week8]$ ls -l courses drwxrwxr-x 2 uli uli 72 Oct 29 11:15 ica101 drwxrwxr-x 2 uli uli 72 Oct 29 11:16 ios110 drwxrwxr-x 2 uli uli 120 Oct 29 11:20 to_do drwxrwxr-x 2 uli uli 72 Oct 29 11:14 uli101

Delete link to a directory To delete a link to a directory, simply use the rm command: [uli@seneca week8]$ ls -l drwxrwxr-x 7 uli uli 168 Oct 29 13:32 courses lrwxrwxrwx 1 uli uli 7 Oct 29 15:41 mydir -> courses [uli@seneca week8]$ rm mydir [uli@seneca week8]$ ls -l drwxrwxr-x 7 uli uli 168 Oct 29 13:32 courses

UNIX processes All programs that are executing on a UNIX system are referred to as processes Each process has an owner Each process has a unique ID (PID) Processes in UNIX can run in: Foreground Background

Process structure UNIX processes are hierarchical This structure has a root, parents, and children Creation of a new process is called forking or spawning Parent can fork a child and children can fork their own children Processes keep their PID for their entire life Usually a parent sleeps when a child is executing The exception is when the child process is executing in the background

Process identification ps (process status) command displays snapshot information about processes By default, the ps command displays information only about the current terminal (ps -U username shows all) The top command provides a continuous update including resource usage

Foreground and background Foreground processing: Is the default Takes away the command line until processing is finished Background processing: Is invoked by putting the ampersand (&) operator at the end of the command line User gets the command line back immediately Both foreground and background processes can be executed on one command line Background processes run concurrently (at the same time)

Process suspending A foreground job can be suspended (temporarily stopped) by pressing Ctrl+Z Stopped jobs can be restarted by using the fg command Syntax: OR OR fg fg %job_number (1,2...) fg PID fg without id/job will bring the last background process to foreground The jobs command will show a list of background/suspended processes

Process restarting Restarting in foreground: fg PID OR fg %job_number Restarting in background: bg PID OR bg %job_number

Terminating processes Foreground processes can be terminated by using Ctrl+C or can be killed Background processes have to be killed unless brought to foreground then Ctrl+C will work

kill command Terminates a process One or more processes can be terminated at once Regular users can only kill processes they own Syntax: kill PID OR kill %job_number In some cases may be ignored by the shell use kill 9 instead pkill command can kill processes based on the program name, for example: pkill firefox