agenda chapter 1: linux (unix) features commands (chapters 2 & 3) command structure / command...

33
Agenda Chapter 1: Linux (Unix) Features Commands (Chapters 2 & 3) Command Structure / Command line editing man, passwd, cal, date, whereis, which Working with Files: file, cat, more, less, grep, head, tail, cp, mv, ls sort, uniq, diff Communicating with Users who, talk, write, mesg, finger

Upload: quentin-francis

Post on 30-Dec-2015

228 views

Category:

Documents


2 download

TRANSCRIPT

Page 1: Agenda Chapter 1: Linux (Unix) Features Commands (Chapters 2 & 3) Command Structure / Command line editing man, passwd, cal, date, whereis, which Working

Agenda Chapter 1: Linux (Unix) Features Commands (Chapters 2 & 3)

Command Structure / Command line editing man, passwd, cal, date, whereis, which Working with Files:

file, cat, more, less, grep, head, tail, cp, mv, ls sort, uniq, diff

Communicating with Users who, talk, write, mesg, finger

Page 2: Agenda Chapter 1: Linux (Unix) Features Commands (Chapters 2 & 3) Command Structure / Command line editing man, passwd, cal, date, whereis, which Working

Unix Structure The Linux operating system can be

visualized in terms of layers: Unix Kernel

controls the computer resources and schedules jobs Shell

acts as a command interpreter that acts as an interface between users and the operating system

Utilities (Commands) comprehensive set of utilities that are universally

required by Unix administrators & users. Utilities are often referred to as commands

Page 3: Agenda Chapter 1: Linux (Unix) Features Commands (Chapters 2 & 3) Command Structure / Command line editing man, passwd, cal, date, whereis, which Working

Linux Structure

Hardware

Linux Kernel

The shell & otherbasic utilities

Compilers

Mail & messagefacilities

Interpreters

Database MgmtSystem

Formatters

Editors

Inventory controlsystems

Spreadsheetapplications

Word processors

Calendar systems

Page 4: Agenda Chapter 1: Linux (Unix) Features Commands (Chapters 2 & 3) Command Structure / Command line editing man, passwd, cal, date, whereis, which Working

Utilities (Commands) For the remainder of this course, utilities

and commands are considered the same. Linux commands are usually typed in

lowercase followed by an argument (or arguments)

Pressing ENTER or RETURN signals that you have completed giving an instruction and that you are ready for the OS to execute the command or respond to your message

Page 5: Agenda Chapter 1: Linux (Unix) Features Commands (Chapters 2 & 3) Command Structure / Command line editing man, passwd, cal, date, whereis, which Working

Linux (Unix) Command Format

command [arg 1] [arg 2] … [arg n]

An argument is a filename, string or text, or some other object that a command acts upon

An option is also an argument that modifies the effect of a command

A space, a number of spaces, or a tab can be used to separate command from argument, or separate arguments.

Page 6: Agenda Chapter 1: Linux (Unix) Features Commands (Chapters 2 & 3) Command Structure / Command line editing man, passwd, cal, date, whereis, which Working

Correcting Mistakes You can correct mis-typed command

prior to pressing ENTER or RETURN Erase Characters

Backspace or CTRL-Backspace or CTRL-h Delete a Word

CTRL-w Delete an Entire Line

CTRL-u

Page 7: Agenda Chapter 1: Linux (Unix) Features Commands (Chapters 2 & 3) Command Structure / Command line editing man, passwd, cal, date, whereis, which Working

Correcting Mistakes Aborting Program Execution

DELETE or CTRL-c

Recalling Previous Commands Depends on shell & .profile setup

Phobos (check .profile for VISUAL variable): if VISUAL=vi <ESC><K> (K - up, J -

down) if VISUAL=emacs <CTRL><P>

Gothic: Up arrow , Down arrow

Page 8: Agenda Chapter 1: Linux (Unix) Features Commands (Chapters 2 & 3) Command Structure / Command line editing man, passwd, cal, date, whereis, which Working

man A comprehensive online manual for

common UNIX commands format:

man [options] command Options:

-k provides short (one-line) explanation relating to the commands matching the character string

eg. man -k mkdir

Page 9: Agenda Chapter 1: Linux (Unix) Features Commands (Chapters 2 & 3) Command Structure / Command line editing man, passwd, cal, date, whereis, which Working

passwd Used to change existing password format:

passwd [options]

Options: -f changes the user information

accessed by the finger command

