Chapter 3: Command Line Utilities Doin’ stuff. In this chapter … Special characters Redirection More utilities than you shake a stick at.

Slides:



Advertisements
Similar presentations
Learning Unix/Linux Bioinformatics Orientation 2008 Eric Bishop.
Advertisements

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.
NETW-240 Shells Last Update Copyright Kenneth M. Chipps Ph.D. 1.
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.
Now, return to the Unix Unix shells: Subshells--- Variable---1. Local 2. Environmental.
Lesson 22 – Introduction to Linux Systems Administration.
UNIX Utilities Software Tools. Slide 2 Getting Started on UNIX The machines in CS Lab2 are named csl2wk01 through csl2wk41. csl2wk01 means “CSLab2, workstation#1”
UNIX Chapter 00 A “ Quick Start ” into UNIX Operating System Mr. Mohammad Smirat.
Guide To UNIX Using Linux Third Edition
T UTORIAL OF U NIX C OMMAND & SHELL SCRIPT S 5027 Professor: Dr. Shu-Ching Chen TA: Samira Pouyanfar Spring 2015.
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.
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.
1 SEEM3460 Tutorial Unix Introduction. 2 Introduction What is Unix? An operation system (OS), similar to Windows, MacOS X Why learn Unix? Greatest Software.
7/17/2009 rwjBROOKDALE COMMUNITY COLLEGE1 Unix Comp-145 C HAPTER 2.
Linux Commands LINUX COMMANDS.
CS 141 Labs are mandatory. Attendance will be taken in each lab. Make account on moodle. Projects will be submitted via moodle.
Help session: Unix basics Keith 9/9/2011. Login in Unix lab  User name: ug0xx Password: ece321 (initial)  The password will not be displayed on the.
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.
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.
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.
Chapter Four UNIX File Processing. 2 Lesson A Extracting Information from Files.
Guide To UNIX Using Linux Fourth Edition
Unix Basics Chapter 4.
The UNIX Shell. The Shell Program that constantly runs at terminal after a user has logged in. Prompts the user and waits for user input. Interprets command.
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.
UNIX and Shell Programming (06CS36) Unit 1 Continued… Shrinivas R. Mangalwede Department of Computer Science and Engineering K.L.S. Gogte Institute of.
System Administration Introduction to Unix Session 2 – Fri 02 Nov 2007 Reference:  chapter 1, The Unix Programming Environment, Kernighan & Pike, ISBN.
1 Day 5 Additional Unix Commands. 2 Important vs. Not Often in Unix there are multiple ways to do something. –In this class, we will learn the important.
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 Bash Programming Ellen Zhang. Previous three classes What have we learnt so far ?
UNIX Commands. Why UNIX Commands Are Noninteractive Command may take input from the output of another command (filters). May be scheduled to run at specific.
BIF713 Additional Utilities. Linux Utilities  You have learned many Linux commands. Here are some more that you can use:  Data Manipulation (Reg Exps)
Second edition Your UNIX: The Ultimate Guide Das © 2006 The McGraw-Hill Companies, Inc. All rights reserved. UNIX Commands cal – will print a calendar.
BIF713 Basic Unix/Linux Commands Getting Help with Commands.
ULI101 More Linux Commands Introduction to UNIX/Linux and the Internet
CSC414 “Introduction to UNIX/ Linux” Lecture 5. Schedule 1. Introduction to Unix/ Linux 2. Kernel Structure and Device Drivers. 3. System and Storage.
Agenda Basic Unix Commands (Chapters 2 & 3) Miscellaneous Commands: which, passwd, date, ps / kill Working with Files: file, touch, cat, more, less, grep,
Lesson 3-Touring Utilities and System Features. Overview Employing fundamental utilities. Linux terminal sessions. Managing input and output. Using special.
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.
CS 245 – Part 1 Using Operating Systems and Networks for Programmers Jiang Guo Dept. of Computer Science California State University Los Angeles.
ATS Programming Short Course I INTRODUCTORY CONCEPTS Tuesday, Feb 3 rd, 2009 Essential Unix Commands …the second half.
File Processing. Introduction More UNIX commands for handling files Regular Expressions and Searching files Redirection and pipes Bash facilities.
File Management commands cat Cat command cat cal.txt cat command displays the contents of a file here cal.txt on screen (or standard out).
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.
Tutorial of Unix Command & shell scriptS 5027
Chapter 11 Command-Line Master Class
Some Linux Commands.
C151 Multi-User Operating Systems
Agenda Basic Unix Commands (Chapters 2 & 3) Miscellaneous Commands:
CSE 374 Programming Concepts & Tools
Tutorial of Unix Command & shell scriptS 5027
Basic UNIX OLC Training.
Tutorial of Unix Command & shell scriptS 5027
CSE 390a Lecture 2 Exploring Shell Commands, Streams, and Redirection
(Chapter 2) John Carelli, Instructor Kutztown University
Tutorial of Unix Command & shell scriptS 5027
Chapter Four UNIX File Processing.
Linux Commands LINUX COMMANDS.
Presentation transcript:

Chapter 3: Command Line Utilities Doin’ stuff

In this chapter … Special characters Redirection More utilities than you shake a stick at

Typing Commands Beware of special characters Characters that have special meaning to the shell Shell expands, modifies and interprets special characters before issuing the command

