CS197U: A Hands on Introduction to Unix

Similar documents
CS197U: A Hands on Introduction to Unix

CS197U: A Hands on Introduction to Unix

Introduction to Linux. Roman Cheplyaka

Part 1: Basic Commands/U3li3es

Perl and R Scripting for Biologists

Computer Systems and Architecture

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

Introduction to Linux

Useful Unix Commands Cheat Sheet

CS197U: A Hands on Introduction to Unix

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

CSC209H Lecture 1. Dan Zingaro. January 7, 2015

Read the relevant material in Sobell! If you want to follow along with the examples that follow, and you do, open a Linux terminal.

CS197U: A Hands on Introduction to Unix

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

First of all, these notes will cover only a small subset of the available commands and utilities, and will cover most of those in a shallow fashion.

Scripting Languages Course 1. Diana Trandabăț

Exercise 1: Basic Tools

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

Lab 2: Linux/Unix shell

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

Introduction Into Linux Lecture 1 Johannes Werner WS 2017

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

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

Essential Unix and Linux! Perl for Bioinformatics, ! F. Pineda

Introduction to UNIX Command Line

Introduction to UNIX command-line

Linux Command Line Interface. December 27, 2017

Introduction to Linux

Command-line interpreters

Shell. SSE2034: System Software Experiment 3, Fall 2018, Jinkyu Jeong

DAVE LIDDAMENT INTRODUCTION TO BASH

Introduction to Unix: Fundamental Commands

The UNIX Shells. Computer Center, CS, NCTU. How shell works. Unix shells. Fetch command Analyze Execute

Introduction of Linux

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

Introduction: What is Unix?

Unix Basics. Benjamin S. Skrainka University College London. July 17, 2010

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

Mastering Linux. Paul S. Wang. CRC Press. Taylor & Francis Group. Taylor & Francis Croup an informa business. A CHAPMAN St HALL BOOK

Introduction to the shell Part II

Computer Systems and Architecture

Lecture 3. Unix. Question? b. The world s best restaurant. c. Being in the top three happiest countries in the world.

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

Embedded Linux Systems. Bin Li Assistant Professor Dept. of Electrical, Computer and Biomedical Engineering University of Rhode Island

Linux Systems Administration Getting Started with Linux

Introduction. File System. Note. Achtung!

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

Operating Systems Lab 1 (Users, Groups, and Security)

CS370 Operating Systems

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.

The Unix Shell & Shell Scripts

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

Unix Tools / Command Line

Linux for Beginners. Windows users should download putty or bitvise:

System Administration

UNIX Quick Reference

LOG ON TO LINUX AND LOG OFF

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

Introduction to Linux

CSC209. Software Tools and Systems Programming.

Introduction to the Linux Command Line

Recitation #1 Unix Boot Camp. August 29th, 2017

Files

Unix as a Platform Exercises. Course Code: OS-01-UNXPLAT

CS 460 Linux Tutorial

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

Introduction to Linux

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

Introduction to Linux

A Brief Introduction to the Linux Shell for Data Science

Unix Filesystem. January 26 th, 2004 Class Meeting 2

Mid Term from Feb-2005 to Nov 2012 CS604- Operating System

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

Chap2: Operating-System Structures

Introduction to Linux Workshop 1

Introduction to Linux Organizing Files

Welcome to Linux. Lecture 1.1

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

Unix System Architecture, File System, and Shell Commands

Unix Workshop Aug 2014

Recitation #1 Boot Camp. August 30th, 2016

Unix Processes. What is a Process?

CISC 220 fall 2011, set 1: Linux basics

ScazLab. Linux Scripting. Core Skills That Every Roboticist Must Have. Alex Litoiu Thursday, November 14, 13

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

EECS 2031E. Software Tools Prof. Mokhtar Aboelaze

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

Lab Working with Linux Command Line

Linux Essentials Objectives Topics:

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

