A Brief Introduction to Unix

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

Mills HPC Tutorial Series. Linux Basics I

commandname flags arguments

Chapter-3. Introduction to Unix: Fundamental Commands

Unix Filesystem. January 26 th, 2004 Class Meeting 2

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

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

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 Unix: Fundamental Commands

You will automatically be in your user (home) directory when you login.

Introduction of Linux

Introduction: What is Unix?

Week 2 Lecture 3. Unix

Introduction to the Linux Command Line

CSCI 2132 Software Development. Lecture 4: Files and Directories

Introduction to Linux

CHAPTER 1 UNIX FOR NONPROGRAMMERS

Getting your department account

Unix Basics. Systems Programming Concepts

Getting started with Hugs on Linux

CS Fundamentals of Programming II Fall Very Basic UNIX

Files

5/20/2007. Touring Essential Programs

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

Getting started with Hugs on Linux

Introduction to remote command line Linux. Research Computing Team University of Birmingham

Perl and R Scripting for Biologists

Introduction to Linux

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

Lab 2: Linux/Unix shell

Linux Shell Script. J. K. Mandal

Welcome to getting started with Ubuntu Server. This System Administrator Manual. guide to be simple to follow, with step by step instructions

Course 144 Supplementary Materials. UNIX Fundamentals

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

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

UNIX File Hierarchy: Structure and Commands

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.

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).

Useful Unix Commands Cheat Sheet

Files and Directories

CS 215 Fundamentals of Programming II Spring 2019 Very Basic UNIX

SECTION -C. Getting Started with UNIX

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

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

Linux Command Line Primer. By: Scott Marshall

Outline. Structure of a UNIX command

Commands are in black

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

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

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

Unix Workshop Aug 2014

The Unix Shell. Pipes and Filters

Operating Systems. Copyleft 2005, Binnur Kurt

CENG 334 Computer Networks. Laboratory I Linux Tutorial

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

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

CISC 220 fall 2011, set 1: Linux basics

Introduction to Linux

CSE 390a Lecture 2. Exploring Shell Commands, Streams, Redirection, and Processes

Introduction to the UNIX command line

CS197U: A Hands on Introduction to Unix

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

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

CS4350 Unix Programming. Outline

EECS2301. Lab 1 Winter 2016

Practical Session 0 Introduction to Linux

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

Introduction to Linux

LAB 8 (Aug 4/5) Unix Utilities

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

Open up a terminal, make sure you are in your home directory, and run the command.

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

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

Introduction to UNIX. Introduction EECS l UNIX is an operating system (OS). l Our goals:

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

Oxford University Computing Services. Getting Started with Unix

Computer Systems and Architecture

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

Introduction to Linux Basics

Introduction to UNIX. Introduction. Processes. ps command. The File System. Directory Structure. UNIX is an operating system (OS).

Introduction to UNIX. CSE 2031 Fall November 5, 2012

CSE 390a Lecture 2. Exploring Shell Commands, Streams, and Redirection

Lec 1 add-on: Linux Intro

Introduction to Linux. Roman Cheplyaka

The Linux Command Line & Shell Scripting

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

Introduction to UNIX command-line

A Brief Introduction to the Linux Shell for Data Science

Essential Linux Shell Commands

UNIX Quick Reference

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

Multiple Choice - 58 Questions - 10 of 15%

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

Unix basics exercise MBV-INFX410

M.C.A. (Sem.-lll) (CBCS) Examination November CCA-3003 Operating System and LinuxlUnix programming

LOG ON TO LINUX AND LOG OFF

Introduction to UNIX Command Line

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

Computer Systems and Architecture

Transcription:

A Brief Introduction to Unix Sean Barag <sjb89@drexel.edu> Drexel University March 30, 2011 Sean Barag (Drexel University) CS 265 - A Brief Introduction to Unix March 30, 2011 1 / 17

Outline 1 Directories 2 Commands 3 Editors 4 Using the Unix Shell 5 Permissions 6 Moving Forward Sean Barag (Drexel University) CS 265 - A Brief Introduction to Unix March 30, 2011 2 / 17

Outline 1 Directories 2 Commands 3 Editors 4 Using the Unix Shell 5 Permissions 6 Moving Forward Sean Barag (Drexel University) CS 265 - A Brief Introduction to Unix March 30, 2011 2 / 17

