CSCI 2132 Software Development. Lecture 5: File Permissions

Similar documents
Files and Directories

CSCI 2132 Software Development. Lecture 4: Files and Directories

CSCI 2132: Software Development. Norbert Zeh. Faculty of Computer Science Dalhousie University. Subversion (and Git) Winter 2019

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

27-Sep CSCI 2132 Software Development Lab 4: Exploring bash and C Compilation. Faculty of Computer Science, Dalhousie University

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

Introduction: What is Unix?

Introduction to the UNIX command line

System Administration

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

CSC209H Lecture 1. Dan Zingaro. January 7, 2015

Midterm 1 1 /8 2 /9 3 /9 4 /12 5 /10. Faculty of Computer Science. Term: Fall 2018 (Sep4-Dec4) Student ID Information. Grade Table Question Score

22-Sep CSCI 2132 Software Development Lecture 8: Shells, Processes, and Job Control. Faculty of Computer Science, Dalhousie University

Command-line interpreters

Perl and R Scripting for Biologists

CSCI 4152/6509 Natural Language Processing. Lab 1: FCS Computing Environment

Introduction to Linux

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

Lec 1 add-on: Linux Intro

Lecture 01 - Working with Linux Servers and Git

Week 2 Lecture 3. Unix

CHAPTER 1 UNIX FOR NONPROGRAMMERS

SECTION -C. Getting Started with UNIX

Mills HPC Tutorial Series. Linux Basics I

This lab exercise is to be submitted at the end of the lab session! passwd [That is the command to change your current password to a new one]

Unix Introduction to UNIX

Getting Started. Running Utilities. Shells. Special Characters. Special Characters. Chapter 2 Unix Utilities for non-programmers

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

Chapter 1 - Introduction. September 8, 2016

CSCI 2132 Software Development. Lecture 7: Wildcards and Regular Expressions

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

Working with Basic Linux. Daniel Balagué

Unix Basics. UNIX Introduction. Lecture 14

Unix Basics. Systems Programming Concepts

Introduction to UNIX command-line

RH033 Red Hat Linux Essentials

CS CS Tutorial 2 2 Winter 2018

9 and 11-Jan CSCI 4152/6509 Natural Language Processing Lab 1: FCS Computing Environment, SVN Tutorial. FCS Computing Environment, SVN Tutorial

Lab Working with Linux Command Line

: the User (owner) for this file (your cruzid, when you do it) Position: directory flag. read Group.

Linux Command Line Primer. By: Scott Marshall

Basic UNIX commands. HORT Lab 2 Instructor: Kranthi Varala

Practical Session 0 Introduction to Linux

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

Introduction to Linux Workshop 1

Computer Systems and Architecture

commandname flags arguments

Version Control with Git

28-Nov CSCI 2132 Software Development Lecture 33: Shell Scripting. 26 Shell Scripting. Faculty of Computer Science, Dalhousie University

AN INTRODUCTION TO UNIX

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

A Brief Introduction to the Linux Shell for Data Science

Unix Filesystem. January 26 th, 2004 Class Meeting 2

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: ~

Find out where you currently are in the path Change directories to be at the root of your home directory (/home/username) cd ~

Unix File System. Class Meeting 2. * Notes adapted by Joy Mukherjee from previous work by other members of the CS faculty at Virginia Tech

Files

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.

CS356: Discussion #1 Development Environment. Marco Paolieri

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

CS2720 Practical Software Development

CS246 Spring14 Programming Paradigm Notes on Linux

5/20/2007. Touring Essential Programs

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

UNIX File Hierarchy: Structure and Commands

Introduction to Linux

Git. Charles J. Geyer School of Statistics University of Minnesota. Stat 8054 Lecture Notes

Introduction to UNIX command-line II

CSCI 2132 Software Development. Lecture 2: Introduction to UNIX and Unix-like Operating Systems

GNU/Linux 101. Casey McLaughlin. Research Computing Center Spring Workshop Series 2018

Introduction to Linux Organizing Files

Exercise 1: Basic Tools

The Unix Shell. Pipes and Filters

2) clear :- It clears the terminal screen. Syntax :- clear

The Unix Shell & Shell Scripts