Linux Essentials. Smith, Roderick W. Table of Contents ISBN-13: Introduction xvii. Chapter 1 Selecting an Operating System 1

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

commandname flags arguments

Some useful UNIX Commands written down by Razor for newbies to get a start in UNIX

Introduction to UNIX command-line II

QUESTION BANK ON UNIX & SHELL PROGRAMMING-502 (CORE PAPER-2)

Unix File System. Class Meeting 2. * Notes adapted by Joy Mukherjee from previous work by other members of the CS faculty at Virginia Tech

BIOINFORMATICS POST-DIPLOMA PROGRAM SUBJECT OUTLINE Subject Title: OPERATING SYSTEMS AND PROJECT MANAGEMENT Subject Code: BIF713 Subject Description:

First of all, these notes will cover only a small subset of the available commands and utilities, and will cover most of those in a shallow fashion.

Transcription:

CS197U: A Hands on Introduction to Unix Lecture 11: WWW and Wrap up Tian Guo University of Massachusetts Amherst CICS 1

Reminders Assignment 4 was graded and scores on Moodle Assignment 5 was due and you can stop the cron jobs after 10 emails I will grade it this weekend. And those who have more than 45 (including attendance) will have flexibility for the remaining assignments. Assignment 6 is due Oct 29; please start early! Assignment 7 is going to post soon! 2

Goal: Set up your personal website (EdLab) How to access to your website? http://www-edlab.cs.umass.edu/~username/index.html How to modify your website? Default path is under your home directory: ~/public_html By default, index.html already exists there What else could you put inside ~/public_html? Everything you want others to see 3

Putting stuffs into public_html Copy through command line (Mac/Linux) scp filename USERNAME@elnux4.cs.umass.edu:~/public_html Copy using WinSCP (Windows) Connect to elnux4.cs.umass.edu and drag the file How do others see it? Assuming we have a new file empty.html URL: http://www-edlab.cs.umass.edu/~username/empty.html 4

Control the permission What permissions to set for files in public_html? What happens if empty.html is set to 600? Make it visible: set to 755 or 644 - Chmod 755 empty.html Or Chmod 644 empty.html 5

HTML: HyperText Markup Language A markup language of tags that can create a webpage in couple lines <html> <body> <!- - This is a comment - - > This is a webpage. </body> </html> 6

Tags Paired Tags: Opening and closing tag Headings of different sizes: h1~h6: <h1> Heading1 </h1> Start paragraph: <p> A Paragraph </p> Hyperlink: <a href= http://www.google.com/ >link_to_google</a> - Link to your email: replace http://url by mailto:my@email.com Unpaired Tags Reference Image: <img src= myphoto.jpg" width= 60" height= 90 /> Line Breaker: <br> Horizontal line: <hr> 7

Heading Tags Code Result 8

Paragraph Tag Code Result 9

Hyperlink Code Result 10

Image Tag Code Result 11

br Tag Code Results 12

hr Tag Code Result 13

More Resources Code Academy: HTML & CSS https://www.codecademy.com/tracks/web w3school http://www.w3schools.com/ 14

The last but very useful command xargs: commonly used in pipe to convert multiple lines into single-line argument list Example 1: Check out xargs by itself ls -1 data/ xargs Converts output into one line elnux4 tian) > ls -1 data/ xargs data-1.txt data-2.txt data-3.txt Why is it useful? 15

The last but very useful command Combine it with find: filters out a list of finds and perform some actions Do things for all python files (including subdirectories) find. -name *.py xargs wc -l # Counts the lines of the code find. -name *.py xargs grep import # Looks for import package 16