Page 10: Agenda Chapter 1: Linux (Unix) Features Commands (Chapters 2 & 3) Command Structure / Command line editing man, passwd, cal, date, whereis, which Working

cal Used to display a calendar Format:

cal [month] [year] (calendar for specified

month & year) cal (displays calendar for current

month)

eg. cal 12 2000 (displays calendar month of December Year

2000)

Page 11: Agenda Chapter 1: Linux (Unix) Features Commands (Chapters 2 & 3) Command Structure / Command line editing man, passwd, cal, date, whereis, which Working

date Used to display or set the time & date Format:

date [option] [+format]

+format argument specifies format of display

After the + sign, can specify (within quotes) text as well as % followed by a field descriptor to indicate how date will be displayed

Page 12: Agenda Chapter 1: Linux (Unix) Features Commands (Chapters 2 & 3) Command Structure / Command line editing man, passwd, cal, date, whereis, which Working

date Popular Field Descriptors:

%A Full Weekday name %d Number of day %B Full month name %m Number of month %y Last 2 digits of year %Y 4-digit-year % I Hour %H Hour (Military time) %M Minutes %S Seconds %n New Line %r h:m:s with am or pm

eg. date +”Today is %A” (note no space between + and “)

%n is used to advance to the next line

Page 13: Agenda Chapter 1: Linux (Unix) Features Commands (Chapters 2 & 3) Command Structure / Command line editing man, passwd, cal, date, whereis, which Working

whereis / which whereis is a utility that lists all directory

paths that contains command or program For Example: whereis mv