Introduction To. Barry Grant

Essential Linux Shell Commands

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

Introduction to UNIX I: Command Line 1 / 21

CSE 15L Winter Midterm :) Review

Recitation #1 Boot Camp. August 30th, 2016

Name: Peter Lemieszewski Venue: Education

Introduction to Linux

TEL2821/IS2150: INTRODUCTION TO SECURITY Lab: Operating Systems and Access Control

CS395T: Introduction to Scientific and Technical Computing

Course 144 Supplementary Materials. UNIX Fundamentals

Operating Systems. Copyleft 2005, Binnur Kurt

CS/CIS 249 SP18 - Intro to Information Security

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

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

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

Introduction to Supercomputing

DAVE LIDDAMENT INTRODUCTION TO BASH

Introduction to Linux

Data and File Structures Chapter 2. Basic File Processing Operations

Unix Guide. Meher Krishna Patel. Created on : Octorber, 2017 Last updated : December, More documents are freely available at PythonDSP

Getting Started With UNIX Lab Exercises

CSE Linux VM. For Microsoft Windows. Based on opensuse Leap 42.2

CENG 334 Computer Networks. Laboratory I Linux Tutorial

Linux Essentials Objectives Topics:

Transcription:

CSCI 2132 Software Development Lecture 5: File Permissions Instructor: Vlado Keselj Faculty of Computer Science Dalhousie University 14-Sep-2018 (5) CSCI 2132 1

Files and Directories Pathnames Previous Lecture Commands for managing and navigating directory structure Commands: cat, logout, exit, ls, dirname, basename, pwd, cd, mkdir, rmdir, mv, rm, tree File manipulation commands File permissions: users, groups checking permissions 14-Sep-2018 (5) CSCI 2132 2

A Note About SVN SVN (Subversion) Software Versioning and Revision Control System A simplified view: Backups creating backups in a repository Historical time machine, labeled versions Collaborative different users can contribute and merge changes SVN Repository files, directories files, directories Working Copy 2 Working Copy 1 files, directories Working Copy 3 14-Sep-2018 (5) CSCI 2132 3

SVN Checkout ( svn co or svn checkout ) SVN checkout command is used to create an initial working copy SVN Repository svn co (svn checkout) SVN Repository files, directories Working Copy 1 14-Sep-2018 (5) CSCI 2132 4

svn add command We can create new files in the working copy, but they are ignored by SVN With svn add we add files and directories to an SVN internal list, i.e., we mark them not to be ignored The SVN repository does not know that we added files yet svn add new file SVN Repository Working Copy 14-Sep-2018 (5) CSCI 2132 5

svn commit command svn commit will save changes to the repository svn commit SVN Repository files, directories Working Copy Changes are saved to the SVN repository Local working copy stays (you can delete it if you want, SVN repository does not need to know) Remember that you must provide a log message: svn commit -mmessage 14-Sep-2018 (5) CSCI 2132 6

svn update command It is possible that someone, or yourself, made new changes in the repository and your working copy has old versions of the files svn update will update your local copy according to the changes in the repository svn update SVN Repository files, directories Working Copy It is a good idea to run svn update if you did not modify the working copy in a long time 14-Sep-2018 (5) CSCI 2132 7

svn rm and svn mv If we remove or rename an SVN-marked file using rm or mv, SVN will complain about it and will not remove or rename the file in the respository Use svn rm to remove a file and remove it form the SVN internal list of marked files Use svn mv to rename or move a file Changes will take affect at the next commit 14-Sep-2018 (5) CSCI 2132 8