The last but very useful command Run command on different files without for loop The for loop way for file in data/* do echo $file awk -f avg.awk $file done Get the file name; and invoke command for each file xargs way: ls -1 data/ xargs -I {} awk -f avg.awk data/{} 17

What we ve learned Using the command line: cd mv rm mkdir pwd ls Reading files head tail cat less more grep Editing files vim awk sed

and... Using pipes grep Romeo file.txt head - n 100 tail - n 10 Using output redirection to save output to a file grep Romeo file.txt > RandJ.txt grep Juliet file.txt >> RandJ.txt Some special symbols.././ * & parent directory current directory match all files run cmd in background

Important concepts OS enforces file permissions for user, group, and world elnux7> ls - l - rwxr- xr- x 1 twood grad 97 Feb 21 11:33 script.sh - rw- r- - r- - 1 twood grad 298 Feb 21 11:22 data.txt chmod command is used to change permissions Root user has absolute power, or use sudo Package managers can help find and install software sudo apt- get install firefox

About the filesystem The filesystem is hierarchical Directories can contain files or other directories / is the root directory, where the hierarchy begins Other important directories to remember: /bin/ - executable files /sbin/ - privileged executables /dev/ - devices /etc - system configuration /opt/ - third-party software /sys/ - Kernel, device drivers, etc /usr/ - Other OS programs and data /var/ - Logs, databases, rapidly-changing file /home/ - user home directories /lib/ - libraries 21

How to get system info ps and top to learn about running processes elnux5> ps PID TTY TIME CMD 17786 pts/0 00:00:00 tcsh 17830 pts/0 00:00:00 bash 17832 pts/0 00:00:00 top 17833 pts/0 00:00:00 ps Lots of log and system files with OS information tail /var/log/messages cat /proc/cpuinfo

Programming and scripting C / C++ tools gcc c compiler g++ Python, perl, ruby, and many more gdb Shell scripting make c++ compiler debugger build automator # Command line arguments: dir=$1 if [ - d $dir ] then echo Reading files in $d else echo Not a directory exit fi for f in $dir/*.csv do awk - F, {print $3+$4} $f done 23

awk Awk is a scripting language for processing structured data Log files, experimental results, etc Can use on the command line or write in a file: awk - F, - f script.awk data.txt awk - F, Very powerful! '{print $2}' data.txt Often used with grep and pipe <COMMAND> grep <KEYWORD> head n 10 awk F : {print $n}

Version Control Version control systems are used to store and track source code Subversion is an open source version Important concepts: Repository - stores history of all files being tracked You never edit these files directly Local copy - check out files from repository to edit them Modify the files as you like Update - updates your local copies Detects if another user modified the same file Attempts to merge changes (only works for text files) Commit - sends your versions of the files to the repository Will only update repository if there are no conflicts

Working with Files tar command creates one file that is an archive of other files also allows you to compress files scp command allows you to copy files to or from a remote machine rsync synchronizes files and directory

Managing Processes screen : detach/attach to terminal sessions Useful for running long processes ctrl- z : Suspend a job jobs : Provides status of suspended jobs bg : Runs jobs in the background fg : Runs jobs in the foreground nohup: run jobs in detached manner from terminal cron: schedule reoccurring jobs nice and renice allow you to control process priority

Your network ifconfig/if up/if down Information about interfaces iwconfig/iwlist Wireless connection/association dhclient Getting an IP address from DHCP server ping Checking out a remote host host Resolve the name/ip address of a site traceroute Tracking a packet s end-to-end path/delay 28

Network security and traffic monitoring arp Address resolution protocol (IP vs. MAC) ifstat Real time bandwidth monitoring on all interfaces iftop Monitoring details of specific interface ftp/scp (Un)secure file transport wireshark Packet sniffing 29

Random useful commands find - prints the path to a file locate finds system files whereis/which - locate a binary file diff - compares two files sort sorts a file alphabetically or numerically uniq - removes identical adjacent lines cd - - moves to the last directory you were in export declare and export variables alias - creates a shortcut to a command for the bash shell

Take some more classes 377 Operating Systems Learn how the Linux kernel works 453 Networking and 491G Networking Lab Networking protocols, routing configuration 365 Digital Forensics Learn about security and low level forensics