In a Nutshell

Total Page:16

File Type:pdf, Size:1020Kb

In a Nutshell UNIX IN A NUTSHELL Fourth Edition Arnold Robbins O'REILLY® Beijing • Cambridge- Farnham • Köln • Paris • Sebastopol • Talpel -Tokyo Table of Contents Preface xiii Part I. Commands and Shells 1. Introduction 3 Unix in the 21st Century 3 Obtaining Compilers 5 Building Software 6 What's in the Quick Reference 7 Beginner's Guide 8 Solaris: Standard Compliant Programs 11 2. Unix Commands 13 Introduction 13 Alphabetical Summary of Common Commands 15 Alphabetical Summary of Solaris Commands 241 Alphabetical Summary of GNU/Linux Commands 260 Alphabetical Summary of Mac OS X Commands 304 Alphabetical Summary of Java Commands 321 3. The Unix Shell: An Overview 341 Introduction to the Shell 341 Purpose of the Shell 342 Shell Flavors 343 vii Shell Source Code URLs 344 Common Features 344 Differing Features 345 4. The Bash and Korn Shells 347 348 Overview of Features Invoking the Shell 349 Syntax 350 Functions 357 Variables 358 Arithmetic Expressions 366 368 Command History Job Control 372 Command Execution 372 373 Restricted Shells Built-in Commands (Bash and Korn Shells) 374 5. tcsh: An Extended C Shell 417 Overview of Features 417 Invoking the Shell 418 Syntax 419 Variables 423 Expressions 435 Command History 438 Command-Line Manipulation 442 Job Control 445 Built-in Commands 446 6. Package Management 467 Linux Package Management 467 The Red Hat Package Manager 470 Yum: Yellowdog Updater Modified 484 up2date: Red Hat Update Agent 489 The Debian Package Manager 492 Mac OS X Package Management 520 Solaris Package Management 521 Part II. Text Editing and Processing 7. Pattern Matching 535 Filenames Versus Patterns 535 Metacharacters 536 Metacharacters, Listed by Unix Program 538 Examples of Searching 539 8. The Emacs Editor 543 Conceptual Overview 543 Command-Line Syntax 545 Summary of Commands by Group 546 Summary of Commands by Key 552 Summary of Commands by Name 555 9. The vi, ex, and vim Editors 561 Conceptual Overview 561 Command-Line Syntax 562 Review of vi Operation 565 vi Commands 567 vi Configuration 574 ex Basics 579 Alphabetical Summary of ex Commands 580 10. The sed Editor 595 Conceptual Overview 595 Command-Line Syntax 596 Syntax of sed Commands 598 Group Summary of sed Commands 600 Alphabetical Summary of sed Commands 601 11. The awk Programming Language 611 Conceptual Overview 611 Command-Line Syntax 613 Patterns and Procedures 614 Built-in Variables 616 Operators 617 Variable and Array Assignment 618 User-Defined Functions 619 Gawk-Specific Features 620 622 Implementation Limits Group Listing of awk Functions and Commands 623 Alphabetical Summary of awk Functions and Commands 623 Output Redirections 632 Source Code 634 Part HI. Software Development 12. Source Code Management: An Overview 637 Introduction and Terminology 637 Usage Models 639 Unix Source Code Management Systems 640 Other Source Code Management Systems 641 13. The Revision Control System 643 Overview of Commands 643 Basic Operation 644 General RCS Specifications 645 Alphabetical Summary of Commands 649 14. The Concurrent Versions System 659 Conceptual Overview 659 Command-Line Syntax and Options 661 Dot Files 664 Environment Variables 665 Keywords and Keyword Modes 667 Dates 669 CVSROOT Variables 672 Alphabetical Summary of Commands 674 15. The Subversion Version Control System 697 Conceptual Overview 697 Ob taining Subversion 702 Using Subversion: A Quick Tour 704 The Subversion Command Line Client: svn 706 Repository Administration: svnadmin 733 Examining the Repository: svnlook 737 Providing Remote Access: svnserve 742 Other Subversion Components 743 16. The GNU make Utility 745 Conceptual Overview 745 Command-Line Syntax 746 Makefile Lines 749 Macros 754 Special Target Names 761 Writing Command Lines 762 17. The GDB Debugger 765 Conceptual Overview 765 Command-Line Syntax 768 Initialization Files 770 GDB Expressions 771 The GDB Text User Interface 773 Group Listing of GDB Commands 773 Summary of set and show Commands 777 Summary of the Info Command 788 Alphabetical Summary of GDB Commands 790 18. Writing Manual Pages 813 Introduction 813 Overview of nroff/troff 814 Alphabetical Summary of man Macros 819 Predefined Strings 823 Internal Names 823 Sample Document 823 Part IV. References ISO 8859-1 (Latin-1) Character Set 829 Bibliography 837 Index 849.
Recommended publications
  • Job Scheduling for SAP® Contents at a Glance
    Kees Verruijt, Arnoud Roebers, Anjo de Heus Job Scheduling for SAP® Contents at a Glance Foreword ............................................................................ 13 Preface ............................................................................... 15 1 General Job Scheduling ...................................................... 19 2 Decentralized SAP Job Scheduling .................................... 61 3 SAP Job Scheduling Interfaces .......................................... 111 4 Centralized SAP Job Scheduling ........................................ 125 5 Introduction to SAP Central Job Scheduling by Redwood ... 163 6Installation......................................................................... 183 7 Principles and Processes .................................................... 199 8Operation........................................................................... 237 9Customer Cases................................................................. 281 The Authors ........................................................................ 295 Index .................................................................................. 297 Contents Foreword ............................................................................................... 13 Preface ................................................................................................... 15 1 General Job Scheduling ...................................................... 19 1.1 Organizational Uses of Job Scheduling ..................................
    [Show full text]
  • Installation Guide
    Installation Guide Installation Guide Schrödinger Suite 2011 Schrödinger Press Installation Guide Copyright © 2011 Schrödinger, LLC. All rights reserved. While care has been taken in the preparation of this publication, Schrödinger assumes no responsibility for errors or omissions, or for damages resulting from the use of the information contained herein. Canvas, CombiGlide, ConfGen, Epik, Glide, Impact, Jaguar, Liaison, LigPrep, Maestro, Phase, Prime, PrimeX, QikProp, QikFit, QikSim, QSite, SiteMap, Strike, and WaterMap are trademarks of Schrödinger, LLC. Schrödinger and MacroModel are registered trademarks of Schrödinger, LLC. MCPRO is a trademark of William L. Jorgensen. Desmond is a trademark of D. E. Shaw Research. Desmond is used with the permission of D. E. Shaw Research. All rights reserved. This publication may contain the trademarks of other companies. Schrödinger software includes software and libraries provided by third parties. For details of the copyrights, and terms and conditions associated with such included third party software, see the Legal Notices, or use your browser to open $SCHRODINGER/docs/html/third_party_legal.html (Linux OS) or %SCHRODINGER%\docs\html\third_party_legal.html (Windows OS). This publication may refer to other third party software not included in or with Schrödinger software ("such other third party software"), and provide links to third party Web sites ("linked sites"). References to such other third party software or linked sites do not constitute an endorsement by Schrödinger, LLC. Use of such other third party software and linked sites may be subject to third party license agreements and fees. Schrödinger, LLC and its affiliates have no responsibility or liability, directly or indirectly, for such other third party software and linked sites, or for damage resulting from the use thereof.
    [Show full text]
  • CA Workload Automation Ixp Admin Guide
    CA Workload Automation iXp Administration Guide Release 7.1 SP1 This Documentation, which includes embedded help systems and electronically distributed materials, (hereinafter referred to as the “Documentation”) is for your informational purposes only and is subject to change or withdrawal by CA at any time. This Documentation may not be copied, transferred, reproduced, disclosed, modified or duplicated, in whole or in part, without the prior written consent of CA. This Documentation is confidential and proprietary information of CA and may not be disclosed by you or used for any purpose other than as may be permitted in (i) a separate agreement between you and CA governing your use of the CA software to which the Documentation relates; or (ii) a separate confidentiality agreement between you and CA. Notwithstanding the foregoing, if you are a licensed user of the software product(s) addressed in the Documentation, you may print or otherwise make available a reasonable number of copies of the Documentation for internal use by you and your employees in connection with that software, provided that all CA copyright notices and legends are affixed to each reproduced copy. The right to print or otherwise make available copies of the Documentation is limited to the period during which the applicable license for such software remains in full force and effect. Should the license terminate for any reason, it is your responsibility to certify in writing to CA that all copies and partial copies of the Documentation have been returned to CA or destroyed. TO THE EXTENT PERMITTED BY APPLICABLE LAW, CA PROVIDES THIS DOCUMENTATION “AS IS” WITHOUT WARRANTY OF ANY KIND, INCLUDING WITHOUT LIMITATION, ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NONINFRINGEMENT.
    [Show full text]
  • Processes in Linux/Unix
    Processes in Linux/Unix A program/command when executed, a special instance is provided by the system to the process. This instance consists of all the services/resources that may be utilized by the process under execution. • Whenever a command is issued in unix/linux, it creates/starts a new process. For example, pwd when issued which is used to list the current directory location the user is in, a process starts. • Through a 5 digit ID number unix/linux keeps account of the processes, this number is call process id or pid. Each process in the system has a unique pid. • Used up pid’s can be used in again for a newer process since all the possible combinations are used. • At any point of time, no two processes with the same pid exist in the system because it is the pid that Unix uses to track each process. Initializing a process A process can be run in two ways: 1. Foreground Process : Every process when started runs in foreground by default, receives input from the keyboard and sends output to the screen. When issuing pwd command $ ls pwd Output: $ /home/geeksforgeeks/root When a command/process is running in the foreground and is taking a lot of time, no other processes can be run or started because the prompt would not be available until the program finishes processing and comes out. 2. Backround Process : It runs in the background without keyboard input and waits till keyboard input is required. Thus, other processes can be done in parallel with the process running in background since they do not have to wait for the previous process to be completed.
    [Show full text]
  • UNIX Reference Card Create a Directory Called Options: -I Interactive Mode
    File System Manipulation Move (Rename) Files and Directories mv present-filename new-filename to rename a file Create (or Make) a Directory mv source-filename destination-directory to move a file into another directory mkdir directory-name directory-name UNIX Reference Card create a directory called options: -i interactive mode. Must confirm file overwrites. Anatomy of a Unix Command Look at a File Copy Files more filename man display file contents, same navigation as cp source-filename destination-filename to copy a file into command-name -option(s) filename(s) or arguments head filename display first ten lines of a file another file tail filename display last ten lines of a file Example: wc -l sample cp source-filename destination-directory to copy a file into another directory : options options: The first word of the command line is usually the command name. This -# replace # with a number to specify how many lines to show is followed by the options, if any, then the filenames, directory name, or -i interactive mode. Must confirm overwrites. Note: this other arguments, if any, and then a RETURN. Options are usually pre- option is automatically used on all IT’s systems. -R recursive delete ceded by a dash and you may use more than one option per command. List Files and Directories The examples on this reference card use bold case for command names Remove (Delete) Files and Directories and options and italics for arguments and filenames. ls lists contents of current directory ls directory-name list contents of directory rm filename to remove a file rmdir directory-name to remove an Important Note about UNIX Commands empty directory : options options: -a list all files including files that start with “.” UNIX commands are case sensitive.
    [Show full text]
  • Project Shell 2 Due: November 6, 2019 at 11:59Pm
    CSCI0330 Intro Computer Systems Doeppner Project Shell 2 Due: November 6, 2019 at 11:59pm 1 Introduction 2 Before you write any code, read this handout in its entirety. 2 2 Assignment 2 2.1 Stencil 2 2.2 Jobs vs. Processes 3 2.3 Foreground vs. Background 3 2.4 Specifications 3 3 Signals 5 3.0 Sending Signals 6 3.1 Ignoring Signals 6 3.2 Signal Handling in the Child Process 6 3.3 Process Groups 6 4 Multiple Jobs 7 4.1 Process State 8 5 Reaping 8 5.1 Reaping a Child Process 9 6 fg and bg 10 7 Support Code 10 8 Library Functions 12 9 Testing Your Shell 12 9.1 Format of the Tracefiles 13 9.2 Test Executables 13 9.3 Demo 13 9.4 Error Checking 13 9.5 Shell Clean Up 13 10 GDB Tips for Shell 2 14 10.1 handle signal 14 10.2 catch signal 14 11 Grading 14 1 CSCI0330 Project Shell 2 October 31, 2018 12 Handing In 14 1 Introduction Tom was drifting through the water with his new chum the magic conch. Suddenly, an enormous tentacle emerged from the depths of the ocean and speared into the heart of his friend, splitting the shell evenly in two. Tom was otterly overwhelmed with emocean and blinked mildly, looking at his friends, shell_1 and shell_2. Shell_2 was trying to communicate, but Tom couldn’t quite catch the signals. Kelp Tom reestablish connection with his shelly friends. CTRL-\. Now, your shell can run only one program at a time since it runs programs in the foreground, occupying the entire shell.
    [Show full text]
  • Signals and Inter-Process Communication
    2/21/20 COMP 790: OS Implementation COMP 790: OS Implementation Housekeeping Signals and Inter-Process • Paper reading assigned for next class Communication Don Porter 1 2 1 2 COMP 790: OS Implementation COMP 790: OS Implementation Logical Diagram Last time… Binary Memory • We’ve discussed how the OS schedules the CPU Threads Formats Allocators User – And how to block a process on a resource (disk, network) Today’s Lecture System Calls Kernel Process • Today: RCU FileCoordination System Networking Sync – How do processes block on each other? – And more generally communicate? Memory Device CPU Management Drivers Scheduler Hardware Interrupts Disk Net Consistency 3 4 3 4 COMP 790: OS Implementation COMP 790: OS Implementation Outline What is a signal? • Signals • Like an interrupt, but for applications – Overview and APIs – <64 numbers with specific meanings – Handlers – A process can raise a signal to another process or thread – Kernel-level delivery – A process or thread registers a handler function – Interrupted system calls • For both IPC and delivery of hardware exceptions • Interprocess Communication (IPC) – Application-level handlers: divzero, segfaults, etc. – Pipes and FIFOs • No “message” beyond the signal was raised – System V IPC – And maybe a little metadata – Windows Analogs • PID of sender, faulting address, etc. • But platform-specific (non-portable) 5 6 5 6 1 2/21/20 COMP 790: OS Implementation COMP 790: OS Implementation Example Example Pid 300 Pid 300 Pid 400 int main() { int main() { ... ... PC signal(SIGUSR1, &usr_handler);
    [Show full text]
  • Job Control Profile
    1 Job Control Profile 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 Document Number: DCIM1034 24 Document Type: Specification Document Status: Published 25 Document Language: E 26 Date: 2012-03-08 27 Version: 1.2.0 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 THIS PROFILE IS FOR INFORMATIONAL PURPOSES ONLY, AND MAY CONTAIN TYPOGRAPHICAL 52 ERRORS AND TECHNICAL INACCURACIES. THE CONTENT IS PROVIDED AS IS, WITHOUT 53 EXPRESS OR IMPLIED WARRANTIES OF ANY KIND. ABSENT A SEPARATE AGREEMENT 54 BETWEEN YOU AND DELL™ WITH REGARD TO FEEDBACK TO DELL ON THIS PROFILE 55 SPECIFICATION, YOU AGREE ANY FEEDBACK YOU PROVIDE TO DELL REGARDING THIS 56 PROFILE SPECIFICATION WILL BE OWNED AND CAN BE FREELY USED BY DELL. 57 58 © 2010 - 2012 Dell Inc. All rights reserved. Reproduction in any manner whatsoever without the express 59 written permission of Dell, Inc. is strictly forbidden. For more information, contact Dell. 60 61 Dell and the DELL logo are trademarks of Dell Inc. Microsoft and WinRM are either trademarks or 62 registered trademarks of Microsoft Corporation in the United States and/or other countries. Other 63 trademarks and trade names may be used in this document to refer to either the entities claiming the 64 marks and names or their products. Dell disclaims proprietary interest in the marks and names of others. 65 2 Version 1.2.0 66 CONTENTS 67 1 Scope ...................................................................................................................................................
    [Show full text]
  • Introduction to Linux
    Introduction to Linux Yuwu Chen HPC User Services LSU HPC LONI [email protected] Louisiana State University Baton Rouge June 12, 2019 Why Linux for HPC - 2014 OS family system share OS family performance share http://www.top500.org/statistics/list/ November 2014 Introduction to Linux 2 Why Linux for HPC - 2018 OS family system share OS family performance share Linux is the most popular OS used in supercomputers http://www.top500.org/statistics/list/ November 2018 Introduction to Linux 3 Why should you learn Linux? . Linux is everywhere, not just on HPC . Linux is used on most web servers. Google or Facebook . Android phone . Linux is free and you can personally use it . You will learn how hardware and operating systems work . A better chance of getting a job Introduction to Linux 4 Roadmap • What is Linux • Linux file system • Basic commands • File permissions • Variables • Use HPC clusters • Processes and jobs • File editing Introduction to Linux 5 History of Linux (1) . Unix was initially designed and implemented at AT&T Bell Labs 1969 by Ken Thompson, Dennis Ritchie, Douglas McIlroy, and Joe Ossanna . First released in 1971 and was written in assembly language . Re-written in C by Dennis Ritchie in 1973 for better portability (with exceptions to the kernel and I/O) Introduction to Linux 6 History of Linux (2) . Linus Torvalds, a student at University of Helsinki began working on his own operating system, which became the "Linux Kernel", 1991 . Linus released his kernel for free download and helped further development Introduction to Linux 7 History of Linux (3) .
    [Show full text]
  • Unix Shell 2
    1 Unix Shell 2 Lab Objective: Introduce system management, calling Unix Shell commands within Python, and other advanced topics. As in the last lab, the majority of learning will not be had in nishing the problems, but in following the examples. File Security To begin, run the following command while inside the Shell2/Python/ directory (Shell2/ is the end product of Shell1/ from the previous lab). Notice your output will dier from that printed below; this is for learning purposes. $ ls -l -rw-rw-r-- 1 username groupname 194 Aug 5 20:20 calc.py -rw-rw-r-- 1 username groupname 373 Aug 5 21:16 count_files.py -rwxr-xr-x 1 username groupname 27 Aug 5 20:22 mult.py -rw-rw-r-- 1 username groupname 721 Aug 5 20:23 project.py Notice the rst column of the output. The rst character denotes the type of the item whether it be a normal le, a directory, a symbolic link, etc. The remaining nine characters denote the permissions associated with that le. Specically, these permissions deal with reading, wrtiting, and executing les. There are three categories of people associated with permissions. These are the user (the owner), group, and others. For example, look at the output for mult.py. The rst character - denotes that mult.py is a normal le. The next three characters, rwx tell us the owner can read, write, and execute the le. The next three characters r-x tell us members of the same group can read and execute the le. The nal three characters --x tell us other users can execute the le and nothing more.
    [Show full text]
  • RAIK 284H, Spring 2010 Writing Your Own Unix Shell Assigned: Apr. 1, Due: Thur., Apr
    RAIK 284H, Spring 2010 Writing Your Own Unix Shell Assigned: Apr. 1, Due: Thur., Apr. 15, 9:00PM Dylan Douglas ([email protected]) is the lead person for this assignment. Introduction The purpose of this assignment is to become more familiar with the concepts of process control and sig- nalling. You’ll do this by writing a simple Unix shell program that supports job control. Logistics You may work in a group of up to two people in solving the problems for this assignment. The only “hand- in” will be electronic. Any clarifications and revisions to the assignment will be posted on the course Web page. Hand Out Instructions Start by copying the file shlab-handout.tar to the protected directory (the lab directory) in which you plan to do your work. Then do the following: • Type the command tar xvf shlab-handout.tar to expand the tarfile. • Type the command make to compile and link some test routines. • Type your team member names and CSE/cree login names in the header comment at the top of tsh.c. Looking at the tsh.c (tiny shell) file, you will see that it contains a functional skeleton of a simple Unix shell. To help you get started, we have already implemented the less interesting functions. Your assignment is to complete the remaining empty functions listed below. As a sanity check for you, we’ve listed the approximate number of lines of code for each of these functions in our reference solution (which includes lots of comments). 1 • eval: Main routine that parses and interprets the command line.
    [Show full text]
  • Signals and Inter-Process Communication (IPC)
    Spring 2017 :: CSE 506 Signals and Inter-Process Communication (IPC) Nima Honarmand Spring 2017 :: CSE 506 Outline • Signals • Overview and APIs • Handlers • Kernel-level delivery • Interrupted system calls • Interprocess Communication (IPC) • Pipes and FIFOs • System V IPC Spring 2017 :: CSE 506 What is a Signal? • Like an interrupt, but for applications • < 64 numbers with specific meanings • Sending: A process can raise a signal to another process or thread • Sending: Kernel can send signals to processes or threads • Receiving: A process or thread registers a handler function • For both IPC and delivery of hardware exceptions • Application-level handlers: divzero, segfaults, etc. • No “message” beyond the signal was raised + a little metadata • PID of sender, faulting address, etc. Spring 2017 :: CSE 506 Example Pid 300 int main() { ... signal(SIGUSR1, &usr_handler); ... } Register usr_handler() to handle SIGUSR1 Spring 2017 :: CSE 506 Example Pid 300 Pid 400 int main() { ... PC } kill(300, SIGUSR1); int usr_handler() { … Send signal to PID 300 Spring 2017 :: CSE 506 Basic Model • Application registers handlers with signal() or sigaction() • Send signals with kill() and friends • Or raised by hardware exception handlers in kernel • Signal delivery jumps to signal handler • Irregular control flow, similar to an interrupt API names are admittedly confusing Spring 2017 :: CSE 506 Some Signal Types See man7 signal for the full list: (varies by sys/arch) SIGTSTP: Stop typed at terminal (Ctrl+Z) SIGKILL: Kill a process SIGSEGV: Segmentation
    [Show full text]