OnWorks Linux and Windows Online WorkStations


Free Hosting Online for WorkStations

Next >

The Linux Command Line

Third Internet Edition

William Shotts

A LinuxCommand.org Book

A LinuxCommand.org Book



Copyright ©2008-2016, William E. Shotts, Jr.

This work is licensed under the Creative Commons Attribution-Noncommercial-No De- rivative Works 3.0 United States License. To view a copy of this license, visit the link above or send a letter to Creative Commons, PO Box 1866, Mountain View, CA 94042.

A version of this book is also available in printed form, published by No Starch Press. Copies may be purchased wherever fine books are sold. No Starch Press also offers elec- tronic formats for popular e-readers. They can be reached at: https://www.nostarch.com.

Linux® is the registered trademark of Linus Torvalds. All other trademarks belong to their respective owners.

This book is part of the LinuxCommand.org project, a site for Linux education and advo- cacy devoted to helping users of legacy operating systems migrate into the future. You may contact the LinuxCommand.org project at http://linuxcommand.org.

Release History





July 28, 2016

Third Internet Edition.


July 6, 2013

Second Internet Edition.


December 14, 2009

First Internet Edition.


IntroductionWhy Use The Command Line?What This Book Is AboutWho Should Read This BookWhat's In This BookHow To Read This BookPrerequisitesAcknowledgmentsFirst Internet EditionSecond Internet EditionThird Internet EditionYour Feedback Is Needed!What's New In The Third Internet EditionFurther ReadingColophonPart 1 – Learning The Shell1 – What Is The Shell?Terminal EmulatorsYour First KeystrokesTry Some Simple CommandsEnding A Terminal SessionSumming UpFurther Reading2 – NavigationUnderstanding The File System TreeThe Current Working DirectoryListing The Contents Of A DirectoryChanging The Current Working DirectorySumming Up3 – Exploring The SystemMore Fun With lsDetermining A File's Type With fileViewing File Contents With lessA Guided TourSymbolic LinksHard LinksSumming UpFurther Reading4 – Manipulating Files And DirectoriesWildcardsmkdir – Create Directoriescp – Copy Files And Directoriesmv – Move And Rename Filesrm – Remove Files And Directoriesln – Create LinksLet's Build A PlaygroundSumming UpFurther Reading5 – Working With CommandsWhat Exactly Are Commands?Identifying CommandsGetting A Command's DocumentationCreating Your Own Commands With aliasSumming UpFurther Reading6 – RedirectionStandard Input, Output, And ErrorRedirecting Standard OutputRedirecting Standard ErrorRedirecting Standard InputPipelinesSumming Up7 – Seeing The World As The Shell Sees ItExpansionQuotingSumming UpFurther Reading8 – Advanced Keyboard TricksCommand Line EditingCompletionUsing HistorySumming UpFurther Reading9 – PermissionsOwners, Group Members, And Everybody ElseReading, Writing, And ExecutingChanging IdentitiesExercising Our PrivilegesChanging Your PasswordSumming UpFurther Reading10 – ProcessesHow A Process WorksViewing ProcessesControlling ProcessesSignalsShutting Down The SystemMore Process Related CommandsSumming UpPart 2 – Configuration And The Environment11 – The EnvironmentWhat Is Stored In The Environment?How Is The Environment Established?Modifying The EnvironmentSumming UpFurther Reading12 – A Gentle Introduction To viWhy We Should Learn viA Little BackgroundStarting And Stopping viEditing ModesMoving The Cursor AroundBasic EditingSearch-And-ReplaceEditing Multiple FilesSaving Our WorkSumming UpFurther Reading13 – Customizing The PromptAnatomy Of A PromptTrying Some Alternative Prompt DesignsAdding ColorMoving The CursorSaving The PromptSumming UpFurther ReadingPart 3 – Common Tasks And Essential Tools14 – Package ManagementPackaging SystemsHow A Package System WorksCommon Package Management TasksSumming UpFurther Reading15 – Storage MediaMounting And Unmounting Storage DevicesCreating New File SystemsTesting And Repairing File SystemsFormatting Floppy DisksMoving Data Directly To/From DevicesCreating CD-ROM ImagesWriting CD-ROM ImagesSumming UpFurther ReadingExtra Credit16 – NetworkingExamining And Monitoring A NetworkTransporting Files Over A NetworkSecure Communication With Remote HostsSumming UpFurther Reading17 – Searching For Fileslocate – Find Files The Easy Wayfind – Find Files The Hard WaySumming UpFurther Reading18 – Archiving And BackupCompressing FilesArchiving FilesSynchronizing Files And DirectoriesSumming UpFurther Reading19 – Regular ExpressionsWhat Are Regular Expressions?grepMetacharacters And LiteralsThe Any CharacterAnchorsBracket Expressions And Character ClassesPOSIX Basic Vs. Extended Regular ExpressionsAlternationQuantifiersPutting Regular Expressions To WorkSumming UpFurther Reading20 – Text ProcessingApplications Of TextRevisiting Some Old FriendsSlicing And DicingComparing TextEditing On The FlySumming UpFurther ReadingExtra Credit21 – Formatting OutputSimple Formatting ToolsDocument Formatting SystemsSumming UpFurther Reading22 – PrintingA Brief History Of PrintingPrinting With LinuxPreparing Files For PrintingSending A Print Job To A PrinterMonitoring And Controlling Print JobsSumming UpFurther Reading23 – Compiling ProgramsWhat Is Compiling?Compiling A C ProgramSumming UpFurther ReadingPart 4 – Writing Shell Scripts24 – Writing Your First ScriptWhat Are Shell Scripts?How To Write A Shell ScriptScript File FormatExecutable PermissionsScript File LocationMore Formatting TricksSumming UpFurther Reading25 – Starting A ProjectFirst Stage: Minimal DocumentSecond Stage: Adding A Little DataVariables And ConstantsHere DocumentsSumming UpFurther Reading26 – Top-Down DesignShell FunctionsLocal VariablesKeep Scripts RunningSumming UpFurther Reading27 – Flow Control: Branching With ififExit StatustestA More Modern Version Of test(( )) - Designed For IntegersCombining ExpressionsControl Operators: Another Way To BranchSumming UpFurther Reading28 – Reading Keyboard Inputread – Read Values From Standard InputValidating InputMenusSumming UpFurther Reading29 – Flow Control: Looping With while / untilLoopingBreaking Out Of A LoopReading Files With LoopsSumming UpFurther Reading30 – TroubleshootingSyntactic ErrorsLogical ErrorsTestingDebuggingSumming UpFurther Reading31 – Flow Control: Branching With casecaseSumming UpFurther Reading32 – Positional ParametersAccessing The Command LineHandling Positional Parameters En MasseA More Complete ApplicationSumming UpFurther Reading33 – Flow Control: Looping With forfor: Traditional Shell Formfor: C Language FormSumming UpFurther Reading34 – Strings And NumbersParameter ExpansionArithmetic Evaluation And Expansionbc – An Arbitrary Precision Calculator LanguageSumming UpExtra CreditFurther Reading35 – ArraysWhat Are Arrays?Creating An ArrayAssigning Values To An ArrayAccessing Array ElementsArray OperationsAssociative ArraysSumming UpFurther Reading36 – ExoticaGroup Commands And SubshellsTrapsAsynchronous ExecutionNamed PipesSumming UpFurther ReadingIndex

Top OS Cloud Computing at OnWorks: