CSE 391 Lecture 3. bash shell continued: processes; multi-user systems; remote login; editors

Similar documents
CSE 390a Lecture 3. bash shell continued: processes; multi-user systems; remote login; editors

CSE 391 Editing and Moving Files

CSE 390a Lecture 3. Multi-user systems; remote login; editors; users/groups; permissions

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

CSE 391 Lecture 1. introduction to Linux/Unix environment

CSE 391 Lecture 1. introduction to Linux/Unix environment

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

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

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.

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

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

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

Lab 2: Linux/Unix shell

Mills HPC Tutorial Series. Linux Basics I

Intro to Linux & Command Line

CS Fundamentals of Programming II Fall Very Basic UNIX

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]

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

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

CS 460 Linux Tutorial

Introduction to UNIX Command Line

Review of Fundamentals. Todd Kelley CST8207 Todd Kelley 1

CSE 390a Lecture 6. bash scripting continued; remote X windows; unix tidbits

Computer Systems and Architecture

CS370 Operating Systems

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

Introduction to Linux

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

Editors in Unix come in two general flavours:

CS CS Tutorial 2 2 Winter 2018

Lab 3a Using the vi editor

CSE 351. Introduction & Course Tools

Outline. Structure of a UNIX command

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

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

Linux Fundamentals (L-120)

Linux Bootcamp Fall 2015

AMS 200: Working on Linux/Unix Machines

Review of Fundamentals

CS 215 Fundamentals of Programming II Spring 2019 Very Basic UNIX

Linux Command Line Primer. By: Scott Marshall

Introduction to UNIX Shell Exercises

UNIX Quick Reference

An Introduction to Unix

CSE 390a Lecture 5. Intro to shell scripting

CSE 390a Lecture 4. Persistent shell settings; users/groups; permissions

CSCE 212H, Spring 2008, Matthews Lab Assignment 1: Representation of Integers Assigned: January 17 Due: January 22

CSE 391 Lecture 5. Intro to shell scripting

Unix/Linux Operating System. Introduction to Computational Statistics STAT 598G, Fall 2011

Introduction to Linux Workshop 1

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

Linux crash lecture by Andrey Lukyanenko

Getting started with Hugs on Linux

The Unix Shell & Shell Scripts

STA 303 / 1002 Using SAS on CQUEST

COMS 6100 Class Notes 3

LINUX FUNDAMENTALS (5 Day)

A Brief Introduction to the Linux Shell for Data Science

Connecting to ICS Server, Shell, Vim CS238P Operating Systems fall 18

CSE 390a Lecture 6. bash scripting continued; remote X windows; unix tidbits

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

CS4350 Unix Programming. Outline

CHE3935. Lecture 1. Introduction to Linux

Computer Systems and Architecture

Review of Fundamentals. Todd Kelley CST8207 Todd Kelley 1

Chap2: Operating-System Structures

LAB #5 Intro to Linux and Python on ENGR

Linux Command Line Interface. December 27, 2017

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

commands exercises Linux System Administration and IP Services AfNOG 2015 Linux Commands # Notes

CSE 390a Lecture 4. Persistent shell settings; users/groups; permissions

Practical Session 0 Introduction to Linux

The student will have the essential skills needed to be proficient at the Unix or Linux command line.

Parallel Programming Pre-Assignment. Setting up the Software Environment

Short Read Sequencing Analysis Workshop

More Raspian. An editor Configuration files Shell scripts Shell variables System admin

Exploring UNIX: Session 5 (optional)

Introduction To. Barry Grant

Exercise 1: Basic Tools

Command-line interpreters

Lab 1 Introduction to UNIX and C

An Introduction to Cluster Computing Using Newton

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

Using the Zoo Workstations

Introduction: What is Unix?

CSE 391 Lecture 10. Do anything from anywhere tools to free your choice of OS

Helpful Tips for Labs. CS140, Spring 2015

