CISC 220 fall 2011, set 1: Linux basics

Similar documents
Introduction: What is Unix?

CS246 Spring14 Programming Paradigm Notes on Linux

CS Fundamentals of Programming II Fall Very Basic UNIX

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

Introduction to Linux Basics

Mills HPC Tutorial Series. Linux Basics I

CS 215 Fundamentals of Programming II Spring 2019 Very Basic UNIX

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

*nix Crash Course. Presented by: Virginia Tech Linux / Unix Users Group VTLUUG

Linux Training. for New Users of Cluster. Georgia Advanced Computing Resource Center University of Georgia Suchitra Pakala

Exercise Sheet 2. (Classifications of Operating Systems)

Linux & Shell Programming 2014

Perl and R Scripting for Biologists

EE516: Embedded Software Project 1. Setting Up Environment for Projects

Introduction to the Linux Command Line

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

Practical Computing-II. Programming in the Linux Environment. 0. An Introduction. B.W.Gore. March 20, 2015

Using LINUX a BCMB/CHEM 8190 Tutorial Updated (1/17/12)

EECS 2031E. Software Tools Prof. Mokhtar Aboelaze

Working with Basic Linux. Daniel Balagué

Lezione 8. Shell command language Introduction. Sommario. Bioinformatica. Mauro Ceccanti e Alberto Paoluzzi

CSE 390a Lecture 1. introduction to Linux/Unix environment

Introduction to Linux. Woo-Yeong Jeong Computer Systems Laboratory Sungkyunkwan University

Exploring UNIX: Session 3

Linux Essentials. Programming and Data Structures Lab M Tech CS First Year, First Semester

CSE 391 Lecture 1. introduction to Linux/Unix environment

Chapter-3. Introduction to Unix: Fundamental Commands

Brief Linux Presentation. July 10th, 2006 Elan Borenstein

EECS2301. Lab 1 Winter 2016

EECS Software Tools. Lab 2 Tutorial: Introduction to UNIX/Linux. Tilemachos Pechlivanoglou

Lezione 8. Shell command language Introduction. Sommario. Bioinformatica. Esercitazione Introduzione al linguaggio di shell

Introduction to Linux

Week 2 Lecture 3. Unix

Introduction to Unix and Linux. Workshop 1: Directories and Files

Introduction to Linux Workshop 1

Introduction to Linux

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

Introduction to Linux. Fundamentals of Computer Science

Introduction of Linux

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

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

Getting started with Hugs on Linux

The Unix Shell & Shell Scripts

Introduction to Unix: Fundamental Commands

Linux at the Command Line Don Johnson of BU IS&T

Introduction to Linux

Operating Systems. Copyleft 2005, Binnur Kurt

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

Introduction in Unix. Linus Torvalds Ken Thompson & Dennis Ritchie

Common UNIX Commands. Unix. User Interfaces. Unix Commands Winter COMP 1270 Computer Usage II 9-1. Using UNIX. Unix has a command line interface

Introduction to Linux

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

CS CS Tutorial 2 2 Winter 2018

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

CSE 391 Lecture 1. introduction to Linux/Unix environment

Bioinformatics? Reads, assembly, annotation, comparative genomics and a bit of phylogeny.

Introduction to UNIX. SURF Research Boot Camp April Jeroen Engelberts Consultant Supercomputing

Introduction to Linux

Introduction to Linux Basics Part I. Georgia Advanced Computing Resource Center University of Georgia Suchitra Pakala

History. Terminology. Opening a Terminal. Introduction to the Unix command line GNOME

Introduction to the UNIX command line

Unix Introduction to UNIX

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

Introduction to Linux

Outline. Structure of a UNIX command

System Administration

Essential Linux Shell Commands

COSC UNIX. Textbook. Grading Scheme

Week 2. Exp 2 (a) (b): Introduction to LINUX OS, Installation of LINUX OS, Basic DOS commands

Welcome to Linux. Lecture 1.1

CS 300. Data Structures

BIOINFORMATICS POST-DIPLOMA PROGRAM SUBJECT OUTLINE Subject Title: OPERATING SYSTEMS AND PROJECT MANAGEMENT Subject Code: BIF713 Subject Description:

Basic UNIX commands. HORT Lab 2 Instructor: Kranthi Varala

INTRODUCTION TO LINUX

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

Introduction to Linux

Lab Working with Linux Command Line

Computer Systems and Architecture

Getting started with Hugs on Linux

12/7/10 ATSC 212 UNIX ATSC 212 ATSC 212 UNIX