Outline 1 Directories 2 Commands 3 Editors 4 Using the Unix Shell 5 Permissions 6 Moving Forward Sean Barag (Drexel University) CS 265 - A Brief Introduction to Unix March 30, 2011 2 / 17

Outline 1 Directories 2 Commands 3 Editors 4 Using the Unix Shell 5 Permissions 6 Moving Forward Sean Barag (Drexel University) CS 265 - A Brief Introduction to Unix March 30, 2011 2 / 17

Outline 1 Directories 2 Commands 3 Editors 4 Using the Unix Shell 5 Permissions 6 Moving Forward Sean Barag (Drexel University) CS 265 - A Brief Introduction to Unix March 30, 2011 2 / 17

Outline 1 Directories 2 Commands 3 Editors 4 Using the Unix Shell 5 Permissions 6 Moving Forward Sean Barag (Drexel University) CS 265 - A Brief Introduction to Unix March 30, 2011 2 / 17

Basics In Unix, everything is considered a file, even directories! Forward slash (/) instead of backslash (\) Root directory / Home directory ~ Current directory. or./ Parent directory.. or../ Windows Unix C:\Documents and Settings\[user]\Desktop\Presentation.pdf /home/[user]/desktop/presentation.pdf or ~/Desktop/Presentation.pdf Sean Barag (Drexel University) CS 265 - A Brief Introduction to Unix March 30, 2011 3 / 17

Basics In Unix, everything is considered a file, even directories! Forward slash (/) instead of backslash (\) Root directory / Home directory ~ Current directory. or./ Parent directory.. or../ Windows Unix C:\Documents and Settings\[user]\Desktop\Presentation.pdf /home/[user]/desktop/presentation.pdf or ~/Desktop/Presentation.pdf Sean Barag (Drexel University) CS 265 - A Brief Introduction to Unix March 30, 2011 3 / 17

Interesting Directories / Root Directory /bin Executable programs /dev Device Files /etc System-level configuration files /lib Essential libraries /opt Packages and software not typically part of the system /tmp Temporary files (Cleaned on restart) /usr User file system /usr/man Manuals /usr/src Source code for utilities and libraries Sean Barag (Drexel University) CS 265 - A Brief Introduction to Unix March 30, 2011 4 / 17

How to Get Help man an interface to the on-line reference manuals Nearly every command has an entry (if not, try -h or --help) Typically: Synopsis Description Options Defaults Examples References Related Commands Sean Barag (Drexel University) CS 265 - A Brief Introduction to Unix March 30, 2011 5 / 17

How to Get Help man an interface to the on-line reference manuals Nearly every command has an entry (if not, try -h or --help) Typically: Synopsis Description Options Defaults Examples References Related Commands Sean Barag (Drexel University) CS 265 - A Brief Introduction to Unix March 30, 2011 5 / 17

Working with Directories Command pwd cd [path] mkdir [path] rmdir [path] Action Prints present working directory (where you are) Change directory Makes directory Removes an empty directory Sean Barag (Drexel University) CS 265 - A Brief Introduction to Unix March 30, 2011 6 / 17

Working with Files Command ls cp [foo] [bar] mv [foo] [bar] rm [foo] cat [foo] wc [foo] Action List names of all files in the current directory Copy foo to bar, overwrites bar if it exists Moves foo to bar, overwrites bar if it exists Removes named files Prints contents of a file to the command line Counts lines, words, and characters for any named files There is no Recycle Bin, unless you specifically set one up! Sean Barag (Drexel University) CS 265 - A Brief Introduction to Unix March 30, 2011 7 / 17

Options for ls and Pattern Matching Option Result [none] All the files in the current directory -t Sorts by date modified (most recent first) -u Same as -t, but sorts by time of last use -l Shows results as a detailed list -r Uses reverse order when sorting -a Show all, including hidden files Command Result ls foo Show the file foo ls * Show all the files ls *.pdf Show all files who s filename ends with.pdf ls b[aeiou]n Show any file with name ban, ben, bin, bon, or bun ls?ob Show any file that ends with ob and has one character before that. ls *.mp[345] Show all files that end in.mp3,.mp4, or.mp5 Many others, and you can use any of the above options with these Sean Barag (Drexel University) CS 265 - A Brief Introduction to Unix March 30, 2011 8 / 17

