Week 2 Lecture 3. Unix

Similar documents
Mills HPC Tutorial Series. Linux Basics I

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 Workshop 1

Introduction to the Linux Command Line

CS Fundamentals of Programming II Fall Very Basic UNIX

Outline. Structure of a UNIX command

Unix Basics. Systems Programming Concepts

Unix Filesystem. January 26 th, 2004 Class Meeting 2

Files

CS 307: UNIX PROGRAMMING ENVIRONMENT KATAS FOR EXAM 1

A Brief Introduction to Unix

Introduction to Unix: Fundamental Commands

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

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

CSE 303 Lecture 2. Introduction to bash shell. read Linux Pocket Guide pp , 58-59, 60, 65-70, 71-72, 77-80

Chapter-3. Introduction to Unix: Fundamental Commands

Introduction to Linux

Introduction: What is Unix?

Exercise Sheet 2. (Classifications of Operating Systems)

CS 215 Fundamentals of Programming II Spring 2019 Very Basic UNIX

Lab 2: Linux/Unix shell

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

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

CISC 220 fall 2011, set 1: Linux basics

Introduction to Linux

CS246 Spring14 Programming Paradigm Notes on Linux

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

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

Introduction to UNIX command-line

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

CSCI 2132 Software Development. Lecture 4: Files and Directories

Introduction to UNIX command-line II

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

Basic UNIX commands. HORT Lab 2 Instructor: Kranthi Varala

Introduction to Linux Basics

Operating Systems. Copyleft 2005, Binnur Kurt

Useful Unix Commands Cheat Sheet

CS4350 Unix Programming. Outline

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

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

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]

CSCI 2132 Software Development. Lecture 5: File Permissions

CHAPTER 1 UNIX FOR NONPROGRAMMERS

Getting your department account

Files and Directories

CSE 391 Lecture 1. introduction to Linux/Unix environment

Chapter 1 - Introduction. September 8, 2016

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

Introduction of Linux

CENG 334 Computer Networks. Laboratory I Linux Tutorial

Unix File System. Learning command-line navigation of the file system is essential for efficient system usage

UNIX COMMANDS AND SHELLS. UNIX Programming 2015 Fall by Euiseong Seo

Unix tutorial. Thanks to Michael Wood-Vasey (UPitt) and Beth Willman (Haverford) for providing Unix tutorials on which this is based.

commandname flags arguments

Working with Basic Linux. Daniel Balagué

UNIX Quick Reference

CSE 303 Lecture 4. users/groups; permissions; intro to shell scripting. read Linux Pocket Guide pp , 25-27, 61-65, , 176

Unix basics exercise MBV-INFX410

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

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

LOG ON TO LINUX AND LOG OFF

Unix Introduction to UNIX

Linux & Shell Programming 2014

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

SECTION -C. Getting Started with UNIX

CSE 391 Lecture 1. introduction to Linux/Unix environment

Introduction Into Linux Lecture 1 Johannes Werner WS 2017

EECS2301. Lab 1 Winter 2016

genome[phd14]:/home/people/phd14/alignment >

Week Overview. Unix file system File types and file naming Basic file system commands: pwd,cd,ls,mkdir,rmdir,mv,cp,rm man pages

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

Essential Linux Shell Commands

UNIX File Hierarchy: Structure and Commands

Std: XI CHAPTER-3 LINUX

Course 144 Supplementary Materials. UNIX Fundamentals

The Unix Shell. Pipes and Filters

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

Perl and R Scripting for Biologists

Introduction to the UNIX command line

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

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

Introduction to Linux Part I: The Filesystem Luca Heltai

AOS Linux Tutorial. Introduction to Linux. Michael Havas Dept. of Atmospheric and Oceanic Sciences McGill University. September 15, 2011

Linux Command Line Primer. By: Scott Marshall

The Unix Shell. Permissions

CS CS Tutorial 2 2 Winter 2018

The Linux Command Line & Shell Scripting

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

CS 3410 Intro to Unix, shell commands, etc... (slides from Hussam Abu-Libdeh and David Slater)

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

Command Line Interface The basics

Using Linux as a Virtual Machine

Oregon State University School of Electrical Engineering and Computer Science. CS 261 Recitation 1. Spring 2011

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

Intro to Linux & Command Line

Introduction to Linux

Introduction to UNIX I: Command Line 1 / 21

Introduction to Linux Part 1. Anita Orendt and Wim Cardoen Center for High Performance Computing 24 May 2017

MTU Computer Structure

Introduction to Linux

Transcription:

Lecture 3 Unix

Terminal and Shell 2

Terminal Prompt Command Argument Result 3

Shell Intro A system program that allows a user to execute: shell functions (e.g., ls -la) other programs (e.g., eclipse) shell scripts Linux/UNIX has a bunch of shell programs We will use bash 4

Typing in bash Left and right arrows move left and right Backspace and delete characters Ctrl-a: beginning of line; Ctrl-e: end of line <Tab> completes file names Always use <Tab> when typing file or command names to minimize misspelling 5