CSC209H Lecture 1. Dan Zingaro. January 7, 2015

The Linux Command Line & Shell Scripting

A Brief Introduction to Unix

CS4350 Unix Programming. Outline

Introduction. Let s start with the first set of slides

LAB #7 Linux Tutorial

Introduction to Linux

EKT332 COMPUTER NETWORK

Unix Handouts. Shantanu N Kulkarni

Operating Systems and Using Linux. Topics What is an Operating System? Linux Overview Frequently Used Linux Commands

Examples: Directory pathname: File pathname: /home/username/ics124/assignments/ /home/username/ops224/assignments/assn1.txt

Linux Operating System Environment Computadors Grau en Ciència i Enginyeria de Dades Q2

UNIX Kernel. UNIX History

Introduction to Linux

INSE Lab 1 Introduction to UNIX Fall 2017

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

Linux for Beginners. Windows users should download putty or bitvise:

Getting Started with UNIX

Unix Filesystem. January 26 th, 2004 Class Meeting 2

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

Transcription:

CISC 220: System-Level Programming instructor: Margaret Lamb e-mail: malamb@cs.queensu.ca office: Goodwin 554 office phone: 533-6059 (internal extension 36059) office hours: Tues/Wed/Thurs 2-3 (this week only) course web site: research.cs.queensu.ca/home/cisc220 my home page: research.cs.queensu.ca/home/malamb labs start next week (none during week 1) Web page contains the above information plus: these slides, audio/video more administrative info 1

What's This Course About? From Calendar: Basic concepts of Unix-like systems. Shells and scripting. System-level programming in the C language. Software development tools and techniques. Useful Skills: Linux & C programming. Concepts Include: command-line interfaces, shell scripting, processes, signals, pipes, memory management 2

Marking Scheme assignments: 20% (best 6 of 8) 3 quizzes: 40% each (best 2 of 3) final exam: 40% up to 2 bonus points possible (see web site) Warning about final exam scheduling: don t make travel plans yet! Quizzes & Final Exam are closed book -- but will include summary sheets 3

More Administrivia web site (admin, slides, labs, audio/video) Moodle Academic Integrity prerequisites & backgrounds assignments (marked & unmarked) labs (starting next week, work on assignment 1) text: in bookstore special accommodations, excuses attendance learning, getting help 4

Operating Systems Operating System = software that manages what happens on a computer: programs memory file system hardware & external devices diagram from wikipedia 5

Unix History Originally developed at Bell Labs (AT&T) 1960s: Bell & others working on Multics Operating System (Multiplexed Information and Computing Service) some good ideas, but poor performance, never commercially successful 1970s: Bell employees created simpler, efficient variant: "Unics" (Uniplexed Information and Computing System) spelling later changed to "Unix" originally written in assembly 1973: re-written in C, so more portable Unix has evolved since then 6

Kernel "kernel" of a Unix or Unix-like system: the basics file system device drivers memory management ability to load & run programs Kernel doesn't include a user interface Unix or Unix-like system includes kernel plus: text-oriented user interface ("shell") often a GUI interface as well utility programs & libraries for accessing kernel functions other tools such as compilers 7

Linux & GNU Linux = Unix-like kernel written by Linus Torvalds GNU project = Unix-like libraries, utilities, compilers & other programs recursive acronym: "GNU's Not Unix" CASLab's "Linux" system: Linux kernel + GNU software more correctly named GNU/Linux CASLab Linux is Ubuntu verison 10 GNU & Linux are open-source software 8

How To Get To Linux 1. dual-boot machines in labs 2. install Linux on your own computer alone or dual-boot 3. putty or NXwindows to CASLab Linux machines from anywhere on the Internet 4. boot from Linux Live DVD 5. Macintosh terminal = Linux-like For 220, your scripts & programs must run on CASLab Linux. Scripts must work with bash. 9

Text vs. GUIs Older Unix systems: user communicates via a "shell" program. CLI = Command Line Interface Most newer Unix-like systems also have a GUI interface (point & click like Windows) Advantage of GUIs over CLIs? CLIs over GUIs? 10

Linux Shells "Shell" = text program for communicating with the OS Original shell: "sh" (Bourne shell) Many other versions: csh: C shell ksh: Korn shell bash: ("Bourne-again shell") For CISC 220: use bash! 11

The Shell: Make Sure You're Running Bash command: echo $SHELL result should be /bin/bash if not: use CASLab account management tool 12