Options for ls and Pattern Matching Option Result [none] All the files in the current directory -t Sorts by date modified (most recent first) -u Same as -t, but sorts by time of last use -l Shows results as a detailed list -r Uses reverse order when sorting -a Show all, including hidden files Command Result ls foo Show the file foo ls * Show all the files ls *.pdf Show all files who s filename ends with.pdf ls b[aeiou]n Show any file with name ban, ben, bin, bon, or bun ls?ob Show any file that ends with ob and has one character before that. ls *.mp[345] Show all files that end in.mp3,.mp4, or.mp5 Many others, and you can use any of the above options with these Sean Barag (Drexel University) CS 265 - A Brief Introduction to Unix March 30, 2011 8 / 17

Working with Files (cont d) Command grep [pattern] [foo] grep -v [pattern] [foo] tail [foo] tail -n [foo] tail +n [foo] cmp [foo] [bar] diff [foo] [bar] Result Print lines in foo matching a pattern Print lines in foo that don t match the pattern Print last 10 lines of foo Print last n lines of foo Start printing foo at line n Print location of the first difference Print all of the differences Sean Barag (Drexel University) CS 265 - A Brief Introduction to Unix March 30, 2011 9 / 17

Editors vi vim emacs nano Very minimal, installed on nearly every Unix/Linux machine by default Vi IMproved. Much easier to use, also installed on nearly every Unix/Linux machine by default. Extensible and very customizable. More feature-packed than vi/vim. Extensible, very customizable, and very powerful. Installed on most Unix/Linux machines by default. Very simple to use, but at the cost of extensibility and features. Sean Barag (Drexel University) CS 265 - A Brief Introduction to Unix March 30, 2011 10 / 17

Editors vi vim emacs nano Very minimal, installed on nearly every Unix/Linux machine by default Vi IMproved. Much easier to use, also installed on nearly every Unix/Linux machine by default. Extensible and very customizable. More feature-packed than vi/vim. Extensible, very customizable, and very powerful. Installed on most Unix/Linux machines by default. Very simple to use, but at the cost of extensibility and features. Sean Barag (Drexel University) CS 265 - A Brief Introduction to Unix March 30, 2011 10 / 17

Editors vi vim emacs nano Very minimal, installed on nearly every Unix/Linux machine by default Vi IMproved. Much easier to use, also installed on nearly every Unix/Linux machine by default. Extensible and very customizable. More feature-packed than vi/vim. Extensible, very customizable, and very powerful. Installed on most Unix/Linux machines by default. Very simple to use, but at the cost of extensibility and features. Sean Barag (Drexel University) CS 265 - A Brief Introduction to Unix March 30, 2011 10 / 17

Editors vi vim emacs nano Very minimal, installed on nearly every Unix/Linux machine by default Vi IMproved. Much easier to use, also installed on nearly every Unix/Linux machine by default. Extensible and very customizable. More feature-packed than vi/vim. Extensible, very customizable, and very powerful. Installed on most Unix/Linux machines by default. Very simple to use, but at the cost of extensibility and features. Sean Barag (Drexel University) CS 265 - A Brief Introduction to Unix March 30, 2011 10 / 17

Reserved/Special Characters bar > foo bar >> foo bar < foo bar foo bar ; foo bar & foo bar & (foo ; bar) Directs the standard output (stdout) of bar to foo Append stdout of bar to foo Executes bar with foo as the input Executes foo with it s input as the output of bar Runs bar. When it finishes, runs foo Run bar, but don t wait for it to finish to run foo Run bar in the background, freeing the terminal Run foo and bar as a sub-shell, treating their output as one. Sean Barag (Drexel University) CS 265 - A Brief Introduction to Unix March 30, 2011 11 / 17

Arguments and Macros Consider the command: mkdir alice bob chuck Macro Meaning Value $0 Command name mkdir $1 Argument 1 alice $2 Argument 2 bob $* All arguments alice bob chuck $# Number of arguments 3 # Rest of the line is a comment [none] Sean Barag (Drexel University) CS 265 - A Brief Introduction to Unix March 30, 2011 12 / 17