which is a utility that lists only the directory path that the shell will run the command or program (used to help avoid confusion if more that 1 command but perform differently. Example: which mv

Page 14: Agenda Chapter 1: Linux (Unix) Features Commands (Chapters 2 & 3) Command Structure / Command line editing man, passwd, cal, date, whereis, which Working

Working with Files file, cat, more, less grep, head, tail cp, mv, ls sort, uniq, diff

Page 15: Agenda Chapter 1: Linux (Unix) Features Commands (Chapters 2 & 3) Command Structure / Command line editing man, passwd, cal, date, whereis, which Working

file Used to classify the type of file:

ASCII (text) or executable (binary)

Format: file [options] file-list

Page 16: Agenda Chapter 1: Linux (Unix) Features Commands (Chapters 2 & 3) Command Structure / Command line editing man, passwd, cal, date, whereis, which Working

cat Used to combine contents multiple files

(“catenate” means to join together). Can be used to display contents of one file

format: cat [options] [file-list]

*Refer to on-line manual regarding options for cat command

Page 17: Agenda Chapter 1: Linux (Unix) Features Commands (Chapters 2 & 3) Command Structure / Command line editing man, passwd, cal, date, whereis, which Working

more Displays a file, one screenful (spacebar) at

a time or scroll one line at a time (RETURN)

format: more [options] [file-list] Options:

-d prompts user to continue at bottom of screen note: when searching for text within more process, user can type k/pattern? ENTER to initiate text search.

In addition u for page up, d for down (can also use numbers to indicate amount of movement)

Page 18: Agenda Chapter 1: Linux (Unix) Features Commands (Chapters 2 & 3) Command Structure / Command line editing man, passwd, cal, date, whereis, which Working

less Less is a program similar to more, but

which allows backward movement in the file as well as forward movement (more movement options than more)

Format: less [options] [file-list] Please refer to online manual for movement options

Page 19: Agenda Chapter 1: Linux (Unix) Features Commands (Chapters 2 & 3) Command Structure / Command line editing man, passwd, cal, date, whereis, which Working

grep Used to search for a pattern which is

stored in a file or files. Format:

grep [options] pattern [file-list] Options:

-c displays # of lines that contains a match -i ignores case sensitivity -n displays line number of file that contains a

match -l displays only name of file that contains a match

Page 20: Agenda Chapter 1: Linux (Unix) Features Commands (Chapters 2 & 3) Command Structure / Command line editing man, passwd, cal, date, whereis, which Working

head Display the beginning lines of a file

format: head [-number] [file-list]

* “-number” indicates the number of lines (from the beginning of the file) that you want to have displayed

Page 21: Agenda Chapter 1: Linux (Unix) Features Commands (Chapters 2 & 3) Command Structure / Command line editing man, passwd, cal, date, whereis, which Working

tail Displays the tail or ending lines of a file

format: tail [-number] [+number] [options] [file]

* “-number” indicates the number of lines (from the bottom of the file) that you want to have displayed. “+number” indicates line number to display until end (tail) of file

Page 22: Agenda Chapter 1: Linux (Unix) Features Commands (Chapters 2 & 3) Command Structure / Command line editing man, passwd, cal, date, whereis, which Working

cp Used to copy one or more files format:

cp [options] sourcefile destinationfile

Options: -r subdirectories & contents are copied -i prompts user to overwrite existing

file

Page 23: Agenda Chapter 1: Linux (Unix) Features Commands (Chapters 2 & 3) Command Structure / Command line editing man, passwd, cal, date, whereis, which Working

mv Used to move or rename files format:

mv [options] oldfilename newfilename mv [options] existingfile-list directory mv [options] existingdirectory

newdirectory

Options: -i prompts user to overwrite existing file

Page 24: Agenda Chapter 1: Linux (Unix) Features Commands (Chapters 2 & 3) Command Structure / Command line editing man, passwd, cal, date, whereis, which Working

ls Used to display information regarding a

file or directory format:

ls [options] [file-list] Options:

-a short display of all files (incl. hidden files) -l detailed display of files (excl. hidden files) -al detailed display of all files -F displays / after directory, * after

executable file

Page 25: Agenda Chapter 1: Linux (Unix) Features Commands (Chapters 2 & 3) Command Structure / Command line editing man, passwd, cal, date, whereis, which Working

sort Used to sort or merge files.

Particularly useful as a filter to sort standard input.

Format: sort [options] [field-specifier-list][file-list]

Examples sort output.txt who | sort | more ls | sort > listing.txt

Page 26: Agenda Chapter 1: Linux (Unix) Features Commands (Chapters 2 & 3) Command Structure / Command line editing man, passwd, cal, date, whereis, which Working

uniq Used to display lines from a file that are

unique. Used after a sort, uniq will only display total “unique” lines of text

uniq [options] [inputfile] [outputfile]

Options: -c preceed line with # of occurrence line in input file -d display only lines that are repeated

-u display only lines that are not repeated

Page 27: Agenda Chapter 1: Linux (Unix) Features Commands (Chapters 2 & 3) Command Structure / Command line editing man, passwd, cal, date, whereis, which Working

diff Displays the differences between

two files. Provides instructions as to editing steps to make files identical

diff [options] [file1] [file2]diff [options] [directory1] [directory2]

Options: -b ignore blanks

Page 28: Agenda Chapter 1: Linux (Unix) Features Commands (Chapters 2 & 3) Command Structure / Command line editing man, passwd, cal, date, whereis, which Working

Communicating with Others

who talk write mesg finger

Page 29: Agenda Chapter 1: Linux (Unix) Features Commands (Chapters 2 & 3) Command Structure / Command line editing man, passwd, cal, date, whereis, which Working

who Used to display names of users logged

into system Format:

who [options] who or who am i or whoami Options:

-H displays head above user information -i displays # of minutes user was idle -T displays message reception status

Page 30: Agenda Chapter 1: Linux (Unix) Features Commands (Chapters 2 & 3) Command Structure / Command line editing man, passwd, cal, date, whereis, which Working

talk / write talk allows user to conduct a two-way text-

based conversation. To initiate talk you type: talk phobos_user_id (use who -T to determine if user is receiving messages)

write is used to send a message to another user. To send a message, type:write phobos_user_id (Mainly used to broadcast a message but can be used to chat - user who -T to check mesg status first)

Page 31: Agenda Chapter 1: Linux (Unix) Features Commands (Chapters 2 & 3) Command Structure / Command line editing man, passwd, cal, date, whereis, which Working

mesg Used to “turn on” or “turn-off” reception

of messages from other users.

To turn on message reception status, type:mesg y <ENTER>

To turn-off message reception status, type:mesg n <ENTER>

Page 32: Agenda Chapter 1: Linux (Unix) Features Commands (Chapters 2 & 3) Command Structure / Command line editing man, passwd, cal, date, whereis, which Working

finger Used to display user names and related

information format:

finger [options] [user-list] Options:

-l displays detailed information of all users -m matches names specified from user-list -q displays short report of users logged on -s displays a short report for each user

incl.name

Page 33: Agenda Chapter 1: Linux (Unix) Features Commands (Chapters 2 & 3) Command Structure / Command line editing man, passwd, cal, date, whereis, which Working

finger Interesting point:

finger utility will display contents in file “.plan” and “.project” in the user’s home directory.

These files are useful to provide additional information about the user

eg. finger msaul (In phobos) finger jankul (In phobos) Note: you need to set the file permissons to

allow group & others to read file!