Introduction to Unix – CS 21

Slides:



Advertisements
Similar presentations
Linux File & Folder permissions. File Permissions In Ubuntu, files and folders can be set up so that only specific users can view, modify, or run them.
Advertisements

ATS Programming Short Course I INTRODUCTORY CONCEPTS Tuesday, Jan. 27 th, 2009 Essential Unix Commands.
Chapter 10 File System Security. Security Policies security policies are doors maintain a balance between total access and total security UNIX has two.
File security and Permissions A file is owned by the user who created it That user can then specify who can read, write and execute that file A file when.
Lesson 22 – Introduction to Linux Systems Administration.
Linux+ Guide to Linux Certification, Second Edition
User Accounts and Permissions Chapter IV / Part II.
Linux Linux File System.
Lecture 02CS311 – Operating Systems 1 1 CS311 – Lecture 02 Outline UNIX/Linux features – Redirection – pipes – Terminating a command – Running program.
UNIX Files and Security Software Tools. Slide 2 File Systems l What is a file system? A means of organizing information on the computer. A file system.
Getting Started with Linux Linux System Administration Permissions.
Linux Commands LINUX COMMANDS.
COMP1070/2002/lec4/H.Melikian COMP1070 Lecture #5  Files and directories in UNIX  Various types of files  File attributes  Notion of pathname  Commands.
Filesystem Hierarchy Standard (FHS) –Standard of outlining the location of set files and directories on a Linux system –Gives Linux software developers.
Offline File Storage. Module 12 Offline File Storage ♦ Introduction Backup is usually done by first collecting all the data in a single archive file,
Linux Directory Navigation. File & Directory Commands This is a minimal list of Unix commands that you must know for file management: ls (list) mkdir.
1 Lecture 2 Working with Files and Directories COP 3344 Introduction to UNIX.
Basic unix commands that everyone should know (Even if you have a mac) Slightly more advanced:
File Permissions. What are the three categories of users that apply to file permissions? Owner (or user) Group All others (public, world, others)
Linux+ Guide to Linux Certification, Second Edition
Introduction to Unix – CS 21 Lecture 9. Lecture Overview Shell description Shell choices History Aliases Topic review.
The UNIX File System. The UNIX File A file is a container for storing information and data. Filename limited to 255 characters. Can’t contain / or NULL.
Module 4 - File Security. Security Overview File Ownership Access to Files and Dircetories Changing File and Directory Ownership Changing File and Directory.
File Permission and Access. Module 6 File Permission and Access ♦ Introduction Linux is a multi-user system where users can assign different access permission.
Lesson 9-Setting and Using Permissions. Overview Describing file permissions. Using execute permissions with a file. Changing file permissions using mnemonics.
Chapter 3 Some additional notes… File permissions A file has three types of permissions (read, write and execute). Available to three categories of users.
Linux file system "On a UNIX system, everything is a file; if something is not a file, it is a process." Sorts of files (on a Linux system) Directories:
Introduction to Unix – CS 21 Lecture 4. Lecture Overview * cp, mv, and rm Looking into files The file command head and tail cat and more What we’ve seen.
File Security and Permissions. File Permissions (1) u With respect to a particular file, Unix divides the set of all users on a system into three categories:
Chapter 4: File Security & Permissions Also: Hard and Soft Links, see p77-80 &
Linux+ Guide to Linux Certification, Third Edition
Linux+ Guide to Linux Certification, Third Edition
Workbook 4 User & Group Permissions RH030 Linux Computing Essentials.
PacNOG 6: Nadi, Fiji UNIX ™/ /Linux Permissions Hervey Allen Network Startup Resource Center.
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.
The Unix File system (UFS) Presented by: Gurpreet Singh Assistant Professor Department of School of Computing and Engineering Galgotias University.
1 Lecture 2 Working with Files and Directories COP 3353 Introduction to UNIX.
UNIX filesystem CS 2204 Class meeting 2 *Notes by Doug Bowman and other members of the CS faculty at Virginia Tech. Copyright
File System Security ls -l. First Columm d = directory l = symbolic link b = block special file c = character special file p = fifo (or named pipe) special.
A Brief Overview of Unix Brandon Bohrer. Topics What is Unix? – Quick introduction Documentation – Where to get it, how to use it Text Editors – Know.
Agenda The Linux File System (chapter 4 in text) Setting Access Permissions Directory vs File Permissions chmod Utility Symbolic Method Absolute Method.
The Unix File System R Bigelow. The UNIX File System The file system refers to the way in which UNIX implements files and directories. The UNIX file system.
BIF703 File Permissions. As you recall from our previous notes, that Unix/Linux recognizes everything as a file: Regular files to store data, programs,
ORAFACT The Linux File System. ORAFACT Filesystem Support Support for dozens of filesystem types including: Minix, ext2, MS-DOS, UMSDOS, VFAT, NTFS, NFS,
Agenda The Linux File System (chapter 4 in text) Linking Files Hard Links / Symbolic Links Disk Storage Checking for Disk Space (df / du) Archiving (Backing.
Linux Filesystem Management
Privileges: who can control what
Permissions: who can control what Unix/IP Preparation Course July 19, 2009 Eugene, Oregon, USA
Linux file system "On a UNIX system, everything is a file;
Chapter 3 Maintaining Security
Lecture 2 Working with Files and Directories
CS314 – Section 5 Recitation 1
BIF703 File Permissions.
Privileges: who can control what
File system(conti..) Lecture November 2018.
Security and File Permission
Agenda The Linux File System (chapter 4 in text)
Chien-Chung Shen CIS, UD
In the last class,. ls –l command. seven fields
Software I: Utilities and Internals
Lab 3: File Permissions.
Linux Commands LINUX COMMANDS.
FILE SECURITY AND ACCESS CONTROL
Figure 6-13: Managing Permissions
In the last class, The concept of file system
BASIC FILE ATTRIBUTES.
January 26th, 2004 Class Meeting 2
Presentation transcript:

Introduction to Unix – CS 21 Lecture 3

Lecture Overview Lab review More on files and listings Disk usage and compressing files Permissions and ownership

How Did Lab Go? What was missing? What did I want you to get out of it? 1. Basic differences between Windows and Unix 2. Difference between a good design and a bad design A, b, x don’t really make good descriptions

Lab Continued 3. Getting used to navigating the system 4. rmdir can only remove empty directories 5. A lot of environment variables are automatically set, but not every one will be used every time 6. Difference between an environment variable and a local variable 7. Get used to reading man pages 8. Think about the future

What ls Output Means

Properties Of Files All files have these properties Permissions Links For directories, this lists the number of subdirectories Owner Owner group Size Timestamp Name

Disk Space And Quota Every file takes some amount of space, even an empty file Space for the name, and information about the file Your account has limited space quota can be used to check available space Du shows how much space you are using and where it is located “du –s” summarizes and just gives you the total

The du Command

Saving Disk Space Compressing files Decompressing files Zip gzip bzip2 GNU version of zip bzip2 Different algorithm Decompressing files unzip, gunzip, bunzip2

Running zip, gzip, And bzip2

A Special Type of File: A Symbolic Link Not an actual file, but a pointer to another file Acts as a shortcut Can act as a shortcut to a directory Provides a quick link to any file Often used so files can be changed without disturbing other programs

Graphical Representation /home/csmajs/user /home/csmajs/user/cs21 /home/csmajs/user/cs21/link /home/csmajs/user2/otherFile

Creating Symbolic Links With ln ln –s TARGET NAME -s signifies a symbolic link Without the –s, a hard link is created Difference between a hard link and a symbolic link? A hard link’s target must exist A symbolic link can point to nothing (broken link)

Overview Of Permissions -rwxrwxrwx - rwx rwx rwx File Type Owner Group World

Owner, Group, The World Owner Group The world The creator of the file A set of users grouped together The world Every other account not in the group

Read, Write, Execute Read Write Execute File can be read, but not modified Write Permission is granted to modify the file Execute Run directly as if the file is a program All programs should be executable (/bin)

What Permissions Mean On A Directory Read Users can get a listing of that directory Write Users can create and remove files in that directory Execute Users can examine files in that directory

Changing Permissions With chmod chmod SETTINGS FILENAME u = user g = group o = other a = all + (add) (remove) = (set) r = read w = write x = execute chmod a-x testFile

More Examples Set read and write access for all? chmod a=rw FILE Add executable access for others? chmod o+x FILE Remove all access for owner? chmod u-rwx FILE

Advanced chmod Usage Most Unix hackers don’t use this form They prefer the more direct approach Set permissions for owner, group, and others all with one number Unfortunately, this approach requires a little bit of information

How Decimal Numbers Work 1234 1 * 1000 + 2 * 100 + 3 * 10 + 4 * 1 1 * 10 + 2 * 10 + 3 * 10 + 4 * 10 10 distinct values 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 Why is this system so comfortable? 3 2 1

Binary Numbers Only two distinct values 0 and 1 On and off Binary numbers work the exact same way as decimal numbers

Conversion 1010 111 1 * 2 + 0 * 2 + 1 * 2 + 0 * 2 8 + 0 + 2 + 0 = 10 1 * 2 + 1 * 2 + 1 * 2 4 + 2 + 1 = 7 3 2 1 2 1

Powers Of Two x 2 Decimal Value 1 4 8 16 32 64 1 2 3 4 5 6

Octal Numbers Eight distinct numbers 0, 1, 2, 3, 4, 5, 6, 7 Binary numbers can be split into groups of three and represented by an octal number exactly

Conversion Table Binary Number Octal/Decimal Number 000 001 1 010 2 001 1 010 2 011 3 100 4 101 5 110 6 111 7

Relationship Between Binary Numbers And Permission Each permission can be represented by a binary number Each slot is either on or off --- = 000 rwx = 111 rw- = 110 r-x = 101 Each group of three corresponds exactly to an octal number

Conversion Examples Read, write, and execute permission for everybody? rwx rwx rwx = 111 111 111 = 777 Read and execute permission for everyone? r-x r-x r-x = 101 101 101 = 555 Read permission for owner, write permission for group, and execute permission for everyone else? r-- -w- --x = 100 010 001 = 421

More Examples All permission for owner, read and execute for everyone else? rwx r-x r-x = 111 101 101 = 755 Read, write for owner, and read only for everyone else? rw- r-- r-- = 110 100 100 = 644

Back To chmod The advanced way to use chmod is to use octal numbers and set all permissions at once

chgrp And chown chgrp will change the group setting of a file to another that you are a member of You probably don’t belong to more than one group chown will change the owner of a file Only the owner may chown a file Once chown’ed, the new owner is the only one who can grant permission back

Using umask To Set Default Permissions Every time you create a file, the permissions are set to a default umask will set this default Unfortunately, it does it the exact opposite way than you would think

How umask Works If you want default permissions to be 770, you set your umask with the opposite: 007 Permissions = 770 = 111 111 000 umask 007 = 000 000 111 Unix tries to be helpful and clears the executable flags, though

Examples Read, write, execute permission for owner, nothing for anyone else? Permissions = 700 = 111 000 000 umask 077 = 000 111 111 All permissions for owner and read, write for group? Permissions = 760 = 111 110 000 umask 017 = 000 001 111

More Examples Read and write permissions for everybody? umask 111 = 001 001 001 No permissions for anybody? Permissions = 000 = 000 000 000 umask 777 = 111 111 111

A Couple Simple Commands echo Simply prints out whatever it is given Example:

Using echo To Make A Simple File

Timestamps touch command Without any flags, it will make the modification time of that file the current time Can be used to create a new file, but the file will be empty (0 byte size)

Final Notes For Today We have covered up through chapter 5 in the book, so you will be expected to have read these chapters Next time we will delve deeper into creating files and moving them around in the file system