Arguments and Macros Consider the command: mkdir alice bob chuck Macro Meaning Value $0 Command name mkdir $1 Argument 1 alice $2 Argument 2 bob $* All arguments alice bob chuck $# Number of arguments 3 # Rest of the line is a comment [none] Sean Barag (Drexel University) CS 265 - A Brief Introduction to Unix March 30, 2011 12 / 17

Key Combos ˆc Stop the running process, returning to shell (process can prevent this) ˆz Pause the running process, returning to shell (resume with fg ) ˆ\ Kill whatever process is running (process can t stop this) ˆr Reverse command search through your history ˆl Clears the terminal window (same as the clear command)!! Macro for the previously run command!$ Macro for the previous argument Sean Barag (Drexel University) CS 265 - A Brief Introduction to Unix March 30, 2011 13 / 17

Permissions What can t you do? Permissions described two ways: letter combo or octal string for each type of user Owner Other users in the owner s group Users not in the owner s group Letter combo: rwx (Read, Write, Execute) Read (r) - can read the file Write (w) - can make changes or remove the file Execute (x) - Can execute the program contained in the file or execute the script rwxr-xr-x = Owner can do all, everyone else can read and execute Sean Barag (Drexel University) CS 265 - A Brief Introduction to Unix March 30, 2011 14 / 17

Permissions What can t you do? Permissions described two ways: letter combo or octal string for each type of user Owner Other users in the owner s group Users not in the owner s group Letter combo: rwx (Read, Write, Execute) Read (r) - can read the file Write (w) - can make changes or remove the file Execute (x) - Can execute the program contained in the file or execute the script rwxr-xr-x = Owner can do all, everyone else can read and execute Sean Barag (Drexel University) CS 265 - A Brief Introduction to Unix March 30, 2011 14 / 17

Permissions What can t you do? Permissions described two ways: letter combo or octal string for each type of user Owner Other users in the owner s group Users not in the owner s group Letter combo: rwx (Read, Write, Execute) Read (r) - can read the file Write (w) - can make changes or remove the file Execute (x) - Can execute the program contained in the file or execute the script rwxr-xr-x = Owner can do all, everyone else can read and execute Sean Barag (Drexel University) CS 265 - A Brief Introduction to Unix March 30, 2011 14 / 17

Permissions What can t you do? (cont d) Octal string: rwx represented in binary Value r w x Permission 0 0 0 0 No permissions (Most restrictive) 1 0 0 1 Only execute permissions 2 0 1 0 Only write permissions 3 0 1 1 Write and execute permissions 4 1 0 0 Read-only permissions..... 7 1 1 1 All permissions (Most permissive) One octal value for each group. 755 = Owner can do all, everyone else can read and execute Sean Barag (Drexel University) CS 265 - A Brief Introduction to Unix March 30, 2011 15 / 17

Permissions What can t you do? (cont d) Octal string: rwx represented in binary Value r w x Permission 0 0 0 0 No permissions (Most restrictive) 1 0 0 1 Only execute permissions 2 0 1 0 Only write permissions 3 0 1 1 Write and execute permissions 4 1 0 0 Read-only permissions..... 7 1 1 1 All permissions (Most permissive) One octal value for each group. 755 = Owner can do all, everyone else can read and execute Sean Barag (Drexel University) CS 265 - A Brief Introduction to Unix March 30, 2011 15 / 17

Changing Permissions chmod change the file mode bits Simplest method is octal string: chmod 755 foo.pdf Must be the file s owner to do this, unless you are the root user (su). Still restrictions with su. Sean Barag (Drexel University) CS 265 - A Brief Introduction to Unix March 30, 2011 16 / 17

Changing Permissions chmod change the file mode bits Simplest method is octal string: chmod 755 foo.pdf Must be the file s owner to do this, unless you are the root user (su). Still restrictions with su. Sean Barag (Drexel University) CS 265 - A Brief Introduction to Unix March 30, 2011 16 / 17

Changing Permissions chmod change the file mode bits Simplest method is octal string: chmod 755 foo.pdf Must be the file s owner to do this, unless you are the root user (su). Still restrictions with su. Sean Barag (Drexel University) CS 265 - A Brief Introduction to Unix March 30, 2011 16 / 17

Customization ~/.bashrc (launch of terminal) and ~/.bash_profile (login) Aliasing Settings Colors Anything you find useful Sean Barag (Drexel University) CS 265 - A Brief Introduction to Unix March 30, 2011 17 / 17