System Administration Introduction to Unix Session 2 – Fri 02 Nov 2007 Reference:  chapter 1, The Unix Programming Environment, Kernighan & Pike, ISBN.

Slides:



Advertisements
Similar presentations
By: Tony Andrews.  Linux directory ordering system  Navigating and creating directories ◦ Listing directories and files ◦ Creating directories ◦ Changing.
Advertisements

Learning Unix/Linux Bioinformatics Orientation 2008 Eric Bishop.
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.
Introduction to UNIX CSE 2031 Fall May 2015.
NETW-240 Shells Last Update Copyright Kenneth M. Chipps Ph.D. 1.
ATS Programming Short Course I INTRODUCTORY CONCEPTS Tuesday, Jan. 27 th, 2009 Essential Unix Commands.
Guide To UNIX Using Linux Third Edition
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.
Linux Commands LINUX COMMANDS.
L INUX C OMMAND L INE I NTERFACE G UNAANBAN.G
CS 141 Labs are mandatory. Attendance will be taken in each lab. Make account on moodle. Projects will be submitted via moodle.
Introduction to Linux Workshop February Introduction Rob Lane & The HPC Support Team Research Computing Services CUIT.
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”
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.
CHAPTER 1 UNIX FOR NONPROGRAMMERS By U ğ ur Halıcı.
Linux environment ● Graphical interface – X-window + window manager ● Text interface – terminal + shell.
1 Lecture 2 Working with Files and Directories COP 3344 Introduction to UNIX.
Essential Unix at ACEnet Joey Bernard, Computational Research Consultant.
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
Basic unix commands that everyone should know (Even if you have a mac) Slightly more advanced:
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.
LIN Unix Lecture 3 Hana Filip. LIN UNIX Resources UNIX Tutorials UNIX help for.
Linux overview. Architecture Kernel File system Shell: Korn, Bourne, C, Bash X Windows: Motif, Open Look, X.OrgX.Org Desktop: Gnome, KDE,etc.
Session 2 Wharton Summer Tech Camp Basic Unix. Agenda Cover basic UNIX commands and useful functions.
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.
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.
1 System Administration Introduction to Scripting, Perl Session 3 – Sat 10 Nov 2007 References:  chapter 1, The Unix Programming Environment, Kernighan.
1 Operating Systems and Using Linux Topics What is an Operating System? Linux Overview Frequently Used Linux Commands Some content in this lecture added.
Lesson 2-Touring Essential Programs. Overview Development of UNIX and Linux. Commands to execute utilities. Communicating instructions to the shell. Navigating.
Chapter Five Advanced File Processing. 2 Lesson A Selecting, Manipulating, and Formatting Information.
Introduction to Programming Using C An Introduction to Operating Systems.
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.
2 Manual & Filestore Mauro Jaskelioff. Introduction Using the manual The UNIX filestore File permissions.
1 Lecture 2 Working with Files and Directories COP 3353 Introduction to UNIX.
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.
1 CS3695 – Network Vulnerability Assessment & Risk Mitigation – Introduction to Unix & Linux.
Unix Fundamentals CS 127. File navigation cd - change directory cd /var/log cd /etc/apache2 cd ~/Desktop ~ is a shortcut for the home directory.
Learning basic Unix command It 325 operating system.
Lesson 6-Using Utilities to Accomplish Complex Tasks.
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.
UNIX To do work for the class, you will be using the Unix operating system. Once connected to the system, you will be presented with a login screen. Once.
Quality Thought Technologies
Commands Basic syntax of shell commands UNIX or shell commands have a basic structure command -options target command comes first (such as cd or ls) any.
Prepared by: Eng. Maryam Adel Abdel-Hady
Some Linux Commands.
C151 Multi-User Operating Systems
The Command Prompt Commands are the way to “do things” in Unix
INTRODUCTION TO UNIX: The Shell Command Interface
Tutorial of Unix Command & shell scriptS 5027
Basic UNIX OLC Training.
Introduction to UNIX.
Tutorial of Unix Command & shell scriptS 5027
Using Linux Commands Lab 3.
LING 408/508: Computational Techniques for Linguists
Introduction to Linux Week 0 - Thursday.
Guide To UNIX Using Linux Third Edition
Tutorial of Unix Command & shell scriptS 5027
Chapter Four UNIX File Processing.
Linux Shell Script Programming
Linux Commands LINUX COMMANDS.
Presentation transcript:

System Administration Introduction to Unix Session 2 – Fri 02 Nov 2007 Reference:  chapter 1, The Unix Programming Environment, Kernighan & Pike, ISBN X Albert Lingelbach, Jr.

History of Unix Begun in 1969 at Bell Labs  Timesharing / Multiuser One computer, many terminals Programming Typesetting Group Communication

Architecture Kernel Windowing System  Gnome Shell Programs

The shell environment tty (teletype) / terminal  text only  24 lines, 80 columns default shell: Bourne shell  to open a tty: right-click on desktop, choose “Open Terminal” echo  print text to the tty  try: echo Hello what shell is running ? echo $0

Simple commands bash  compatible with sh, added features: command history with up arrow editable command line backspace (vs. delete)‏ date  system date and time who  what users are on the system

Flow Control characters ctrl-C  stop a running command  try: troff ctrl-S / ctrl-Q  pause/unpause output  try: countdown 1000 end input  ctrl-D

Command Arguments / Parameters mis-typed command  gold: not found command arguments / parameters  try: who am i  try: gold coins

User Communication news  get local system news (written by the system administrator)‏  try: news write  write messages to another user on the system; like IM but local  try: pair off using who, find userid of your partner write userid (and your partner does same) exchange messages

Manual Pages You have seen the following commands:  date  who  news  write  sh  bash How to find more about them ?  command -? often returns a short command synopsis  man command returns the complete manual page reference for the command

Files As in any computer system, data is stored in files Most Unix files are (ASCII) text Many Unix commands manipulate text files

File Naming case sensitive spaces are problematic dot and underscore are useful separators

File Commands – 1 current (“working”) directory pwd  print the working directory ls  list the files in the working directory cd path  change the working directory

File Paths 1 filenames without a path default to the current directory  example: myfile.txt / is the root or top of the file system tree a file path contains directories separated by “/” (not “\” as in DOS/windows)‏  example: /home/export/staff/alingelb/file.txt

File Paths 2 relative paths (not starting with “/”) start at the current directory current directory (.)‏ parent directory (..)‏  relative to any preceding directory examples: ./file.txt (the same as file.txt )‏ ../../student/kate/file.txt in general, any command that takes a file as an argument, will accept a path + file (path/file)‏

File Commands - 2 touch filename  create an empty file  example: touch myfile.txt rm filename  delete a file (forever – be careful!)‏  example: rm myfile.txt cp original_file new_file  copy a file  example: cp myfile.txt copy_of_myfile.txt

File Commands - 3 mv original_file new_filename mv original_file new_location  new_location must already exist  file keeps same name mv original_file new_location/new_filename  move a file  examples: mv myfile.txt newname.txt mv myfile.txt.. mv myfile.txt /usr/bin/students.txt

File Commands - 4 cat file cat file1 file2...  display the contents of the file(s) on the screen more file  display the contents of the file on the screen, on screenful at a time (press space for the next screen, return to advance one line)‏ gedit file  edit the file in the gnome graphical editor

Directory Commands mkdir dirname mkdir path/dirname  create the directory rmdir dirname  remove the directory (it must be empty)‏

Shell filename wildcards 1 it can be useful to match filenames by pattern:  * matches any set of characters (or no characters)‏  ? matches one character examples:  *file* matches any filename containing “file”  *.txt matches any filename that ends in “.txt”  this* matches any filename that starts with “this”

Shell filename 2 wildcards  More examples:

Shell filename wildcards 3 More examples:  cat chapter*.txt will output to the screen all files that start in chapter and end in.txt  ls *.txt will list all files that end in.txt  mv *.txt /export/home/alingelb will move all files ending in.txt to the directory /export/home/alingelb

More useful (text) file commands 1 grep pattern file search for the pattern in the file, and output the line(s) containing the pattern sort file sort the lines of the file in alphabetical order head file display the first 10 lines of the file

More useful (text) file commands 2 tail file display the last 10 lines of the file wc file count the number of lines, words, and characters in the file diff file1 file2 display the differences between the two files

File permissions 1 Every file has read, write, and execute permissions (RWX)‏ These are set by the owner, for the owner, the group, and everyone else; so there are 9 permissions total (plus a few special ones to be discussed later).

File permissions 2 ls -l will display file permissions, along with the group and owner  example: $ ls -l total 3 -rwxr-xr-x 2 alingelb staff 512 Nov 2 10:38 Desktop drwxr-xr-x 3 alingelb staff 512 Oct 16 11:15 Documents -rw alingelb staff 40 Nov 2 12:13 foonly.txt

File permissions 3 chmod ### file is used to change file permissions  the first # is owner permissions  the second # is group permissions  the third # is everyone else permissions  the # is composed of (add the numbers): 4 for read 2 for write 1 for execute

File permissions 4 chmod example:  chmod 744 file sets owner to read/write/execute sets group to read sets everyone else to read

Shell theory The shell is a command interpreter It interfaces between the user and programs and the kernel It has its own syntax In addition to providing access to programs and to the kernel, the shell has some powerful features of its own, including  wildcards  I/O redirection  scripting

I/O management 1 Every process has 3 channels of information:  “standard” input  “standard” output  error output These can be controlled by the shell:  command > file sends the standard output of the command to a file  command < file sends the contents of a file to the standard input of the command  command >> file appends the standard output of the command to the end of a file

std I/O management Examples  ls > listing.txt  echo “this is a test” > test.txt  echo “the test continues” >> test.txt  echo “6 + 6” > math.txt  bc < math.txt

more I/O management More I/O redirection  There is a special empty file /dev/null it discards all output  command 2> /dev/null discards all error output example: touch testfile chmod 000 testfile cat testfile 2> /dev/null  command1 | command2 send the output of command1 as the input of command 2 example: ls | wc

I/O management: pipe Advanced example of pipe  wanted: list of users on system. build it incrementally using pipe.  who gives list of users, but there are duplicates (because user appears once for each session); also, who gives too much information  using cut to remove extraneous information: who | cut -d\ -f1 gives list of users, still with duplicates  who | cut -d\ -f1 | sort sorts list, putting duplicates together  who | cut -d\ -f1 | sort | uniq removes duplicates; this is the desired list

Review Concepts  Unix history, multiuser/timesharing, kernel, shell, man pages, file permissions Flow control  ctrl-C, ctrl-S, ctrl-Q, ctrl-D Commands:  echo, bash, date, who, pwd, ls, cd, touch, rm, cp, mv, cat, more, gedit, mkdir, rmdir, grep, sort, head, tail, wc, diff, chmod, bc File paths & wildcards  *, ? I/O management  >, >>,