SECTION -C. Getting Started with UNIX

Similar documents
Basic File Attributes

CHAPTER 1 UNIX FOR NONPROGRAMMERS

UNIX File Hierarchy: Structure and Commands

Basic File Attributes

commandname flags arguments

Unix Filesystem. January 26 th, 2004 Class Meeting 2

Introduction to the Linux Command Line

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

Unix background. COMP9021, Session 2, Using the Terminal application, open an x-term window. You type your commands in an x-term window.

CSCI 2132 Software Development. Lecture 5: File Permissions

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

A Brief Introduction to Unix

Mills HPC Tutorial Series. Linux Basics I

Working with Basic Linux. Daniel Balagué

Week 2 Lecture 3. Unix

CSCI 2132 Software Development. Lecture 4: Files and Directories

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

Chapter-3. Introduction to Unix: Fundamental Commands

Set 1 MCQ Which command is used to sort the lines of data in a file in reverse order A) sort B) sh C) st D) sort -r

Introduction: What is Unix?

UNIX Quick Reference

Essential Linux Shell Commands

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

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

Quick Start Guide. by Burak Himmetoglu. Supercomputing Consultant. Enterprise Technology Services & Center for Scientific Computing

CENG 334 Computer Networks. Laboratory I Linux Tutorial

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.

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

acmteam/unix.pdf How to manage your account (user ID, password, shell); How to compile C, C++, and Java programs;

Introduction to Unix: Fundamental Commands

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.

Exploring UNIX: Session 3

AN INTRODUCTION TO UNIX

Listing Directory Attributes. Bamuengine.com Page 1. BY Prof. P. Katkar, DIEMS, AURANGABAD

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

Unix Basics. Systems Programming Concepts

CS 215 Fundamentals of Programming II Spring 2019 Very Basic UNIX

Basic Survival UNIX.

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

Chapter Two. Lesson A. Objectives. Exploring the UNIX File System and File Security. Understanding Files and Directories

Operating Systems. Copyleft 2005, Binnur Kurt

Introduction to Linux

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

Access Permissions. Agenda. chmod Command (Relative Method) File / Directory Permissions

CS Fundamentals of Programming II Fall Very Basic UNIX

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

Course 144 Supplementary Materials. UNIX Fundamentals

CS246 Spring14 Programming Paradigm Notes on Linux

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

Hitchhiker s Guide to VLSI Design with Cadence & Synopsys

CSE 390a Lecture 3. Multi-user systems; remote login; editors; users/groups; permissions

Chapter 1 - Introduction. September 8, 2016

CSE II-Sem)

Files and Directories

1. What statistic did the wc -l command show? (do man wc to get the answer) A. The number of bytes B. The number of lines C. The number of words

The Unix Shell & Shell Scripts

Using the Zoo Workstations

Unix basics exercise MBV-INFX410

Introduction to Linux Workshop 1

Basic Unix Commands. CGS 3460, Lecture 6 Jan 23, 2006 Zhen Yang

Introduction of Linux

Practical Session 0 Introduction to Linux

CSCE 212H, Spring 2008, Matthews Lab Assignment 1: Representation of Integers Assigned: January 17 Due: January 22

Full file at

The Unix Shell. Pipes and Filters

A Big Step. Shell Scripts, I/O Redirection, Ownership and Permission Concepts, and Binary Numbers

CISC 220 fall 2011, set 1: Linux basics

last time in cs recitations. computer commands. today s topics.

CSC209. Software Tools and Systems Programming.

Quick Start Guide. by Burak Himmetoglu. Supercomputing Consultant. Enterprise Technology Services & Center for Scientific Computing

Practical 4. Linux Commands: Working with Directories

Basic UNIX commands. HORT Lab 2 Instructor: Kranthi Varala

Introduction. SSH Secure Shell Client 1

Scripting. Shell Scripts, I/O Redirection, Ownership and Permission Concepts, and Binary Numbers

Introduction to Linux (Part I) BUPT/QMUL 2018/03/14

Operating Systems. Engr. Abdul-Rahman Mahmood MS, PMP, MCP, QMR(ISO9001:2000) alphapeeler.sf.net/pubkeys/pkey.htm

Overview LEARN. History of Linux Linux Architecture Linux File System Linux Access Linux Commands File Permission Editors Conclusion and Questions

A Brief Introduction to the Linux Shell for Data Science

CSC209H Lecture 1. Dan Zingaro. January 7, 2015

Oxford University Computing Services. Getting Started with Unix

LING 408/508: Computational Techniques for Linguists. Lecture 5

CS4350 Unix Programming. Outline

Python for Astronomers. Week 1- Basic Python

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 Computing

MTU Computer Structure

Introduction to UNIX command-line

Unix. 1 tblgrant projects 0 Jun 17 15:40 doc1.txt. documents]$ touch doc2.txt documents]$ ls -l total 0

LOG ON TO LINUX AND LOG OFF

Lecture 3. Unix. Question? b. The world s best restaurant. c. Being in the top three happiest countries in the world.

Handling Ordinary Files

UTA Tech Orientation Spring 2019

Welcome. IT in AOS. Michael Havas Dept. of Atmospheric and Oceanic Sciences McGill University. September 21, 2012

Operating Systems, Unix Files and Commands SEEM

Introduction to Linux

CSN08101 Digital Forensics. Module Leader: Dr Gordon Russell Lecturers: Robert Ludwiniak

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.

Hands-on Keyboard: Cyber Experiments for Strategists and Policy Makers

Welcome to Linux. Lecture 1.1

Transcription:

Lecture 15 SECTION -C Getting Started with UNIX

Introduction Changing permission modes Absolute & Relative Permissions