Part I. UNIX Workshop Series: Quick-Start

Getting started with Hugs on Linux

Research. We make it happen. Unix Basics. User Support Group help-line: personal:

Introduction to the shell Part II

Intermediate Programming, Spring Misha Kazhdan

Linux/Cygwin Practice Computer Architecture

Unix Workshop Aug 2014

unix intro Documentation

Introduction to Linux and Supercomputers

CS101 Linux Shell Handout

Basic Linux Command Line Interface Guide

System Administration

COSC UNIX. Textbook. Grading Scheme

Transcription:

CSE 391 Lecture 3 bash shell continued: processes; multi-user systems; remote login; editors slides created by Marty Stepp, modified by Jessica Miller and Ruth Anderson http://www.cs.washington.edu/391/ 1

Lecture summary A bit more on combining commands Processes and basic process management Connecting to remote servers (attu) multi-user environments Text editors 2

Review: Redirection and Pipes command > filename Write the output of command to filename (>> to append instead) command < filename Use filename as the input stream to command command1 command2 Use the console output of command1 as the input to command2 command1 ; command2 Run command1 and then run command2 command1 && command2 Run command1, if completed without errors then run command2 3

Tricky Examples The wc command can take multiple files: wc names.txt student.txt Can we use the following to wc on every txt file in the directory? ls *.txt wc Amongst the top 250 movies in movies.txt, display the third to last movie that contains "The" in the title when movie titles are sorted. Find the disk space usage of the man program Hints: use which and du... Does which man du work? Answers posted in lecture_commands.txt after lecture 4

Command Substitution command1 $(command2) run command2 and pass its console output to command1 as a parameter; best used when command2's output is short (one line) Finish the example! du $(which man) 5

xargs command xargs description run each line of input as an argument to a specified command xargs allows you to repeatedly run a command over a set of lines often used in conjunction with find to process each of a set of files Example: Remove all my.class files. find ~ -name *.class xargs rm Find the disk usage of man using xargs which man xargs du 6

Processes process: a program that is running (essentially) when you run commands in a shell, it launches a process for each command Process management is one of the major purposes of an OS PID: 1232 Name: ls PID: 1173 Name: gedit PID: 1343 Name: man PID: 1723 Name: Mozilla PID: 1288 Name: cp 7

Process commands command ps or jobs top kill killall description list processes being run by a user; each process has a unique integer id (PID) show which processes are using CPU/memory; also shows stats about the computer terminate a process by PID (sometimes KILL is needed) terminate several processes by name use kill or killall to stop a runaway process (infinite loop) similar to ^C hotkey, but doesn't require keyboard intervention 8

Background processes command description & ^Z fg, bg (special character) when placed at the end of a command, runs that command in the background (hotkey) suspends the currently running process resumes the currently suspended process in either the foreground or background If you run a graphical program like gedit or emacs from the shell, the shell will lock up waiting for the graphical program to finish instead, run the program in the background, so the shell won't wait: $ emacs homework1.txt & if you forget to use &, suspend emacs by hitting ^Z at the TERMINAL (NOT in emacs), then run bg from the terminal lets play around with an infinite process 9

Connecting with ssh command ssh description open a shell on a remote server Linux/Unix are built to be used in multi-user environments where several users are logged in to the same machine at the same time users can be logged in either locally or via the network You can connect to other Linux/Unix servers with ssh once connected, you can run commands on the remote server other users might also be connected; you can interact with them can connect even from other operating systems 10

The CSE attu server attu : The UW CSE department's shared Linux server (only available to CSE majors) Connect to attu by typing: ssh attu.cs.washington.edu (or ssh username@attu.cs.washington.edu if your Linux system's user name is different than your CSE user name) Students with EE accounts may use their departmental servers All UW students may use UW Linux servers. (how to activate your account) Note: There are several computers that respond as attu (to spread load), so if you want to be on the same machine as your friend, you may need to connect to attu2, attu3, etc. 11

