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

Slides:



Advertisements
Similar presentations
“Linux at the Command Line” Don Johnson of BU IS&T
Advertisements

Linux commands exercise 1. What do you need, if you try to these at home? You need to download and install Ubuntu Linux from the Internet – DVD is need.
Learning Unix/Linux Bioinformatics Orientation 2008 Eric Bishop.
Chapter One The Essence of UNIX.
LINUX System : Lecture 3 (English-Only Lecture) Bong-Soo Sohn Assistant Professor School of Computer Science and Engineering Chung-Ang University Acknowledgement.
Cosc 4750 Getting Started in UNIX Don’t be afraid of the prompt, in linux it can be your best friend. In some cases, the only way to do certain things.
Git/Unix Lab March Version Control ●Keep track of changes to a project ●Serves as a backup ●Revert to previous version ●Work on the same files concurrently.
Introducing the Command Line CMSC 121 Introduction to UNIX Much of the material in these slides was taken from Dan Hood’s CMSC 121 Lecture Notes.
Linux+ Guide to Linux Certification, Second Edition
Linux Files. Files and directories As in Windows directories are structures which contain –Other directories –Files.
CS 202 Computer Science II Lab Fall 2009 September 3.
T UTORIAL OF U NIX C OMMAND & SHELL SCRIPT S 5027 Professor: Dr. Shu-Ching Chen TA: Samira Pouyanfar Spring 2015.
Guide to Linux Installation and Administration, 2e1 Chapter 6 Using the Shell and Text Files.
Chapter 6 Basic Directory and File Management. Command Line Control Characters Control-s - Stops screen output - rarely used Control-q - Resumes screen.
Lecture 02CS311 – Operating Systems 1 1 CS311 – Lecture 02 Outline UNIX/Linux features – Redirection – pipes – Terminating a command – Running program.
CMPE 151: Network Administration Spring Class Description Focus: system and network administration. Sequence of exercises. E.g., installing/configuring.
Very Quick & Basic Unix Steven Newhouse Unix is user-friendly. It's just very selective about who its friends are.
Linux & Shell Scripting Small Group Lecture 4 How to Learn to Code Workshop group/ Erin.
“Linux at the Command Line” Don Johnson of BU IS&T.
Introduction to UNIX/Linux Exercises Dan Stanzione.
Unix Primer. Unix Shell The shell is a command programming language that provides an interface to the UNIX operating system. The shell is a “regular”
UNIX command line. In this module you will learn: What is the computer shell What is the command line interface (or Terminal) What is the filesystem tree.
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.
Linux environment ● Graphical interface – X-window + window manager ● Text interface – terminal + shell.
Second edition Your UNIX: The Ultimate Guide Das © 2006 The McGraw-Hill Companies, Inc. All rights reserved. UNIX – The Shell The Shell The agency that.
Unix Basics Chapter 4.
Chapter Three The UNIX Editors. 2 Lesson A The vi Editor.
Linux+ Guide to Linux Certification Chapter Four Exploring Linux Filesystems.
FTP Server and FTP Commands By Nanda Ganesan, Ph.D. © Nanda Ganesan, All Rights Reserved.
HKOI 2012 TRAINING INTRO TO LINUX /CUHK/SHB123]$ date Sat Feb 18 13:00:00 HKT 2012.
Before we start…Getting Started. UST Outline History Getting Started Basic commands (command line) Operations on Files and Directories Input and Output.
Agenda Link of the week Use of Virtual Machine Review week one lab assignment This week’s expected outcomes Review next lab assignments Break Out Problems.
Introduction to UNIX Geraint Vaughan. What is UNIX? Command-line operating system (not point- and click) Designed for ‘experts’ Lots of different variants.
Log-in to the Unix Server A successful log-in allows access to the server through the Secure Shell. SSH, also known as Secure Shocket Shell, is a Unix.
Unix and Samba By: IC Labs (Raj Kidambi). What is Unix?  Unix stands for UNiplexed Information and Computing System. (It was originally spelled "Unics.")
Unix Commands PowerPoint Presentation developed for LS 560 Information Technology online class - University of Alabama by Debey Sklenar TENacious Cohort.
Lesson 4-Mastering the Visual Editor. Overview Introducing the visual editor. Working in an existing file with vi. Understanding the visual editor. Navigating.
Chapter Three The UNIX Editors.
40 Years and Still Rocking the Terminal!
E X C E E D I N G E X P E C T A T I O N S Basic LINUX Linux System Administration Dr. Hoganson Kennesaw State University Operating Systems Directory structure:
UNIX History - joint venture between MIT and Bell Labs (originally called Multics) – Ken Thompson (AT&T) created an operating system to run Space.
Week Two Agenda Announcements Link of the week Use of Virtual Machine Review week one lab assignment This week’s expected outcomes Next lab assignments.
Lesson 3-Touring Utilities and System Features. Overview Employing fundamental utilities. Linux terminal sessions. Managing input and output. Using special.
Using the “CLI” Unix / Linux Preparation Course June 9, 2013 Lusaka, Zambia.
Text editing and more basic commands CS 2204 Class meeting 3 *Notes by Doug Bowman and other members of the CS faculty at Virginia Tech. Copyright
CS 245 – Part 1 Using Operating Systems and Networks for Programmers Jiang Guo Dept. of Computer Science California State University Los Angeles.
PTA Linux Series Copyright Professional Training Academy, CSIS, University of Limerick, 2006 © Workshop III - Part A Shell Commands Professional Training.
Linux+ Guide to Linux Certification, Second Edition Chapter 4 Exploring Linux Filesystems.
1 Introduction to Unix. 2 What is UNIX?  UNIX is an Operating System (OS).  An operating system is a control program that helps the user communicate.
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.
 Last lesson, the Windows Operating System was discussed along with the Windows command shell  Unix is a computer operating system, that similarly manages.
