CSE 374 Programming Concepts & Tools Hal Perkins Fall 2015 Lecture 2a – A Unix Command Sampler (Courtesy of David Notkin, CSE 303)

Slides:



Advertisements
Similar presentations
David Notkin Autumn 2009 CSE303 Lecture 2 Dictionary.com, "bash," in Dictionary.com Unabridged. Source location: Random House, Inc.
Advertisements

Introduction to UNIX CSE 2031 Fall May 2015.
NETW-240 Shells Last Update Copyright Kenneth M. Chipps Ph.D. 1.
David Notkin Autumn 2009 CSE303 Lecture 3 Dictionary.com, “shell," in Dictionary.com Unabridged. Source location: Random House, Inc.
1 CSE 390a Lecture 1 introduction to Linux/Unix environment slides created by Marty Stepp, modified by Josh Goodwin
1 CSE 390a Lecture 2 Exploring Shell Commands, Streams, and Redirection slides created by Marty Stepp, modified by Josh Goodwin
CSE 303 Lecture 2 Introduction to bash shell
CS 141 Labs are mandatory. Attendance will be taken in each lab. Make account on moodle. Projects will be submitted via moodle.
Introduction to Linux Workshop February Introduction Rob Lane & The HPC Support Team Research Computing Services CUIT.
Chapter 9 Part II Linux Command Line Access to Linux Authenticated login using a Linux account is required to access a Linux system. The Linux prompt will.
INTRODUCTION TO LINUX Jacob Chan. GNU/Linux Consists of Linux kernel, GNU utilities, and open source and commercial applications Works like Unix –Multi-user.
Second edition Your UNIX: The Ultimate Guide Das © 2006 The McGraw-Hill Companies, Inc. All rights reserved. UNIX Commands cal – will print a calendar.
Introduction to UNIX Road Map: 1. UNIX Structure 2. Components of UNIX 3. Process Structure 4. Shell & Utility Programs 5. Using Files & Directories 6.
BIF713 Basic Unix/Linux Commands Getting Help with Commands.
1 CSE 303 Lecture 3 bash shell continued: processes; multi-user systems; combining commands read Linux Pocket Guide pp , , , 118, 122,
Agenda Basic Unix Commands (Chapters 2 & 3) Miscellaneous Commands: whereis, which, whoami, finger, passwd, cal, date Working with Files: cat, more, less.
1 CSE 390a Lecture 1 introduction to Linux/Unix environment slides created by Marty Stepp, modified by Jessica Miller & Ruth Anderson
1 CSE 390a Lecture 1 introduction to Linux/Unix environment slides created by Marty Stepp, modified by Jessica Miller & Ruth Anderson
Agenda Basic Unix Commands (Chapters 2 & 3) Miscellaneous Commands: which, passwd, date, ps / kill Working with Files: file, touch, cat, more, less, grep,
Linux Commands C151 Multi-User Operating Systems.
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.
Lecture 1: Introduction, Basic UNIX Advanced Programming Techniques.
1 CSE 390a Lecture 2 Exploring Shell Commands, Streams, and Redirection slides created by Marty Stepp, modified by Jessica Miller & Ruth Anderson
introduction to Linux/Unix environment
Linux Tutorial Lesson Two *Getting Help in Linux *Data movement and manipulation *Relative and Absolute path *Processes Note: see chapter 1,2,3 from Linux.
1 CSE 390a Lecture 3 bash shell continued: processes; multi-user systems; remote login; editors slides created by Marty Stepp, modified by Jessica Miller.
Learning Unix/Linux Based on slides from: Eric Bishop.
Exploring Shell Commands, Streams, and Redirection
introduction to Linux/Unix environment
Linux Commands Help HANDS ON TRAINING Author: Muhammad Laique
introduction to Linux/Unix environment
Some Linux Commands.
C151 Multi-User Operating Systems
introduction to Linux/Unix environment
Agenda Basic Unix Commands (Chapters 2 & 3) Miscellaneous Commands:
Exploring Shell Commands, Streams, and Redirection
CSE 374 Programming Concepts & Tools
introduction to Linux/Unix environment
Exploring Shell Commands, Streams, and Redirection
Basic UNIX OLC Training.
Introduction to UNIX.
CSE 390a Lecture 2 Exploring Shell Commands, Streams, and Redirection
CSE 390a Lecture 1 introduction to Linux/Unix environment
CSE 390a Lecture 3 bash shell continued: processes; multi-user systems; remote login; editors slides created by Marty Stepp, modified by Jessica Miller.
Exploring Shell Commands, Streams, and Redirection
Exploring Shell Commands, Streams, and Redirection
Exploring Shell Commands, Streams, and Redirection
CSE 390a Lecture 1 introduction to Linux/Unix environment
introduction to Linux/Unix environment
Exploring Shell Commands, Streams, Redirection, and Processes
CSE 390a Lecture 2 Exploring Shell Commands, Streams, and Redirection
introduction to Linux/Unix environment
CSE 390a Lecture 3 bash shell continued: processes; multi-user systems; remote login; editors slides created by Marty Stepp, modified by Jessica Miller.
Linux Shell Script Programming
CSE 391 Lecture 3 bash shell continued: processes; multi-user systems; remote login; editors slides created by Marty Stepp, modified by Jessica Miller.
CSE 303 Concepts and Tools for Software Development
CSE 390a Lecture 3 bash shell continued: processes; multi-user systems; remote login; editors slides created by Marty Stepp, modified by Jessica Miller.
CSE 390a Lecture 3 bash shell continued: processes; multi-user systems; remote login; editors slides created by Marty Stepp, modified by Jessica Miller.
introduction to Linux/Unix environment
CSE 390a Lecture 3 bash shell continued: processes; multi-user systems; remote login; editors slides created by Marty Stepp, modified by Jessica Miller.
Module 6 Working with Files and Directories
CSE 391 Lecture 3 bash shell continued: processes; multi-user systems; remote login; editors slides created by Marty Stepp, modified by Jessica Miller.
introduction to Linux/Unix environment
introduction to Linux/Unix environment
introduction to Linux/Unix environment
Exploring Shell Commands, Streams, and Redirection
Exploring Shell Commands, Streams, and Redirection
Exploring Shell Commands, Streams, and Redirection
introduction to Linux/Unix environment
Exploring Shell Commands, Streams, and Redirection
Presentation transcript:

CSE 374 Programming Concepts & Tools Hal Perkins Fall 2015 Lecture 2a – A Unix Command Sampler (Courtesy of David Notkin, CSE 303)

Command line arguments Most options are given after the command name using a dash followed by a letter: -c, -h, -S, … Some options are longer words preceded by two dashes: --count, --help Parameters can be combined: ls -l -a -r can be ls –lar Many programs accept a –help parameter; others provide help if run with no arguments Many commands accept a file name parameter; if it is omitted, the program will read from standard input 2

Directory commands commanddescription ls list files in a directory pwd output the current working directory cd change the working directory mkdir create a new directory rmdir delete a directory (must be empty) 3

Relative naming directorydescription. the directory you are in ("working directory").. the parent of the working directory (../.. is grandparent, etc.) ~ your home directory (on many systems, this is /home/username ) ~username username 's home directory ~/Desktop your desktop 4

Shell/system commands "man pages" are a very important way to learn new commands commanddescription man or info get help on a command apropos (man –k) search for commands by keyword clear clears out the output from the console exit exits and logs out of the shell commanddescription date output the system date/time cal output a text calendar uname print information about the current system 5

File commands CAUTION: the above commands do not prompt for confirmation, so it’s easy to overwrite/delete a file This setting can be overridden (how?) commanddescription cp copy a file mv move or rename a file rm delete a file touch update a file’s last-modified time stamp (or create a new empty file) 6

File examination Suppose you are writing a paper, and the teacher says it can be anything as long as it is at least 200 words long and mentions chocolate... commanddescription cat output a file's contents on the console more, less output a file's contents, one page at a time head, tail output the first or last few lines of a file wc count words, characters, and lines in a file du report disk space used by a file(s) diff compare two files and report differences 7

Searching and sorting grep is a very powerful search tool; more later... Exercise : Given a text file students.txt, display the students arranged by the reverse alphabetical order of their last names. –Can we display them sorted by first name? commanddescription grep search a file for a given string sort convert an input into a sorted output by lines uniq strip duplicate lines find search for files within a given directory locate search for files on the entire system which shows the complete path of a command 8

Keyboard shortcuts ^KEY means hold Ctrl and press KEY keydescription Up arrow repeat previous commands Home / End or ^A / ^E move to start/end of current line " quotes surround multi-word arguments and arguments containing special characters * "wildcard", matches any files; can be used as a prefix, suffix, or partial name Tab auto-completes a partially typed file/command name ^C or ^\ terminates the currently running process ^D end of input; used when a program is reading input from your keyboard and you are finished typing ^Z suspends (pauses) the currently running process ^S don't use this; hides all output until ^G is pressed 9

File system directorydescription / root directory that contains all others (drives do not have letters in Unix) /bin programs /dev hardware devices /etc system configuration files  /etc/passwd stores user info  /etc/shadow stores passwords /home users' home directories /media,/mnt,... drives and removable disks that have been "mounted" for use on this computer /proc currently running processes (programs) /tmp, /var temporary files /usr user-installed programs 10

Process commands commanddescription ps list processes being run by a user; each process has a unique integer id (PID) top show which processes are using CPU/memory; also shows stats about the computer Keeps executing until killed! kill terminate a process by PID killall terminate processes by name use kill or killall to stop a runaway process (infinite loop) similar to ^C hotkey 11

Background processes You would like some processes to continue while you are doing other things – maybe your editor, maybe a browser, etc. You can do this by running some processes “in the background”, so the shell doesn’t have to wait until those processes finish; ex: $ emacs & If you forget to use &, suspend your process with ^Z, then run bg commanddescription & (special character) when placed at the end of a command, runs that command in the background ^Z (hotkey) suspends the currently running process fg bg resumes the currently suspended process in either the foreground or background 12