12 Multi-user environments command whoami passwd hostname w or finger write description outputs your username changes your password outputs this computer's name/address see info about people logged in to this server send a message to another logged in user Exercise : Connect to attu, and send somebody else a message.

Network commands command links or lynx ssh sftp or scp wget curl alpine, mail description text-only web browsers (really!) connect to a remote server transfer files to/from a remote server (after starting sftp, use get and put commands) download from a URL to a file download from a URL and output to console text-only email programs 13

Text editors command description pico or nano emacs vi or vim simple editors More advanced text editor More advanced text editor you cannot run graphical programs when connected to attu (yet) so if you want to edit documents, you need to use a text-only editor most advanced Unix/Linux users learn emacs or vi I would recommend you try to pick up the basics of one of these. Your choice! 14

Aliases command alias description assigns a pseudonym to a command alias name=command must wrap the command in quotes if it contains spaces Do not put spaces on either side of the = Example: When I type q, I want it to log me out of my shell. Example: When I type ll, I want it to list all files in long format. alias q=exit alias ll="ls -la" Exercise : Make it so that typing q quits out of a shell. Exercise : Make it so that typing woman runs man. Exercise : Make it so that typing attu connects me to attu. Answers posted in lecture_commands.txt after lecture 15

Mounting remote files command sshfs description mount and interact with remote directories and files An alternate usage model to remotely connecting to servers is mounting remote directories and files and work on them locally once mounted, use remote directories and files as if they were local 16

Mounting cse homedir on VM https://www.cs.washington.edu/lab/software/homevms/linuxvm#install Create a directory in your home directory, called csehomedir: cd mkdir csehomedir Now to use that directory as a link to your CSE files on your VM: sshfs username@attu: ~/csehomedir OR sshfs username@attu.cs.washington.edu:/homes/iws/username ~/csehomedir/ It is a good idea to back up your files from your VM regularly. Actually keep your files on your CSE home directory Regularly move files from your VM to another location If you need to get a fresh VM image, you can save the files from your old VM using this procedure: "My VM Seems Broken. How Do I Recover?" https://www.cs.washington.edu/lab/software/homevms/linuxvm#faq 17

18 Remote editing Gnome's file browser and gedit text editor are capable of opening files on a remote server and editing them from your computer press Ctrl-L to type in a network location to open

My VM is Broken! https://www.cs.washington.edu/lab/software/homevms/linuxvm#install If your VM is misbehaving, first try a reboot of the VM and also of your machine. If that doesn t work, often it is easiest just to get a fresh VM image and start over (maybe you saved the.zip file you downloaded previously?) BEFORE you delete your current copy of the VM, you can save the files from your current copy of the VM using this procedure: See "My VM Seems Broken. How Do I Recover? here: https://www.cs.washington.edu/lab/software/homevms/linuxvm#faq 19

Basic Emacs Commands C- = control key M- = meta/alt key read a file into Emacs: C-x C-f save a file back to disk: C-x C-s exit Emacs permanently: C-x C-c search forward: C-s search backward: C-r scroll to next screen: C-v scroll to previous screen: M-v Undo: C-x u entity to move over backward forward character C-b C-f word M-b M-f line C-p C-n go to line beginning/end C-a C-e go to buffer beginning/end M-< M-> https://courses.cs.washington.edu/courses/cse391/17sp/handouts/emacs.pdf 20

Basic Vim Commands :w Write the current file :wq Write the current file and exit. :q! Quit without writing To change into insert mode: i or a Use escape to exit search forward /, repeat the search backwards: N Basic movement: h l k j character left, right; line up, down (also arrow keys) b w word/token left, right ge e end of word/token left, right 0 $ jump to first/last character on the line x delete u undo https://wiki.gentoo.org/wiki/vim/guide and http://tnerual.eriogerg.free.fr/vimqrc.p 21