1 CS3695 – Network Vulnerability Assessment & Risk Mitigation – Introduction to Unix & Linux.
BIF703 FTP (File Transfer Protocol) Utility vi editor Utility.
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.
Unix Lab Fall Shell Scripting ●Through the shell (LXTerminal) you can: ●Run programs. ●Interact with the file system. ●Change settings. ●Send/receive.
“Linux at the Command Line
Tutorial of Unix Command & shell scriptS 5027
Introduction to the Linux Commandline
Prepared by: Eng. Maryam Adel Abdel-Hady
Guide To UNIX Using Linux Third Edition
Shell Script Assignment 1.
Assignment Preliminaries
Tutorial of Unix Command & shell scriptS 5027
Tutorial of Unix Commands
Tutorial of Unix Command & shell scriptS 5027
Intro to UNIX System and Homework 1
Web Programming Essentials:
Tutorial of Unix Command & shell scriptS 5027
UNIX/LINUX Commands Using BASH Copyright © 2017 – Curt Hill.
Remote Computing Services Cloud connection Distributed system
Presentation transcript:

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

What is Linux? It’s an Operating System

(i) Make each program do one thing well. To do a new job, build afresh rather than complicate old programs by adding new features. (ii) Expect the output of every program to become the input to another, as yet unknown, program. Don't clutter output with extraneous information. Avoid stringently columnar or binary input formats. Don't insist on interactive input. (iii) Use tools in preference to unskilled help to lighten a programming task, even if you have to detour to build the tools and expect to throw some of them out after you've finished using them. The *Nix Philosophy of Doug McIlroy

 You need a “xterm” emulator: software that emulates an “X” terminal and connects using the “SSH” secure shell protocol.  You are sitting at the “client,” either a Windows, Macintosh or even possibly a Linux machine.  You are connecting to a “server,” typically the “head” or “gateway” node of a cluster of computers. You will be working on the head node or submitting jobs to execution nodes, all of them, Linux machines.  You can also connect to a Linux machine by using VNC to get a whole desktop if it’s supported by the server.

When there are problems connecting to a login host, try:  ping katana.bu.edu  telnet katana.bu.edu 22

 Note: is short for “carriage return” and equals the ASCII press the “Enter” or “Return” key. It tells the shell that you finished sending one line (see ascii-table.pdf).  Try ◦ telnet  GET / HTTP/1.1  Host:   What happened?

Emulate a Browser Connecting to a Linux Host

 Try ◦ telnet locahost 25  ehlo me  mail from:  rcpt to:  data  Subject:  .   What Happened?

