ULI101 More Linux Commands Introduction to UNIX/Linux and the Internet

Slides:



Advertisements
Similar presentations
Jump to first page Unix Commands Monica Stoica Jump to first page Introduction to Unix n Unix was born in 1969 at Bell Laboratories, a research subdivision.
Advertisements

Working with Files How to create, view, copy, rename and print files.
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.
ATS Programming Short Course I INTRODUCTORY CONCEPTS Tuesday, Jan. 27 th, 2009 Essential Unix Commands.
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.
UNIX Chapter 00 A “ Quick Start ” into UNIX Operating System Mr. Mohammad Smirat.
Guide To UNIX Using Linux Third Edition
Lecture 01CS311 – Operating Systems 1 1 CS311 – Lecture 01 Outline Course introduction Setting up your system Logging onto the servers at OSU with ssh.
Lecture 02CS311 – Operating Systems 1 1 CS311 – Lecture 02 Outline UNIX/Linux features – Redirection – pipes – Terminating a command – Running program.
Linux+ Guide to Linux Certification, Second Edition
CS 497C – Introduction to UNIX Lecture 13: - The File System Chin-Chih Chang
UNIX Utilities Learning Objectives: 1. To understand the some basic utilities of UNIX File 2. To compare UNIX shell and popular shell 3. To learn Input/Output.
CSCI 330 T HE UNIX S YSTEM File operations. OPERATIONS ON REGULAR FILES 2 CSCI The UNIX System Create Edit Display Contents Display Contents Print.
UNIX Filters.
1 Some basic Unix commands u Understand the concept of loggin into and out of a Unix shell u Interact with the system in a basic way through keyboard and.
CS 141 Labs are mandatory. Attendance will be taken in each lab. Make account on moodle. Projects will be submitted via moodle.
Chapter 4: UNIX File Processing Input and Output.
BILKENT UNIVERSITY DEPARTMENT OF COMPUTER TECHNOLOGY AND INFORMATION SYSTEMS CTIS156 INFORMATION TECHNOLOGIES II CHAPTER 10: ADVANCED FILE PROCESSING.
Advanced File Processing
1 THE UNIX FILE SYSTEM By Chokechai Chuensukanant ID COSC 513 Operating System.
Working with Files Chapter 5. Display a Calendar Display a calendar for a specific month – cal Display a calendar for a specific year – cal 2000.
Lesson 11-Locating, Printing, and Archiving User Files.
BIF703 Miscellaneous Commands. File related commands  grep - print lines matching a pattern  head - output the first part of files  tail - output the.
Chapter 3: Command Line Utilities Doin’ stuff. In this chapter … Special characters Redirection More utilities than you shake a stick at.
Agenda User Profile File (.profile) –Keyword Shell Variables Linux (Unix) filters –Purpose –Commands: grep, sort, awk cut, tr, wc, spell.
File Processing. Introduction More UNIX commands for handling files Regular Expressions and Searching files Redirection and pipes Bash facilities.
Guide To UNIX Using Linux Fourth Edition
– Introduction to the Shell 10/1/2015 Introduction to the Shell – Session Introduction to the Shell – Session 2 · Permissions · Users.
Unix programming Term: III B.Tech II semester Unit-II PPT Slides Text Books: (1)unix the ultimate guide by Sumitabha Das (2)Advanced programming.
Title Slide CSS 404/504 The UNIX Operating System (2) By Ralph B. Bisland, Jr.
Agenda Chapter 1: Linux (Unix) Features Commands (Chapters 2 & 3) Command Structure / Command line editing man, passwd, cal, date, whereis, which Working.
Jozef Goetz, expanded by Jozef Goetz, 2009 Credits: Parts of the slides are based on slides created by UNIX textbook authors, Syed M. Sarwar, Robert.
The Shell Chapter 7. Overview The Command Line Standard IO Redirection Pipes Running a Program in the Background Killing (a process!)
Advanced File Processing. 2 Objectives Use the pipe operator to redirect the output of one command to another command Use the grep command to search for.
Chapter Five Advanced File Processing Guide To UNIX Using Linux Fourth Edition Chapter 5 Unix (34 slides)1 CTEC 110.
Chapter Five Advanced File Processing. 2 Objectives Use the pipe operator to redirect the output of one command to another command Use the grep command.
Agenda Regular Expressions (Appendix A in Text) –Definition / Purpose –Commands that Use Regular Expressions –Using Regular Expressions –Using the Replacement.
De Anza College Instructor: Clare Nguyen
BIF713 Additional Utilities. Linux Utilities  You have learned many Linux commands. Here are some more that you can use:  Data Manipulation (Reg Exps)
Lesson 2-Touring Essential Programs. Overview Development of UNIX and Linux. Commands to execute utilities. Communicating instructions to the shell. Navigating.
Linux file system "On a UNIX system, everything is a file; if something is not a file, it is a process." Sorts of files (on a Linux system) Directories:
Introduction to UNIX Geraint Vaughan. What is UNIX? Command-line operating system (not point- and click) Designed for ‘experts’ Lots of different variants.
1 © 2001 John Urrutia. All rights reserved. Chapter 3 An Introduction to the Utilities.
Chapter Five Advanced File Processing. 2 Lesson A Selecting, Manipulating, and Formatting Information.
Linux+ Guide to Linux Certification, Third Edition
Introduction to Programming Using C An Introduction to Operating Systems.
Basic of UNIX For fresh members of SPARCS
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.
ATS Programming Short Course I INTRODUCTORY CONCEPTS Tuesday, Feb 3 rd, 2009 Essential Unix Commands …the second half.
CSCI 330 UNIX and Network Programming Unit II Basic UNIX Usage: File System.
Lecture 1: Introduction, Basic UNIX Advanced Programming Techniques.
CIT 140: Introduction to ITSlide #1 CSC 140: Introduction to IT File Processing.
Lesson 6-Using Utilities to Accomplish Complex Tasks.
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.
Learning Unix/Linux Based on slides from: Eric Bishop.
Filters and Utilities. Notes: This is a simple overview of the filtering capability Some of these commands are very powerful ▫Only showing some of the.
ULI101 Week 05. Week Overview ● File system links ● Hard and symbolic links ● Process management ● Storage quota information (quota) ● Printing.
Linux Commands Help HANDS ON TRAINING Author: Muhammad Laique
Linux file system "On a UNIX system, everything is a file;
Some Linux Commands.
Agenda Basic Unix Commands (Chapters 2 & 3) Miscellaneous Commands:
Shell Script Assignment 1.
Basic UNIX OLC Training.
The Linux Command Line Chapter 6
Guide To UNIX Using Linux Third Edition
Chapter Four UNIX File Processing.
Linux Shell Script Programming
Presentation transcript:

ULI101 More Linux Commands Introduction to UNIX/Linux and the Internet Seneca College of Applied Technology

File related commands grep - print lines matching a pattern head - output the first part of files tail - output the last part of files sort - sort lines of text files diff - find differences between two files file - determine file type

Utility commands who – show who is logged in date – print or set the system date and time which – show the full path of (shell) commands quota – display disk usage and limits finger – user information lookup program mail – send and receive mail

Print commands lpr – print files lpq – show print queue status lprm – cancel print jobs

Print lines matching a pattern grep Print lines matching a pattern grep takes a pattern, read standard input or a list of files, and outputs the lines containing matches for the pattern. Example: grep foo * Print lines in any of the files in the current directory that contain the pattern “foo”.

grep examples grep -r foo . grep -lr foo . Print all the lines in all the files in the current directory and all its subdirectories that contains the pattern “foo”. grep -lr foo . Similar as above but only print the names of the files that contains the pattern “foo”

Contents of the sample file [uli@seneca misc]$ cat bar The name of this file is called bar. This file has only five line. This line contains the word foo and bar. Do you like to play football or basket ball? This is the end of the file. [uli@seneca misc]$ nl bar 1 The name of this file is called bar. 2 This file has only five line. 3 This line contains the word foo and bar. 4 Do you like to play football or basket ball? 5 This is the end of the file.

