Introduction to Unix

Total Page:16

File Type:pdf, Size:1020Kb

Introduction to Unix Introduction to Unix BorisBoris KonevKonev [email protected] http://www.csc.liv.ac.uk/~konev Important information Instructor: – Boris Konev – Office: 1.12 – Email: [email protected] – Web resources: www.csc.liv.ac.uk/~konev/COMP110 NoNo lectureslectures onon Monday!!Monday!! Objectives • Basic structure of the operating system • What makes Unix special? • Unix System Design • Essential commands • Essential concepts • Shells • Shell programming • Text processing • Unix utilities Why Bother Studying Unix? • Most powerful computers (supercomputers) use the Unix operating system • Unix runs the Internet • Unix is used as an embedded system in hardware – networking, user appliances (DVD players) • A knowledge of Unix is likely to be helpful in your future career, regardless of where you pursue it. History of Unix 1960s “multics” project (MIT, GE, AT&T) 1970s AT&T Bell Labs 1970s/80s UC Berkeley 1980s DOS imitated many Unix ideas Commercial Unix fragmentation GNU Project 1990s Linux now Unix is widespread and available from many sources, both free and commercial Unix Systems • Commercial – SunOS/Solaris Sun Microsystems – Digital Unix (Tru64) Digital/Compaq – HP-UX Hewlett Packard – Irix SGI – UNICOS Cray – Mac OS X Apple – … • Free – NetBSD, FreeBSD, … – Linux – … What makes Unix so special? (1) • Portability (runs on almost every hardware) • Old and popular – it is easy to find information and get help • Simplicity, elegance & flexibility • Time-sharing: multi-tasking & multi-user environment • Unix is very stable – computers running Unix almost never crash What makes Unix so special? (2) • Unix is very efficient – it gets maximum number crunching power out of your processor (and multiple processors) – it can smoothly manage extremely huge amounts of data – it can give a new life to otherwise obsolete Macs and PCs • System design decisions (made by programmers for programmers) • Free and open source flavors available (Linux, *BSD) • It is not Windows ☺ The Unix Philosophy • A large set of primitive tools, which can be put together in an infinite number of powerful ways • An example: – Three separate tools are necessary to develop software: • Text editor • Compiler • Debugger – MSVC is an “IDE” (“Integrated Development Environment”) • All three tools are found in one shrink-wrapped box – (There are IDE tools for Unix) Unix Has Home Drawbacks • Unix computers are controlled by a command line interface – NOT user-friendly – difficult to learn, even more difficult to truly master • Hackers love Unix – there are lots of security holes (first software viruses were Unix-specific) – most computers on the Internet run Unix , so hackers can apply the same tricks to many different computers • There are many different versions of Unix with subtle (or not so subtle) differences Mac OS X The K Desktop Environment (KDE) Gnome Operating Systems Managing Hardware and Software Disk Screen Keyboard Drive Printer Application Software Utilities Unix Structure Kernel: controls hardware, creates processes, implements multi-tasking, manages file system Programs interact with the kernel • Unix Utilities: compilers, text processors,… • Shell: interprets user commands and sends them to kernel • GUI: based on X Window System • User programs Getting Started—Logging In Unix is a multi-user operating system • Login and password prompt to log in • login is user’s unique name • password is changeable; known only to user, not to system staff (!!) /like the debit card PIN number/ • Unix is case sensitive Passwords (1) Do: • make sure nobody is looking over your shoulder when you are entering your password. • change your password often • choose a password you can remember • use eight characters, more on some systems • use a mixture of character types – include punctuation and other symbols Passwords (2) Don’t: • use a word (or words) in any language • use a proper name • use information in your wallet • use information commonly known about you • use control characters • write your password anywhere • EVER give your password to anybody Command Line Interface (1) A command is a program that tells the Unix system to do something. It has the form: command options arguments • “Whitespace” separates parts of the command line • An argument indicates on what the command is to perform its action • An option modifies the command, usually starts with “-” Example: $ ls –l –a Papers Command Line Interface (2) • Not all Unix commands will follow the same standards • Options and syntax for a command are listed in the “man page” for the command Some First Commands (1) $ date Sun Feb 29 18:27:09 GMT 2004 $ who konev pts/0 Feb 27 18:15 konev pts/1 Feb 27 18:15 konev pts/2 Feb 27 18:22 konev pts/3 Feb 28 19:32 konev pts/4 Feb 29 18:17 (konev- lt.laptop.csc.liv.ac.uk) $ who –q konev konev konev konev konev # users=5 Some First Commands (2) $ finger $ finger <username> Who is logged in? $ finger <real name> $ man <command name> UNIX Manual Pages Hands-on Practice • In the department: – “Open Unix session” • At home: – A range of free Unix-like systems is available • FreeBSD (www.freebsd.org) • NetBSD (www.netbsd.org) • SUN Solaris (www.sun.com) • Linux Linux Distributions • RedHat – probably the best-known Linux company in the world • SUSE – popular in Europe, especially in Germany. Acquired by Novell in late 2003. • Mandrake – French distribution (special attention to usability) • Debian – completely non-commercial project • Knoppix – great for trying out Linux without getting your hands dirty as it runs directly from a CD, no installation required (www.knoppix.com) The Hierarchical File System Ordinary (plain) files - text, data, programs, etc Directories – files containing references to other files (folders) Special files - interfaces to hardware (e.g. /dev/rmt8), named pipes,… Unix Filenames • Unix is case sensitive (myfile.txt and MyFile.txt are different) • UNIX filenames contain only letters, numbers, and the _ (underscore), . (dot), and - (dash) characters. • Unix does not allow two files to exist in the same directory with the same name. – Whenever a situation occurs where a file is about to be created or copied into a directory where another file has that exact same name, the new file will overwrite (and delete) the older file. – Unix will generally may alert you when this is about to happen, but it is easy to ignore the warning. Filename Extensions • Most Unix filenames start with a lower case letter and end with a dot followed by one, two, or three letters: myfile.txt – However, this is just a common convention and is not required. – It is also possible to have additional dots in the filename. • For example, myfyle.txt.gz • The part of the name following the dot is called the “extension.” Some common extensions • The extension is often used to designate the type of file. • By convention: – files that end in .txt are text files – files that end in .c are source code in the "C” language – files that end in .html are HTML files for the Web – Compressed files have the .zip or .gz extension • Unix does not require these extensions (unlike Windows), but it is a sensible idea and one that you should follow The working directory At any given time when interacting with Unix, you are “working in” or “connected to” some directory. This is called your ``working directory.'' You will typically change your working directory (with the cd command, discussed later) several times during a single session. The pwd command prints the name of the current working directory. $ pwd [print working directory] Files & Directories $ file <filename(s)> $ ls <directory> $ ls –a $ ls –l To copy, move & remove a file $ cp <source-file> <destination-file> $ mv <source-file> <destination> $ rm <filename> Directories Making, removing & changing directories $ mkdir <directory-name> $ rmdir <directory-name> $ cd <directory-name> Displaying the current path $ pwd Wildcard Operators Asterisk * matches any character sequence, e.g. in file names Question mark ? matches any single character Brackets [ ] match specified characters $ cp *.doc WordFiles/ $ cp *.??? WordFiles/ $ rm ab*c $ ls art[12] Shortcuts • There are some important shortcuts in Unix for specifying directories – . (dot) means "the current directory" – .. means "the parent directory" - the directory one level above the current directory, so cd .. will move you up one level – ~ (tilde) means your Home directory, so cd ~ will move you back to your Home. • Just typing a plain cd will also bring you back to your home directory Unix File Protections • File protection (also known as permissions) enables the user to set up a file so that only specific people can read (r), write/delete (w), and execute (x) it. • Write and delete privilege are the same on a Unix system since write privilege allows someone to overwrite a file with a different one. File Owners and Groups • Unix file permissions are defined according to ownership. The person who creates a file is its owner. – Everyone is a user – You are the owner of files in your Home directory and all its sub-directories • In addition, there is a concept known as a Group. – Members of a group have privileges to see each other's files. – Users are in at least one group View File Permissions A “long” ls listing shows file permissions: $ls -l … -rw------- 1 konev csc 477658 Feb 21 17:20 main_save.ps -rw------- 1 konev csc 2040 Feb 3 17:33 michael -rw-r--r-- 1 konev csc 365089 Jun 4 2003 old.ps drwx--x--x 3 konev csc 1024 Feb 21 17:29 one_file … The first character in the attribute string indicates
Recommended publications
  • Beginning Portable Shell Scripting from Novice to Professional
    Beginning Portable Shell Scripting From Novice to Professional Peter Seebach 10436fmfinal 1 10/23/08 10:40:24 PM Beginning Portable Shell Scripting: From Novice to Professional Copyright © 2008 by Peter Seebach All rights reserved. No part of this work may be reproduced or transmitted in any form or by any means, electronic or mechanical, including photocopying, recording, or by any information storage or retrieval system, without the prior written permission of the copyright owner and the publisher. ISBN-13 (pbk): 978-1-4302-1043-6 ISBN-10 (pbk): 1-4302-1043-5 ISBN-13 (electronic): 978-1-4302-1044-3 ISBN-10 (electronic): 1-4302-1044-3 Printed and bound in the United States of America 9 8 7 6 5 4 3 2 1 Trademarked names may appear in this book. Rather than use a trademark symbol with every occurrence of a trademarked name, we use the names only in an editorial fashion and to the benefit of the trademark owner, with no intention of infringement of the trademark. Lead Editor: Frank Pohlmann Technical Reviewer: Gary V. Vaughan Editorial Board: Clay Andres, Steve Anglin, Ewan Buckingham, Tony Campbell, Gary Cornell, Jonathan Gennick, Michelle Lowman, Matthew Moodie, Jeffrey Pepper, Frank Pohlmann, Ben Renow-Clarke, Dominic Shakeshaft, Matt Wade, Tom Welsh Project Manager: Richard Dal Porto Copy Editor: Kim Benbow Associate Production Director: Kari Brooks-Copony Production Editor: Katie Stence Compositor: Linda Weidemann, Wolf Creek Press Proofreader: Dan Shaw Indexer: Broccoli Information Management Cover Designer: Kurt Krames Manufacturing Director: Tom Debolski Distributed to the book trade worldwide by Springer-Verlag New York, Inc., 233 Spring Street, 6th Floor, New York, NY 10013.
    [Show full text]
  • Introduction to Unix
    Introduction to Unix Rob Funk <[email protected]> University Technology Services Workstation Support http://wks.uts.ohio-state.edu/ University Technology Services Course Objectives • basic background in Unix structure • knowledge of getting started • directory navigation and control • file maintenance and display commands • shells • Unix features • text processing University Technology Services Course Objectives Useful commands • working with files • system resources • printing • vi editor University Technology Services In the Introduction to UNIX document 3 • shell programming • Unix command summary tables • short Unix bibliography (also see web site) We will not, however, be covering these topics in the lecture. Numbers on slides indicate page number in book. University Technology Services History of Unix 7–8 1960s multics project (MIT, GE, AT&T) 1970s AT&T Bell Labs 1970s/80s UC Berkeley 1980s DOS imitated many Unix ideas Commercial Unix fragmentation GNU Project 1990s Linux now Unix is widespread and available from many sources, both free and commercial University Technology Services Unix Systems 7–8 SunOS/Solaris Sun Microsystems Digital Unix (Tru64) Digital/Compaq HP-UX Hewlett Packard Irix SGI UNICOS Cray NetBSD, FreeBSD UC Berkeley / the Net Linux Linus Torvalds / the Net University Technology Services Unix Philosophy • Multiuser / Multitasking • Toolbox approach • Flexibility / Freedom • Conciseness • Everything is a file • File system has places, processes have life • Designed by programmers for programmers University Technology Services
    [Show full text]
  • Ardpower Documentation Release V1.2.0
    ardPower Documentation Release v1.2.0 Anirban Roy Das Sep 27, 2017 Contents 1 Introduction 1 2 Screenshot 3 3 Documentaion 5 3.1 Overview.................................................5 3.2 Installation................................................7 3.3 Usage................................................... 12 4 Indices and tables 13 i ii CHAPTER 1 Introduction Its a custom Oh-My-Zsh Theme inspired by many custom themes suited for a perfect ZSH Environment under Byobu with Tmux Backend. 1 ardPower Documentation, Release v1.2.0 2 Chapter 1. Introduction 3 ardPower Documentation, Release v1.2.0 CHAPTER 2 Screenshot 4 Chapter 2. Screenshot CHAPTER 3 Documentaion You can also find PDF version of the documentation here. Overview We will start with understanding the individual components of an entire CLI. Generally we don’t put much attention to what we do. We just fire up a terminal or some say sheel and start typing our commands and get the result. That’s all. But there are a lot of things that goes behind all this. Terminal The very first component is the Terminal. So what is a Terminal? A terminal emulator, terminal application, term, or tty for short, is a program that emulates a video ter- minal within some other display architecture. Though typically synonymous with a shell or text terminal, the term terminal covers all remote terminals, including graphical interfaces. A terminal emulator inside a graphical user interface is often called a terminal window.A terminal window allows the user access to a text terminal and all its applications such as command-line interfaces (CLI) and text user interface (TUI) applications.
    [Show full text]
  • Unix Shell Programming – by Dinesh Kumar S
    1 Unix Shell Programming – by Dinesh Kumar S PDF by http://www.k2pdf.com Contents Chapters Topic Page no. Chapter 1 Introduction 3 Chapter 2 SSH Client 4 Chapter 3 Unix Shells 8 Chapter 4 Text Editors 11 Chapter 5 A Beginning to Shell Scripting 19 Chapter 6 Operators 33 Chapter 7 Variables Manipulation (Advance) 39 Chapter 8 Conditional Statements 43 Chapter 9 Looping Statements 47 Chapter 10 Control Statements 74 Chapter 11 Functions 79 2 Unix Shell Programming – by Dinesh Kumar S Chapter 1 Introduction Linux : It is an operating system based on UNIX . Kernel : It is the backbone of Linux OS, which is used to manage resources of Linux OS like memory, I/O, software, hardware management processes. User Shell Script Kernel PC h/w User writes script. Script contains instructions. Kernel interprets the instruction in machine language. As per the instruction kernel controls the PC hardware. Shell script : It’s a collection of OS commands or instructions. Advantages of Shell Script : Script is always a platform independent. Performance will be faster than programming languages. Very easy to debug. 3 Unix Shell Programming – by Dinesh Kumar S Chapter 2 SSH Client Secure Shell (or) SSH is a network protocol that is used to exchange or share information between two different networks. This is used on Linux & UNIX systems to access SHELL accounts. All the information exchanged/transmitted between networks is encrypted . It uses public key cryptography to authenticate remote computer user. Free Serial, Telnet, and SSH client Putty Tera Term Putty : It is a terminal emulator application which acts as client for SSH, Telnet, rLogin.
    [Show full text]
  • Augmented Unix Userland
    Project MXC-403 Augmented Unix Userland Major Qualifying Project Submitted to the Faculty of Worcester Polytechnic Institute in partial fulfillment of the requirements for the Degree in Bachelor of Science in Computer Science By Sam Abradi [email protected] Ian Naval [email protected] Fredric Silberberg [email protected] Submitted On: April 30, 2015 Project Advisor: Professor Michael Ciaraldi [email protected] This report represents work of WPI undergraduate students submitted to the faculty as evidence of a degree requirement. WPI routinely publishes these reports on its web site without editorial or peer review. For more information about the projects program at WPI, see http: // www. wpi. edu/ Academics/ Projects . Abstract The Unix philosophy has resulted in stringing together simple general purpose utili- ties to accomplish complex tasks. However, using text as a communication medium between these programs requires several formatting utilities to transform output from one program into valid input to another. These transformations can be very complicated and confusing. This project looked at two alternative shell designs that use different communication methods between programs, simplifying interprogram communication and leveraging existing technologies to make developing new utilities and shell scripts easier. i Contents Abstracti List of Figuresv List of Tables vi 1 Introduction1 1.1 AUU Terminology.............................1 1.2 Motivation.................................1 1.3 The AUU Project.............................3 2 JSON Shell4 2.1 Motivation: Why JSON?.........................4 2.2 JSON Protocol Design..........................4 Streams..................................4 Standards and Definitions........................5 Example Use Case: ps..........................6 2.3 Tributary.................................8 Tributary Selectors............................8 Using Tributary to Standardize Output.................9 2.4 Utilities Implemented..........................
    [Show full text]
  • A User's Guide to the Z-Shell
    A User’s Guide to the Z-Shell Peter Stephenson 2003/03/23 2 Contents 1 A short introduction 11 1.1 Other shells and other guides . 12 1.2 Versions of zsh . 13 1.3 Conventions . 14 1.4 Acknowledgments . 15 2 What to put in your startup files 17 2.1 Types of shell: interactive and login shells . 17 2.1.1 What is a login shell? Simple tests . 18 2.2 All the startup files . 19 2.3 Options . 21 2.4 Parameters . 21 2.4.1 Arrays . 23 2.5 What to put in your startup files . 24 2.5.1 Compatibility options: SH_WORD_SPLIT and others . 24 2.5.2 Options for csh junkies . 32 2.5.3 The history mechanism: types of history . 34 2.5.4 Setting up history . 36 2.5.5 History options . 37 2.5.6 Prompts . 39 2.5.7 Named directories . 42 2.5.8 ‘Go faster’ options for power users . 43 2.5.9 aliases . 45 2.5.10 Environment variables . 46 3 4 CONTENTS 2.5.11 Path . 47 2.5.12 Mail . 48 2.5.13 Other path-like things . 49 2.5.14 Version-specific things . 50 2.5.15 Everything else . 50 3 Dealing with basic shell syntax 51 3.1 External commands . 51 3.2 Builtin commands . 53 3.2.1 Builtins for printing . 53 3.2.2 Other builtins just for speed . 56 3.2.3 Builtins which change the shell’s state . 57 3.2.4 cd and friends . 59 3.2.5 Command control and information commands .
    [Show full text]
  • Linux Shells What Is Linux and Why Should We Use It?
    Linux Shells What is linux and why should we use it? Linux is a fast growing operating system, and it is inexpensive and flexible. Linux is also a major player in the small and mid-sized server field, and it’s an increasingly viable platform for workstation and desktop use as well. By understanding Linux, you’ll increase your standing in the job market... Linux is a clone of the UNIX operating system (OS) that has been popular in academia and many business environments for years. Formerly used exclusively on large mainframes, UNIX and Linux can now run on small computers. Because of its mainframe heritage, UNIX (and hence also Linux) scales well to perform today’s demanding scientific, engineering, and network server tasks. Linux consists of a Kernel, which is the core control software, and many libraries and utilities that rely on the Kernel to provide features with which user interact. The OS is available in many different distributions, which are collections of a specific Kernel with specific support programs. Command-Line Basics. Before you can do anything else with Linux, you should understand how to use a Linux shell. Several shells are available, but most of them provide similar capabilities. Understanding a few basics will take you a long way in your use of Linux, so I describe some of these techniques and commands. Linux Shell Options: Linux provides a range of options for shells. A complete list would be quite long so I only named the more common choices which include the following: bash – The GNU Bourne Again Shell (bash) is based on the earlier Bourne shell for UNIX but extends it in several ways.
    [Show full text]
  • Tip 36: Try a New Shell
    Tip 36: Try a new shell Ben Klemens 12 December 2011 level: command-line habitant purpose: get comfortable in your shell I started (Entry #082) this set of shell tips with a list I made up: the shell provides (1) facilities for interactive comfort, (2) history, (3) a ton of macro-like expansions, and (4) programming standards like for loops and if statements. I then gave you tips for parts (2), (3), and (4). Here’s my tip for item (1): try a new shell. There is no particular reason for the interactive features to stick to any one standard, because it is by definition not the programmable and scriptable part of things, so some shells provide much more user comfort than others. If some shell wants to have an animated paperclip in the corner kibbitzing your work, who’re they hurting? The shell you’re using now is probably bash, the Bourne-again shell, so named because it’s a variant of Stephen Bourne’s shell for the original UNIX. It is part of the GNU project, and so has very wide distribution. But wide distribution means that it can’t be too experimental with new features and comforts, because it has to run everywhere, and for every stupid quirk somebody has written a really important shell script that depends upon that quirk. I have my own complaints: GNU tools tend to provide half-hearted support for the vi keymap (which I have very much internalized), and the manual page is amazing for having absolutely no examples. If you are on a Mac with software a couple of years old, then you may be on a version of the C shell.
    [Show full text]
  • Introduction Configuring and Using the Z Shell
    Laboratory Assignment One 1 Due: February 3, 2014 CMPSC 440 Operating Systems Spring 2014 Laboratory Assignment One: Customizing and Using the Z Shell Introduction Computer scientists who use, configure, and implement an operating system (OS) often interact with the OS through the use of the shell. There are many operating system shells available for the Unix, Linux, and Mac OSX operating systems (i.e., sh, tcsh, bash, and fish). In this laboratory session, you will learn how to configure and use zsh, arguably the most advanced and customizable shell for the Linux operating system; learn more about it by visiting http://zsh.sourceforge.net. Configuring and Using the Z Shell To start using the Z shell, hereafter abbreviated as zsh, you must open a terminal window and type zsh. Try to navigate your file system and run a program through zsh. Do you notice any differences between this new shell and the one that you were using previously? What is the name of the shell that is the default for the Ubuntu operating system? Which do you like better? Why? Zsh can be quickly and easily configured with a community-driven configuration framework called oh-my-zsh. You can learn more about this framework by visiting the following Web site: https://github.com/robbyrussell/oh-my-zsh. Once you understand the basics of oh-my-zsh, please follow the instructions on the project's Web site to install it in your home account. After installing this framework, does your shell operate in a different way? If yes, then how? The oh-my-zsh framework supports a wide variety of themes for your shell.
    [Show full text]
  • Basic Bash Programming
    Basic Bash programming Simon Funke1;2 Hans Petter Langtangen1;2 Joakim Sundnes1;2 Ola Skavhaug3 Jonathan Feinberg Center for Biomedical Computing, Simula Research Laboratory1 Dept. of Informatics, University of Oslo2 Expert Analytics (formerly Dept. of Informatics, University of Oslo)3 Aug 25, 2015 1 Some more course information 2 Basic Bash programming We will use Piazza as a knowledge platform Allows students to ask and answer questions. Great discussion platform. Lecturers/teaching assistants will be active on the platform to help. Sign up: http://piazza.com/uio.no/fall2015/inf3331inf4331 Assignment 1 Deadline: 4st September. Make sure that you have your private INF3331 repository in your github account (you should have gotten an email with instructions). If not, visit the group session 1 today (14:15-16:00) or ask on Piazza. Download this and future assignments from the INF3331 website. http://www.uio.no/studier/emner/matnat/i/INF3331/h15 Good introductions to git A Quick intro to Git and GitHub: http://hplgit.github.io/teamods/bitgit/Langtangen_github.pdf A more extensive introduction to Git: https://git-scm.com/book/en/v2 (rst three chapters). 1 Some more course information 2 Basic Bash programming Overview of Unix shells The original scripting languages were (extensions of) command interpreters in operating systems Primary example: Unix shells Bourne shell (sh) was the rst major shell C and TC shell (csh and tcsh) had improved command interpreters, but were less popular than Bourne shell for programming Bourne Again shell (Bash/`bash`):
    [Show full text]
  • Linux/Unix Shell Intro Outline
    12/10/13 Linux/Unix Shell Intro Dr. Chokchai (Box) Leangsuksun Louisiana Tech University Original slides were created by Dr. deBry from uvu.edu 1 Outline Louisiana Tech University 2 2 1 12/10/13 USER Interface • Command Line Interface • Shell commands • C-shell, tsh-shell, bourne shell etc.. • Graphic User Interface • GNOME, KDE etc.. Louisiana Tech University 3 CLI or Shell • Command Line Interface • The shell is a command interpreter • It provides the interface between a user and the operating system via command line • Shell commands. Egshell. ls , cd, pwd etc • Various shells: C-shell, tsh-shell, bourne shell etc.. • When you log in to a Unix system, a shell starts running. You interact with the default shell 2 12/10/13 this is the shell prompt this is where the shell the SHELL environment variable tells program is located which shell is being used /bin/bash In MAC Louisiana Tech University 6 6 3 12/10/13 Various shell programs Shell name Program (Command) name rc rc Bourne Shell sh C Shell csh Bourne Again Shell bash Z shell zsh Korn Shell ksh TC tcsh you can change shells by typing the shell command return to the default shell by typing “exit” 4 12/10/13 The shell command line prompt shows command current directory. list of arguments ~ is your home directory The shell command line command options (usually preceded with a hyphen) 5 12/10/13 finger displays information for logged in users finger [options] user-list -l detailed listing -s brief listing How command line is interpreted ? What happens when you type a command? 1.
    [Show full text]
  • Z Shell – the Last Shell You‟Ll Ever Need
    Z Shell – the last shell you‟ll ever need changlp Computer Center, CS, NCTU CS, Computer Center, Introduction - Shell 殼 Fetch → Analyze → Execute • Fork Type Login Non-login Interactive User‟s shell Shell executed after login Non- ? Script interactive 2 Computer Center, CS, NCTU CS, Computer Center, Introduction – ZSH (1/2) Originally by Paul Falstad in 1990 A shell designed for interactive use • Powerful user experience Use sh as underlying syntax • Easy for using / migrating Completion & correction Available in ports: shells/zsh 3 Computer Center, CS, NCTU CS, Computer Center, Introduction – ZSH (2/2) % rsync -<TAB> % cd /usr/lica<TAB> 4 Computer Center, CS, NCTU CS, Computer Center, Startup Files (1/2) For all ZSH • /etc/zshenv • ~/.zshenv If [ login shell ] • /etc/zprofile Login Non-login • ~/.zprofile Interactive User‟s shell Shell executed after login Non- ? Script If [ interactive ] interactive • /etc/zshrc • ~/.zshrc If [ login shell ] • /etc/(z)login • ~/.(z)login 5 Computer Center, CS, NCTU CS, Computer Center, Startup Files (2/2) zshenv • Settings for ALL types of ZSH zprofile • Settings for each login session (path … etc) zshrc • Some interactive settings (prompt … etc) zlogin (zlogout) • Execute some program on login / logout 6 Computer Center, CS, NCTU CS, Computer Center, IO Redirection - Multios % date >file1 >file2 … >fileN % date >file1 | prog1 % cat -n < /var/log/**/*log(R.) • All files under /var/log and its subdir with 0004 permission % cat bar | sort <foo • % cat bar foo | sort # note the order
    [Show full text]