Changing file permissions : chmod A file or directory is created with a default set of permissions. Generally the default setting write- protects a file from all except user( the owner of the file) though all users may have read access. However this may not be so on your system. To know your system s default settings, create a file xstart: $ cat /usr/bin/startx > xstart actually copies the file startx $ ls l xstart -rw-r- - r - - 1 kumar metal 1906 Sep 5 23:58 xstart It seems that, by default a file doesn t also have execute permissions. So how does one execute such file? To do that, the permission of the file need to be changed. This is done with the chmod. The chmod (change mode) command is used to set the permissions of one or more files for all three categories of users ( user, group and others). It can run only by the user( the owner) and the super user. The command can be used in two ways: i l ti b if i th h t th t

We ll consider both ways of using chmod in the following sections: (1) Relative permissions: i when changing permission in a relative manner, chmod only changes the permissions specified in the command line and leaves the other permissions unchanged. In this mode it uses the following syntax : chmod category operation permission filename(s) chmod takes as its arguments an expression comprising i some letters and symbols that t completely l describe the user category and the type of permission being assigned or removed. The expression contains three components : User category (user, group, others)

By using suitable abbreviations for each of these components, you can frame a compact expression and then use it as an argument to chmod. The abbreviations used for these three components are shown in table: Abbreviations used by chmod: Category Operation Permission u User + - Assigns permissions r -read g Group - - Remove permissions permission o others a All (ugo) = - assign absolute permissions w write permission x Execute permission

Now let s consider an example. To assign execute permission to the user (owner) of the file xstart, we need to frame a suitable expression by using appropriate expression by using appropriate characters from each of the three columns of above table. Since the file need to be executable only by the user, the expression required is u + x: $ chmod u+x xstart $ ls l xstart -rwxr--r-- 1 kumar metal 1906 May 10:20 : 30 xstart The command assigns (+) execute (x) permission to the user (u), but other permissions i remain unchanged. You can now execute the file if you are the owner of the file but the other categories (i.e. group and others) still can t. To enable all of them to execute this file, you have to use multiple characters to represent the user category (ugo): $ chmod ugo+x xstart ; ls l xstart Or $ chmod a+x xstart (a implies ugo) Or $ chmod +x (Bydefault a is implied) -rwxr-xr-x 1 kumar metal 1906 May 10:20 : 30

(2) Absolute Permissions : Sometimes you don t need to know what a file s current permissions are, but want to set all nine permission bits explicitly. The expression used by chmod here is a string of three octal numbers(base 8). Octal numbers use the base 8, and octal digits have the values 0 to 7. This means that a set of three bits can represent one octal digit. If we represent the permissions of each category by one octal digit, it this is how the permissions can be represented : Read permission 4 (Octal 100) Write permission 2 (Octal 010)

For each category we add up the numbers. For instance, 6 represents read and write permissions. Binary Octal Permissions Significance 000 0 -- - No permissions 001 010 011 1 2 3 --x -w- -w x Executable only Writable only Writable and executable 100 101 110 111 4 5 6 7 r - - r - x r w - rwx Readable only Readable and executable Readable and Writable Readable, Writable and executable

Now you can use a different method : $ chmod 666 xstart ; ls l xstart - rw - rw rw - 1 kumar metal 1906 May 10 20:30 xstart t The 6 indicates the read and write permissions(4+2) i

Filters :Using Both Standard Input and Standard Output Unix command can be grouped into four categories: 1. Directory-oriented commands like mkdir, rmdir, cd and basic file handling commands like cp, mv and rm use neither standard input nor standard output. 2. Commands like ls, pwd, who etc don t read standard input but they write to standard d output.. t 3. Commands like lp that read standard input but don t write to standard output.(lp command is used for printing a file.) $ lp xyz.ps Request id is prl-320 (1 file) $ _ this command notifies the request id a combination of a printer name and (prl) and job number (320) 4. Commands like cat, wc, cmp, gzip etc that use both standard input and standard output.

Command in the fourth category, in UNIX is called FILTERS, and the dual stream handling features makes filters powerful text manipulators. NOTE: Most filters can also read directly from files whose names are provided as arguments. Let s use bc command as a filter this time. Consider this file containing some arithmetic expressions: $ cat calc.txt 2^32 maximum memory on a 32 bit computer. 25 * 50 30* 25 + 15 ^ 2 You can redirect bc s standard input to come from this file and save output in yet another : $bc<calc. calc. txt> result.txt $ cat result.txt 4294967296 This is 2^32 1250 this 25*30 975 this is 30*25 + 15 ^ 2

Applications in Games There are lots of fun things and games you can use in UNIX. Most of the ones listed below are local to Brown University. Try each of these commands. Check the man pages or the links below if you have trouble, but note, some of the commands do not have man pages. Have fun! banner figlet WhatsForDinner food dilbert Forecast fortune say Xteddy xdeady BattleTris nethack Netris xbill xblast xboing xroach

Research Unix Commands CCR's computing resources are primarily Linux based and therefore using them requires a basic understanding of the Unix operating system. Some basic commands are provided below. Basic Unix Commands CCR Reference Card for Linux/UNIX commands pdf Show pathname of current directory: pwd List files: ls Make a directory: mkdir directory-name Change directory: cd directory-name Change directory back to home directory: cd Copy a file: cp old-filename new-filename View a file: cat filename more filename less filename Edit a file: emacs filename vi filename Delete a file: rm filename Delete a directory y( (recursively): rm -R directory-name All files and subdirectories are deleted Move a file: mv old-filename new-filename Change permissions: Arguments to chmod command: ugo+-rwx where ugo are user, group and other; rwx are read, write and execute Add execute permission for yourself: chmod u+x filename Remove read, write and execute for group and other from a directory its contents: chmod -R go-rwx directory-name