More grep examples Print all the lines in the file “bar” that contains the pattern “foo” [uli@seneca misc]$ grep foo bar This line contains the word foo and bar. Do you like to play football or basket ball? Same as above but prefix each line of output with the line number within the file “bar” [uli@seneca misc]$ grep -n foo bar 3:This line contains the word foo and bar. 4:Do you like to play football or basket ball?

More grep examples Print all the lines in the file “bar” that contains the word “foo” [uli@seneca misc]$ grep -w foo bar This line contains the word foo and bar. Print all the lines in the file “bar” that does not contain the pattern “foo” [uli@seneca misc]$ grep -v foo bar The name of this file is called bar. This file has only five line. This is the end of the file.

grep options Major options for grep “-l” display name of the file that has matching line “-r” search all the files in the current directory and all its subdirectory for the given pattern “-n” prefix each output with line number “-w” search for matching word “-v” output lines that do not contain the given pattern

head & tail head bar head -5 bar tail bar tail -5 bar Display the first 10 line of the file “bar” head -5 bar Display the first 5 lines of the file “bar” tail bar Display the last 10 lines of the file “bar” tail -5 bar Display the last 5 lines of the file “bar”

sort Sort line of text file [root] sort numbers 101 984 2314 5678 101 984 2314 5678 345 2231 4842 6543 98 11001 [root] sort -n numbers Sort line of text file [root] cat numbers 2314 5678 345 2231 101 984 4842 6543 98 11001 String order Numeric order

More sort examples [root] cat numbers 2314 5678 345 2231 101 984 2314 5678 345 2231 101 984 4842 6543 98 11001 [root] sort numbers 101 984 2314 5678 345 2231 4842 6543 98 11001 [root] sort -k2 numbers Sort by the 2nd field Sort by the 1st field

More sort examples [root] cat numbers 2314 5678 345 2231 101 984 2314 5678 345 2231 101 984 4842 6543 98 11001 [root] sort numbers 101 984 2314 5678 345 2231 4842 6543 98 11001 [root] sort -r numbers Sort in reverse order

diff Display the differences between two files Syntax: diff [options] file1 file2 useful options: “-y” or “--side-by-side” use the side by side output format “-W n” or “--width=n” use an output width of columns n in side by side format

diff default output When using “diff” without any options, it produces a series of lines containing Add (a) Delete (d), and Change (c) instructions Each of these lines is followed by the lines from the file that you need to add, delete, or change to make the files the same.

diff examples $cat file1 $cat file2 blue blue red yellow white black orange $cat file2 blue yellow black red orange Steps to convert file1 to file2: $diff file1 file2 2,3d1 < red < white 4a3,4 > black > red 1. Delete line 2 through 3 from file1 2. Append lines 3 through 4 from file2 after line 4 in file1

diff examples $cat file1 $diff -y -W 30 file1 file2 blue blue blue red white yellow orange $diff -y -W 30 file1 file2 blue blue red < white < yellow yellow > black > red orange orange $cat file2 blue yellow black red orange

diff examples $cat file1 $cat file2 blue blue red yellow white black orange $cat file2 blue yellow black red orange $diff --side-by-side --width=30 file1 file2

file Display the classification of a file Syntax: file [option] file-list option: -L reports on the files that symbolic links point to option: -f file reads the names of the files to be examined from file option: -i Causes the file command to output mime type strings

file examples [uli@seneca notes]$ file * introunix.html: exported SGML document text links.sxi: Zip archive data, at least v2.0 to extract misc-commands.sxi: Zip archive data, at least v2.0 to extract template.sxi: Zip archive data, at least v2.0 to extract ULI01LabLing02.ppt: Microsoft Office Document ULI01LabLing-fast.ppt: Microsoft Office Document [ray@localhost notes]$ file -i * introunix.html: text/html; charset=iso-8859-1 links.sxi: application/x-zip misc-commands.sxi: application/x-zip template.sxi: application/x-zip ULI01LabLing02.ppt: application/msword ULI01LabLing-fast.ppt: application/msword