Special Characters & ; | * ? ‘ “ ` [ ] ( ) $ { } ^ # / \ % ! ~ + Plus whitespace (tabs, spaces, newlines) Do not use these in filenames unless you have to To use them, either put in single quotes, or proceed with a backslash –ls ‘filename with special chars!!’ –ls \[cat\]

Special Characters con’t All special characters have special meaning to the shell We’ll explore these in great detail in upcoming chapters

Utilities Linux & Unix come with thousands of utilities Some used explicitly, others implicitly Some text-based, some GUI, some both

Some tips before we start Tab completion –When typing a filename or command name, you can type the first few letters then hit TAB to auto- complete the command Pipe (|) symbol –Used to chain commands together –The output of one command becomes the input of another –We’ll revisit this in detail later

ls: LiSt files Used to list files contained in a directory Can narrow the search using pattern matching Examples –ls  displays ‘all’ the files in the directory –ls cats  displays the file cats in the directory –ls ca*  displays files starting with ‘ca’

cat: catenate a file Displays the contents of one or more files Beware – don’t try with binary files Examples –cat myfile  displays contents of myfile –cat file1 file2  displays contents of file1 followed by contents of file2

rm: ReMoves a file Similar to del in DOS Use the –i option to invoke interactive mode, which prompts you if you’re sure Examples: –rm myfile  deletes myfile –rm –i myfile  prompts you before deleting

more and less: pagers more and less are similar in that they both break up long files into page long chunks Press h to display possible commands Examples –less myfile  displays myfile one page at a time

hostname: Where am I? hostname will display the name of the system you are currently logged onto Usually a fully qualified domain name (FQDN) Example: –hostname  displays: ares.bcs.solano.cc.ca.us

cp: CoPies files Usage: cp sourcefile destinationfile Creates a copy, leaves sourcefile intact If destinationfile exists, it will be overwritten –Unless you use –i option Example: –cp myfile myfile.backup

mv: MoVe files / change name Usage: mv existingfile newfile Just like cp, can overwrite with –i option Renames a file, which can also move it to another directory Examples: –mv myfile foshizzle –mv /dir1/myfile /dir2/myfile

lpr: Line PRinter Places files into the print queue Usage: lpr [-Pprintername] files You can check the status of queue with lpq You can delete a job with lprm Sorry, we don’t have a printer

grep: global regular expression print Used to search for strings in files/output Usage: grep expression filename Returns lines with expression in filename Example: –grep ‘automagically’ myfile

head: display beginning Displays beginning of file head -X filename displays first X lines Check out pg 727/691 for more options

tail: duh Displays the end of a file tail -X myfile displays the last X lines Check out pg 843/783 for more options

sort: displays sorted info sort displays data in a sorted manner, without altering the original file Lots of options – sort alphabetically, numerically, with or without repeats, reverse order, etc Check out pg 817/762

uniq: removes duplicates uniq displays data, omitting successive repeat entries Have to sort file first – otherwise it might not find all duplicates Does not alter original file

file: what kind of file is this? Usage: file filename Tells you what kind of file you’re working with and what kind of data is in it Examples include program, shell builtin, ASCII text, compressed data, etc

echo: display text Displays (echoes) text back to the terminal screen Can print out contents of shell variables Useful in shell scripts In other words, seems dumb now but we’ll use it a lot down the road

date: displays time and date Command options can change formatting Privileged accounts can use date to change date and time Can be useful for scripting

script: captures session Captures all input and output on the terminal and saves to a file A good way to document your work, or capture errors for analysis Type script to start capture, exit to quit By default stores everything in the file typescript

Text Converters unix2dos and dos2unix Unix and DOS use different end of line characters Use these utilities when moving text files back and forth between Windows and Linux systems Weird script error? Try dos2unix

Compressing files bzip2 files gzip files compress files Each use their own algorithms and have their uses

Uncompressing files bunzip2 compressed-file gunzip compressed-file ucompress compressed-file

tar: Tape ARchive Packs and unpacks files from archives *Does not compress, only assembles* Tons of options, allowing you to add or remove files from archive, and also apply compression using third party support

which: locates utilties Will display the location of a utility which ls  displays location of ls command you’re using In case of there being multiple locations, which only displays the first (i.e., the one you will be using)

whereis: locates utilities Similar to which, but displays the utilities in a standard set of locations The first one listed may not be the one you will issue when you enter the command All depends on your PATH (chapter 4)

Sidenote which and whereis do not list shell builtins Shell builtins are functions that are internal to the shell itself – no binary executable To see if you’re using a builtin, use type

apropos: what do I use? Not sure what utility you’re looking for? Try apropos keyword Displays utilities and libraries related to your keyword Found one, but not sure? whatis utility to show what it does, or check man page

locate: search for files System maintains a database of files Your system administrator should configure a job to regularly update this database Searches for any kind of file – not just utilities Some systems use slocate (secure) Latest distros use mlocate via locate

who: Who’s online? Displays what users are logged on Also displays when they logged on, and with what device (terminal or console, etc) Also try who am i

finger: reach out and touch … finger by itself displays users logged on like who, but also shows idle time and office location finger username shows info about that user, like home directory, last logon, their shell, if they have unread mail, and.plan and.project files

w: What’s up? w is similar to who by showing who’s logged on Also shows system uptime, and memory and CPU load averages Good overall status of the system

write: send a message write username opens up a text-based chat with the user Type message Wait for response CTRL-D to exit write

mesg: Enable/disable write Usage: mesg y|n Turns off whether users can write you or not Useful if you don’t want to be bugged

mail: system mail Our system is a closed system You can send mail to other users on the system No public mail