CSE 374 Programming Concepts & Tools

Slides:



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

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 Jacob Chan. GNU/Linux Consists of Linux kernel, GNU utilities, and open source and commercial applications Works like Unix –Multi-user.
Introduction to UNIX Road Map: 1. UNIX Structure 2. Components of UNIX 3. Process Structure 4. Shell & Utility Programs 5. Using Files & Directories 6.
1 CSE 303 Lecture 3 bash shell continued: processes; multi-user systems; combining commands read Linux Pocket Guide pp , , , 118, 122,
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,
CSE 374 Programming Concepts & Tools Hal Perkins Fall 2015 Lecture 2a – A Unix Command Sampler (Courtesy of David Notkin, CSE 303)
Linux Commands C151 Multi-User Operating Systems.
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
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.
Exploring Shell Commands, Streams, and Redirection
introduction to Linux/Unix environment
slides created by Marty Stepp, modified by Josh Goodwin
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
Linux Commands Help HANDS ON TRAINING Author: Muhammad Laique
introduction to Linux/Unix environment
introduction to Linux/Unix environment
CSE 391 Lecture 3 bash shell continued: processes; multi-user systems; remote login; editors slides created by Marty Stepp, modified by Jessica Miller.
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
introduction to Linux/Unix environment
Exploring Shell Commands, Streams, and Redirection
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.
CSE 391 Lecture 3 bash shell continued: processes; multi-user systems; remote login; editors slides created by Marty Stepp, modified by Jessica Miller.
slides created by Marty Stepp, modified by Jessica Miller
Exploring Shell Commands, Streams, and Redirection
CSE 391 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
CSE 390a Lecture 1 introduction to Linux/Unix environment
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
slides created by Marty Stepp, modified by Jessica Miller
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
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
CSE 391 Lecture 3 bash shell continued: processes; multi-user systems; remote login; editors slides created by Marty Stepp, modified by Jessica Miller.
Presentation transcript:

CSE 374 Programming Concepts & Tools Hal Perkins Winter 2017 Lecture 2a – A Unix Command Sampler (Courtesy of David Notkin) UW CSE 374 Winter 2017

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 Options often can be combined: ls -l -a -r can be ls –lar Many programs accept –-help; 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 UW CSE 374 Winter 2017

Directory commands command description 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) UW CSE 374 Winter 2017

Relative naming directory description . 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 UW CSE 374 Winter 2017

Shell/system commands description 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 command description date output the system date/time cal output a text calendar uname print information about the current system "man pages" are a very important way to learn new commands UW CSE 374 Winter 2017

File commands command description 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) CAUTION: the above commands do not prompt for confirmation, so it’s easy to overwrite/delete a file This setting can be overridden (how?) UW CSE 374 Winter 2017

File examination command description 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 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... UW CSE 374 Winter 2017

Searching and sorting command description 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 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? UW CSE 374 Winter 2017

^KEY means hold Ctrl and press KEY Keyboard shortcuts ^KEY means hold Ctrl and press KEY key description 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

File system directory description / 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 UW CSE 374 Winter 2017

Process commands command description 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 Exercise: Modify your Java program so that it produces infinite output. Compile and run it; your terminal is now stuck in an infinite loop. Find 2 or 3 ways to get out of this loop and stop the program from running. use kill or killall to stop a runaway process (infinite loop) similar to ^C hotkey UW CSE 374 Winter 2017

Background processes command description & (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 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 UW CSE 374 Winter 2017