Command Format Format: command and 0 or more arguments: % commandname [arg1]... [argn] % sign represents prompt here and hereafter. Arguments can be options (switches to the command to indicate a mode of operation) ; usually prefixed with a hyphen (-) or two (--) in GNU style non-options, or operands, basically the data to work with (actual data, or a file name) 6

Command Types Shell functions: The shell executes the commands when the enter key is hit, and prints results onto the terminal. Other programs: The shell executes the compiled program. Shell scripts: Programs consisting of shell functions, other programs and shell scripts. 7

exit Exit from your terminal session. % exit Ctrl-d Close the window by clicking on the 'x' 8

Files 9

Files and directories Unix provides files and directories. A directory contains files and other directories. The directories and files are called the file system. The directory that contains all other directories is called the root directory, whose name is written /. 10

Example Every file has a name (root's name is written / Every directory has two paths Absolute paths start with the root Relative paths start from the current directory bin (/bin) dev (/dev) Directory structure home (/home) larry nat (/home/nat or ~) classes (/home/nat/classes) adobe-air.sh (/home/nat/adobe-air.sh) 11

Permissions Every file and directory have a set of permission for: Self: what the file owner can do Group: what the file's group can do All: what everyone can do Each set of permission has three settings Read: the person or group can read the file Write: the person or group can write the file Execute: the person or group can execute the file 12

Permission example drwxrwxr-x 17 nat nat 4096 May 28 09:29 sp Directory Self: read write execute permissions Group: read write execute permissions All: read execute permissions Owner is nat Group is nat Last touched on May 28 9:29 AM Directory name is sp 13

Wild Cards You can refer to files and directories using the wild cards: * and?. * matches any string of characters a*z matches abz, abbz, abcdez, and azzz but not abcza az* matches azzz, aza but not abz? matches a single character a?z matches abz, and acz, but not abbz, or abza 14

Execute Permission Files: execute means the file is a command Directories: execute means the user can see the contents 15

File Commands 16

Print Working Directory: pwd Prompt Me Computer Directory Command: pwd Current directory Next Prompt 17

Directory contents: ls Prompt Me Computer Directory Command: ls Directory contents Next Prompt 18

ls List directory contents Has whole bunch of options, see man ls for details. % ls all files except those starting with a. % ls -a all % ls -A all without. and.. % ls -F append / to dirs and * to executables % ls -l long format % ls -al % ls -lt sort by modification time (latest - earliest) % ls -ltr reverse 19

Finding Permission: ls -l The -l parameter displays permissions 20

Seeing hidden files: ls -a The -a parameter display files that start with a '.' '.' is the name of the current directory '..' is the name of the parent directory 21

cat Display and concatenate files. % cat Will read from STDIN and print to STDOT every line you enter. % cat file1 [file2]... Will concatenate all files in one and print them to STDOUT % cat > filename Will take whatever you type from STDIN and will put it into the file filename To exit cat or cat > filename type Ctrl+D to indicate EOF (End of File). 22

more / less Pagers to display contents of large files page by page or scroll line by line up and down. Have a lot of viewing options and search capability. Interactive. To exit: q 23

less less ("less is more") smarter than the more command to display contents of a file: % less filename To display line numbers: % less -N filename To display a prompt: % less -P"Press 'q' to quit" filename Combine the two: % less -NP"Blah-blah-blah" filename For more information: % man less 24

touch By touching a file you either create it if it did not exists (with 0 length). Or you update it s last modification and access times. There are options to override the default behavior. % touch file % man touch 25

cp Copies files / directories. % cp [options] <source> <destination> % cp file1 file2 % cp file1 [file2] /directory Useful option: -i to prevent overwriting existing files and prompt the user to confirm. -r to copy a directory and all of its contents 26

mv Moves or renames files/directories. % mv <source> <destination> The <source> gets removed % mv file1 dir/ % mv file1 file2 rename % mv file1 file2 dir/ % mv dir1 dir2 27

rm Removes file(s) and/or directories. % rm file1 [file2]... % rm -r dir1 [dir2]... % rm -r file1 dir1 dir2 file4 -r option removes directory and all of its contents 28

mkdir Creates a directory. % mkdir newdir Often people make an alias of md for it. 29

cd Changes your current directory to a new one. % cd /some/other/dir Absolute path % cd subdir Assuming subdir is in the current directory. % cd Returns you to your home directory. 30

rmdir Removes a directory. % rmdir dirname Almost equivalent: % rm -r dirname rmdir will complain if the file isn't empty rm -r will not. 31

ln Symbolic link or a shortcut. % ln s <real-name> <fake-name> 32

chmod Changes file permissions Possible invocations % chmod 600 filename -rw------- 1 user group 2785 Feb 8 14:18 filename % chmod u+rw filename the same thing, more readable For the assignment: % chmod u+x myshellscript (mysshellscript is now executable) -rwx------ 1 user group 2785 Feb 8 14:18 myshellscript 33

Why does 600 = rw-? Permissions are represented as an octal number (i.e., 3 bits) r: 4 w: 2 x: 1 600 is self rw or 4+2, 0, 0 755 is rwxr-xr-x or 4+2+1, 4+0+1, 4+0+1 Common directory permissions 644 is rw-r r-- or 4+2, 4, 4 Common file permissions 34