More file examples [ray@localhost week8]$ ls -l mydir lrwxrwxrwx 1 ray ray 7 Oct 29 15:41 mydir -> courses [ray@localhost week8]$ file mydir mydir: symbolic link to courses [ray@localhost week8]$ file -L mydir mydir: directory

Recap grep head tail sort diff file

who Show who is logged on Phobos: /home/rchan>$ who rchan pts/0 Oct 30 02:08 (toronto-hse-ppp3) sslui pts/1 Oct 30 01:11 (CPE00112f0fe590-) Phobos: /home/rchan>$ who -H Name Line Time Hostname Phobos: /home/rchan>$ who -qH Name Hostname rchan (toronto-hse-ppp3) sslui (CPE00112f0fe590-) Total users: 2

date Display the system time and date [ray@localhost week8]$ date Sun Oct 30 01:48:10 EST 2005 [ray@localhost week8]$ date +"%D" 10/30/05 [ray@localhost week8]$ date +"%T" 01:54:05 [ray@localhost week8]$ date +"%D %T" 10/30/05 01:54:13 Refer to the man page for more formatting codes

which Shows the full path of (shell) commands [ray@localhost week8]$ which mkdir /bin/mkdir [ray@localhost week8]$ which type /usr/bin/which: no type in (/usr/local/bin:/usr/bin:/bin:/usr/X11R6/bin :/home/ray/bin)

quota Display disk usage and limits Phobos: /home/rchan>$ quota Disk quotas for user rchan (uid 1628): Filesystem blocks quota limit grace files quota limit grace /home_sharedfs 8296 10000 12001 97 10000 12001 /public_sharedfs 4 5000 5001 2 5000 5001 /mail_sharedfs 4 5000 5001 1 5000 5001

finger User information lookup program Phobos: /home/rchan>$ finger rchan Login name: rchan In real life: Raymond Chan Directory: /home/rchan Shell: /usr/bin/ksh On since Oct 30 02:08:55 on pts/0 from toronto-hse-ppp3 (messages off) No Plan.

mail Send and receive mail To read your mail on phobos, type the “mail” command by itself: Phobos: /home/rchan>$ mail Mail [5.2 UCB] [AIX 4.1] Type ? for help. "/var/spool/mail/rchan": 1 message 1 new >N 1 rchan Wed Oct 26 00:24 10/340 "Mail testing"

Sending mail To send a file called “letter” through email on phobos to the user “rchan”: Phobos: /home/rchan>$ mail -s “subject” rchan < letter

Recap who date which quota finger mail

lpr, lpq, lprm lpr – submit file for printing lpr [ -P printer-name ] [ -# copies ] file-name [ -P printer-name] : send files to the named printer [ -# copies ] :sets the number of copies to print between 1 and 100 file-name : name of file to be printed

Show printer queue status lpq - show printer queue status lpq [ -P printer-name] [ -a ] [ -l] [ -P printer-name] : show status on the named printer [ -a ] : reports jobs on all printers [ -l ] : display more verbose (long) format

Cancel Print Jobs lprm – cancel print jobs lprm [ - ] [ -P printer-name] [ job ID(s)] [ - ] : all print jobs [ -P printer-name] : print jobs on the named printer [ job ID(s) ]: jobs to be cancel

Recap

Reference Man Pages A practical Guide to Linux by Mark G. Sobell

Questions and Answers How do you print all the lines in all the files in the current directory and all its subdirectories that contains the <title> tag? How do you print all the lines in the file called “index.html” that contains the word “seneca”? How do you print the last line of the file called “task.html”? How do you print the classification of each file in the currently directory?

Questions and Answers What does the command “who” do? What does the command “who -q” do? How do you find out your disk usage and limits on phobos? How do you read your mail on Phobos? How do you cancel a print job?