Linux File System Hierarchical file system Directories (folders) contain files & other directories. Separate directory & file names with forward slash: / No device names as in Windows (a:, c:, etc.) Root of file system is /. File/Directory names are case sensitive Special file names:. : current directory.. : parent directory ~ or $HOME: your home directory Some special system files & directories start with "." Commands for moving between directories: cd, pwd, pushd, popd 13

General Structure of Linux Commands command = sequence of words, separated by spaces first word = name of command remaining words = arguments arguments starting with a dash ("-") are "flags" command may be: basic command built into shell utility program provided with GNU other program (shell script or executable program) 14

Listing File Information: ls Command arguments should be names of files and/or directories for each file: lists the file for each directory: lists contents of directory no arguments: equivalent to ls. flags: -a: include files & directories starting with "." -d: for directories, show directory itself instead of contents -l: (lower-case L) long format (lots of info) -R: list sub-directories recursively -1: (one) list each file on separate line (no columns) may combine flags: ls -al 15

Wildcards Use wildcards to specify several file names. * = any sequence of zero or more characters? = any single character [abc] = a or b or c [a-f] = single character in range a through f Note: wildcards won't match an initial "." 16

Online Command Information man command: information about command 17

More Useful Commands cat (concatenate): show contents of file less: show contents of file one screenful at a time rm: remove files cp: copy a file mv: move a file (rename) mkdir: create a directory rmdir: remove a directory exit: end current shell logout: ends Linux session (if login shell) echo > filename: creates new, empty file 18

Text Editors: Creating & Changing Files Many Linux editors nano (simple & easy, fairly limited) xemacs vim (more powerful) scite or gedit (GUI only) quick demos... 19

More than one program running at once: one is "foreground" others are "background" Many programs can be suspended with control-z Or type a command followed by "&" to run it in the background. To see a list of current jobs: jobs To switch to a background job: % + number of job or unique prefix of job name To terminate a job: kill %vim or: kill %3 Jobs 20

Three Features That Save Typing 1. filename completion 2. history 3. command-line editing All three: many options, fancy features. Basics are simple. 21

1. Filename Completion When typing arguments to a command, tab can help. Unique prefix of file name + tab: Linux completes file name. Non-unique prefix + tab: Linux adds all the characters it can guess Non-unique prefix of file name + two tabs: Linux shows you all possible choices 22

2. Bash History Facilities To repeat the last command you typed:!! To see list of last commands typed: history To see last 10 commands: history 10 To repeat command 137:!137 To repeat the most recent command that started with "ls":!ls Use up and down arrow keys to browse among previous commands. 23

3. Command-Line Editing To edit command you're currently typing: arrow keys to move within line (or ^f and ^b) type normal characters to insert before cursor delete or ^d to delete character at cursor backspace to delete character before cursor Use with up and down arrows to edit previous lines. 24

File Permissions Three kinds of permissions for a file: read write execute (if it's a program) Every file has an owner and a group. We won't be doing much with groups in 220. Permissions are set for three categories of users: the file's owner users in the file's group everyone else 25

Viewing File Permissions Example: malamb@linux4:~/demo$ ls -l game -rwxr-xr-x 1 malamb cisfac 630 2007-01-01 14:20 game all other users can read and execute other group members can read and execute owner can read, write and execute 26

Directory Permissions A directory is a special file containing pointers to other files read = can list contents of directory write = can add & remove files from directory execute = can access files in directory Example: malamb@linux4:~$ ls -ld $HOME drwx------ 34 malamb cisfac 1536 2007-01-02 11:54 /cas/staff/malamb/ No one except me can see or change my home directory. Another Example: malamb@linux4:~$ ls -ld /cas/course/cisc220 drwxr-xr-x 3 malamb cisfac 512 2007-01-01 16:18 /cas/course/cisc220/ Everyone can see & use files in this directory, but only I can add & delete files. 27

Changing File/Directory Permissions chmod command (change mode) Category of user denoted by single character: u = user who owns file g = users in file's group o = all other users Type of permission denoted by single character: r = read, w = write, x = execute To allow all users (outside the file's group) to read myfile: chmod o+r myfile To remove permission for group members to change myfile: chmod g-w myfile To set permission for group members to r&w, not x: chmod g=rw myfile 28

Protecting Your Linux Files Your assignment solutions should be read protected! One easy way: put in read-protected directory. To make sure your home directory can't be read by others: chmod go-rwx $HOME Another way: check the default protections of new files: umask S To change your default: umask go-rwx 29