Send and Connecting to an Linux Host

 go to beginning  go to end  forward one word  back one word  forward one character  back one character  delete character  delete word  delete from cursor to beginning of line  delete from cursor to end of line See emacs-editing-mode.pdf and emacs-editing-mode-short.pdf Go to through command history in shell and practice editing.

 All files and directories have a individual and a group ownership.  All files and directories have read (r), write (w), and execute (x) permissions assigned as octets to the individual owner (u), the group (g) owner and all others (o) that are logged into the system.  You can change permissions if you are the individual owner or a member of the group.  Only root can change ownership.

The root user is the master root

 Try ◦ cd ◦ touch myfile (create file) ◦ mkdir mydir (create directory) ◦ ls –l myfile (examine file) ◦ ls –ld mydir (examine directory) ◦ chmod g+w myfile (add group write permission) ◦ ls –l myfile ◦ chmod ugo+x myfile (add user, group and other execute permission) ◦ ls –l myfile ◦ chmod ugo+w mydir (add user, group and other write permission) ◦ ls –ld mydir ◦ chmod a-w (a=ALL, remove user, group and other write permission)

Examining and changing file and directory permissions File and Directory Ownership and Permissions

 Syntax: BEGIN { Actions} {ACTION} # Action for every line in a file END { Actions }  Try ◦ ls –l /usr ◦ ls –l /usr | awk ‘{print $9 “\t” $5}’ ◦ ls –l /usr > usr.txt ◦ awk ‘print $9 “\t” $5}’ usr.txt (gives same results as 2 nd command line, but awk is acting on a file instead of saved output) ◦ ls –lh /lib | awk ‘{printf “%20s\t%s\n”,$9,$5}’ ◦ ls –l /lib | awk ‘BEGIN {sum=0} {printf “%20s\t%s\n”,$9,$5; sum+=$5} END{sum/= ; printf “\nTotal: %d GB\n”,sum}’

Output from awk commands Editing Output Lines With awk

 sed replaces one substring with another  sed operates on every line in a file or processes every line piped into it  sed matches patterns using regular expressions (See regular-expressions.pdf cheat sheet)  Common regular expression metacharacters: ◦. – any character ◦ ? – quantified zero or one ◦ * - quantifier none or more ◦ + - quantifier one or more ◦ ^ - beginning of line ◦ $ - end of line ◦ [XxYy] – character class matching upper or lower case “X” or “”Y”

 Try ◦ echo “The rain in Spain stays mainly in the plain.” > easy_sed.txt; cat easy_sed.txt ◦ sed –i.bak ‘s/rain/snow/;s/Spain/Sweden/;s/plain/mountains /’ easy_sed.txt; cat easy_sed.txt ◦ ls -l /lib | awk 'BEGIN {sum=0} {printf "%s\t%s\n",$9,$5; sum+=$5} END{printf "\nTotal: %d\n",sum}' | sed -e 's/\.so\(\.[0-9]*\)*//' | less (challenge: get rid of soname extension) ◦ ls -l /lib | awk 'BEGIN {sum=0} {printf "%s\t%s\n",$9,$5; sum+=$5} END{printf "\nTotal: %d GB\n",sum}' | sed -e 's/\.so\(\.[0-9]*\)*//' | awk '{printf "%20s\t%s\n",$1,$2}‘ | less (pretty print)

Output from sed commands Editing Output Lines With sed

You don’t have to take sides and there is always “nedit” Editing Files with Emacs and Vim

Emacs – Control Keys C=Ctrl and M=Meta (Alt) Vim – Modal Cmd, Insert, and Visual  Cheat sheet: emacs.pdf  Movement:,,,,,,,,, ’ >,  Change/Delete/Replace:,,,,,  Copy/Paste:,,,,  Search/Replace:,,, ’srchstr’ ’replace ment’  Save/Quit:,, >  Cheat sheet: vim.pdf  Movement:,,,,,,,,,  Change/Delete/Replace:,,,,,  Copy/Paste:,,,,  Search/Replace:,,,  Save/Quit:,,

Someone has corrupted Edgar Allen Poe’s poem, “The Raven.” Your mission, should you decide to accept it, is to repair the damage with emacs or vim and then confirm with the “diff” command. Hint: Also use diff to find corruption. emacs –nw bad-the-raven.txt or vim bad-the-raven.txt After editing and saving your file, confirm you work with: diff bad-the-raven.txt good-the-raven.txt Mission Possible: Editing Files with Emacs and Vim