SVN Troubleshooting Do not interrupt an SVN operation (unless it takes very long time) Helpful commands: svn info, svn status -v, svn log -v A working copy can be recognized by the hidden.svn directory A way to resolve a problem is to move or remove working copy, and make a new checked out working copy If you allow SVN to save your password, you can remove the record with: rm /.subversion/auth/svn.simple/* 14-Sep-2018 (5) CSCI 2132 9

SVN and Git There are many Version Control Systems Git and SVN are probably the most popular Both are open-source, with a lot of similarities and some differences svn co is similar to git clone svn add is similar to git add svn commit is similar to git commit + git push svn update is simlar to git pull We will cover git in more details later 14-Sep-2018 (5) CSCI 2132 10

A Short Note about wc You used wc command in the lab wc stands for word count It prints the number of characters, words, and lines Options -c, -w, and -l can be used to print only one of those numbers Example: wc -c file1 Concepts: command, arguments, options or flags 14-Sep-2018 (5) CSCI 2132 11

A Short Note about Pipelines You were asked in the Lab to create a pipeline The concept of the pipeline, which belongs to the pipe-filter software architectural pattern Use pipe symbol to connect commands to create pipeline in the Unix command-line interface If filename can be specified as the input file, use it only with the first command 14-Sep-2018 (5) CSCI 2132 12

Back to Permissions... We will now continue with the topic of file permissions 14-Sep-2018 (5) CSCI 2132 13

Octal Representation of Permissions Permissions can be represented with 9 bits: user {}}{ rwx group {}}{ rwx other {}}{ rwx For practical reasons octal system is used For example, what permissions are represented by octal number 750? 14-Sep-2018 (5) CSCI 2132 14

Checking Permissions Command: ls -l Note: a few more useful ls options: -a -t -r Example: $ echo test > tmpfile.txt $ ls -l tmpfile.txt -rw-r--r-- 1 vlado csfac 5 Sep 13 11:21 file.txt 14-Sep-2018 (5) CSCI 2132 15

Changing Permissions Command: chmod mode files chmod changing file mode bits Some examples: chmod 664 file.txt chmod og-r file.txt chmod u+x,og+r file.txt chmod u=rw,og= file.txt chmod a+r file.txt chmod -R u+r+w+x dir1 Note: a is used for all 14-Sep-2018 (5) CSCI 2132 16

Changing Owner and Group of a File Examples: chown newuser file.txt chown -R newuser files dirs chgrp newgroup file.txt chgrp -R newgroup files dirs -R is used for directory recursive change 14-Sep-2018 (5) CSCI 2132 17

Effective UserID and GroupID How does the system decide access permission for a process? Each process has an effective UserID and GroupID, as well as real UserID and GroupID Example: our shell has our UserID and a GroupID How are processes assigned effective userids and groupids? 14-Sep-2018 (5) CSCI 2132 18

Changing Effective GroupID and UserID newgrp newgroup changes into newgroup (logs into new group) su newuser changes effective user needs to be superuser (root user) Additional permission bits: setuid, setgid, and sticky bit bits 14-Sep-2018 (5) CSCI 2132 19

Reading Reading: UNIX book, Ch1 and Ch2 to page 51, so far The book contains tutorials on vi and emacs 14-Sep-2018 (5) CSCI 2132 20

Redirection and Pipes The three standard channels: standard input, standard output, standard error output Modifying channels: redirection and pipes 14-Sep-2018 (5) CSCI 2132 21

Output Redirection Remember what we learned about: stdin, stdout, stderr Redirecting the standard output of a program into a file: command > filename Creates a file (filename) if it does not exist Example: ls lab1 > listing Important: > redirection deletes previous file contents To append a file with new content use >> Example: ls lab1 >> listing Creates a file ( listing ) if it does not exist, as well 14-Sep-2018 (5) CSCI 2132 22

Input Redirection Redirects the standard input from a file into a process Useful in testing Syntax: command < filename Example: sort < names.txt sorts names in a file names.txt and prints out Example 2: sort < names.txt > names-sorted.txt Example 3: mail csusername < HelloWorld.java Example 4: mail full@email < HelloWorld.java 14-Sep-2018 (5) CSCI 2132 23

Error Redirection Standard error output is not redirected by > Syntax (bash specific): command 2> filename Cannot be a space between 2 and > Example: rm x 2> error If file x does not exist, it will produce an error message >> can be used to append output: command 2>> filename 14-Sep-2018 (5) CSCI 2132 24

More About Redirection File descriptors of stdin, stdout, and stderr are 0, 1, and 2, respectively That is where 2 comes from in error redirection Similarly we can use 0 and 1 in input and output redirection: command 0< filename command 1> filename These are equivalent to previous redirections 14-Sep-2018 (5) CSCI 2132 25