From 155cdb9c5d4254a9bfed290ba163bab5f560f157 Mon Sep 17 00:00:00 2001 From: gferg <> Date: Thu, 20 Apr 2006 13:18:40 +0000 Subject: [PATCH] new --- .../GNU-Linux-Tools-Summary.sgml | 1825 +++++++++++++++++ .../GNU-Linux-Tools-Summary/appendix.sgml | 37 + .../GNU-Linux-Tools-Summary/bibliography.sgml | 276 +++ .../GNU-Linux-Tools-Summary/icon_smile.png | Bin 0 -> 575 bytes 4 files changed, 2138 insertions(+) create mode 100644 LDP/guide/docbook/GNU-Linux-Tools-Summary/GNU-Linux-Tools-Summary.sgml create mode 100644 LDP/guide/docbook/GNU-Linux-Tools-Summary/appendix.sgml create mode 100644 LDP/guide/docbook/GNU-Linux-Tools-Summary/bibliography.sgml create mode 100644 LDP/guide/docbook/GNU-Linux-Tools-Summary/icon_smile.png diff --git a/LDP/guide/docbook/GNU-Linux-Tools-Summary/GNU-Linux-Tools-Summary.sgml b/LDP/guide/docbook/GNU-Linux-Tools-Summary/GNU-Linux-Tools-Summary.sgml new file mode 100644 index 00000000..1b893d52 --- /dev/null +++ b/LDP/guide/docbook/GNU-Linux-Tools-Summary/GNU-Linux-Tools-Summary.sgml @@ -0,0 +1,1825 @@ + + + + + + + + ]> + +GNU/Linux Command-Line Tools Summary + +Gareth Anderson + +
+ somecsstudent(at)gmail.com +
+
+
+ +Conversion from LyX to DocBook SGML, Index generation +Chris Karakas + +
+ +Linux +Unix +commands +Linux commands +Unix commands +Linux tools +Unix tools +tutorial +command line +prompt +command reference +command tutorial +command line reference +command line tutorial +tools tutorial +tools reference +tool +linux command reference +linux command tutorial +linux command line reference +linux command line tutorial +linux tools tutorial +linux tools reference +linux tool +Unix command reference +Unix command tutorial +Unix command line reference +Unix command line tutorial +Unix tools tutorial +Unix tools reference +Unix tool + +This document is an attempt to provide a summary of useful command-line tools available to a GNU/Linux based operating system, the tools listed are designed to benefit the majority of users and have being chosen at the authors discretion. This document is not a comprehensive list of every existent tool available to a GNU/Linux based system, nor does it have in-depth explanations of how things work. It is a summary which can be used to learn about and how to use many of the tools available to a GNU/Linux based operating system. + +1.2 +15th April 2006 +GA + +Corrected typing errors, generated new, much smaller index (more accurate in my opinion). Updated errors in document for TLDP. + + + +1.1 +28th February 2006 +CK + +Corrected typos, generated new index (9000 index entries!). + + + +1.0 +6th February 2006 +GA + +Major restructuring, now in a docbook book format. Removed large chunks of content and revised other parts (removed chapters and sectioned some areas more). This is likely the final release by the author, I hope that someone finds this guide useful as I do not intend to continue work on this guide. + + + +0.7.1 +25th February 2005 +CK + +Set special characters in math mode, produced PDF and PS with Computer Modern fonts in OT1 encoding and created correct SGML for key combinations. + + + +0.7 +5th December 2004 +GA + +Updated document with new grammatical review. Re-ordered the entire Text section. Removed a fair amount of content. + + + +v0.6 +20th April 2004 +GA + +Attempted to fix document according to TLDP criticisms. Added notes and tips more sectioning. Now complying to the open group standards for the UNIX system trademark. Document should be ready for TLDP site. + + + +v0.5 +6th October 2003 +GA + +Fixed a variety of errors as according to the review and made some consistency improvements to the document. + + + +v0.4 +15th July 2003 +GA + +Made small improvements to the document as suggested (so far) by the thorough TLDP review, improved consistency of document and made small content additions. + + + +v0.3 +26th June 2003 +GA + +Minor errors fixed, updated the appendix with information for finding where a tool is from. Fixed referencing/citation problems and improved further reading and intro sections, added an audio section. + + + +v0.2 +20th April 2003 +GA + +This is the initial public release. Added more code-style then before, broke text-section into more subsections. Improved consistency of document and fixed various index entries. + + + +v0.1 +27th March 2003 +GA + +This is the initial draft release (the first release to be converted from LyX to DocBook SGML). + + + +
+IntroductionThis document is an attempt to summarise summarisethe many command-line based command-line-basedtools available to a GNU/Linux based operating system. This guide guideis not a complete listing (I doubt it's possible to documentdocument all available programs), this document lists many tools which are available to GNU/Linux systems and which are, or can be useful to the majority majorityof users.Each tool description descriptionprovides a quick overview of it's function functionand some useful options optionsfor that individual tool.The tools listed listedthat require a GUI,GUI usually the X windowing X windowingsystem, are those listed in the Graphics GraphicsTools section. All other tools are completely command-line-based command-line-basedand do not require a GUI GUIto run. If you are looking lookingfor information on GUI GUIbased tools you will need to look elsewhere.Also note that a few of the tools in this guide are bash bash(the Bourne-Again-SHellBourne-Again-SHell) specific, tools specific specificto other shells shellsare not listed in this document.For some of the tools that are harder to use, or perform a more complexcomplex task,task there are several mini-tutorials mini-tutorials(or mini-guides;mini-guides ) within this document.Where a mini-guide mini-guidewas considered unncessary, detailed descriptions that explain in detail how a particular tool works, and some examples examplesof how to use it are provided.providedPlease note that the word “tool” is used interchangeably interchangeablywith the word “command”, both have the same meaning (at least in this guide). For a more detailed detailedexplanation, read about the UNIX Tools Philosophy UNIX Tools Philosophyhere: or visit the links in the appendix,appendix .enable +To find out which tools are bash specific +To find out which tools are bash specific you can type: +enable -a + + + +Who would want to read this guide?Anyone who is interested in learning learningabout the tools (also known as commands) available to them when using their GNU/Linux based operating system.Why would you want to learn learnhow to use the command-linecommand-line (and available tools)? The Command Line-Interface (CLI)CLIcommand line-interface, while difficult to learn, is the quickest quickestand most efficient efficientway to use a computer for many different tasks. The CLI CLIis the normal method of use for most UNIX UNIX systemsystem administrators,administrators programmers programmersand some power userspower users. While a GUI GUIis better suited suitedto some tasks, many operations are best suited to the CLI.CLIThe major motivationmotivation behind learning learningthe GNU/Linux CLI CLIis the authors authorsideaidea that, with software softwarein general, the more time spent learning something equals less time spent performing that particular task (authors opinion onlyauthors opinion).This guide is aimed at beginnersbeginners to intermediate intermediateusers who want to learnlearn about the command-line command-linetools available to them. Advanced users may wish to use it as a command reference,reference however this document aims to list listcommands of interest, as judged judgedby the authors opinion,authors opinion it is not designed designedto be completely comprehensive,comprehensive see the appendix,appendix for further information. Or if you are not looking for a command reference referenceguide, but a more gentle introduction to GNU/Linux you may be interested in the Introduction to Linux guideIntroduction to Linux guide authored authoredby Machtelt Garrels.Machtelt GarrelsThis guide could also be considered a summarised summarisedversion of the Linux Cookbook.Linux Cookbook If you are looking for a book bookwith more detailed descriptions of each tool have a look at the Linux Cookbook Homepage, also check out the command list from "Linux in a Nutshell 3rd Edition"command listLinux in a Nutshell 3rd Edition for an index indexof 300+ commands and their explanations.explanations +Who would not want to read this guide?Anyone who is not interested in the command-linecommand-line, or anyone looking for a detailed reference to all available GNU/Linux tools should look elsewhere. This is only a summary,summary while it does list many commands, it's not a completecomplete listing listing(I don't think it's possible to make a complete listing anyway).This document would not be of interest to those who already have an expert expertknowledge knowledgeof the command-line interface command-line interfaceand do require any reference referenceinformation.information Or those readers readerswho require detailed detailedlists listsof options optionsfor each command, the man pagesman pages are better suited suitedto this purpose.purpose +Availability of sourcesThe modifiable modifiablesources sourcesof the original originalbook book(in english), are availableavailable in LyX LyXformat format(LyX Document Processor) or Machine-translated Machine-translatedSGML SGML(SGML markup languagemarkup language). LyX is a completely free document processor document processorbased on LaTeX,LaTeX downloadabledownloadable from the LyX homepage..See for the modifiable modifiablesources sourcesof this document. These are the official officialversions.versions We (the translators translatorsand current maintainersmaintainers) plan to continue work on this document and add new chapters and enhancements.enhancements If you want to see the version versionwe are currently working on (the "bleeding edge" version), check the GNU/Linux Command-Line Tools Summary HomepageGNU/Linux Tools Summary Homepage from time to time (kindly hosted hostedby Chris KarakasChris Karakas). +Conventions used in this guideThe following conventions conventionsare used within this guide:italic +italicAnything appearing in italic, like this is either an executable executablecommand or emphasized emphasizedtext. Tools (executable commands) are in italics italicsto prevent confusion. Some tools have names which are real english englishwords, such as the “locate” tool.key combinations +key combinationsAre represented by using a '-' (dash sign)dash sign in-between the key(s), which must be used in combination.combination All combinations combinationsare also printed printedin italics italicsto improve clarity.clarity For example + + CTRL + Z + + + CTRL-Z + + means hold down the Control keyControl key and press the z key.admonitions +admonitionsAdmonitions are little pictures picturesused to emphasize emphasizesomething of importance importanceto the reader.reader The five types used are: +This is a note + +Notes often give important information about a tool. + + + +This is a tip + +This will offer a useful switch or useful way to use a tool. + + + +This is something important + +This is something that is considered very important. Consider it like a note with extra importance, they are usually there to save the reader time. + + + +This is a caution + +This will inform you of something that you be careful about (because it could be harmful to your system). + + + +This is a warning + +This will inform you of something that you shouldn't do (because it probably will break something within your system). + + +code examples +Code Codeexamples examplesare shown for most commands. Below is an example of what code codelooks like:command syntax +command syntax(or a similar phrase) simply shows how you would normally use the command. Often real examples examplesare used instead of explaining explainingthe command syntax. The phrase “ Command syntax” is always followed by the way you would type a command in a shell.shellThe standard standardsyntax syntaxfor any tool is usually: +Note +Note that some tools do not accept options. + +wildcards +wildcardsAlso note that most commands, even when not explicitly explicitlystated, will work with standard wildcards standard wildcards (or globbing patternsglobbing patterns) such as *, [A-Z] and various other standard wildcards. Refer Referto for further information.access keys +access keysAccess keys enable enablenavigation through the document, without relying on a mouse.mouse The following keys have been given special specialmeaning in this document:P +Previous Previouspage.pageN +Next Nextpage.H +Home Homeof the document (Table of Contents).Table of ContentsU +UpUp (takes you one level levelup the section sectionhierarchy).If you also happen to be reading readingthe document from its original originallocation, then the following access keys can also be used:S +Start Start(takes you to the author's start page).T +The current current(“This”) page, without the Sitemenu Sitemenuon the left.M +The current page in a frameset,frameset where the left frame framecontains a Menu.Menu +To use the access keys, you have to simultaneously press a modifier key, which may vary from browser to browser. For example in NN6+/Mozilla, the modifier key is ALT, so you have to use + +ALT +N + +to go to the next page, and + +ALT +P + +to come back. In other browsers such as IE6, the access keys just give focus to the associated link, so the sequence becomes + + +ALT +N + +Enter + +. Try it, you'll like it! ]]> ]]> ]]> ]]> Inline graphic + +Resources used to create this document To create the GNU/Linux Command-Line Command-LineTools Summary,Summary I used LyX, the document processor.document processor To convert convertthe LyX files to DocBook DocBookSGML SGMLI used the lyxtox Scriptslyxtox created by Chris KarakasChris Karakas.You may also want to check out the db2lyx db2lyx package,package created by Dr. B GuillionDr. B. Guillion, which can be used to convert LyX files to XML XMLDocBook and XML DocBook DocBookback to LyX. I also had assistance assistancefrom various The Linux Documentation ProjectThe Linux Documentation Project volunteers volunteers(see the contributors contributorssection section for specific specificdetails). +FeedbackFeedback Feedbackis necessary for the advancement advancementof this guide. Positive,Positive constructive criticism criticismis encouraged.encouraged If you have ideas,ideas suggestions,suggestions advice,advice or problems problemswith this guide, please send sendan email emailto the author authorGareth AndersonGareth Anderson. +Contributions + +If you wish to make contributions it is recommended (if possible) to read the LyX file(s) for this document. They contain various notes which you can't see in the other versions. +These notes highlight the areas that need contributions, certain tools which I cannot understand, tools which have not been added, or tools which were removed. These notes also explain some of the structure of this document. + + + +Contributors As you may be able to see, parts partsof this guide are based off based offvarious adviceadvice columns columnson GNU/Linux, anything that has being directly quoted quotedfrom an articlearticle can be found foundin the references,references , section sectionof this document. The following is a list listof people peoplewho have made a significant contributioncontribution to this document, in a rough roughchronological chronologicalorder.Chris Karakas: +Chris allowed the use of his lyxtox lyxtoxscripts scriptsto convert the LyX LyXfile of the document to working DocBook SGML SGMLoutput (to learn learnhow to use the lyxtoxlyxtox scripts scriptsyourself, see Document processing with LyX and SGML).Chris provided useful suggestions suggestionsand advice,advice and added an index indexlistinglisting for many of the commands. Chris is also responsible for the great looking HTML HTMLfile for this documentdocument (the CSS CSSfile and HTML HTMLcustomisations customisationsare completely his work).Chris has also helped fix up problems problemsin the document (many times), especially with docbook/sgml, and LyX related issues.issuesChris has also improved improvedthe structure structureof the document by adding labels and fixing fixingminor errors.William West: +William WestWilliam provided a thorough review reviewof the document as requiredrequired by the Linux Documentation ProjectLinux Documentation Project. He is responsible responsiblefor a variety of improvements improvementsto the quality qualityof this document.His contributions contributionsinclude:include Improvements Improvementsto the readability readabilityof this document. Improvements Improvementsto the structure structureand consistency consistencyof this document. Various grammar grammarimprovements throughout the document. Repair Repairof some minor minortechnical errors.errorsTabatha Persad/Marshall: +Tabatha PersadTabatha MarshallTabatha, as the Linux Documentation ProjectLinux Documentation Project Review CoordinatorReview Coordinator (at the time) also gave a brief review reviewof this document. Her general advice was used to improve improvethe structure,structure language languageand grammargrammar of the document.Rahul Sundaram: +Rahul SundaramRahul provided a brief review reviewof this document for the Linux Documentation ProjectLinux Documentation Project. Advice from his brief review reviewwas integrated integratedinto this document to improveimprove readability readabilityand structure,structure several severalreferences referenceswere added as recommendedrecommended by Rahul.David Lawyer: +David LawyerDavid's criticism criticismof the document document(via the TLDP TLDPdiscuss listdiscuss list) were listened to, and attempts to improve the document were made. A number of his criticisms criticismswere addressed addressedand improved.improved George Harmon: +George HarmonGeorge provided provideda second language reviewlanguage review. His detailed detailedreview of the material materialallowed me to improve the general grammargrammar of the document and some minor minorerrors.Machtelt Garrels (tille): +tilleMachtelt GarrelsMachtelt provided tips in regard to referencingreferencing the correct correctLDP documents documentsfrom this guide.guide As well as general generaladvice on improvements improvementsto the guide.Michael Kerrisk: +Michael KerriskMichael pointed out a number of technical errors in the document after his brief review reviewon behalf of the TLDP TLDPduring posts to the discussion list.discuss list + +LegalThe legal legalchapter provides information informationabout the disclaimer disclaimerthat applies to the entire document and the licensing licensinginformation.DisclaimerNo liability liabilityfor the contents contentsof this document documentscan be accepted. Use the concepts,concepts examples examplesand other content contentat your own risk.risk There may be errors errorsand inaccuracies,inaccuracies that may of course be damaging to your system. Although this is highly highlyunlikely, you should proceed proceedwith caution.caution The author authordoes not accept any responsibility responsibilityfor any damage damageincurred.All copyrights copyrightsare held by their respective ownersrespective owners, unless specificallyspecifically noted otherwise. Use of a term termin this document should not be regarded regardedas affecting the validity validityof any trademark trademarkor service markservice mark.Naming Namingof particular products productsor brands brandsshould not be seen as endorsements.endorsementsUNIX UNIXis a registered trademark trademarkof The Open GroupThe Open Group. +LicenseCopyright Copyright© 2003 - 2006 Gareth Anderson.Gareth Anderson Permission Permissionis granted grantedto copy,copy distribute distributeand/or modify modifythis document under the terms termsof the GNU GNUFree Documentation License,GNU Free Documentation LicenseGFDL Version Version1.1 or any later version versionpublished by the Free Software Foundation;FSFFree Software Foundation with no Invariant InvariantSections,Sections with no Front-Cover Front-CoverTexts, and with no Back-Cover Back-CoverTexts.Texts A copy of the license licensecan be found in the section called the GNU Free Documentation License or at the GNU Documentation License Site.GNU Documentation License Site + +The Unix Tools PhilosophyA tool is a simple program,program usually designed for a specific purpose, it is sometimes referred referredto (at least throughout this document) as a command.The “ Unix tools philosophy”Unix Tools Philosophy emerged emergedduring the creation of the UNIX UNIXoperating system, after the breakthrough invention inventionof the pipe pipe'|' (refer to for information on using the pipe).The pipe pipeallowed the output outputof one program to be sent to the input inputof another. The tools philosophy was to have small programs to accomplish a particular task instead of trying to develop large monolithic programs to do a large number of tasks. To accomplish more complex complextasks,tasks tools would simply be connected connectedtogether, using pipes.pipesAll the core coreUNIX system UNIX systemtools were designed designedso that they could operateoperate together. The original text-based text-basededitors (and even TeX TeXand LaTeXLaTeX) use ASCII ASCII(the American text encoding standard;American text encoding standard an open standard) and you can use tools such as; sed, awk, vi, grep, cat, more, tr and various other text-based text-basedtools in conjunction conjunctionwith these editors.editors Using this philosophy philosophyprogrammers programmersavoided writing writinga program (within their larger program) that had already been written by someone else (this could be considered a form of code coderecycling). For example, command-linecommand-line spell spellcheckers are used by a number of different applications instead of having each application applicationcreate its own own spell checker.checkerThis philosophy philosophylives on today todayin GNU/Linux and various other UNIX system-based operating systems (FreeBSD,FreeBSD NetBSD,NetBSD OpenBSD,OpenBSD etc.).For further information (articles) on the UNIX tools philosophy UNIX tools philosophyplease see the further reading further readingsection, here: +Shell TipsThe shell shelltips chapter provides handy tricks that you may wish to use when you are using a GNU/Linux shell (the command-linecommand-line interface). This information includes handy handyshortcut shortcutkey combinations,key combinations the shell's command historycommand history and information on virtual terminals.virtual terminals +If you can't boot into your system +If your having problems booting into your system you may like to use a shell so you can boot into your system and attempt to fix things up again. +To do this you need to pass the “init=/bin/sh” to your system before you boot up. +If you don't know how to do this please see Security, the technique is the same except this time you pass "init=bin/sh" rather than "single". + +General Shell TipsAutomatic Command Completion +Automatic Command CompletionUse the TAB TABkey and bash bashwill attempt attemptto completecomplete the command for you automatically.automatically You can use it to complete command (tool) names. You can also use it when working with the file-system,file-system when changing directories, copying copyingfiles et cetera.There are also other lesser lesserknown ways to use automatic command completionautomatic command completion (for example completing user names):This information was adopted (with editing) from Mandrakesoft's Command Line Manual, see [7] in the for further information. + + ESC + Y + + + ESC-Y + + (Y: special character) +testing autoindexing Will attempt to complete the command name for you. If it fails it will either list listthe possible completions completions(if they exist). If there are none noneit will simply beep beep(and/or) flash flashthe screen.screen + + CTRL + X + Y + + + CTRL-X-Y + + (Y: special character) +Lists the possible completions (it won't attemptattempt to complete it for you) or beep beepif there are no possible possiblecompletions.Special-characters:Use the following followingspecial charactersspecial characters combined with either + + ESC + Y + + + ESC-Y + + or + + CTRL + X + Y + + + CTRL-X-Y + +, where Y is some special characters. For example + + ESC + $ + + + ESC-$ + + or + + CTRL + X + $ + + + CTRL-X-$ + + to complete an environment variableenvironment variable name.~ (tilde)tilde~ complete a user nameuser name@ (at sign)@ complete a machine namemachine name$ (dollars sign)$ complete an environment variableenvironment variable name! (exclamation mark)! a magic charactermagic character for completing a command namecommand name or a file name.file name The ! special character special characterhas the same function functionas the TAB TABkey. It works in some other situations; for example when completing man pageman page names.alias +aliasThe alias command will list your current aliases.aliases You can use unalias unaliasto remove removethe alias (to disable disableit just for one command add a “\”\ (back-slash) before the command)...An alias allows one command to be substituted substitutedfor another. This is used to make a command do something else or to automatically automaticallyaddadd certain options.options This can be either be done during one session sessionusing the alias command (see below) or the information informationcan be added to the .bashrc file (found in the users home directory).Below is an example of what an alias section (within your .bashrc file) might look like:On any Mandriva GNU/Linux system the global aliases global aliases(for all users) are all in /etc/profile.d/alias.sh. The above listed listedcommands already have aliases,aliases as well as several severalother commonly commonlyused commands.set -x +-x set setis one of bash's inbuilt inbuiltcommands, try looking in the bash bashmanual for its many usage usageoptions.Using set with the -x option optionwill make bash bashprint out each command it is going to run runbefore it runs it. This can be useful to find findout what is happening with certain commands such as things being quoted quotedthat contain wildcards wildcardsor special symbols special symbolsthat could cause causeproblems, or complex complexaliases. Use set +x to turn turnthis back off.back offExamplesAfter using set -x you can run the command:ls-F--color=autoThe output outputprinted printedbefore the command runs (for example):Which means that the command is really an alias to run ls with the -F and --color=auto options. Use a “\” (backslash) before the command to run runit without the alias.\ (backslash) +\The backslash backslashescape character charactercan be used before a shell command to override overrideany aliases.For example if rm was made into an alias for rm -i-irm -i then typing “rm” would actually run rm -i. However, typing \rm lets the shell ignore the alias aliasand just run rm (its runs exactly exactlywhat you type), this way it won't confirm confirmif you want to delete deletethings. +Using rm +Please note that the alias for the remove command is there for a reason. Using it incorrectly could remove files which you don't want removed. +Only use \rm if you know exactly what you are doing (recovering files is not easy, rm does not send things to a recycle bin). + +The “\” character charactercan be used before special charactersspecial characters (such as a space spaceor a wildcardwildcard), to stop stopbash bashfrom trying to expand expandthem. You can make a directory directoryname with a spacespace in it using a backslash before the space. For example you could type cd My\ Directory\ With\ Spaces which normally wouldn't work. The “\” character charactercan also be used to stop stopbash bashfrom expanding expandingcertain symbolssymbols (as an alternative alternativeyou could use single quotation quotationmarks, although you may need to use both). +The TAB Key<indexterm><primary>TAB key</primary></indexterm> +Please note that using the TAB key (automatic-command-completion) will automatically use escapes for spaces (so you don't have to type them manually). + +script +scriptThe “script” command creates a typescript,typescript or "capture log" of a shell session - it writes a copy copyof your session sessionto a file, including includingcommands you type and their output.~ (tilde character) +~The tilde tildecharacter characteris used as an alias to a users home directory. For example, if your user-name user-namewas “fred”, instead of typing cd /home/fred you could simply type cd cd~. Or to get to fred's tmp directory (under his home homedirectory) you could type cd cd~/tmp. +Home directory shortcut +~ (tilde) can also be used as a shortcut to other users home directories, simply type: ~user_name and it will take you to the users home directory. Note that you need to spell the username exactly correct, no wildcards. + + + set bell-style none +set bell-styleThis particular particularset command will turn off turn offthe system bellsystem bell from the command-line command-line(use xset xset-b for X windows). If you want the bell bellto stay off pernamently (no audible audiblebell) then you can add this command to your “.bashrc” or “.bash_profile” (just add it to the same one you have your alises in...).reset +resetThe reset command re-initializes your current terminal.terminal This can be useful when the text textfrom your terminal terminal becomes garbled,garbled simply type “reset” and this will fix fixyour terminal.exit +exitCloses your current terminal (with x-terminals) or logs-out.logs-out Also try + + CTRL + D + + + CTRL-D + +.logout +logoutLogs out of a terminal, also try + + CTRL + D + + + CTRL-D + +.echo +echoA little command that repeats repeatsanything you type.Example:Simply displays “ hello world”. Example:This will output what will be passed passedto the rmrm command (and therefore what would be deleted), putting puttingecho before a command renders rendersit harmless harmless(it just expands expandswildcards so you know what it will do).Also try using the -e -e option optionwith echo.echo This will allow allowyou to use the escape escapecharacter sequencescharacter sequences to format formatthe output of a line.line Such as '\t' for tab,tab '\n' for newline newlineetc. +Using echo to prevent accidents + +Typing: echo command(s) could save you the trouble of accidentally doing something you didn't expect. + + +Using echo allows you to expand the wildcards to understand what will happen before you actually run the command. + + + +The command-line historyUsing the command history +command historyUse the up and down key's to scroll scrollthrough previously typed commands. Press [Enter] to execute executethem or use the left and right arrow arrowkeys to editedit the command first. Also see history (below).The history command +The history history command can be used to list Bash's log logof the commands you have typed:This log logis called the “history”. To access accessit type:This will only list the last lastn commands. Type “history” (without options) to see the the entire history historylist.listYou can also type !n!n to execute command numbercommand number n. Use !!!! to execute the last command you typed.!-n!-n will execute the command n times timesbefore (in other words !-1 is equivalent equivalentto !!). !string!string will execute the last command starting startingwith that “string” and !?string? will execute the last command containing the word “string”. For example:Will re-run the command that you last typed starting with “cd”.“ commandName commandName!*” will execute the “commandName” with any arguments argumentsyou used on your last command. This maybe useful if you make a spelling spellingmistake, for example. If you typed:In an attempt attemptto execute emacs emacson the above two files this will obviously fail.fail So what you can do is type:This will execute emacs emacswith the arguments argumentsthat you last typed on the command-line.command-line In other words this is equivalent equivalentto typing:Searching through the Command History ( + + CTRL + R + + + CTRL-R + +) +Command HistoryUse the CTRL-R key keyto performperform a “reverse-i-search”. For example, if you wanted to use the command you used the last time you used snortsnort, you would type: + +CTRL +R + then type “snort”. + +What you will see in the console consolewindow windowis:After you have typed what you are looking for, use the + + CTRL + R + + + CTRL-R + + key combinationkey combination to scroll scrollbackward through the history.history Use + + CTRL + R + + + CTRL-R + + repeatedlyrepeatedly to find findevery reference referenceto the string stringyou've entered.entered Once you've found foundthe command you're looking for, use [Enter] to execute it. Alternatively,alternatively using the right or left arrow keysarrow keys will place placethe command on an actual command-line command-lineso you can edit it. +Other Key combinationsGNU/Linux shells shellshave many shortcut shortcutkeys which you can use to speed speedup your work, below is a rough list of some (also see + + CTRL + R + + + CTRL-R + + in the history historysection of the commands, over here, ). + + CTRL + D + + + CTRL-D + + the “end-of-file” (EOF) key combination can be used to quickly log out of any terminal. + + CTRL + D + + + CTRL-D + + is also used in programs such as “at” to signal that you have finished typing your commands (the EOF command). + + CTRL + Z + + + CTRL-Z + +key combinationkey combination is used to stop a process. It can be used to put something in the background temporarily.For example, if you were editing a file with vim or emacs just press + + CTRL + Z + + + CTRL-Z + + to regain control of the terminal do what you want and then type fg fg to bring it back. For further information please see . +If <emphasis>fg</emphasis> doesn't work +If fg doesn't work you may need to type jobs and then fg job_name or fg job_number + + + + CTRL + A + + + CTRL-A + + and  + + CTRL + E + + + CTRL-E + +These key combinations are used for going to the start and end of the line on the command line. Use + + CTRL + A + + + CTRL-A + + to jump to the start of the line, and + + CTRL + E + + + CTRL-E + + to jump to the end of the line. + + CTRL + K + + + CTRL-K + +This key combination can be used to cut or delete what is currently in front of the cursor. + + CTRL + Y + + + CTRL-Y + +This key combination can be used to paste the last thing you deleted (using + + CTRL + K + + + CTRL-K + + or + + CTRL + W + + + CTRL-W + +). + + CTRL + W + + + CTRL-W + +This key combination can be used to cut or delete the entire line that has being typed. +Virtual Terminals and screenUsing the key combination + +ALT +F* + + keys you may change to different virtual terminals. You will have several (usually 6) virtual terminals setup with shells. Number 7 is usually setup with X you need to use + + CTRL + ALT + F* + + + CTRL-ALT-F* + + to change to a terminal from within X (X as in the X windowing system). + +screen +screenvirtual terminalsis a great program that allows allowsyou to switch switchbetween multiple virtual terminalsvirtual terminals on the one physical physicalterminal that you are using. Its a command-line command-linebased window managerwindow manager, clearly this isn't that useful if you do have virtual terminals, but its amazingly useful when you loglog into machines remotely, using ssh sshand similar, see . It works on key-combinations,key-combinations you typeOn the command-line to begin. Now you start with one virtual terminal by default, but using the key combination + + CTRL + A + + + CTRL-A + + and then hitting "C" you can create another virtual terminal to use. Use + + CTRL + N + + + CTRL-N + + to go to the next virtual terminal and + + CTRL + P + + + CTRL-P + + to go to the previous virtual terminal. Also try hitting + + CTRL + A + + + CTRL-A + + to go backwards and forwards between two particular terminals.screen screenalso has various other abilities abilitiesthat you can test testout. The documentation documentationand guides are well written so please feel free to read the manual manualpage pageor try searching searchingthe internet.internet + +HelpThe help helpchapter provides providesinformation on how you may access the documentationdocumentation of the GNU/Linux system. There is normally a document documentdescribing every single tool you have installed,installed even if its only brief...man +manThis command displays summary summaryinformation informationon a program from an onlineonline manual.manual For example typing man man will bring up the manual manualpage for man (the manual manualpage viewer). Note: q is the quit quitkey.Command syntax: +Also try +Specifying the section of the manual page, sometimes the man page is different for the same tool in different sections, note sections are numbered 1 to 9. Use apropos to find which section number to look in. + + +The syntax to look at a different section is: + +man section_number tool_name + +For example: + +man 2 time + +This will show you the man page called time in section 2, the equivalent page in section 1 is completely different + + +man -K keyword +man -KSearch the manual manualpages for a string,string as in it will searchsearch all manual manualpages for a particular string within each individual individualman page, it will then prompt promptwhether you would like to view vieweach page it will find. Use double doublequotes “ and ” if there are spaces spacesin the string you are typing. +Speed issue + Please be warned that this method is going to be really, really slow. You are searching *all* man pages for a string + +man -f command +man -fThis will list listdetails detailsassociated associatedwith the command. The root rootuser must run runmakewhatis makewhatis(see below) before this command will work. +Equivalent to <emphasis>whatis</emphasis> + This command is the same as running whatis + + +info +infoProvides a more detailed detailedhyper-text manual manualon a particular command, this only works for some commands.Command syntax:whatis +whatisDisplays a one-line description descriptionof what a program programdoes. The string needs to be an exact exactmatch, otherwise whatis won't output outputanything. Relies on the whatis database (see below).Command syntax:makewhatis +makewhatisMake the whatis database for apropos, whatis and man -f.-f +Root Privileges +This takes some time and you require root privileges to do this. + +apropos +aproposSearches Searchesthe whatis database for strings,strings similar to whatis except it finds findsand prints printsanything matching matchingthe string (or any part of the string). Also relies on the whatis database (see above). Command syntax: +Equivalent to... + apropos is the same as doing man -k (lowercase k). + + +Please note + +You need to run makewhatis (as root) so whatis, man -f and apropos will work. + + + +Also try + +Using a program with the -?,-? --h,--h --help--help, and the -h-h options, they will display very short summary information on the command usage options. + + + +Directing Input/OutputThe directing input/output chapter explains explainshow you can use a program and send sendits output to a file or to another command that you wish to use. This technique techniqueis very powerful powerfuland there are a number numberof ways of doing this.Concept DefinitionsAll three of the following followingdefinitions definitionsare called “ File Streams.”File StreamsStreams They hold information that is either received receivedfrom somewhere or sent to somewhere. In a UNIX UNIXsystem, the keyboard keyboardinput (standard input), information printed to the screen screen(standard output) and error erroroutput (also printed printedto the screen) are treated as separate File Streams.Standard output +Standard output Standard outputis the output from the program printed printedto the screen,screen not including error output Error output(see below).Standard input +Standard input Standard inputis the input inputfrom the user. Normally the keyboard keyboardis used as the standard input standard inputdevice in a UNIX UNIXsystem.Standard error +Standard error Standard erroris error erroroutput from programs.programs This output is also sent to the screen screenand will normally be seen mixedmixed in with standard output.standard output The difference differencebetween standard output standard outputand standard error standard erroris that standard error is unbuffered unbuffered(it appears immediately on the screen) and standard error is only printed printedwhen something goes wrong (it will give you details of what went wrong). +Usage> +>The greater greaterthan symbol symbolis used to send sendinformation somewhere (for example a text file)Example: file1_and_2.txt +]]>This will concatenate concatenatethe files together into one big file named “file1_and_2.txt”. Note that this will overwrite overwriteany existing existingfile.< +<The less lessthan symbol will insert insertinformation from somewhere (a text file) as if you typed it yourself. Often used with commands that are designed designedto get information from standard input standard inputonly.For example (using tr): fileNameNew.txt +]]>The example above would insert insertthe contents contentsof “fileName.txt” into the input inputof tr trand output the results resultsto “fileNameNew.txt”.>> +>>The >> symbol symbolappends (adds) information to the end of a file or creates one if the file doesn't exist.exist<< +<<The << symbol symbolis sometimes used with commands that use standard inputstandard input to take information. You simply type << word (where word can be any string) at the end endof the command. However its main use is in shell scripting.shell scripting The command takes your input until you type “word”, which causes the command to terminate terminateand process processthe input. Using << is similar to using + + CTRL + D + + + CTRL-D + + (EOF key), except it uses a string stringto perform performthe end-of-file function. This design allows it to be used in shell scripts.shell scriptsFor example type "cat"cat (with no options...) and it will work on standard input.standard inputTo stop stopentering standard input standard inputyou would normally hit + + CTRL + D + + + CTRL-D + +.As an alternative alternativeyou can type "cat << FINISHED", then type what you want. When you are finished,finished instead of hitting hitting + + CTRL + D + + + CTRL-D + + you could type "FINISHED"FINISHED and it will end (the word FINISHED will not be recorded).2> +2>Redirects error output.error output For example, to redirect redirectthe error output error outputto /dev/null/dev/null, so you do not see it, simply append this to the end of another command...For example: /dev/null +]]>This will run make on a file and send sendall error output to /dev/null| +|pipeThe “pipe” command allows the output of one command to be sent to the input of another.For example:Concatenates Concatenatesthe files together, then runs less on them. If you are only going to look lookat a single file, you would simply use lessless on the file...tee +teeSends output of a program to a file and to standard output.standard output Think of it as a T intersection...it goes two ways.For example:Lists Liststhe files (displays the output on the screen) and sends sendsthe output to a file: “my_directories.txt”.&> +&>Redirects standard output standard outputand error output error outputto a specific specificlocation.locationFor example: /dev/null +]]>Sends Sendsboth error output error outputand standard output standard outputto /dev/null so you won't see anything... +Command SubstitutionCommand substitutioncommand substitution is basically another way to do a pipe,pipe you can use pipes and command substitution interchangeably,interchangeably it's up to you which one you find easier...Command substitution can be done in two distinct distinctways. + Method One (back-quotes) + Simply type:This will execute execute“command_2” and it's output outputwill become the input to “command_1”. +Backquote key + +The back-quote key is usually located at the same place as the tilde, above the [Tab] key. + + +Method Two (dollars sign) + Simply type:This will execute “command_2” and it's output will become the input to “command_1”.Using the pipe instead + You can of course use pipes pipesto do the same thing, if you don't know what a pipe pipeis, please see . For example instead of doing:You could do:And end up with exactly exactlythe same result,result it's up to you which way you find easier. +Performing more than one commandExecuting the second command only if the first is successful + To do this you would type:&&command2command2 will be executed if command1 command1successfully completes (if command1 fails failscommand2 command2won't be run). This is called a logical logicalAND.ANDExecuting the second command only if the first fails + To do this you would type:||command2 command2will be executed if command1 command1does not successfully complete (if command1 command1is successful successfulcommand2 won't be run). This is called a logical logicalOR.ORExecuting commands sequentially + To execute commands sequentially sequentiallyregardless of the success/failure of the previous previousyou simply type:;command2 command2will execute once command1 command1has completed. +More than two commands +You can continue to use ';' (semicolon) characters to do more and more commands on the one line. + + + +Working with the file-systemThe working with the file-system file-systemchapter explains a number numberof commands that you use to move around the file system file systemhierarchy hierarchyand manipulate manipulatethe files. Also explained are finding findingfiles and how to mass-rename mass-renamefiles.Moving around the filesystemcd +cdChange directory. Use “ cd ..” to go up one directory. One dot dot'.' represents representsthe current directory current directorywhile two dots dots'..' representrepresent the parent directory.parent directory “ cd -” will return returnyou to the previous previousdirectory (a bit like an “undo”). You can also use cd absolute path or cd relative path (see below):Absolute paths +Absolute pathAn “ absolute path” is easily recognised recognisedfrom the leadingleading forward slash, /. The // means that you start startat the top level directory and continue down.For example to get to /boot/grub you would type:This is an absolute path because you start at the top of the hierarchy and go downwards downwardsfrom there (it doesn't matter where in the filesystem filesystemyou were when you typed the command).Relative paths +Relative pathsA “ relative path” doesn't have a preceding precedingslash. Use a relative path when you start from a directory below the top toplevel directory structure. This is dependent dependenton where you are in the filesystem.filesystemFor example if you are in root's home homedirectory and want to get to /root/music, you type:Please note that there is no / using the above cd cdcommand. Using a / would cause causethis to be an absolute absolutepath,path working from the toptop of the hierarchy downward.ls +lsList files and directories.directories Typing “ls” will list listfiles and directories, but will not list hidden hiddenfiles or directoriesdirectories that start with a leading full stop leading “.”..Example options:ls -l --- long -llongstyle,style this lists listspermissions, file size,size modification modificationdate,date ownership.ownershipls -a --- -athis means "show all", this shows showshidden hiddenfiles, by default defaultany file or directory directorystarting startingwith a '.' will not be shown.shownls -d --- -dlist directory entires rather than contents contents(see example below)ls -F --- -Fappend appendsymbols symbolsto particular files, such as * (asterisk) for executableexecutable files. ls -S --- -Ssort sortthe output of the command in decending decendingorder ordersorted sortedby size.ls -R --- -R(recursive) to list everything everythingin the directories directoriesbelow as well as the current directory.Command syntax, either:This simply lists everything in the current directory, the options optionsare not required required(options such as -l, -a et cetera).This lists files using a certain string. The string stringcan contain standard wildcards standard wildcardsto list multiple files, to learnlearn more about standard wildcards please read You can use ls -d to show showdirectories that match matchan exact exactstring, or use standard wildcards. Type “ ls -d */” to list all subdirectories subdirectoriesof the current directory. Depending Dependingon the setup setupof your aliases (see ) you may simply be able to type lsd lsdas the equivalent equivalentto ls -d */.Examples Examplesfor ls -d:Lists all subdirectories subdirectoriesof current directory.Lists directories that start with "string".Lists all directories directoriesthat are two levels levelsbelow the /usr/ directory and have a directory called “doc”, this trick trickcan come in quite handy sometimes. +You can also use + +Depending on how your aliases (see ) are setup you can also use l, la (list all) and ll (list long) to perform the above commands + + +pwd +pwdPrint working directoryprint working directory. Print Printthe absolute absolute(complete) path pathto the directory the user is currently in. Command syntax:This will tell you the full path pathto the directory you are in, for example it may output output“/usr/local/bin” if you are currently in that directory.tree +treeOutputs Outputsan ASCII ASCIItext tree/graph graphstarting at a given directory (by default defaultthe current currentdirectory). This command recursively lists listsall files and all directories.directoriesIn other words, it will list files within the directories directoriesbelow the current one, as well as all files in the current directory.tree has a large number of options, refer referto the manual manualpage pagefor details.detailsCommand syntax:orFinding filesfind +findfind is a tool which looks looksfor files on a filesystem.filesystem find has a large number numberof options which can be used to customise customisethe searchsearch (refer to the manual/info pages).Note that find works with standard wildcards,standard wildcards, and can work with regular expressionsregular expressions, .Basic Basicexample:This would look lookfor a file named named“file” and start at the root directory root directory(it will search all directories directoriesincludingincluding those that are mounted mountedfilesystems).The `-name'-name option optionis case sensitive sensitiveyou can use the `-iname' option to find something regardless regardlessof case.Use the '-regex'-regex and '-iregex'-iregex to find something according to a regular expression (either case sensitivesensitive or case insensitive insensitiverespectively).The '-exec'-exec option is one of the more advanced advancedfind findoperations.operations It executes a command on the files it finds finds(such as moving movingor removingremoving it or anything else...).To use the -exec option: use find to find something, then add addthe -exec option to the end,end then: +command_to_be_executed then '{}' (curly brackets) then the arguments (for example a new directory) and finally a ';' . + +See below for an example of use this command. + + + This is the tool you want to execute on the files find locates. For example if you wanted to remove everything it finds then you would use -exec rm -f + + + + + The curly brackets are used in find to represent the current file which has been found. ie. If it found the file shopping.doc then {} would be substituted with shopping.doc. It would then continue to substitute {} for each file it finds. The brackets are normally protected by backslashes (\) or single-quotation marks ('), to stop bash expanding them (trying to interpret them as a special command eg. a wildcard). + + + + + This is the symbol used by find to signal the end of the commands. It's usually protected by a backslash (\) or quotes to stop bash from trying to expand it. + + + +The above command would find findany files with the extension extension'.doc' and copycopy them to your /tmp directory, obviously this command is quite useless, it's just an example of what find can do. Note that the quotation quotationmarks are there to stop stopbash bashfrom trying to interpretinterpret the other characters charactersas something.Excluding Excludingparticular folders folderswith find can be quite quiteconfusing, but it may be necessary if you want to search your main disk disk(without searching searchingevery mounted mountedfilesystem). Use the -path -path option to exclude excludethe particular folder (note, you cannot have a '/' (forward slash) on the end) and the -prune -prune option to exclude excludethe subdirectories.subdirectories An example is below:-path-prune-o-printThis example will search your entire directory tree (everything that is mounted mountedunder it) excluding excluding/mnt/win_c and all of the subdirectories subdirectoriesunder /mnt/win_c. When using the -path option you can use wildcards.wildcardsNote that you could add addmore -path -path'/directory' statements statementson if you wanted.find has many, many different differentoptions, refer referto the manual (and info) pagepage for more moredetails.slocate +slocateslocate outputs outputsa list listof all files on the system that match matchthe pattern,pattern giving their full path pathname (it doesn't have to be an exact exactmatch, anything which contains the word is shown). +Replaces <emphasis>locate</emphasis> +Secure locate is a replacement for locate, both have identical syntax. On most distributions locate is an alias to slocate. + +Commmand Commmandsyntax:syntax +This won't work unless + +You need to run either updatedb (as root) or slocate -u-u (as root) for slocate to work. + + +whereis +whereiswhereis locates locatesthe binary,binary source,source and manual page for a particular program, it uses exact exactmatches only, if you only know part partof the name use slocateslocate.Command syntax:which +whichVirtually the same as whereis,whereis except it only finds findsthe executableexecutable (the physical physicalprogram). It only looks in the PATH PATH(environment variable) of a users shell.shell Use the -a-a option to list all occurances occurancesof the particular program_name program_namein your pathpath (so if theres more than one you can see it).Command syntax: + +Working with files and foldersmkdir +mkdirMake a directory. Use mkdir -p-p to create subdirectories subdirectoriesautomatically.automatically +Directories are Folders +Directories are sometimes called folders in other operating systems (such as Microsoft Windows) + +Examples:This would create the directories directories“work” and “maths” under matt's home homedirectory (if matt's home homedirectory directorydidn't exist existit would create that too).This would create a directory in the current path pathnamed “foo”.rm +rmRemove/deletedeleteremove a file(s) or directories(s). You can use standard wildcards standard wildcardswith this command .Command syntax:You can of course use standard wildcards to delete multiple files or multiplemultiple directories directoriesand files.Use the -R-R or -r-r option to remove removerecursively, this removes removeseverything everythingwithin subdirectories.subdirectories Also try the -f-f option to force forceremoval (useful when you don't want to be prompted). +Disabling Aliases (per execution) + +On some systems such as Mandrake an alias will send rm to rm -i-i (prompting you for every file you wish to delete). To override this use: \rm -R directory (using the \ disables the alias for this run only) + + +rmdir +rmdirRemove an empty emptydirectory. If you want to remove removea directory with files in it type “ rm -R directory”, read above for information informationon rm -RCommand syntax:This will only remove removedirectory if it's empty emptyotherwise it will exit exitwith an error errormessage.mv +mvMove a file or a directory to a new newlocation or rename renamea file/directory.Rename Renameexample: Renames Renamesfilename1 filename1to filename2.filename2To move movea file or directory, simply type: Note that this command can use standard wildcards standard wildcards to move movefiles (not for renaming). +Move and rename + +Note that you can also move and rename a file in a single command. The difference is with the destination (right hand side) you change the filename to the new name of the file. + +For example typing: + +This would move the file "configuration.txt" to /home/joe/ and rename it "backupconfig" + +cp +cpCopy a file. Has a number numberof useful options, such as -R -R(or -r) which whichrecursively recursivelycopies copiesdirectories and subdirectories.subdirectoriesCommand syntax:Examples:Simply copy file1 file1to file2 file2(in the same directory).Where the last lastoption is the directory to be copied to. The above example copies Copiestwo files from different areas of the file system to /mnt/win_cThis command will copy directories (and all subdirectories) and/or files to new_locationnew_location Note that this command can use standard wildcards standard wildcards to copy copymultiple files.You may also like to try the “-u”-u when moving movinglarge directories directoriesaround, this copies copiesonly if the source sourcefile is newer newerthan the destination destinationto where you are copying copyingto, or if the destination file does not exist existat all.ln +lnCreate a link linkto a file. There are two types typesof links:linksHard links +hard linksHard links are considered pointers pointersto a file (the number is listed listedby typing ls -l)ls. Each hard-link hard-linkis a reference referenceto a file.The file itself only goes away when all hard-links hard-linksare deleted.deleted If you delete the original originalfile and there are hard links linksto it the original file will remain. Example:Will create a “hard link” to target_name target_namecalled link_name,link_name you need to delete both of these to removeremove the file.Symbolic links +Symbolic linksSymbolic links are created by typing “ln -s”.-s When you remove removethe original originalfile the symbolic link symbolic linkbecomes broken,broken a symbolic link linkis similar to a windows windows“short-cut”. The advantage advantageof symbolic symboliclinks is that the target can be to something on another file-system, while hard-links hard-linkscan only exist existon the same file-system.file-systemFor example:This creates a symbolic link to “target_name” called “link_name”, if you delete the original originalfile the symbolic link won't work (it becomes a broken brokenlink).shred +shredSecurely remove removea file by overwriting overwritingit first. Prevents Preventsthe data datafrom being recovered recoveredby software software(and even by most hardware), please be very careful carefulwhen using shred as you may never be able ableto retrieveretrieve the data datayou have run runthe application applicationon.For example:
-n-z-v“What this tells shred, is to overwrite overwritethe partition partition2 times with randomrandom data data(- n 2) then finish finishit up by writing writingover it with zeroes zeroes(-z) and show showyou its progress (-v). Of course, change change/dev/hda1 to the correct partition partition. Each pass passcan take some time,time which is why I set setit to only do 2 randomrandom passes passesinstead of the default default25. You can adjust adjustthis number, of course, to your particular level of paranoiaparanoia and the amount amountof time you have.Since shred writes on such a low-level,low-level it doesn't actually matter what kind of filesystem filesystemis on the partition--everything will be unrecoverable.unrecoverable Once shred is finished,finished you can shutdown the machine machineand sell sellor throwthrow away the drive drivewith peace peaceof mind.mind...However, even shre dding devices devicesis not always completely reliable.reliable For example, most disks disksmap mapout bad sectors sectorsinvisibly to the application;application if the bad sectors sectorscontain sensitive sensitivedata,data `shred' won't be able ableto destroydestroy it. [ shred info page page].”This information (as quoted) has come from the “Please, For the Love of All That's Recoverable, Shred Your Hard Drive!” article, number 18 in the
+Shredding files doesn't work with all filesystems + +Please note that as mentioned in the shred manual page (please see the manual and preferably info pages for more information). shred does not work correctly on log-structured or journaled filesystems, such as JFS, ReiserFS, XFS, Ext3 and many other modern filesystems + + + +Alternatives to using shred +shred has its disadvantages when run on a filesystem. First of all since it has to be installed you cannot run shred on your operating systems filesystem, you also cannot use shred on a windows machine easily since you cannot install shred on this machine. +You may like to try alternatives such as the DBAN project that create self-booting floppy disks that can completely erase a machines hard disk. + +You may also like to see how chattr chattrcan assist assistyou in shredding shreddingfiles once they are removed (it has similar problems problemsto shred,shred only ext2 ext2and ext3ext3 style filesystems...), please see .
du +duDisplays information informationabout file size. Use du filename to display displaythe size sizeof a particular particularfile. If you use it on directories directoriesit will display the information on the size of the files in the directory and each subdirectory.subdirectory Options Optionsfor du du(use du -option(s)):-c-c -- this will make du print printa grand grandtotal totalafter all arguments argumentshave being processed.processed-s-s -- summarises summarisesfor each argument argument(prints the total).-h-h -- prints printsthings in “ human readablehuman readable” mode;mode for example printing printing1M (megabyte) rather than 1,024,000 (bytes).Using the -hs options on a directory will display the total totalsize of the directory directoryand all subdirectories.subdirectoriesCommand syntax:Example:This command will list listthe size of all files in the current directory and it will list the size of subdirectories,subdirectories it will list things in human-readablehuman-readable sizes sizesusing 1024 Kb Kbis a Megabyte,Megabyte M for megabyte,megabyte K for kilobyte kilobyteetc.file +Attempts Attemptsto find findout what type of file it is, for example it may say it's: binary,binary an image imagefile (well it will say jpeg,jpeg bmp bmpet cetera), ASCIIASCII text,text C header headerfile and many other kinds of files, it's a very useful utility.utility Command syntax:stat +statTells you detailed detailedinformation informationabout a file, including includinginode number creation/access date. Also has many advanced advancedoptions and uses. For simple use type:dd +ddCopies data dataon a very low lowlevel and can be used to create copies copiesof disksdisks and many other things (for example CD image imagefiles). dd can also perform performconversions on files and vary the block blocksize used when writing writingthe file. Command syntax, note the block blocksize and count countare optional optionaland you can use files instead of devices... +Please note +dd is an advanced and difficult to use command. Its also very powerful, so be careful what you do with it + +Command syntax: +Warning + +The command dd is used to work on a very low level. It can be used to overwrite important information such as your master-boot record or various important sections of your hard-disk. Please be careful when using it (especially when working with devices instead of files). + + +touch +touchThis command is used to create empty emptyfiles, simply do touch file_name. It is also used to update updatethe timestamps timestampson files.touch can be used to change changethe time and/or date of a file:-tThis particular command and explanation has been used (with editing) from the Linux Online Classroom, see [4] in the for further information.This command would change changethe timestamp timestampon my_report.txt so that it would look looklike you created it at 9:15. The first four digits digitsstand for May 7th (0507), in MM-DD (American style), and the last lastfour (0915) the time,time 9:15 in the morning.morning Instead of using plain plainnumbers to change changethe time, you can use options similar to that of the date tool. For example:You can also use --date= instead of -d-d--date=. Also have a look at the date command under for examples exampleson using -d and --date= (the syntax syntaxfor the date datepart is exactly exactlythe same when using -d or --date).split +splitSplits Splitsfiles into several severalsmaller smallerfiles. Use the -b xx -boption optionto split splitinto xx bytes,bytes also try -k -kfor kilobytes,kilobytes and -m -mfor megabytes.megabytes You can use it to split text files and any other files... you can use cat to re-combine re-combinethe files. This may be useful if you have to transfer transfersomething to floppy floppydisks disksor you wish to divide dividetext files into certain sizes.sizesCommand syntax:This will split splitthe input inputfile into 1000 lines linesof input each (thats the default...), and output output(using the above example), with the input name file, “fileaa” (1st part partof file), “fileab” (2nd part partof file), “fileac” (3rd part partof file) etc. until the there is no more moreof the file left to split.split
+Mass Rename/copy/link ToolsThere are a few different ways to perform mass renamingmass renaming of files in GNU/Linux (yes, mass renaming is possible!). There is also a perl perlscript that renames renamesthe extentions extentionson files, see .Below are three ways to perform mass renaming of files, using the commands mmv, rename (a perl perlscript) or some bash bashshell scripting.scripting + mmv +mmvmmv is a mass massmove/copy/renaming tool moverenamingthat uses standard wildcards standard wildcardsto perform its functions.functionsmmv's manual page is quite difficult to understand, I have only a limited limitedunderstanding ngof this tool. However mmv supports supportssome standard standardwildcards.standard wildcardswildcardsAccording to the manual manualthe “;”; wildcard wildcardis useful for matching matchingfiles at any depth depthin the directory tree (ie it will go below the current directory, recursively).An example of how to use mmv mmvis shown shownbelow:The first pattern patternmatches anything with a “.JPG” and renames renameseach file (the “#1” matches the first wildcard) to “.jpg”.Each time you use a \(wildcard) you can use a #x to get that wildcard. Where x is a positive positivenumber starting startingat 1. +mmv Homepage +You can find mmv on the web here. +Also be aware that certain options used with mmv are also applicable to other tools in the suite, these include mcp (mass copy), mad (mass append contents of source file to target name), mln (mass link to a source file). + + +Tip: +A Java alternative to mmv which runs on both GNU/Linux and Windows is available, Esomaniac + +rename +renamerename is a perl perlscript which whichcan be used to mass rename mass renamefiles according to a regular expressionregular expression.An example for renaming renamingall “.JPG” files to “.jpg” is: +Finding rename +You can get rename from various places. I would recommend trying CPAN Search Site, I found the script here Rename Script Version 1.4 + +Bash scripting +scriptingBash Bashscripting is one way to rename renamefiles. You can develop developa set setof instructions instructions(a script) to rename renamefiles. Scripts Scriptsare useful if you don't have mmv or rename...One way to this is shown shownbelow:Note that the above script scriptcame from a usenet usenetpost.post Unfortunately UnfortunatelyI do not know the author's name.The first line linesays find everything everythingwith the “.JPG” extension extension(capitals only, because the UNIX system UNIXis case sensitive).The second line uses basename (type man manbasename for more details) with the '$i' argument.argument The '$i' is a string stringcontaining the name of the file that matches. The next nextportion of the line removes the JPG JPGextension from the end endand adds the jpg jpgextention to each file. The command mv is run runon the output.An alternative alternativeis:The above script renames renamesfiles using a built-in built-inbash bashfunction. For more information informationon bash bashscripting bash scriptingyou may like to see the advanced bash scripting guide, authored by Mendel CooperMendel Cooperadvanced bash scripting. +
+Finding information about the systemtime +If you are looking lookingfor how to change changethe time please refer referto date here: . time is a utility utilityto measure measurethe amount amountof time it takes a program programto execute.execute It also measures measuresCPU CPUusage and displays statistics.statisticsUse time -v-v (verbose mode) to display displayeven more detailed detailedstatistics about the particularparticular program.Example usage:/proc +The files under the /proc/proc (process information pseudo file-system)process information show showvarious information about the system. Consider it a window windowto the information that the kernel kerneluses. For example:Displays information about the CPU.CPU Use the above command to view viewinformation about what kernel-modules kernel-modulesare loaded loadedon your system.dmesg +dmesgdmesg can be used to print print(or control) the “ kernel ring bufferkernel ring buffer”. dmesg is generally used to print the contents contentsof your bootup bootupmessages displayed by the kernel.kernel This is often useful when debugging debuggingproblems.problemsSimply type:df +dfDisplays information about the space spaceon mounted mountedfile-systems. Use the -h -h option optionto have df list listthe space in a 'human readable' format.format ie. if there are 1024 kilobytes kilobytesleft (approximately) then df will say there is 1MB 1MBleft.Command syntax:The latter part partis optional,optional you can simply use df with or without options optionsto list space on all file-systems.file-systemswho +whoDisplays information on which users are logged loggedinto the system including the time they logged in. Command syntax:w +wDisplays information on who whois logged into the system and what they are doing (ie. the processes processesthey are running). It's similar to who but displays slightly different information.Command syntax:users +Very similar to who except it only prints printsout the user names who whoare currently logged in. (Doesn't need or take any options).Command syntax:last +lastDisplays records recordsof when various users have logged in or out. This includes includesinformation on when the computer computerwas rebooted.rebootedTo execute this simply type:lastlog +lastlogDisplays a list of users and what day/time they logged loggedinto the system. Simply type:whoami +whoamiTells the user who they are currently logged in as, this is normally the usename they logged in with but can be changed with commands like su).su whoami does not need or take any options. Simply type:free +freeDisplays memory memorystatistics statistics(total, free, used, cached,cached swap). Use the -t -t option to display totals totalsof everything everythingand use the -m -mto display memory memoryin megabytes.megabytes Example:This will display the memory memoryusage including includingtotals totalsin megabytes.megabytesuptime +uptimePrint how long longthe computer has been “up”, how long longthe computer has been running.running It also displays the number numberof users and the processor processorload (how hard the CPU has been working...). +The w command +The w command displays the output outputof the uptime command when you run this command. You could use the w command instead of uptime. + + +uname +unameuname is used to print information informationon the system such as OS OStype, kernel versionkernel version et cetera.Some uname options:-a-a --- print all the available availableinformation.-m-m --- print only information related to the machine machineitself. -n-n --- print only the machine hostname. -r-r --- print the release numberrelease number of the current currentkernel.kernel -s-s --- print the operating operatingsystem name -p-p --- print the processor processortype. Command syntax:xargs +xargsNote that xargs is an advanced,advanced confusing,confusing yet powerful powerfulcommand. xargs is a command used to run other commands as many times timesas necessary, this way it prevents any kind of overload... When you run a command then add a “| xargs xargscommand2command2”. The results resultsof command1 command1will be passed passedto command2, possibly on a line-by-line basis or something similar.command2 Understanding xargs tends tendsto be very difficult and my explanation explanationis not the best. Refer Referto the examples examplesbelow or try [6] of the for another xargs tutorial.tutorial +Alternatives to using xargs +Please note that the below explanation of xargs is not the strongest (at the time of writing I could not find anything better :()). +Alternatives may include writing a simple bash script to do the job which is not the most difficult task in the world. + +Examples:The first command is obvious, it will list listthe files in the current directory. For each line lineof output of ls, xargs will run grep on that particular line and look lookfor the string “work”. The output have the each time grep is executed on a new newline, the output would look like:If grep didn't find findthe word then there would be no output if it had an error errorthen it will output the error.error Obviously this isn't very useful (you could just do:grep This is just a simple example...xargs xargsalso takes various options:-nx-nx --- will group groupthe first x commands together-lx-lx --- xargs xargswill execute executethe command for every x number of lines linesof inputinput-p-p --- prompt promptwhether or not to execute this particular string-t-t --- (tell) be verbose,verbose echo echoeach command before performing performingit-i-i --- will use substitution substitutionsimilar to find's -exec -execoption, it will execute certain commands on something.Example:The {} would be substituted substitutedfor the current input (in this example the current file/directory) listed listedwithin the directory.directory The above command would move moveevery file listed in dir1 dir1to dir2.dir2 Obviously this command won't be too useful, it would be easier to go to dir1 dir1and type mv * ../dir2Here is a more moreuseful example: This would find all wave wavefiles within the current directory and convertconvert them to mp3 mp3files (encoded with lame) and append appenda “.mp3” to the end of the filename, unfortunately it doesn't remove the .wav and so its not too useful...but it works.Date/Time/CalendarsThere is one command to change changeboth the date dateand time on a UNIX UNIXlike system, date, there is also a simple calendar calendarutility, cal. If you are looking lookingto change changethe timestamps timestampson files please see date +Tells you the date (and the timetime) and is also used to set setthe date/time.To set the date, type date MM:DD:YYYY (American style date) where MM is month,month DD DDis the number of days dayswithin the month monthand YYYY YYYYis the year.yearFor example to set the date to the 1st January 2000 you would type:To set the time (where the -s-s option is to set a new newtime), type:Another useful option you can use is --date=“string” --date=(or -d-d “string”) option to display displaya date from x days daysago or in x days days(or x weeks, months,months years yearset cetera). See the examples below. Examples:Will print the date 3 months monthsand 1 day dayago from the current date. Note that --date=”x month x day ago” and -d -d“x month x day ago” are equivalent.equivalentThe above command will print the date 3 days days in the future from now.cal +calTyping cal will give you the calendar calendarof the present presentmonth on your screen,screen in the nice nicestandard calendar calendarformat. There are various options optionsto customise customisethe calendar,calendar refer referto the info/man page.pageExample:-yWill display a calendar calendarfor a specific specificyear, simply use cal -y -yto print the calendar calendarfor the current year.This will display the calendar calendarfor February 2004 +Finding information about partitionsThere are a number of ways to find out information informationon your hard disk diskdrives, for information on mounted mountedpartitions also try df dfin Using the proc filesystem +You can look lookthrough the information informationin the relevantrelevant area of the proc /procfilesystem,proc filesystemfilesystem under the directory directoryof either /proc/ide/ or /proc/ide?/hd? where the first question questionmark is a number numberand the second is a letter letter(starting with 'a'). For example:Under this directory there will be various information on the hard drivedrive or cdrom cdromconnected.Using fdisk +Using fdiskfdisk with the -l-l option will output information on any hard drives drivesconnected connectedto the system and information on their partitions partitions(for example, the type of partition).Information relating to using fdisk to partition partitionhard disks diskscan be found foundin your distributions distributionsdocumentation,documentation the fdisk manual manualpage or online.online +Root Access Required + This command needs root access to work + + + +Controlling the systemThe controlling controllingthe system chapter details detailscommands that you may wish to use to interact interactwith devices deviceson your system and then details how to controlcontrol processes processesand services/daemons.eject +ejecteject simply tells tellsa device deviceto open open(eject) the drive. Useful for cdrom/DVD drives.drivesFor example the command below would eject the cdrom-drive cdrom-drive(if your cdromcdrom is linked linkedto /dev/cdrom): +This won't work unless + +This will only work if the user has permission to mount the partition. Please see the tip in for more information. + + +Mounting and Unmounting (Floppy/CDROM/Hard-drive Partitions) +Allowing Users to mount partitions + +By default a UNIX system will allow normal users to unmount partitions. However unless given permission by the superuser, users will not be allowed to mount partitions. + + +The commands listed below will not work for normal users unless users have permission to mount that device. + + +If your particular distribution is setup not to allow users to mount partitions its not very hard to change this, simply edit the /etc/fstab file (as root) and: + + +Replace the word "defaults" with "user" or +Add "user" to the end of the options list for the particular partition(s). + + +mount +mountMount a device.device Attach Attachthe device deviceto the file-system file-systemhierarchy hierarchy(the tree tree( / )). This needs to be done so you can access accessthe drive drive(see below, for an example).umount +umount'Unmount' a device.device The command umount (no 'n') unmount's a device.device It removes removesit from the file-system hierarchy (the tree ( / )). This needs to be done before you remove removea floppy/CDROM or any other removableremovable device device(see below, for an example).smbmount //wincomp/c /mnt/win +smbmountWhere “win” would be the place placeyou want it mounted mountedand “wincomp” is the IP addressIP address or name of your windows windowscomputer. +Please note +Using ping/smbmount/ssh or other UNIX system programs with a computer name rather than IP address will only work if you have the computer listed in your /etc/hosts/etc/hosts file. Here is an example: + +192.168.1.100 new + This line says that their is a computer called “new”new with IP address 192.168.1.100192.168.1.100. Now that it exists in the /etc/hosts file I don't have to type the IP address anymore, just the name “new”. + + +smbmount is a tool from the samba sambapackage, it can mount mounta remote remotewindows windowsfile-system onto your current currentcomputer.Un-mounting uses the same syntax syntaxas 'umount', as listed above, or you may like to use:smbumountHere are some more examples of how to mount mounta file-system: +mount -t-t ext2 /dev/fd0 /mnt/floppy +mount -t iso9660 /dev/hdb /mnt/cdrom +mount -t iso /tmp/image_file /mnt/iso_file/ -o loop + + + + + The windows filesystem is known as vfatvfat (standard on Windows 9x) or NFTSNFTS (standard on Windows 2000 and XP). + + + + + for CDROM's + + + + + This will mount an image file (usually a CD image file) so you can view/change the files (it will appear to be like any other device). + + + + +The -t option + +On any system running a newer version of the Linux kernel the -t option is not always necessary and can be left out. + + +Examples of how to unmount unmounta file-system (necessary before you eject/remove disk):An example unmount point could be “/mnt/floppy” or “/mnt/cdrom” +Shutting Down/Rebooting the Systemshutdown now +shutdownShutdown the computer immediately (don't power downpower down). Note that in UNIX UNIXsystems this kind of shutdown shutdownmeans to go to “ single-user mode”.single-usermode Single-user mode is a mode where only the administrator administrator(root) has accessaccess to the computer, this mode modeis designed designedfor maintenance maintenanceand is often used for repairs.repairsFor example this would take you to single user mode shutdown -h now +shutdown -hShutdown (-h-h = halt) the computer immediately. It begins the shutdown procedure,procedure press + + CTRL + C + + + CTRL-C + + (break-key) to stop stopit. After the end of the command you can also leave a message messagein quotationquotation marks markswhich will be broad-casted broad-castedto all users, for example:This would halt haltthe system and send sendthe message messageto anyone who whois currently loggedlogged in. +Shutting down at a particular time +You can also put a time that the system should shutdown instead of “now”. Typing “+x minutesminutes” (any number numberof minutes minutesis appropriate) or you can even set an exact exacttime. For example to shutdown shutdownat at11:50 type: +shutdown -h 11:50 + + + +Shutdown -h vs poweroff +On some systems, shutdown -h and halt do not actually turn the system's power off. On systems that do not power off with these commands use the poweroffpoweroff command + +halt +haltThe same as shutdown -h now doesn't take any options,options this command simply shuts down immediately.shutdown -r now +shutdown -rShutdown ( -r -r= rebootreboot) the computer immediately. It begins the reboot procedure,procedure press press + + CTRL + C + + + CTRL-C + + (break-key) to stop stopit. After the end of the command you can also leave a message messagein quotationquotation marks markswhich will be broad-casted broad-castedto all users, for example: This would reboot the system and send sendthe message messageto anyone who whowas logged in. +Rebooting at a particular time +You can also put a time that the system should reboot instead of “now”. Typing “+x minutesminutes” (any number of minutes minutesis appropriate) or you can even set setan exact exacttime. For example to reboot shutdownat 11:50 type: +shutdown -r 11:50 + + +reboot +The same as shutdown -r now, doesn't take any options, simply reboots rebootsthe computer immediately. + + CTRL + ALT + DEL + + + CTRL-ALT-DEL + + (key-combination) May be used from a terminal terminalto reboot or shutdown,shutdown it depends on your system configuration. Note that this doesn't work from an xterminal.xterminal + + CTRL + ALT + DEL + + + CTRL-ALT-DEL + + begins the reboot/shutdown immediately, the user does not have to be logged in. +You can change the behaviour of +<keycombo> + <keycap>CTRL</keycap> + <keycap>ALT</keycap> + <keycap>DEL</keycap> +</keycombo> +<indexterm> + <primary>CTRL-ALT-DEL</primary> +</indexterm> + from rebooting + +To disable + + CTRL + ALT + DEL + + + CTRL-ALT-DEL + + from rebooting your computer (or to have it do something different), you can edit the /etc/inittab/etc/inittab file (as root). + + +Here is how it looks on a Mandrake/Mandriva Linux system: + +# Trap + + CTRL + ALT + DEL + + + CTRL-ALT-DEL + +ca::ctrlaltdel:/sbin/shutdown -t3 -r now + + + +Note that the # means a comment (and is not used). If you simply put a # (hash) before the command it would disable it (it would become a comment). + + +You could also change the command it runs for example if you changed the -r to a -h the computer would turn off instead of rebooting, or you could have it do anything you want. It's up to your creativity to make it do something interesting. + + + +Controlling Processesps +psWill give you a list listof the processes processesrunning on your system. With no options, ps will list processes processesthat belong to the current user and have a controllingcontrolling terminal.Example options include:-aux --- list all running runningprocesses processes(by all users with some information).-a-a --- list all processes from all users.-u-u --- list more information informationincluding user names, %cpu %cpuusage, and %mem %memusage et cetera.-x-x --- list processes processeswithout controlling controllingterminals.-l-l --- display different information including UID UIDand nice nicevalue.value--forest--forest --- this makes it easier to see the process processhierarchy, which whichwill give you an indication indicationof how the various processes processeson your system interrelateinterrelate (although you should also try pstree).For example to list all running runningprocesses processeswith additional additionalinformation, simply type:pstree +pstreeDisplays the processes processesin the form formof a tree treestructure (similar to how tree does it for directories). Use the -p -p option optionto show showprocess id's.id'sExample:This would list all processes processesand their id's.id'spgrep +pgrepThis command is useful for finding findingthe process id process idof a particularparticular process when you know part partof its name. Use the -l-l option to list the name of the process as well and the -u-u option to search searchvia a particular user(s).Normally pgrep will only return returnthe pid pidnumber; this way you can use it with other commands.Examples:This would kill killany process name that starts startswith mozilla.mozilla Note that this is the same as using pkill (see below).If you are unfamiliar unfamiliarwith the $( ) part partof this command, please refer referto .To list processes id's and names type:top +topDisplays the 'top' (as in CPU CPUusage) processes,processes provides providesmore detaildetail than ps. top also provides providesan updated updateddisplay, it has many options optionthat make it fully customisable,customisable refer referto the manual or info infopage pagefor details. kill +To kill processes processeson your system, you will need their pid's pid'sor id'sid's . Use ps or pstree to find findout the process id's id's(pid's), or use jobs to find out id's.id's +killall and pkill - kill a process by name +pkill and killall can be a lot easier to use than kill. pkill allows you to type part of the name of a process to kill it, while killall requires the full process name. See below for more information. + +Examples:Simply kill a process (allow it time timeto save saveit's files and exit)Same as above, except it uses an id idinstead of a pid,pid you need to use a % (percent) when using an id idto kill.-killForce Forcea process to be killed killed(won't allow allowfiles to be saved savedor updated); only use when necessary because all data datathat the program programhad will be lost.lostThere are also many other kill options such as kill -HUP-HUP (hangup)... refer referto the manual/info pages pagesfor more moreinformation.killall +killallKill a process by it's name, uses names instead of process processid'sid's (pid's). Use -v -vto have killall report reportwhether the kill killwas successful successfulor not and -i -ifor interactive interactivemode (will prompt promptyou before attempting attemptingto kill). +pkill - a little like a killall with regular expressions +pkill is another command that allows processes to be killed but does so using regular expressions. See below for more information. + +For example:Would kill anything named named“mozilla” and prompt promptyou before each kill and report reportwhether the kill was successfulsuccessful or not. Unfortunately Unfortunatelyyou need to get the name exactly exactlyright for killall to work, you would need to use “mozilla-bin” to kill the mozilla mozillabrowser. If you want something where you don't need to know the exact exactname try pkill (below).pkill +pkillpkill is used to kill processes processesaccording to an extended extendedregular expression.regular expression Use the -u-u option to kill using a user name(s) and process name (for example to only kill a process of a certain user). pkill can also send sendspecific signals signalsto processes.processesFor normal normalusage simply type:Note that the “process_name” doesn't have to be an exact match...Or to kill the “process_name” of only the users “fred” and “anon” type:skill +skillskill is used to send senda command/username/tty a particular particularsignal.signalskill has a number numberof options optionsavailable availableto ensure correct correctinterpretation (otherwise it just guesses what it is), simply type skill skill-option(s)-L-L --- list listthe various signals signalsthat can be sent-u-u --- specify specifya username; this is obviously followed followedby the user name or a space-seperated space-seperatedlist of usernames.usernames-p-p --- process id id(followed by the process id)-c-c --- command name (this is the same as killall)-t-t --- (tty number)-v-v --- verbose verbosemode mode-i-i --- interactive interactivemode.skill can be used to stop,stop continue, or kill processes processesusing the username,username command name or process id (or send sendthem any variety varietyof signals signalsyou like). Useful example:-STOPThe above command will stop stopall of that users processes,processes this will causecause his screen screento freeze freezeuntil you type:-CONTThis would tell tellthat all processes processesmay continue as before. Note that this would only work if you are root.root Also note you can list more than one user name with the command so it will apply applyto multiple multipleusers. + + CTRL + C + + + CTRL-C + +The break key,break key will kill (break, stop) something that's runningrunning on your terminal.terminaljobs +jobsPrints Printscurrently running runningjobs, as in processes processesyou have executed within the shell.shellbg +bgBackgrounds Backgroundsa process. To start starta program in the background background(so it doesn't take over the terminal) use an “&” (ampersand) sign signat the end of the command. You usually use + + CTRL + Z + + + CTRL-Z + + to suspend suspendsomething you are currently using. You can simply use bg to resume in the background the last job suspended...Command syntax:orfg +fgBring a process to the foreground,foreground so you can interact interactwith it. The process will use your current terminal.terminal Note simply use fg to foreground the last job number suspended... You can bring jobs jobsto the foreground foregroundby name or by number (use jobs to find the number).Command syntax:or nice +niceSets Setsthe priority priorityfor a process. nice -20 is the maximum maximumpriority priority(only administrative administrativeusers can assign assignnegative priorities), nice 20 is the minimum minimumpriority. You must mustbe root to give a process a higher higherpriority, but you can always lower the priority of your own processes... Example:Would execute executemake and it would run runat maximum priority.priorityrenice +reniceChanges the priority of an existing existingcommand. You may use the options -u-u to change changethe priorities prioritiesof all processes processesfor a particular user name and -g-g to change changepriorities for all processes processesof a particular group.group The default defaultis to change changevia the process id number.Example:This would change changethe priority priorityof process 2222 to +20 (minimum priority).snice +snicesnice works very similarly to skill, only it changes the priority priorityof the process(es). Its function functionis similar to that of renice.To use options (to ensure correct correctinterpretation) you simply type snice -option(s):-u --- specify specifya username; this is obviously followed followedby the user name or a space-seperated space-seperatedlist of usernames.usernames-p --- process id id(followed by the process id)-c --- command name (this is the same as killall)-t --- tty number-v --- verbose verbosemode mode-i-i --- interactive interactivemode.Example:This would increase increasethe priority priorityof all root's processes.processes +Controlling servicesConcept Definitions + UNIX UNIXsystems use scripts scriptsto control control“daemons” which provide provide“services” (for example your sound soundoutput) to run a UNIX system. UNIX systems consist of a variety varietyof services services(daemons).A “daemon” is a system process which runs in the background background(zero interaction) performingperforming a particular task.taskDaemons Daemonsnormally have a “d” on the end of their name and either listen listenfor certain events eventsor performperform a system task,task for example sshd listens listensfor secure shell requests to the particular particularmachine machineand handleshandles them when they occur.Daemons usually perform critical criticalsystem tasks taskssuch as control controlswap-space, memory memorymanagement managementand various other tasks.tasksservice +serviceservice is a shell script available availableon Mandrake/MandrivaMandrivaMandrake and Redhat Redhatsystems which allows allowsyou to perform various tasks taskson services.services Use the -s-s option to print printthe status statusof all services servicesavailable availableUse the -f-f option followed followedby a service servicename to restart restartthat particular service. Use the -R-R option to restart restartall services services(note that this will kill killany current services running,running including the X windows system).For example to restart restartthe daemon daemon sshd sshdyou would type:Using the script directly +You may also execute the shell script directly from /etc/init.d/etc/init.d. Simply go to that directory directorythen type ./script_name.Executing the script scriptshould return returnthe options it can take, by default defaultthey will be:restart restart--- this will make the service servicestop stopand then start again.start --- this option optionwill start a service (assuming its not running).stop --- this option will stop a service (assuming its running).status status--- this option will tell tellyou about the serviceservice + +Managing userssu username +su(Switch User), change changeto a different differentuser. Use su - to switch switchto root or su username, to switch switchto a different differentusername. +Using sudo<indexterm><primary>sudo</primary></indexterm> + Its often considered better practice to use the sudo command rather than switch to the root user + The sudo command allows you to perform actions as root but logs the actions you take (so you can trace anything that was done to the system by yourself or others). sudo has a very good manual page which provides plenty of information about it. + You use sudo similar to how you execute a normal command with sudo prepended to it, for example: + sudo rpm -U myrpm.i386.rpm + This would allow you to install a rpm even if you have the correct sudo access + +Note that if you want to return returnto your original originaluser you don't use su again, type exit or press press + + CTRL + D + + + CTRL-D + +.Simply typing su will give you some root rootprivileges,privileges but there are minor minorcomplications relating to environment environmentvariables. It's generally considered better practice practiceto use su - because it has no restrictions.restrictionsroot +The superuser.superuser This user has power powerover everything everythingand all, and can do anything with the system (including destroy destroyit, and of course fix fixit :)). This user is used to perform most administration administrationfunctions functionson the system.Users/GroupsAll user information informationis normally listed in the “/etc/passwd”/etc/passwd file and the group groupinformation in the “/etc/groups”/etc/groups file.If you need to edit editeither file it is recommended recommendedthat you use vipw to edit the password file and vigr to edit the group groupfile. These particular particularcommands take care of any processing processingand locking lockingof the files before and after editing editingthem.There is a lot of information about adding/removing/controlling users and groups,groups this information is only the minimal minimalinformation required.chsh +chshUsed to change changeyour login loginshell. To list listthe shells shellsavailable availabletype:Simply type chsh chshthen [Enter], then type the name of the shell you would like to use every time timeyou login.loginchfn +chfnChange Changefinger fingerinformation. The information informationthis command changes is reflected reflectedin the /etc/passwd file, use this utility utilityto update updateyour real name, office officeand home homephone numbersnumbers (if they exist). Use the -f option to change a users full name. Use this tool as either chfn or chfn user_name (usable by root only).Command syntax:passwd +passwdChanges the password of a user. You will need to be root if you want to change changeother users passwords.passwordsSimply type passwd passwdto change changeyour own password or to change changeanother users password passwordtype: + +Text Related ToolsThe text textrelated tools chapter is the largest in this guide,guide most of the time on a GNU/Linux machine machineyou will spend spendtime interacting with text. This chapter briefly covers text editors editorsand goes into more moredepth depthon viewingviewing text, using tools to manipulate manipulatetext, finding text within files and changing text formats formatsbetween windows windowsbased systems and GNU/Linux based systems.Text Editorsvi +viA traditional traditionalUNIX UNIXsystem text editor,editor should be on any UNIX system. It requires learning learninga few key keycombinations, but is very powerful,powerful and it is also quite quitesmall. vi viis well known for its minimal minimaluse of resources.resources +vim + vim - vi improved. A newer version of the vulnerable vi editor. Many systems use vim rather than vi. + + +emacs +emacsMore than just a text editor.editor This text editor editorhas a steep steeplearning learningcurve but is also very powerful,powerful it is both advanced advancedand quite quitelarge. emacs Emacscan do anything, surf surfthe internet,internet chat,chat play playgames and many other tasks.tasksOthers +There are too many different text editors editorsto list here. Have a look on the internet,internet either search searchfor them using any search engine or you will find many of them at SourceforgeSourceforge or Freshmeat.Freshmeat +Text Viewing Tools head +headWith no options it shows showsthe first ten lines of a text file. Use head -n -nx (where “x” is a number) to display displaythe first x lines. Try head -F -Fto use a continually updated updatedversion versionof head (if the file changes it will be reloaded reloadedand displayed), please note that using this option optionwill run runhead is a continuous continuousloop so you'll need to use + + CTRL + C + + + CTRL-C + + to exit.exitFor example:Will display the top 20 entries entriesof the file “somelog.txt”.tail +tailWith no options it shows showsthe last lastten lines of a file. Use tail -n -nx (where “x” is a number) to display the last x lines. Try tail -F -Fto use a continually updated updatedversion versionof tail (if the file changes it will be reloaded reloadedand displayed), please note that using this option will run tail is a continuous continuousloop so you'll need to use + + CTRL + C + + + CTRL-C + + to exit.exitFor example:Will display displaythe last 20 entries entriesof the file “somelog.txt”.less +lessViews text, can scroll scrollbackwards and forwards.forwards Has many different options which are all described describedin the manual manualpage.page When less is already running,running use :n:n and :p:p (type a colon colonthen the character) to move moveto the next nextand previous previousfiles (when there are multiple multipleopen openfiles).Command syntax:Or using a tool (in this example cat):more +Displays text, one page full at a time,time more limited than less. In this case less is better than more.Or using a tool (is this example cat):cat +Combines Combines(concatenates) multiple multipledocuments documentsinto one document.document Can be used on individual individualfiles as well.Some useful options:options-b-b --- number numberall non-blank non-blanklines-n-n --- number all lines. Also try using nl to number lines (it can do more complex complexnumbering), you will find it under under this section,section Example: wholefile.txt +]]>This will combine combine(concatenate) filepart1,filepart1 filepart2 filepart2and filepart3 filepart3into the single file “wholefile.txt”.tac +tacCombines (concatenates) multiple multipledocuments documentsinto one document documentand outputsoutputs them in reverse order.reverse Can also be used on individual individualfiles. Notice that tac is cat written backwards. Example: wholefile.txt +]]>This will combine combine(concatenate) filepart1,filepart1 filepart2 filepart2and filepart3 filepart3into the single file but have each of the files written in reverse.reversez* commands +z* commandsMany commands can be prefixed prefixedwith a “z” to read/work within a gzip gzipcompressedcompressed file. Some examples examplesare zcat, zless,zless zmore,zmore zgrep,zgrep zcmp,zcmp zdiffzdiff. There are many utilities utilitiesfor working with text within compressed files without trying to manually de-compress them somewhere first...most begin with a “z”. You will find some of them mentioned over here, .bz* commands +bz* commandsThere are also a few commands that prefixed prefixedwith a “bz” to read/work within a file compressed compressedwith bzip2.bzip2 The tools are bzcat, bzless,bzless bzgrepbzgrep. You will find some of them mentioned over here, . +Text Information Toolswc +wcWord count, count how many words you have in a text textdocument. Can also be used to count countthe lines or bytes byteswithin the file. Use the options -w -wfor words, -l-l for lines linesand -c-c for bytes.bytes Or simply run wc with no options to get all three.Command syntax:style +styleTo run various readability readabilitytests on a particular particulartext file. Will output outputscores scoreson a number of different differentreadability readabilitytests (with no options).Command syntax: +Find style in the diction package +This command is part of the diction package and does not appear to be used too often these days + +cmp +cmpDetermines whether or not two files differ, works on any type of file. Very similar to diff only it compares compareson the binary binarylevel instead of just the text.diff +diffCompares two text files and output a difference differencereport (sometimes called a "diff"diff) containing the text that differs between two files. Can be used to create a 'patch' file (which can be used by patch). Example:diff will output outputa '>' (followed by the line) for each line linethat isn't in the first file but is in the second file, and it will output a '<' (followed by the line) for each line that is in the first file but not in the second file.sdiff +sdiffInstead of giving a difference differencereport, it outputs outputsthe files in two columns,columns side by side, separated separatedby spaces.spacesdiff3 +diff3Same as diff except for three files. + comm +commCompares two files, line-by-line line-by-lineand prints printslines that are unique uniqueto file1 file1(1st column), unique to file2file2 (2nd column) and common commonto both files (3rd column). Use comm with the -1, -2, or -3 to suppress suppressthe printing printingof those particular lines. Simply run runcomm to have all three listed listed(ie. unique uniqueto files 1 and 2 and common commonto both).Command syntax:look +lookTo output a list of words in the system dictionary that begin with a given string string-- this is useful for finding findingwords that begin with a particular phrase phraseor prefix.prefix Give the string as an argument;argument it is not case sensitive.sensitive Command syntax: +Text manipulation tools +Also see +Also see tac, and cat over in this section, , as they can perform text manipulation too + +sort +sortSorting Sortingtext with no options optionsthe sort is alphabetical.alphabetical Can be run on text files to sort sortthem alphabetically alphabetically(note it also concatenatesconcatenates files), can also be used with a pipe pipe'|' to sort sortthe output of a command. Use sort -r-r to reverse reversethe sort sortoutput, use the -g -g option optionto sort sort'numerically' (ie read the entire number,number not just the first digit).Examples:The above command would run cat on the shopping shoppinglist listthen sort the results resultsand display them in alphabetical order.orderThe above command would run sort on a file and sort the file in reverse reversealphabetical alphabeticalorder. Advanced sort commands: sort is a powerful powerfulutility,utility here are some of the more morehard to learn learn(and lesserlesser used) commands. Use the -t-t option to use a particular symbol symbolas the separator separatorthen use the -k option to specify specifywhich column columnyou would like to sort by, where column 1 is the first column columnbefore the separator.separator Also use the -g-g option if numeric numericsorting is not working correctly (without the -g -goption sort just looks looksat the first digit digitof the number). Here is a complex complexexample:-kThis will sort the “/etc/passwd”/etc/passwd file, using the colon colon':' as the separator.separator It will sort via the 4th column column(GID section, in the file) and then sort within that sort using the first (name) to resolve any ties.ties The -g is there so it sorts via full fullnumbers, otherwise it will have 4000 before 50 (it will just look at the first digit...).join +joinWill put two lines together assuming they share at least leastone commoncommon value valueon the relevant relevantline. It won't print printlines if they don't have a common value. Command syntax:cut +cutPrints Printsselected selectedparts of lines (of a text file), or, in other words, removes removescertain sections sectionsof a line. You may wish to remove removethings according to tabs tabsor commas,commas or anything else you can think of... Options for cut:-d -d--- allows allowsyou to specify another delimiter,delimiter for example ':' is often used with /etc/passwd:-f -f--- this option works with the text by columns,columns separated separatedaccording to the delimiter.delimiter For example if your file had lines lineslike “result,somethingelse,somethingelse” and you only wanted result resultyou would use:This would get you only the usernames usernamesin /etc/passwd“,” (commas) --- used to separate separatenumbers, these allow allowyou to cut cutparticularparticular columns.columns For example:This would only show showthe username usernameand the shell shellthat each person personis setupsetup for in /etc/passwd.“-” (hyphen) --- used to show showfrom line x to line y, for example 1-4, (would be from lines 1 to line line4).This would cut (display) characters characters(columns) 1 to 50 of each line (and anything else on that line lineis ignored)-x -x--- where x is a number, to cut cutfrom line 1 to “x”x- --- where x is a number, to cut cutfrom “x” to the end.endThis would display (“cut”) characters characters(columns) 1 to 5, 8 and from 20 to the end.ispell/aspell +aspellispellTo spell spellcheck a file interactively, prompts promptsfor you to replacereplace word or continue. aspell is said to be better at suggesting suggestingreplacement words, but its probablyprobably best to find findout for yourself.aspell example:This will run aspell on a particular file called “FILE.txt”, aspell will run interactively and prompt promptfor user input.ispell example:This will run ispell on a particular file called “FILE.txt” ispell will run interactively and prompt promptfor user input.chcase +chcaseIs used to change the uppercase uppercaseletters in a file name to lowercaselowercase (or vice versa).You could also use trtr to do the same thing... newFileName.txt +]]>The above would convert convertuppercase to lowercase using the the file “fileName.txt” as input inputand outputting the results resultsto “newFileName.txt”. newFileName.txt +]]>The above would convert lowercase to uppercase using the the file “fileName.txt” as input inputand outputting the results resultsto “newFileName.txt”.chcase (a perl perlscript) can be found foundat the chcase homepage.chcase homepagefmt +fmt(format) a simple text formatter. Use fmt fmtwith the -u-u option to output text with "uniform spacing", where the space spacebetween words is reduced to one space character characterand the space between sentences sentencesis reduced to two space characters. Example:Will make sure the amount amountof space between sentences sentencesis two spaces and the amount amountof space between words is one space.paste +pastePuts lines from two files together, either lines of each file side by side (normally separated separatedby a tab-stop tab-stopbut you can have any symbols(s) you like...) or it can have words from each file (the first file then the second file) side by side.To obtain a list listof lines side by side, the first lines from the first file on the left side separated separatedby a tab-stop tab-stopthen the first lines from the second file. You would type:To have the list displayed in serial,serial first line from first file, [Tab], second line from first file, then third and fourth until the end of the first file type: +This command is very simple to understand if you make yourself an example +Its much easier if you create an example for yourself. With just a couple of lines, I used "first line first file" and "first line second file" et cetera for a quick example. + +expand +expandWill convert tabs to spaces spacesand output it. Use the option -t -tnum to specify specifythe size sizeof a “tapstop”, the number of characters charactersbetween each tab.tabCommand syntax:unexpand +unexpandWill convert spaces to tabs tabsand output it.Command syntax:uniq +uniqEliminates duplicate duplicateentries from a file and it sometimes greatly greatlysimplifies the display. uniq options: -c -c --- count countthe number of occurances occurancesof each duplicate -u -u--- list only unique uniqueentries -d -d--- list only duplicate entriesFor example:This would display displayany duplicate entries only and a count countof the number of times timesthat entry entryhas appeared.tr +tr(translation). A filter filteruseful to replace all instances instancesof characters charactersin a text file or "squeeze"squeeze the whitespacewhitespace.Example: new_file +]]>This will run the cat program programon some file, the output of this command will be sent to the tr command, tr will replace all the instances instancesof 3 with 5, like a search searchand replace. You can also do other things such as: new_file +]]>This will run cat on some_file some_fileand convert any capital capitalletters to lowercase letters (you could use this to change the case of file names too...). +Alternatives + +You can also do a search and replace with a one line Perl command, read about it at the end of this section. + + +nl +nlThe number lines number linestool, it's default defaultaction is to write writeit's input (either the file names given as an argument,argument or the standard standardinput) to the standard output. Line Linenumbers are added to every line and the text is indented.indented This command can do take some more moreadvanced advancednumbering numberingoptions, simply read the info infopage pageon it. These advanced advancedoptions mainly relate to customisation customisationof the numbering,numbering including includingdifferent forms formsof separation separationfor sections/pages/footers etc.Also try cat -ncat-n (number all lines) or cat -b-b (number all non-blank non-blanklines). For more moreinfo infoon cat check checkunder this section:section There are two ways you can use nl:The above command would add addnumbers to each line of some_text_file.some_text_file You could use nl to number the output of something as shown shownin the example below;Perl search and replace text +search and replace textTo search and replace text in a file is to use the following followingone-line one-linePerlperl commandThis information has been taken from the Linux Cookbook (without editing). See [3] in the for further information.:In this example, “oldstring”oldstring is the string stringto search, “newstringnewstring is the string to replace it with, and “filespecfilespec is the name of the file or files to work on. You can use this for more than one file. Example: To replace replacethe string “helpless” with the string “helpful” in all files in the current currentdirectory,directory type: Also try using trtr to do the same thing (see further above in this section). +If these tools are too primitive +If these text tools are too simple for your purposes then you are probably looking at doing some programming or scripting. +If you would like more information on bash scripting then please see the advanced bash scripting guideadvanced bash scripting guide, authored by Mendel CooperMendel Cooper. +sed and awk are traditional UNIX system tools for working with text, this guide does not provide an explanation of them. sed works on a line-by-line basis performing substitution and awk can perform a similar task or assist by working on a file and printing out certain information (its a programming language). +You will normally find them installed on your GNU/Linux system and will find many tutorials all over the internet, feel free to look them up if you ever have to perform many similar operations on a text file. + + +Text Conversion/Filter ToolsFilters (UNIX System/dos formats) +The following followingfilters filtersallow you to change changetext from Dos-style Dos-styleto UNIX UNIXsystem style styleand vice-versa,vice-versa or convert a file to other formats.formats Also note that many modern text editors can do this for you...Why use filters? +Because UNIX UNIXsystems and Microsoft Microsoftuse two different standardsstandards to represent representthe end-of-line end-of-linein an ASCII ASCIItext file. This can sometimes causes causesproblems problemsin editors editorsor viewers viewerswhich aren't familiarfamiliar with the other operating operatingsystems end-of-line style. The following followingtools allow you to get around this difference.differenceWhats the difference? +The difference differenceis very simple, on a Windows Windowstext file, a newline newlineis signalled signalledby a carriage carriagereturn returnfollowed by a newline, '\r\n' in ASCII.ASCIIOn a UNIX system a newline newlineis simply a newline, '\n' in ASCII.ASCIIdos2unix +dos2unixThis converts convertsMicrosoft-style end-of-line end-of-linecharacters to UNIX system style end-of-line characters. Simply type:fromdos +fromdosThis does the same as dos2unix dos2unix(above). Simply type:fromdos can be obtained from the from/to dos website.from/to dos websiteunix2dos +unix2dosThis converts UNIX system style end-of-line characters to Microsoft-style end-of-line end-of-linecharacters. Simply type:todos +todosThis does the same as unix2dos (above). Simply type:todos can be obtained from the from/to dos website.from/to dos websiteantiword +antiwordThis filter filterconverts convertsMicrosoft word documents into plain plainASCII text textdocuments.documents Simply type:You can get antiword from the antiword homepage.antiword homepagerecode +recodeConverts text files between various formats formatsincluding HTML HTMLand dozens of different differentforms of text encodings.encodings Use recode -l-l for a full fulllisting.listing It can also be used to convert text to and from Windows Windowsand UNIX UNIXsystem formats formats(so you don't get the weird symbols). + Warning + +By default recode overwrites the input file, use '<' to use recode as a filter only (and to not overwrite the file). + + +Examples: + UNIX system text to Windows text:Windows text to UNIX system text:UNIX system text to Windows text without overwriting overwritingthe original originalfile (and creating a new newoutput file): recoded_file +]]>tr +tr(Windows to UNIX UNIXsystem style conversion conversiononly). While tr is not specifically specificallydesigned to convert files from Windows-format Windows-formatto UNIXUNIX system format formatby doing: outputFile.txt +]]>The -d -dswitch means to simply delete deleteany occurances occurancesof the string. Since we are looking lookingfor '\r'\r, carriage returns carriage returnsit will remove removeany it finds,finds making the file a UNIXUNIX system text file. You can read more about tr over here, .Conversion toolsenscript +enscriptConverts text files to postscript,postscript rtf,rtf HTML HTML(use ghostview to view viewthe postscript postscriptfile). enscript has a large number of options optionswhich can be used to customise customisethe output.Examples:These examples are based off information from the enscript manual page, see [12] in the for further information. This will take some file and output it as a html htmlfile.Display help on using the highlight highlightfeature (list all different types typesof highlighting highlightingavailable)Highlight lang(pretty print), example:Add Addall the files with a .h .hand a .c (C source sourceand header headerfiles) into a file called foo.html, use colour colourand add adda table tableof contentscontentsFor further options refer to the well written manual page pageof enscript.enscriptfiglet +figletUsed to create ASCII ASCII“art”. Figlet can create several severaldifferent forms (fonts) of ASCII ASCIIart,art its one of the more moreunusual unusualprograms programsaround. + +Finding Text Within Filesgrep +grepLooks for text within files. For example:Example options:-v-v --- this option is used to display lines lineswhich do not contain the string.-n-n --- this option displays the line linenumbers-w-w --- this option makes grep grepmatch the whole word -A x or -B x-A-B (where x is a number) --- display display“x” lines After or Before the section sectionwhere the particular particularword is found.found -r-r or rgrep --- search for text textwithin files recursively. This command uses regular expressionsregular expressions, for more information informationplease see, .For example, this command would look lookin the file “rpmlist.txt” for anything starting startingwith “rpm”:Or you could use it like this, to search through the output outputof another file:-q-aThe first command lists listsall RPM's installed installedon your system, the second findsfinds any containing the string “ogg” and outputs outputsthem.rgrep +rgrepA "recursive"recursive version versionof grep (this is a different differentprogram to grep). This will search all the files in the current directory directoryand all it's subdirectories and print printthe names of the files and the matching matchingline. Follows Followssimilar syntax syntaxto grep (see above). You could also use grep with the -r option optionto achieve the same affect.affectfgrep +fgrepThis version versionof grep calls callsgrep with the -F option. This will look for literal literalstrings only, it won't use or expand expandany kind of regular regularexpression.For example you could type:And fgrep would look for the string “a$*b?” in the file “file.txt”. +Other Versions + +There are various versions of grep which are designed to do different things try searching for them on the internet or within your distribution. + + + + +Mathematical tools +num-utils homepage + +The “num-utils” homepage, Num Utils, contains a variety of command line programs that could be useful when performing maths on your GNU/Linux machine. + + +units +unitsConvert Convertunits of measurement measurementbetween different scales.scales For example, centimeters centimetersto inches,inches litres litresto gallons.gallonsSimply run runthe program,program I recommend recommendrunning runningit as follows:follows--verboseThis will run the program and it will tell tellyou exactly exactlywhat it is doing.Example: you enter enter“60 metersmeters” then you want it worked out in “kilometers”. The first line will tell tellyou what this evaluates evaluatesto.If you wanted the conversion conversionrate for “meters” to “kilometers” read the second line of the output output(which will tell tellyou meters/1000). +To exit +Press press + + CTRL + D + + + CTRL-D + + (end-of-file key) when you are finished finishedusing units. + +python +pythonPython Pythonis a very powerful,powerful easy to learn,learn general generalpurpose, interpretedinterpreted programming programminglanguage. And it makes a great greatcalculator! If you don't have a calculator calculatorinstalledinstalled then simply type python, then hit hit[Enter]. This will execute executethe Python Pythoninterpreter in interactive interactivemode. Type your sums sumsjust like you would use a calculator.calculator Note that if you want to work out fractions fractionsmake sure you use a decimaldecimal point and a zero zeroto obtain the correct correctanswer (otherwise it will use integerinteger division).To start startpython in interactive interactivemode, simply type:Once python pythonis started startedyou can use it to add addup sums sumsor maybe do some python programming.programmingUse + + CTRL + D + + + CTRL-D + + (end-of-file key) to exit exitthe Python Pythoninterpreter.numgrep +numgrepA little bit bitlike grep greponly this is designed designedfor numbers numbersonly. Use '/' (forward slashes) to contain each expression.expression Use m<n> to find findmultiples of the number numbern and use f<n> to find factorsfactors of the number n. Use commas commasto seperate expressions expressionsand .. (two dots) to represent representa range.range For example, to input inputfrom standard standardinput inputstandard inputyou could simply type:To input from a file and look lookfor numbers numbersbetween 1 and 1000 you could type: +This tool comes from the num-utils package + +Please note that this tool is part of the num-utils package. + + + +Network CommandsThe network networkcommands chapter explains explainsvarious tools which can be useful when networking networkingwith other computers computersboth within the network networkand accross the internet,internet obtaining more moreinformation informationabout other computers. This chapter also includes includesinformation on tools for network networkconfiguration, file transfer transferand working with remote machines.remote machinesnetstat +netstatDisplays contents contentsof /proc/net files./proc/net It works with the Linux Network Subsystem,Subsystem it will tell tellyou what the statusstatus of ports portsare ie. open,open closed,closed waiting,waiting masquerade masqueradeconnections. It will also display various other things. It has many different options.optionstcpdump +tcpdumpThis is a sniffer,sniffer a program that captures capturespackets off offa networknetwork interface interfaceand interprets interpretsthem for you. It understands all basic basicinternet Internetprotocols,protocols and can be used to save saveentire packets packetsfor later inspection.inspectionping +The ping pingcommand (named after the sound soundof an active sonar system) sends sendsecho requests requeststo the host hostyou specify specifyon the command line, and listslists the responses responsesreceived their round roundtrip time.You simply use ping as:Note to stop stopping (otherwise it goes forever) use + + CTRL + C + + + CTRL-C + + (break). +Please note +Using ping/smbmount/ssh or other UNIX system programs with a computer name rather than IP address will only work if you have the computer listed listedin your /etc/hosts/etc/hosts file. Here is an example: + +192.168.1.100 new + This line says that their is a computer called “new”new with IP address 192.168.1.100192.168.1.100. Now that it exists in the /etc/hosts file I don't have to type the IP address anymore, just the name “new”. + + +hostname +hostnameTells the user the host hostname of the computer they are logged loggedinto. Note: may be called host.hosttraceroute +traceroutetraceroute will show showthe route routeof a packet.packet It attempts attemptsto list listthe series seriesof hosts hoststhrough which whichyour packets packetstraveltravel on their way to a given destination.destination Also have a look at xtraceroute (one of several severalgraphical graphicalequivalents of this program). Command syntax:tracepath +tracepathtracepath performs performsa very simlar function functionto traceroute the main difference differenceis that tracepath doesn't take complicated complicatedoptions.Command syntax:findsmb +findsmbfindsmb is used to list info infoabout machines machinesthat respond respondto SMB SMBname queries queries(for example windows windowsbased machines machinessharing sharingtheir hard disk's). Command syntax:This would find all machines machinespossible,possible you may need to specify a particularparticular subnet to query those machines only...nmap +nmap“ network networkexploration tool and security securityscannerscanner”. nmap is a very advanced advancednetwork tool used to query querymachines (local or remote) as to whether they are up and what ports portsare open openon these machines.machines A simple usage example:This would query your own machine machineas to what ports portsit keeps open.open nmap is a very powerful powerfultool, documentation documentationis available availableon the nmap sitenmap site as well as the information in the manual manualpage.pageNetwork Configuration ifconfig +ifconfigThis command is used to configure configurenetwork networkinterfacesinterfaces, or to display their current configuration.configuration In addition additionto activating and deactivating deactivatinginterfaces interfaceswith the “up” and “down” settings,settings this command is necessary for setting settingan interface's addressaddress information informationif you don't have the ifcfg script.scriptUse ifconfig as either:This will simply list all information on all network networkdevices currently up.This will take eth0 (assuming the device deviceexists) down, it won't be ableable to receive receiveor send sendanything until you put the device back “up” again.Clearly there are a lot more options for this tool, you will need to read the manual/info page to learn learnmore moreabout them. ifup +ifupUse ifup device-name to bring an interface interfaceup by following a script (which will contain your default networking networkingsettings). Simply type ifup ifupand you will get help on using the script.For example typing:Will bring eth0 eth0up if it is currently down.ifdown +ifdownUse ifdown device-name to bring an interface interfacedown using a script (which will contain your default network settings). Simply type ifdown ifdownand you will get help helpon using the script.For example typing:Will bring eth0 eth0down if it is currently up.ifcfg +ifcfgUse ifcfg to configure configurea particular interface.interface Simply type ifcfg ifcfgto get help helpon using this script.For example, to change changeeth0 eth0from 192.168.0.1 192.168.0.1to 192.168.0.2 192.168.0.2you could do:The first command takes eth0 eth0down and removes removesthat stored storedIP addressIP address and the second one brings it back up with the new newaddress.route +routeThe route command is the tool used to display displayor modify modifythe routing routingtable.table To add adda gateway gatewayas the default defaultyou would type: +Internet Specific CommandsNote that should DNS DNSnot be configured correctly correctlyon your machine,machine you need to edit edit“/etc/resolv.conf”/etc/resolv.conf to make things work...host +hostPerforms a simple lookup lookupof an internet internetaddress (using the Domain Name System, DNS). Simply type:ordig +digThe "domain information groper"domain information groper tool. More advanced advancedthen host... If you give a hostname hostnameas an argument argumentto output outputinformation about that host,host including includingit's IP address, hostname and various other information. For example, to look up information about “www.amazon.com” type:To find the host name for a given IP address (ie a reverse reverselookup), use dig with the `-x'-x option.optionThis will look up the address address(which may or may not exist) and returns returnsthe address of the host,host for example if that was the address of “http://slashdot.org”http://slashdot.org then it would return return“http://slashdot.org”.dig takes a huge hugenumber numberof options options(at the point of being too many), referrefer to the manual page for more information.informationwhois +whois(now BW whois) is used to look up the contact contactinformation from the “whois” databases,databases the servers serversare only likely to hold major majorsites. Note that contact information is likely to be hidden hiddenor restricted restrictedas it is often abused by crackers crackersand others looking lookingfor a way to cause causemalicious damage damageto organisation's.wget +wget(GNU Web get) used to download downloadfiles from the World Wide Web.To archive archivea single web-site, use the -m-m or --mirror--mirror (mirror) option.Use the -nc -n(no clobber) option to stop stopwget from overwriting overwritinga file if you already have it.Use the -c-c or --continue option to continue a file that was unfinished unfinishedby wget or another program.programSimple usage usageexample:This would simply get a file from a site.site wget can also retrieve retrievemultiple files using standard wildcards,standard wildcards the same as the type used in bash,bash like *, [ ], ?. Simply use wget as per normal normalbut use single quotation quotationmarks (' ') on the URL URLto preventprevent bash bashfrom expanding expandingthe wildcards.wildcards There are complications if you are retrieving from a http site (see below...).Advanced usage usageexample, (used from wget manual page):This will parse parsethe file bookmarks.html bookmarks.htmland check checkthat all the links linksexist.existAdvanced usage:usage this is how you can download downloadmultiple files using http http(using a wildcard...).Notes: http httpdoesn't support supportdownloading downloadingusing standard wildcards,standard wildcards ftp ftpdoes so you may use wildcards with ftp and it will work fine. A work-around work-aroundfor this http limitation is shown shownbelow:This way around the wildcard limitation has been adopted (with a tiny amount of editing) from wget manual page, see [9] in the for further information.This will download (recursively), to a depth depthof one, in other words in the current currentdirectory directoryand not below that. This command will ignore references referencesto the parent parentdirectory,directory and downloadsdownloads anything that ends in “.gif”. If you wanted to download say, anything that ends endswith “.pdf” as well than add adda -A.pdf -Abefore the website websiteaddress. Simply change changethe website websiteaddress and the type of file being downloadeddownloaded to download something else. Note that doing -A.gif is the same as doing -A “*.gif” (double quotes quotesonly, single quotes quoteswill not work).wget has many more options refer to the examples section of the manual page,page this tool is very well documented. +Alternative website downloaders +You may like to try alternatives like httrackhttrack. A full GUI website downloader written in python and available for GNU/Linux + +curl +curlcurl is another remote remotedownloader.downloader This remote remotedownloader downloaderis designed designedto work without user interaction and supports supportsa variety varietyof protocols,protocols can upload/download and has a large number of tricks/work-arounds for various things. It can access accessdictionary dictionaryservers servers(dict), ldap ldapservers, ftp, http,http gopher,gopher see the manual manualpage for full fulldetails.details To access accessthe full fullmanual (which is huge) for this command type:-MFor general generalusage you can use it like wget. You can also login loginusing a user name by using the -u-u option and typing your username usernameand password like this:To upload uploadusing ftp ftpyou the -T-T option:optionTo continue a file use the -C-C option: +Remote Administration Relatedssh +sshSecure shell,secure shell remotely remotelylogin loginon a machine running runningthe sshd daemon.daemon Once you are logged loggedin you have a secure shell and are able ableto executeexecute various commands on that computer computersuch as copy copyfiles, reboot the computer, just like it was your own GNU/Linux PC.PCOr you can use ssh with a full hostname hostnameto connect connectto a remote remotemachine (as in across the internet). Examples:Connect to a remote remotesystem with your current username, you will obviously need the password of the user on the other machine.Connect to a remote remotesystem with your a different differentusername, you will obviously need the password passwordof the user on the other machine.scp +scpSecure copy,secure copy part partof the ssh sshpackage.package Allows you to copy files from one computer to another computer, use -r-r to copy recursively (copy entire directories directoriesand subdirectories).scp's syntax syntaxis alwaysWhere either machine can be a local localdirectory (on the current filesystemfilesystem /) or a remote remotemachine. Remote machines are usually machinesFullName:/directory (if you omit omitthe directory part it will just assume the home homedirectory of the username you are logging loggingin with).The example below copies copiesall files from the current directory (not includingincluding any directories), the command will login loginto “new” using the username of the person personcurrently logged in on the local localcomputer, the files will be copied to the root rootdirectory of the remote remotecomputer called “new” (which is probably probablyon the LAN):You could also copy files from another computer to another computer. Let's say you are on a computer called “p100”. And you want to copy files (and directories) from “hp166” (in the /tmp directory and anything below that) to “new” and put the files in new's temporary temporarydirectory. You could do:Assuming you were logged in as “fred” you would need passwords passwordsfor user “fred” on the computers hp166 and new.new Add Addan user_name@ before the computer name to login loginunder a different user name. For example to perform performthe above command with user “root” on hp166 hp166and “anon” on new newyou would type:To copy from a remote remotemachine to a local localcomputer computeryou simply do things in reverse:reverseThis will copy files on the remote remotemachine in the directory “mystuff” to your local localcomputer. +Remote Machines +Please note that when working with a remote machine you need to have a : (colon) after the machine name even if you want the files in their home directory. Otherwise the command will fail. + +sftp +sftpSecure ftp,secure ftp another part partof the ssh sshpackage.package This command is similar to ftp but uses an encrypted encryptedtunnel tunnelto connect to an ftp server serverand is therefore more moresecure securethan just plain plainftp.The command usage is very similar to ftp (the command-line tool), sftp (once running) uses commands such as help help(for help), put (send files to the server), get (download files from the server) and various others, refer referto the manual page and internal internaldocumentation documentationfor further details. +Graphical programs +Sometimes its easier to manage files with a GUI, many of these programs do have good GUI equivalents, try searching the internet or sites like SourceforgeSourceforge or Freshmeat.Freshmeat. + + + +SecurityThe security securitychapter is designed designedto give the user a very basic basiclevel levelof understanding of security securitywithin the GNU/Linux operating operatingsystem. This chapter also has information informationon the UNIX UNIXsystem style file permissionspermissions used on most GNU/Linux machines.machines More comprehensive comprehensiveguides can be found foundat the Linux Documentation ProjectLinux Documentation Project, such as the Linux Security howtoLinux Security howto authored authoredby Kevin Fenzi Kevin Fenziand Dave Wreski.Dave Wreski There are also sites sitessuch as Linux Security.Linux Security If your looking lookingfor a program programto assist assistin locking lockingdown your operating system you may want to check checkBastille LinuxBastille Linux that runs on RPM RPMbased distributions distributions(Redhat/Mandriva/SuSE).Changing root's password +root's passwordThis trick trickworks well if you have forgotten forgottenyour superuser superuserpassword, type linux single at a LILO/Grub prompt.prompt Then passwd once the system has started startedand you are at a console.console Grub: +If you are using grub grubgo to the relevant relevantline (the one with the kernelkernel and various options) then press press'e' for edit editand add add“single” on to the end endof the lines sectionthat boot bootsthe kernel.kernel Then hit hit[Enter] and press press'b' (to boot). Lilo: +If you are using lilo lilopress escape escapeand type “ linux linuxsingle” and then hit hit[Enter] to boot.boot +Security Warning + +This is also a basic security hazard if you have others using your computer and security is a concern, you may like to add a password to your LILO or Grub prompt to stop this from being done. + + +umask +The umask umaskis a value valueset setby the shell.shell It controls controlsthe default defaultpermissions of any file created during that shellshell session.session This information is inherited from the shell's parent parentand is normally set in some configuration configurationfile by the root user (in my case /etc/profile/etc/profile).umask has an unusual way of doing things ...to set the umask you must describedescribe file permissions file permissionsby saying what will be disabled.disabled You can do this by doing 777 minus minusthe file permissions you want. Note that umask works with numbers numbersonly, for an explanation explanation please see, For example:You want the default during a particular shell session defaultto be equivalent equivalentto chmod chmod750 (user has r/w/x, group grouphas r/x and other has no permissions), then the command you would use would be:Some basic Security Toolsmd5sum +md5sumCompute an md5 md5checksum (128-bit) for file “file_name” to verify verifyit's integrity.integrity You normally use the “ md5sum -c” -coption optionto check checkagainst a given file (often with a “.asc” extention) to check checkwhether the various files are correct,correct this comes in handy handywhen downloading downloadingisos as the checking checkingis automated automatedfor you.Command syntax:mkpasswd -l 10 +This command will make a random randompassword of length lengthten characters.characters This password passwordgenerator generatorcreates passwords passwordsthat are designed designedto be hard to guess. There are similar alternatives alternativesto this program scattered scatteredaround the internet.internet +File PermissionsUse ls ls-l -lto see the permissions of files (list-long). They will appear like this, note that I have added spaces spacesbetween permissions to make it easier to read:Where: r r= read, w w= write,write x = execute execute + - rwx rw- r-- 1 newuser newuser +typeownergroupothers + + + + + This number is the number of hard links (pointers) to this file. You can use ln to create another hard-link to the file. + + + + + This is the type of file. '-' means a regular file, 'd' would mean a directory, 'l' would mean a link. There are also other types such as 'c' for character device and 'b' for block device (found in the /dev/ directory). + + + + + These are the permissions for the owner of the file (the user who created the file). + + + + + These are the permissions for the group, any users who belong is the same group as the user who created the file will have these permissions. + + + + + These are the permissions for everyone else. Any user who is outside the group will have these permissions to the file. + + + +The two names at the end are the username usernameand group grouprespectively.respectivelychmod +chmodChange Changefile access file accesspermissions for a file(s).There are two methods methodsto change changepermissions using chmod; letters lettersor numbers.numbersLetters Method: +use a + or - (plus or minus minussign) to add addor remove removepermissions for a file respectively. Use an equals equalssign =, to specify specifynew newpermissions and remove removethe old oldones for the particular particulartype of user(s). You can use chmod chmodletter where the letters lettersare:a (all (everyone)), u (user), g (group) and o (other).Examples:This would give the user read and write writepermission.This will remove removeread/write/execute permissions from other users (doesn't include includeusers within your group).This will give everyone everyoneread permission permissionfor the file.This would give everyone execute and read permission to the file, if anyone had write writepermission it would be removed.Numbers Method: +you can also use numbers numbers(instead of letters) to change changefile permissions. Where:r r(read) = 4 w w(write) = 2 x (execute) = 1 Numbers Numberscan be added together so you can specify read/write/execute permissions; read+write = 6, read+execute = 5, read+write+execute = 7Examples:This would give everyone read/write/execute permission on “this_file”. The first number numberis user, second is group groupand third is everyone else (other).This would give the user read and execute executepermission, and the group groupwritewrite permission permission(but not read permission!) and everyone else execute executepermission. (Note that it's just an example, settings like that don't really make sense...).chown +chownChanges the ownership ownershiprights rightsof a file (hence the name 'chown' - change ownerchange owner). This program can only be used by root. Use the -R -R option to change changethings recursively,recursively in other words, all matching matchingfiles including includingthose in subdirectories.subdirectoriesCommand syntax:sticky bit +bitOnly the person personwho whocreated the file within a directory may deletedelete it, even if other people peoplehave write writepermission. You can turn turnit on by typing: or (where t represents representsthe sticky stickybit)To turn turnit off offyou would need to type:or (where t represents representsthe sticky stickybit)-tNote that the permissions permissionsaren't relevant relevantin the numbers numbersexample, only the first number (1 = on, 0 = off).An example of a sticky stickydirectory is usually /tmpsuid +Allow SUID/SGID (switch user ID/switch group groupID) access.access You would normally use chmod to turn turnthis on or off offfor a particular file, suid suidis generally considered a security securityhazard so be careful carefulwhen using this. Example:This will give everyone permission to execute executethe file with the permissions of the user who set the +s switch.switch + +Security Hazard + + +This is obviously a security hazard. You should avoid using the suid flag unless necessary. + + +chattr +chattrChange file system attributes (works on ext2fs and possibly others...). Use the -R option to change changefiles recursively, chattr has a large number numberof attributes attributeswhich can be set seton a file, read the manualmanual page pagefor further information.Example:This example and tiny parts of the explanation have been taken from the Linux Online Classroom, see [4] in the for further information. This sets setsthe 'immutable' flag flagon a file. Use a '+' to add addattributes attributesand a '-' to take them away. The +i will prevent preventany changes (accidental or otherwise) to the “lilo.conf” file. If you wish to modify modifythe lilo.conf file you will need to unset unsetthe immutableimmutable flag:flag chattr -i.-i Note some flags flagscan only be used by root;root -i, -a and probably probablymany others.Note there are many different differentattributes attributesthat chattr can change,change here are a few more which may be useful:AA (no Access time) --- if a file or directory has this attribute set, whenever it is accessed,accessed either for reading readingof for writing,writing it's last lastaccess timeaccess time will not be updated.updated This can be useful, for example, on files or directories directorieswhich are very often accessed accessedfor reading, especially since this parameter is the only one which changes on an inode inodewhen it's opened.openedaa (append only) --- if a file has this attribute attributeset and is open for writing, the only operation possible will be to append appenddata datato it's previous contents. For a directory, this means that you can only add addfiles to it, but not rename renameor delete any existing existingfile. Only root can set or clear this attribute.ss (secure deletion) --- when such a file or directory with this attributeattribute set is deleted,deleted the blocks blocksit was occupying occupyingon disk diskare written back with zeroes zeroes(similar to using shred). Note that this does work on the ext2,ext2 and ext3 ext3filesystems but is unlikely to work on others (please see the documentation documentationfor the filesystem filesystemyou are using). You may also like to see shredshred, please see lsattr +lsattr(list attributes). This will list listif whether a file has any special specialattributes (as set by chattr). Use the -R option to list recursively recursivelyand try using the -d-d option optionto list directories directorieslike other files rather than listing listingtheir contents.contentsCommand syntax:This will list files in the current currentdirectory, you may also like to specifyspecify a directory or a file: + +Archiving FilesThe archiving archivingfiles chapter provides providessome basic basicinformation informationon the simple programs programsthat you can use to archive archivefiles. You will often see these programs programsused when you try to install installprograms without using a package managementpackage management tool. +This is not a backup guide +Please note that while tar is useful for regular purposes, and possibly combined with bash sciprting or similar it can become useful, it is not a great program for performing real backups of data. +You should try searching the internet if you are looking for backup programs on GNU/Linux or try SourceforgeSourceforge or FreshmeatFreshmeat for programs that you can use. You may also like to see rsyncrsync, . + +tar (tape archiver)Type tar then -option(s)Options list:list-c-c --- create.-v-v --- verbose,verbose give more output,output show showwhat files are being worked with (extracted or added).-f-f --- file (create or extract extractfrom file) - should always be the last option otherwise the command will not work. -z-z --- put the file though gzip gzipor use gunzip gunzipon the file first.-x-x --- extract the files from the tarball.tarball-p-p --- preserves preservesdates,dates permissions of the original originalfiles.-j-jj --- send sendarchive through bzip2.bzip2--exclude=patternexclude=pattern --- this will stop stopcertain files from being archived archived(using a standard wild-cardstandard wild-card pattern) or a single file name.tar examples + This would create a tape tapearchive (no compressing).This would extract files (verbosely) from a gzipped gzippedtape tapearchive. +rsyncrsync +rsyncrsync is a replacement replacementfor the old oldrcprcp (remote-copy) command. It can use ssh for encryption encryptionand is a very flexible flexibletool, it can copy from local localmachinemachine to local machine, from local to remote remote(and vice-versa), and to and from rsync rsyncservers.servers rsync uses an advanced advanceddifferencing algorithm,algorithm so when to copies copiesor syncs syncssomething it will (a) only copy new/changed files and (b) if the files have being changed it will copy the differences differencesbetween the files (not the entire file). Using this method methodrsync saves savestime timeand bandwidth.bandwidth rsync also has advanced advancedexclusion options optionssimilar to GNU tar.tar rsync has a well written manual page,page for further information informationread the rsync documentation documentationonline or type:If you wish to visit visitthe rsync rsyncsite you will find findit over herersync site +CompressionThere are two main compression compressionutilities utilitiesused in GNU/Linux. It's normal normalto first “tar” a bunch bunchof files (using the tar program of course) and then compress compressthem with either bzip2 or gzip. Of course either of these tools could be used without tar,tar although they are not designed designedto work on more morethan one file (they use the UNIX UNIXtools philosophy,philosophy let lettar group the files, they will do the compression...this simplifies their program). It's normal normalto use tar and then use these tools on them, or use tar with the correct correctoptions to use these compression compressionprograms.programsGNU zip (gzip) +gzip gzipis the GNU GNUzip zipcompression program programand probably probablythe most common commoncompression format formaton UNIX-like UNIX-likeoperating systems.This will compress compressa tar tararchive archivewith GNU GNUzip,zip usually with a .gz .gzextension. Gzip Gzipcan compress compressany type of file, it doesn't have to be a tar tararchive.This will decompress decompressa gzipped gzippedfile, and leave the contents contentsin the currentcurrent directory.directorybzip2 +bzip2 bzip2is a newer newercompression program taht offers superior superiorcompression to gzip gzipat the cost costof more processor processortime.This will compress compressa tar tararchive with the bzip2 bzip2compression program, usually with a .bz .bzextension. bzip2 bzip2can compress compressany type of file, it doesn't have to be a tar tararchive. This will decompress decompressa file compressed compressedby bzip2,bzip2 and leave the contentscontents in the current directory. zipinfo +zipinfoUse zipinfo to find detailed detailedinformation about a zip ziparchive (the ones usually generally used by ms-dos ms-dosand windows,windows for example winzip). Command syntax:zipgrep +zipgrepWill run rungrep to look lookfor files within a zip zipfile (ms-dos style,style for example winzip) without manually manuallydecompressing the file first.Command syntax:bzip2recover +bzip2recoverUsed to recover recoverfiles from a damaged damagedbzip2 archive.archive It simply extracts out all the working blocks blocksas there own bzip2 bzip2archives,archives you can than use bzip2 -t -ton each file to test testthe integrity integrityof them and extract extractthe working files.bzme +bzmeWill convert converta file that is zipped zippedor gzipped gzippedto a file compressedcompressed using bzip2. Command syntax: +Tip + +Both gzip and bzip2 supply tools to work within compressed files for example listing the files within the archive, running less on them, using grep to find files within the archive et cetera. + + +For gzip the commands are prefixed with z, zcat, zless, zgrep. + + +For bzip2 the commands are prefixed with bz, bzcat, bzless, bzgrep. + + + + +Graphics tools (command line based)The graphics graphicstools chapter explains explainssome image imageprograms programsthat can be called from the command-line.command-line While I have found foundimage programs programsthat can be used from the command-line,command-line zgv zgvis the only one I've ever heard of, I did not find them very useful. All the tools listed listeduse the X windowing windowingsystem to work and simply runrun from the command line (so they can be scripted/automated if necessary).montage +montageCreates a 'montage', an image created of many other images,images arrangedarranged in a random randomfashion. Command syntax:The above would create a “montage” of images (it would tile tilea certain number numberof images) into a composite compositeimage called “skyline_images.miff”, you could always use display displayto view viewthe image. +Note + +Note that the images are converted to the same size (scaled) so they can be tiled together. + + +convert +To convert the file format formatof an image to another image format. convert is used to change changea files format,format for example from a jpeg jpegto a bitmap bitmapor one of many other formats.formats convert can also manipulate manipulatethe images as well (see the man manpage pageor the ImageMagickImageMagick site).Example from Jpeg Jpegto PNG PNGformat:import +importCaptures screen-shots screen-shotsfrom the X server serverand saves savesthem to a file. A screen-dump screen-dumpof what X is doing.Command syntax:display +display is used to display (output) images on the screen.screen Once open openyou are can also perform performediting editingfunctions and are able ableto read/write images.images It has various interesting options optionssuch as the ability abilityto display displayimages as a slide slideshow showand the ability abilityto capture capturescreenshots of a single windowwindow on-screen.on-screen Command syntax (for displaying an image):To display a slide slideshow showof images, open openthe images you want possibly possiblyusing a wildcard, for example:And then click clickon the image to bring up the menu menuand then look under the miscellaneous miscellaneousmenu menufor the slide slideshow showoption. +Speed Warning + +Be careful when opening multiple large sized images (especially on a slow machine) and putting the slide show on a small delay between image changes. Your processor will be overloaded and it will take a significant amount of time to be able to close ImageMagick. + + +identify +Will identify identifythe type of image imageas well as it's size,size colour colourdepth and various other information. Use the -verbose -verbose option optionto show showdetailed detailedinformation on the particular particularfile(s). Command syntax:mogrify +mogrifymogrify is another ImageMagick ImageMagickcommand which is used to transform transformimages in a number of different ways, including includingscaling,scaling rotation rotationand various other effects.effects This command can work on a single file or in batch.batchFor example, to convert a large number numberof tiff tifffiles to jpeg jpegfiles you could type:-formatThis command has the power powerto do a number of things in batch batchincluding making thumbnails thumbnailsof sets setsof images.For this you could type:This example has come been used from (unedited) “CLI for noobies: import, display, mogrify”, see [16] in the for further information.-geometryshowrgb +showrgbshowrgb is used to uncompile uncompilean rgb rgbcolour-name database.database The default defaultis the one that X was built builtwith. This database databasecan be used to find findthe correct correctcolour colourcombination for a particular colour colour(well it can be used as a rough roughguide guideanyway). To list listthe colours coloursfrom the X database,database simply type: +Please note: + +All tools listed, excluding showrgb are part of the ImageMagick package. Type man ImageMagick for a full list of available commands. Or see the ImageMagick site ImageMagickImageMagick for further information. + + + +Working with MS-DOS filesUse the mtools mtoolsprograms programsto work with ms-dos ms-dosbased files, execute executemtools for a full fulllisting listingof available availablem* tools. There are a lot of files within the mtools mtoolspackage packagefor working with ms-dosms-dos disks,disks also try the info infodocumentation documentationof mtools mtoolsfor more moredetails.details +The use of slashes + +Note that with mtools commands you can use the slashes on the a: part either way (ie. backslash (windows-style) or forward slash (UNIX system style)). + + +mformat +mformatFormats Formatsan unmounted unmounteddisk as an ms-dos ms-dosfloppy disk.disk Usage Usageis similar to the ms-dos ms-dosformat formatutility,utility to format formatthe first floppyfloppy disk diskyou can type:mcopy +mcopyCopies files from an ms-dos ms-dosdisk when it's not mounted.mounted Similar to the ms-dos ms-doscopy command except it's more advanced.advanced Command syntax:mmount +mmountMount an ms-dos ms-dosdisk, without using the normal normalUNIX system mount.For example:This will mount mountthe floppy under /mnt/floppy (this option may or may not be necessary, it depends on your /etc/fstab setup).mbadblocks +mbadblocksScans Scansan ms-dos ms-dos(fat formatted formatteddisk) for bad blocks,blocks it marksmarks any unused bad blocks blocksas “bad” so they won't be used. Example:dosfsck +dosfsckThis program programis used to check checkand repair repairms-dos based filesystems.filesystems Use the -a-a option to automatically automaticallyrepair repairthe filesystem filesystem(ie don't ask the user questions), the -t-t option optionto mark markun-readable un-readableclusters clustersas bad and the -v option to be more moreverbose verbose(print more information).Example:This would check checkyour floppy disk diskfor any errors errors(and bad sectors) and repairrepair them automatically.automatically +Scheduling Commands to run in the backgroundThere are two main tools used to perform performscheduled scheduledtasks, at and cron. You may also like to try anacronanacron if your computer computerdoes not run continuously, as cron cronwill only work if your computer is left on (anacron can catch catchup with the scheduled scheduledtasks the next time the computer is on...).at +at'at' executes a command once on a particular particularday,day at ata particular time.time at will add adda particular command to be executed.Examples:You then type the commands you want executed then press pressthe end-of-fileend-of-file key character(normally + + CTRL + D + + + CTRL-D + +). Also try:This will run at the current time + the hours/mins/seconds you specifyspecify (use at atnow + 1 hour hourto have command(s) run in 1 hour from now...)You can also use the -f-f option to have at atexecute a particular particularfile (a shell shellscript).This would run the shell shellscript 1 hour hourfrom now.atq +atqWill list jobs currently in queue queuefor the user who executed it, if rootroot executes at atit will list listall jobs jobsin queue queuefor the at atdaemon. Doesn't need or take any options.optionsatrm +atrmWill remove removea job jobfrom the 'at' queue.queueCommand syntax:Will delete deletethe job job“job_no” (use atq to find out the number numberof the job)cron +croncron can be used to schedule schedulea particular particularfunction functionto occur every minute,minute hour,hour day,day week, or month.month It's normal normalto use the crontab crontabto perform the editing editingfunctions as this automates automatesthe process processfor the cron crondaemon daemonand makes it easier for normalnormal users to use cron.cron +Anacron +anacron is another tool designed for systems which are not always on, such as home computers +While cron will not run if the computer is off, anacron will simply run the command when the computer is next on (it catches up with things). + +crontab +crontabcrontab is used to edit,edit read and remove removethe files which the cron crondaemon daemonreads.reads Options Optionsfor crontab crontab(use crontab crontab-option(s)):-e-e --- to edit the file.-l-l --- to list the contents contentsof the file.-u -uusername --- use the -u with a username usernameargument argumentto work with another users crontab crontabfile.When using crontab -e -eyou have a number of fields fields(6) what they mean is listed listedbelow: + + + + + +Field +Allowed Values + + +minute +0-59 + + +hour +0-23 + + +day of month +1-31 + + +month +1-12 (or names, see below) + + +day of week +0-7 (0 or 7 is Sun, or use three letter names) + + + +There are also a number of shortcut shortcutmethods for common commontasks, including:includingThis information has come from (without editing) a post on the LinuxChix techtalk mailing list, please see [16] in the for further information.@reboot --- run runcommand at atreboot @yearly --- same as 0 0 1 1 * @annually --- same as @yearly @monthly --- same as 0 0 1 * * @weekly --- same as 0 0 * * 0 @daily --- same as 0 0 * * * @midnight --- same as @daily @hourly --- same as 0 * * * * This information comes from the cron manual page with small additions (no changes to original content), refer to [13] in the for further information.Note that * (asterisk) is used to mean anything (similar to the wildcard). For example if you leave the day daypart (the 5th place) with an asteriskasterisk it would mean everyday.everydayLists Listsare allowed.allowed A list is a set setof numbers numbers(or ranges) separated separatedby commas.commas Examples:Examples ``1,2,5,9'', ``0-4,8-12”.Step Stepvalues valuescan be used in conjunction conjunctionwith ranges.ranges Following Followinga range rangewith ``/<number>'' specifies specifiesskips of the number's valuevalue through the range. For example, ``0-23/2'' can be used in the hours hoursfield fieldto specify specifycommand execution executionevery other hour hour(the alternative alternativein the V7 V7standard is ``0,2,4,6,8,10,12,14,16,18,20,22''). Steps Stepsare also permitted permittedafter an asterisk,asterisk so if you want to say ``every two hours'', just use ``*/2''.When writing writinga crontab crontabentry entryyou simply type in six sixfields separated separatedby spaces,spaces the first five fiveare those listed in the table table(using numbers numbersor letters lettersand numbers numbersas appropriate), the 6th field fieldis the command to be executed and any options, cron cronwill read everything everythingup until the newline.newlineExample:This would run the echo echocommand with the string stringshown at 4:05 every Sunday. +MiscellaneousThe miscellaneous miscellaneouschapter contains commands that don't really fit into the other sections sectionsof this guide.renaming extensions +renaming extensionsTo rename renameall of the files in the current currentdirectorydirectory with a '.htm' extension extensionto '.html', type:-xYou can get a copy copyof the chcase chcase perl perlscript here.For more morecomplex complexrenaming renamingyou should read relThis information information comes from the Linux Cookbook (without editing). See [3] in the for further information. +Use rel relto analyze analyzetext files for relevance relevanceto a given set of keywords.keywords It outputs outputsthe names of those files that are relevant relevantto the given keywords, ranked rankedin order orderof relevance;relevance if a file does not meet the criteria,criteria it is not outputted in the relevance relevancelisting.units man page +units man pageThere is a man page, part of the Linux Programmers ProgrammersManual called “units”. It displays various information informationon the various scientific scientificmeasurementsmeasurements (such as mega,mega giga gigaet cetera). This manual manualpage pagealso has a short discussion about the argument argumentover whichwhich standard standardshould be used to measure measuredata (ie. the kibibyte kibibytevs kilobyte). To access accessthis man page type:fortune +fortunefortune is a tool which will print printa random,random hopefully interesting quote quoteor entertaining short piece pieceof writing.writing There are options optionsto customise customisewhich area the epigrams epigramsshould come from. Just type fortune to get a random randomepigram epigramfrom any section.section Simply type: +Mini-GuidesThe mini-guides mini-guideschapter is a section sectionof the document documentthat describes describescertain concepts conceptsin more depth depththan the usual command descriptions.descriptions The information informationlisted is fairly specific specificas I have tried to avoid avoidthe duplication duplicationof too much information that is already online.onlineRPM: Redhat Package Management SystemChecking +Checking Installed InstalledRPM'sUse the rpm rpm-V-V option optionto check checkwhether or not a package packagehas been modified.modified For example:If none noneof the files from the textutils textutilspackage packagehave changed then rpm rpmwill exit exitwithout outputting any data.data If, on the other hand,hand the program programhas changed, you may see something like this:This isn't as cryptic crypticas it appears. The line linereturned returnedfrom rpm rpm-V-V contains any number numberof eight characters charactersplus the full fullpath pathto the file. Here are the characters charactersand their meaning:Note that the list under section 24.1.2 comes from the RPM manual page, see [11] in the for further details.S --- File size differsM --- Mode differs (includes permissions permissionsand file type)5 --- MD5 MD5sum sumdiffersD --- Device Devicemajor/minor number mis-matchmis-matchL --- ReadLink(2) path pathmis-matchU --- User ownership ownershipdiffersG --- Group Groupownership ownershipdiffersT --- mTime mTimediffers +Mandriva<indexterm><primary>Mandriva</primary></indexterm> Users Note + +Mandriva Linux uses a customised version of RPM called urpmiurpmi (It consists of the urpm*urpm* commands, urpmi to install, urpmeurpme to remove and urpmfurpmf and urpmqurpmq to query). + + +This customised version has advantages over standard RPM, including automatic-dependency solving and Debian apt-getapt-get style functions (ability to download programs over the internet and have all dependencies resolved automatically). + + +The urpm* commands are all described in detail in Mandriva's documentation and various sources online. + + + +Checking the Hard Disk for errorsChecking Checkingthe hard disk diskfor errors errorson your primary primarydrive is very, very rarely required requiredin GNU/Linux, most checking checkingis automated automatedon start-up start-upif it is required.required If you do need to check checkthe hard disk for errors you will first need to unmount unmountit. Then use the file system checker, fsck.If you had an ext3 ext3file-system then it would be: +Also try + +You can also try using: + +fsck -t file_system_type-t + + + + +Duplicating disksThis simple technique techniqueshows you how you would duplicate duplicatefloppy disks disksin a GNU/Linux system using dd.dd This technique techniqueis not as useful as it used to be but can still be used for creating an image imageof a cd cd(although that is best done through the cd burning burningprogram).This information informationhas been taken from the Linux Online Classroom,Linux Online Classroom see [4] in the for further details.detailsThe first dd ddmakes an exact exactimage of the floppy floppyto the file floppy-image,floppy-image the second one writes the image to the floppy. (The user has presumably switched switchedthe floppy before the second command. Otherwise the command pair is of doubtful usefulness).Similar techinques techinquescan be used when creating bootdisks,bootdisks you simply use dddd to transfer transferthe image to the floppy disk. +WildcardsWildcards are useful in many ways for a GNU/Linux system and for various other uses. Commands can use wildcards wildcardsto perform performactions on more morethan one file at a time,time or to find findpart of a phrase phrasein a text textfile. There are many uses for wildcards, there are two different differentmajor majorways that wildcards are used, they are globbing globbingpatterns/standard wildcards that are often used by the shell.shell The alternative alternativeis regular expressions, popular popularwith many other commands and popular popularfor use with text searching searchingand manipulation.manipulation + Tip + + If you have a file with wildcard expressions in it then you can use single quotes to stop bash expanding them or use backslashes (escape characters), or both. + + +For example if you wanted to create a file called 'fo*' (fo and asterisk) you would have to do it like this (note that you shouldn't create files with names like this, this is just an example): + + touch 'fo*' + + + +Note that parts partsof both subsections subsectionson wildcards are based (at least leastin part) off offthe grep grepmanual manualand info infopages. Please see the for further information.Standard Wildcards (globbing patterns)Standard wildcardsstandard wildcards (also known as globbing patternsglobbing patterns) are used by various command-line utilities utilitiesto work with multiple multiplefiles. For more information on standard wildcards (globbing patterns) refer referto the manual page pageby typing: + Can be used by + + Standard wildcards are used by nearly any command (including mv, cp, rm and many others). + + +? (question mark)? +this can represent representany single character. If you specified specifiedsomething at the command line like "hd?" GNU/Linux would look lookfor hda,hda hdb,hdb hdc hdcand every other letter/number between a-z,a-z 0-9.* (asterisk)* +this can represent representany number of characters characters(including zero,zero in other words, zero zeroor more characters). If you specified specifieda "cd*" it would use "cda", "cdrom"cdrom, "cdrecord"cdrecord and anything that starts startswith “cd” also including including“cd” itself. "m*l" could by mill, mull,mull ml, and anything that starts with an m and endsends with an l.[ ] (square brackets)[ ] +specifies specifiesa range.range If you did m[a,o,u]m it can become: mam, mum,mum mom momif you did: m[a-d]m it can become anything that starts and ends endswith m and has any character charactera to d inbetween. For example, these would work: mam, mbm,mbm mcm,mcm mdm.mdm This kind of wildcard specifies specifiesan “or” relationship relationship(you only need one to match).{ } (curly brackets){ } +terms termsare separated separatedby commas commasand each term termmust be the name of something or a wildcard. This wildcard will copy anything that matches either wildcard(s), or exactexact name(s) (an “or” relationship,relationship one or the other).For example, this would be valid:validThis will copy anything ending endingwith .doc .docor .pdf .pdfto the users home homedirectory.directory Note that spaces spacesare not allowed allowedafter the commas commas(or anywhere else).[!] +[!]This construct is similar to the [ ] construct, except rather than matching matchingany characters charactersinside insidethe brackets,brackets it'll match matchany character,character as long longas it is not listed listedbetween the [ and ]. This is a logical logicalNOT.NOT For example rm rmmyfile[!9] will remove removeall myfiles* (ie. myfiles1,myfiles1 myfiles2 myfiles2etc) but won't remove removea file with the number 9 anywhere within it's name.\ (backslash)\ +is used as an "escape" character,escape character i.e. to protect protecta subsequent subsequentspecial character.special character Thus, "\\” searches searchesfor a backslash.backslash Note you may need to use quotation quotationmarks and backslash(es). +Regular ExpressionsRegular expressions are a type of globbing pattern globbing patternused when working with text. They are used for any form formof manipulation manipulationof multiple multipleparts partsof text textand by various programming programminglanguages that work with text. For more information informationon regular expressions refer referto the manual page or try an online tutorial, for example IBM DeveloperworksIBM Developerworks using regular expressions. For the manual manualpage pagetype:Type: + Regular expressions can be used by + + Regular Expressions are used by grep (and can be used) by find and many other programs. + + + +Tip +If your regular expressions don't seem to be working then you probably need to use single quotation marks over the sentence and then use backslashes on every single special character. + + +. (dot). +will match matchany single character, equivalent equivalentto ? (question mark) in standard wildcardstandard wildcard expressions.expressions Thus, "m.a" matches "mpa" and "mea" but not "ma" or "mppa". \ (backslash)\ +is used as an "escape" character,escape character i.e. to protect protecta subsequent subsequentspecial character.specialcharacter Thus, "\\" searches searchesfor a backslash.backslash Note you may need to use quotation quotationmarks and backslash(es)..* (dot and asterisk).* +is used to match matchany string,string equivalent equivalentto * in standard wildcards.* (asterisk)* +the proceeding proceedingitem is to be matched matched zero zeroor moremore times.times ie. n* will match matchn, nn,nn nnnn,nnnn nnnnnnn nnnnnnnbut not na or any other character.character^ (caret)^ +means "the beginning beginningof the line". So "^a" means find a line linestarting startingwith an "a".$ (dollar sign)$ +means "the end endof the line". So "a$" means find a line ending with an "a".For example, this command searches searchesthe file myfile myfilefor lines linesstarting with an "s" and ending endingwith an "n", and prints printsthem to the standard output standard output(screen):[ ] (square brackets)[ ] +specifies specifiesa range.range If you did m[a,o,u]m it can become: mam, mum,mum mom momif you did: m[a-d]m it can become anything that starts startsand ends endswith m and has any character charactera to d inbetween. For example, these would work: mam, mbm,mbm mcm,mcm mdm.mdm This kind of wildcard specifies specifiesan “or” relationship relationship(you only need one to match).| +|This wildcard wildcardmakes a logical logicalOR ORrelationship relationshipbetween wildcards.wildcards This way you can search searchfor something or something else (possibly using two different regular expressions). You may need to add adda '\' (backslash) before this command to work, because the shell may attemptattempt to interpret interpretthis as a pipe.pipe[^] +[^]This is the equivalent equivalentof [!][!] in standard wildcards.standard wildcards This performs performsa logical logical“not”. This will match matchanything that is not listed within those square squarebrackets. For example, rm rmmyfile[^9] will remove removeall myfiles* (ie. myfiles1,myfiles1 myfiles2 myfiles2etc) but won't remove removea file with the number number9 anywhere within it's name. +Useful categories of characters (as defined by the POSIX standard)This information has been taken from the grep grepinfo infopage pagewith a tiny tinyamountamount of editing,editing see [10] in the for further information.[:upper:] uppercase uppercaseletters[:lower:] lowercase lowercaseletters [:alpha:] alphabetic alphabetic(letters) meaning upper+lower (both uppercase and lowercase letters)[:digit:] numbers numbersin decimal,decimal 0 to 9 [:alnum:] alphanumeric alphanumericmeaning alpha+digits (any uppercase or lowercase letters lettersor any decimal decimaldigits)[:space:] whitespace whitespacemeaning spaces,spaces tabs,tabs newlines newlinesand similar[:graph:] graphically printable graphically printablecharacters excluding excludingspace[:print:] printable printablecharacters including includingspacespace[:punct:] punctuation punctuationcharacters meaning graphical graphicalcharacters minus minusalphaalpha and digitsdigits[:cntrl:] control controlcharacters meaning non-printable characterscharacters[:xdigit:] characters charactersthat are hexadecimal hexadecimaldigits. +These are used with + +The above commands will work with most tools which work with text (for example: tr). + + +For example (advanced example), this command scans scansthe output outputof the dir dircommand, and prints printslines linescontaining a capital capitalletter followed followedby a digit:digit The command greps for [upper_case_letter][any_digit], meaning any uppercaseuppercase letter letterfollowed by any digit.digit If you remove the [ ] (square brackets) in the middle middleit would look for an uppercase letter or a digit, because it would become [upper_case_letter any_digit] + + +&appendix; +&bibliography; +&index; +
diff --git a/LDP/guide/docbook/GNU-Linux-Tools-Summary/appendix.sgml b/LDP/guide/docbook/GNU-Linux-Tools-Summary/appendix.sgml new file mode 100644 index 00000000..8488798a --- /dev/null +++ b/LDP/guide/docbook/GNU-Linux-Tools-Summary/appendix.sgml @@ -0,0 +1,37 @@ +Appendix +Finding Packages/ToolsFinding more useful toolsIf you are looking to find more tools, the GNU projectGNU (GNU's Not Unix) maintains a directory, a website listing categorized links to various free-software tools (which they consider useful) called the GNU Directory.GNU DirectoryAlso try sites such as Sweet CodeSweet Code which offer mailing lists of useful tools which they find.You may also try looking at the most highly rated, most active or most downloaded programs at SourceForgeSourceForge and FreshMeat.FreshMeat +Finding a particular tool(s)<indexterm><primary>finding tools</primary></indexterm>Many of the tools listed in this guide are part of a package of tools, such as diffutils diffutilswhich contains the various tools used to find differences between files, such as diffdiff, sdiffsdiff, diff3diff3, cmpcmp. Most small tools are bundled together in this fashion. Most major distribution's will offer a search function to help you search the packages by file, you can of course do this via the command-line interfacecommand-line interface or a GUIGUI.If you need to search the distribution's available packagespackages via the command-linecommand-line, the method will vary depending on the distribution you are using, see the subsections below or consult your distribution's documentation (or of course the internet):Mandriva (urpm* commands, rpm based)<indexterm><primary>urpm*</primary></indexterm>To find where a particular file came from use urpmf.urpmfCommand syntax:urpmfThe results are often overwhelming as this particular command will take a string and list every file of every packagepackage in it's database that contains the particular keywordkeyword (ie. both uninstalled and installed packagespackages). To refine the results you may want to add a pipe to it and send it through grep -w file_name grep(the -w option will only show you only exact (whole word) matches). How you would do this is shown below:For more information on the urpm* commands, please refer to the tip towards the end of this section: . +Red Hat (rpm)<indexterm><primary>rpm</primary></indexterm>To find which packagepackage a particular file came from use rpm with the -qf option.Command syntax:rpm -qfThis will find which package the file came from. You need to use rpm -qf not with a keywordkeyword but with the location of the actual file. To find more information on the particular package listed use rpm with the -qi option.rpm -qiCommand syntax:Note that the package name is the name of the package without the .arch.rpm (often .i386.rpm) extension on the end.For more information on the usage of rpm, please refer to this section . +Debian (deb)<indexterm><primary>deb</primary></indexterm>To find where a particular file came from use dpkg with the -S option.There are two ways to do this:dpkgordpkg -S:You may also like to try (if it's installed, it's generally a lot faster than the dpkg search):dlocateFor more information on dpkg and dlocatedlocate please refer to the relevant manual pages and online sources of information. + +Finding package(s)PackagesPackages can be found via the internet utilizing sites such as:RPMFindRPMFind for RPM based packages.Debian Package ListDebian Package Listfor debdeb packages.RPMSeekRPMSeek, this site intends to index Debian packages as well as RPMRPM.TuxFinderTuxFinder where you can search for deb, rpm, tgz, iso and even documentation.Also try the author's homepage and large sites such as FreshMeatFreshMeat and SourceForge.SourceForge + +Further ReadingGeneral Further ReadingThis guide is simply a short summary of some of the available tools of a GNU/Linux based distribution. If you find a particular command interesting and useful, you can look up the on-line manual, or/and info page to learn more about how to use this command or check the HOWTO's online at Linux Documentation Project. Linux Documentation ProjectThe manual/infomanualinfo pages will always be an up-to-date source of information on how to use the command. Also have a look at the documentation installed on your distribution, its normally located in /usr/share/doc.Check the referencesreferences section of this document, , for some links to useful resources which were used in the creation of this document.Of course if you are having trouble with a particular command try using a search engine such as GoogleGoogle or AllTheWebAllTheWeb, or search the usenet groups Google Groups.Google Groups If you still can't find a solution, look for a mailing list which is related to the topic you are having trouble with, or try a forum which is related to the topic.Readers who would like another reference to commands may want to have at:command-listsCommands from "Linux in a Nutshell 3rd Edition"Linux in a Nutshell as published by Orielly --- this document was not used in the creation of this guide, however it is a comprehensive guide to GNU/Linux Commands (it's an indexed listing). It lists and explains 379 commands taken from Linux in a Nutshell 3rd Edition.The Linux Newbie Admin guide list of commandsLinux Newbie Admin guide --- another list of commands from an excellent system administration guide for GNU/Linux.Comptechdoc's Linux Command Quickreference GuideComptechdoc's Linux Command Quickreference --- a good list of commands but only one line explanations of what they actually do...SS64.com list of bash commandsSS64.com list of commands --- this page lists commands and links to their man pages online.If you wish to learn more about GNU/Linux on a variety of subjects also see the various online (free) tutorials published by IBM Developerworks.IBM DeveloperworksIf you are looking for a general reference to everything GNU/Linux try the Rute User's Tutorial and Exposition.Rute User's Tutorial and Exposition Or take a look at your distributions documentation, Debian maintains comprehensive documentation, debian documentation site.Debian documentation +Specific Further reading<indexterm><primary>further reading</primary></indexterm>The most obvious place to look for documentation is to find the homepage of the program. Although sometimes there are other sources of information such as the Linux Documentation ProjectLinux Documentation Project or various online HOWTO'sHOWTO's or similar guides. They are usually easily found using search engines. Try large sites such as (ibiblio) the publics library and digital archiveibiblio or TuxFinderTuxFinder which can search for documentation.Below is a very short list of some further reading for a few of the more complex tools:OpenSSHOpenSSH OpenSSH manual pagevimvim The Vim HOWTOemacsemacs The Emacs HOWTORPMRPM RPM HOWTOSambaSamba Samba documentation siteImageMagickImageMagick ImageMagick command-line toolsBASHBASH BASH reference manualBash scriptingbash scripting Advanced bash scripting guidersyncrsync rsync homepageThe <productname>UNIX</productname> tools philosophy further reading<indexterm><primary>unix-tools</primary></indexterm>An article within the coreutilscoreutils documentation (installed on nearly every GNU/Linux distro) provides further explanation of the UNIX toolsUNIX tools philosophy. To access the article simply type: Then type / (slash; runs a search) then the string “toolbox” (toolbox is the string to be searched for) then hit enter (follow hyperlink) and then go down to the “Toolbox introduction” section and hit enter. This will give you access to the article.Other articles online include an: Orielly article on the UNIX tools philosophy.UNIX tools philosophyOriellyA listing of important qualities of the philosophy.Linux Exposed The Unix Philosophy Explained[http://www.linuxexposed.com/Articles/General/Linux ExposedOr an entire book which is considered the authoritative guide toward understanding the philosophy behind how the UNIX system was built. The book is called “The Unix Philosophy” ISBN: 1555581234.The Unix Philosophy + +Online Manual And Info Pages<indexterm><primary>online man pages</primary></indexterm><indexterm><primary>online info pages</primary></indexterm>While manual pages and info pages are usually installed with the program itself they are also available online if you need them, the listed links are usually listed by category or by the man page sections.Online Manual Page Websites:Manual Page Resource Links (from the Linux Documentation Project)[http://www.tldp.org/dman pagesA RedHat Based Searchable IndexAnother Searchable IndexAnother Manual Page Site (searchable) +Downloadable Manual Pages:Downloadable Man Pages hosted by Ibiblio +Online Info Page Website:GNU Manual'sGNU Manual'sInfo Pages + + +GNU Free Documentation License<indexterm><primary>license</primary></indexterm><indexterm><primary>GNU Free documentation license</primary></indexterm><indexterm><primary>GFDL</primary></indexterm>GNU Free Documentation LicenseVersion 1.1, March 2000Copyright (C) 2000 Free Software Foundation, Inc. 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed.PREAMBLEThe purpose of this License is to make a manual, textbook, or other written document "free" in the sense of freedom: to assure everyone the effective freedom to copy and redistribute it, with or without modifying it, either commercially or noncommercially. Secondarily, this License preserves for the author and publisher a way to get credit for their work, while not being considered responsible for modifications made by others.This License is a kind of "copyleft", which means that derivative works of the document must themselves be free in the same sense. It complements the GNU General Public License, which is a copyleft license designed for free software.We have designed this License in order to use it for manuals for free software, because free software needs free documentation: a free program should come with manuals providing the same freedoms that the software does. But this License is not limited to software manuals; it can be used for any textual work, regardless of subject matter or whether it is published as a printed book. We recommend this License principally for works whose purpose is instruction or reference. +APPLICABILITY AND DEFINITIONSThis License applies to any manual or other work that contains a notice placed by the copyright holder saying it can be distributed under the terms of this License. The "Document", below, refers to any such manual or work. Any member of the public is a licensee, and is addressed as "you".A "Modified Version" of the Document means any work containing the Document or a portion of it, either copied verbatim, or with modifications and/or translated into another language.A "Secondary Section" is a named appendix or a front-matter section of the Document that deals exclusively with the relationship of the publishers or authors of the Document to the Document's overall subject (or to related matters) and contains nothing that could fall directly within that overall subject. (For example, if the Document is in part a textbook of mathematics, a Secondary Section may not explain any mathematics.) The relationship could be a matter of historical connection with the subject or with related matters, or of legal, commercial, philosophical, ethical or political position regarding them.The "Invariant Sections" are certain Secondary Sections whose titles are designated, as being those of Invariant Sections, in the notice that says that the Document is released under this License.The "Cover Texts" are certain short passages of text that are listed, as Front-Cover Texts or Back-Cover Texts, in the notice that says that the Document is released under this License.A "Transparent" copy of the Document means a machine-readable copy, represented in a format whose specification is available to the general public, whose contents can be viewed and edited directly and straightforwardly with generic text editors or (for images composed of pixels) generic paint programs or (for drawings) some widely available drawing editor, and that is suitable for input to text formatters or for automatic translation to a variety of formats suitable for input to text formatters. A copy made in an otherwise Transparent file format whose markup has been designed to thwart or discourage subsequent modification by readers is not Transparent. A copy that is not "Transparent" is called "Opaque".Examples of suitable formats for Transparent copies include plain ASCII without markup, Texinfo input format, LaTeX input format, SGML or XML using a publicly available DTD, and standard-conforming simple HTML designed for human modification. Opaque formats include PostScript, PDF, proprietary formats that can be read and edited only by proprietary word processors, SGML or XML for which the DTD and/or processing tools are not generally available, and the machine-generated HTML produced by some word processors for output purposes only.The "Title Page" means, for a printed book, the title page itself, plus such following pages as are needed to hold, legibly, the material this License requires to appear in the title page. For works in formats which do not have any title page as such, "Title Page" means the text near the most prominent appearance of the work's title, preceding the beginning of the body of the text. +VERBATIM COPYINGYou may copy and distribute the Document in any medium, either commercially or noncommercially, provided that this License, the copyright notices, and the license notice saying this License applies to the Document are reproduced in all copies, and that you add no other conditions whatsoever to those of this License. You may not use technical measures to obstruct or control the reading or further copying of the copies you make or distribute. However, you may accept compensation in exchange for copies. If you distribute a large enough number of copies you must also follow the conditions in section 3.You may also lend copies, under the same conditions stated above, and you may publicly display copies. +COPYING IN QUANTITYIf you publish printed copies of the Document numbering more than 100, and the Document's license notice requires Cover Texts, you must enclose the copies in covers that carry, clearly and legibly, all these Cover Texts: Front-Cover Texts on the front cover, and Back-Cover Texts on the back cover. Both covers must also clearly and legibly identify you as the publisher of these copies. The front cover must present the full title with all words of the title equally prominent and visible. You may add other material on the covers in addition. Copying with changes limited to the covers, as long as they preserve the title of the Document and satisfy these conditions, can be treated as verbatim copying in other respects.If the required texts for either cover are too voluminous to fit legibly, you should put the first ones listed (as many as fit reasonably) on the actual cover, and continue the rest onto adjacent pages.If you publish or distribute Opaque copies of the Document numbering more than 100, you must either include a machine-readable Transparent copy along with each Opaque copy, or state in or with each Opaque copy a publicly-accessible computer-network location containing a complete Transparent copy of the Document, free of added material, which the general network-using public has access to download anonymously at no charge using public-standard network protocols. If you use the latter option, you must take reasonably prudent steps, when you begin distribution of Opaque copies in quantity, to ensure that this Transparent copy will remain thus accessible at the stated location until at least one year after the last time you distribute an Opaque copy (directly or through your agents or retailers) of that edition to the public.It is requested, but not required, that you contact the authors of the Document well before redistributing any large number of copies, to give them a chance to provide you with an updated version of the Document. +MODIFICATIONSYou may copy and distribute a Modified Version of the Document under the conditions of sections 2 and 3 above, provided that you release the Modified Version under precisely this License, with the Modified Version filling the role of the Document, thus licensing distribution and modification of the Modified Version to whoever possesses a copy of it. In addition, you must do these things in the Modified Version:A. Use in the Title Page (and on the covers, if any) a title distinct from that of the Document, and from those of previous versions (which should, if there were any, be listed in the History section of the Document). You may use the same title as a previous version if the original publisher of that version gives permission.B. List on the Title Page, as authors, one or more persons or entities responsible for authorship of the modifications in the Modified Version, together with at least five of the principal authors of the Document (all of its principal authors, if it has less than five).C. State on the Title page the name of the publisher of the Modified Version, as the publisher.D. Preserve all the copyright notices of the Document.E. Add an appropriate copyright notice for your modifications adjacent to the other copyright notices.F. Include, immediately after the copyright notices, a license notice giving the public permission to use the Modified Version under the terms of this License, in the form shown in the Addendum below.G. Preserve in that license notice the full lists of Invariant Sections and required Cover Texts given in the Document's license notice.H. Include an unaltered copy of this License.I. Preserve the section entitled "History", and its title, and add to it an item stating at least the title, year, new authors, and publisher of the Modified Version as given on the Title Page. If there is no section entitled "History" in the Document, create one stating the title, year, authors, and publisher of the Document as given on its Title Page, then add an item describing the Modified Version as stated in the previous sentence.J. Preserve the network location, if any, given in the Document for public access to a Transparent copy of the Document, and likewise the network locations given in the Document for previous versions it was based on. These may be placed in the "History" section. You may omit a network location for a work that was published at least four years before the Document itself, or if the original publisher of the version it refers to gives permission.K. In any section entitled "Acknowledgements" or "Dedications", preserve the section's title, and preserve in the section all the substance and tone of each of the contributor acknowledgements and/or dedications given therein.L. Preserve all the Invariant Sections of the Document, unaltered in their text and in their titles. Section numbers or the equivalent are not considered part of the section titles.M. Delete any section entitled "Endorsements". Such a section may not be included in the Modified Version.N. Do not retitle any existing section as "Endorsements" or to conflict in title with any Invariant Section.If the Modified Version includes new front-matter sections or appendices that qualify as Secondary Sections and contain no material copied from the Document, you may at your option designate some or all of these sections as invariant. To do this, add their titles to the list of Invariant Sections in the Modified Version's license notice. These titles must be distinct from any other section titles.You may add a section entitled "Endorsements", provided it contains nothing but endorsements of your Modified Version by various parties--for example, statements of peer review or that the text has been approved by an organization as the authoritative definition of a standard.You may add a passage of up to five words as a Front-Cover Text, and a passage of up to 25 words as a Back-Cover Text, to the end of the list of Cover Texts in the Modified Version. Only one passage of Front-Cover Text and one of Back-Cover Text may be added by (or through arrangements made by) any one entity. If the Document already includes a cover text for the same cover, previously added by you or by arrangement made by the same entity you are acting on behalf of, you may not add another; but you may replace the old one, on explicit permission from the previous publisher that added the old one.The author(s) and publisher(s) of the Document do not by this License give permission to use their names for publicity for or to assert or imply endorsement of any Modified Version. +COMBINING DOCUMENTSYou may combine the Document with other documents released under this License, under the terms defined in section 4 above for modified versions, provided that you include in the combination all of the Invariant Sections of all of the original documents, unmodified, and list them all as Invariant Sections of your combined work in its license notice.The combined work need only contain one copy of this License, and multiple identical Invariant Sections may be replaced with a single copy. If there are multiple Invariant Sections with the same name but different contents, make the title of each such section unique by adding at the end of it, in parentheses, the name of the original author or publisher of that section if known, or else a unique number. Make the same adjustment to the section titles in the list of Invariant Sections in the license notice of the combined work.In the combination, you must combine any sections entitled "History" in the various original documents, forming one section entitled "History"; likewise combine any sections entitled "Acknowledgements", and any sections entitled "Dedications". You must delete all sections entitled "Endorsements." +COLLECTIONS OF DOCUMENTSYou may make a collection consisting of the Document and other documents released under this License, and replace the individual copies of this License in the various documents with a single copy that is included in the collection, provided that you follow the rules of this License for verbatim copying of each of the documents in all other respects.You may extract a single document from such a collection, and distribute it individually under this License, provided you insert a copy of this License into the extracted document, and follow this License in all other respects regarding verbatim copying of that document. +AGGREGATION WITH INDEPENDENT WORKSA compilation of the Document or its derivatives with other separate and independent documents or works, in or on a volume of a storage or distribution medium, does not as a whole count as a Modified Version of the Document, provided no compilation copyright is claimed for the compilation. Such a compilation is called an "aggregate", and this License does not apply to the other self-contained works thus compiled with the Document, on account of their being thus compiled, if they are not themselves derivative works of the Document.If the Cover Text requirement of section 3 is applicable to these copies of the Document, then if the Document is less than one quarter of the entire aggregate, the Document's Cover Texts may be placed on covers that surround only the Document within the aggregate. Otherwise they must appear on covers around the whole aggregate. +TRANSLATIONTranslation is considered a kind of modification, so you may distribute translations of the Document under the terms of section 4. Replacing Invariant Sections with translations requires special permission from their copyright holders, but you may include translations of some or all Invariant Sections in addition to the original versions of these Invariant Sections. You may include a translation of this License provided that you also include the original English version of this License. In case of a disagreement between the translation and the original English version of this License, the original English version will prevail. +TERMINATIONYou may not copy, modify, sublicense, or distribute the Document except as expressly provided for under this License. Any other attempt to copy, modify, sublicense or distribute the Document is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. +FUTURE REVISIONS OF THIS LICENSEThe Free Software Foundation may publish new, revised versions of the GNU Free Documentation License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. See Copyleft.Each version of the License is given a distinguishing version number. If the Document specifies that a particular numbered version of this License "or any later version" applies to it, you have the option of following the terms and conditions either of that specified version or of any later version that has been published (not as a draft) by the Free Software Foundation. If the Document does not specify a version number of this License, you may choose any version ever published (not as a draft) by the Free Software Foundation. + + diff --git a/LDP/guide/docbook/GNU-Linux-Tools-Summary/bibliography.sgml b/LDP/guide/docbook/GNU-Linux-Tools-Summary/bibliography.sgml new file mode 100644 index 00000000..6ff46d07 --- /dev/null +++ b/LDP/guide/docbook/GNU-Linux-Tools-Summary/bibliography.sgml @@ -0,0 +1,276 @@ + + + + + + +Steidler-Dennison +(1) Tony + +<ulink url="http://www.lockergnome.com">Lockergnome Penguin Shell Series</ulink> + +Lockergnome + + + +Responsible for many of the commands listed in this document. In particular Lockergnome inspired much of the wildcards section: + + + + + + + +Rhodes +(2) Brandon + +<ulink url="http://rak.isternet.sk/linux-netman/commands.html">Linux Network Commands Page</ulink> + + +Responsible for parts of the network commands section: + + + + + + + +Stutz +(3) Michael + +<ulink url="http://dsl.org/cookbook/">Linux Cookbook Homepage</ulink> + +No Starch Press + + + +Many of these commands have come from the Linux Cookbook (version 1.2). I highly recommend this book to any novice or intermediate GNU/Linux user, have a look at it online, and then of course buy it :). + + + + + + + +Jordan +(4) Michael + +<ulink url="http://www.linux.org/lessons/">Linux Online Classroom</ulink> + +Linux Online + + + +Some very small sections of this document were taken from the Beginner's course on the Linux Online Website. + + + + + + +(5) man and info pages + + +The man and info pages of various tools listed in this document have been used as a resource to assist in the creation of this document. They are a useful resource of up-to-date information on a program and should be consulted when you require information about a particular tool. + + + + + + +(6) <ulink url="http://www.unix.about.com">Focus On Unix -- Unix.about.com</ulink> + + +Some of the tutorials under the power commands section of the unix.about.com site were used in the construction of this guide. In particular parts of the xargs command: and parts of the cut command: were used from their tutorials. + + + + + + +(7) <ulink url="http://www.mandrakelinux.com/en/fdoc.php3">MandrakeSoft Command Line Manual</ulink> + +MandrakeSoft + + + +The Command Line Manual developed for Mandake Linux 9.0 was used in the creation of this document. A small section (in regard to command-line completion) was used from this document. If you are running mandrake you will most likely find this guide here. + + + + + + +(8) <ulink url="http://www.mandrakelinux.com/en/fdoc.php3">MandrakeSoft Starter Guide</ulink> + +MandrakeSoft + + + +The MandrakeSoft Starter Guide, a guide developed for Mandake Linux 9.0 was used in the creation of this document. A small section (in regard to how to recover from a system freeze) was used from this document. If you are running a mandrake system you will most likely find the document here. + + + + + + + +Niksic +(9) Hrvoje + +<ulink url="http://www.gnu.org/manual/wget-1.5.3/">Wget Manual page</ulink> + +Free Software Foundation + + + +A section of the wget manual page was used in this guide, from this page, Wget Manual page. In particular relating to downloading multiple files while using the http protocol. + + + + + + +(10) Grep + +Free Software Foundation + + + +Both wildcards subsections are based off the grep manual and info pages. The Useful Categories of Characters (as defined from the POSIX standard) was taken from the grep info page. + + + + + + + + +Ewing +(11) Marc + + +Johnson +Jeff + + +Troan +Erik + + +RPM Manual Page + +Red Hat + + + +A small section of the RPM manual page was used in the creation of the RPM verifying subsection, without any kind of editing. + + + + + + + +Rossi +(12) Markku + +Enscript Manual Page + +Free Software Foundation + + + +The examples for enscript are based off those shown in the enscript manual page. + + + + + + + +Vixie +(13) Paul + +Cron Manual Page + +4th Berkeley Distribution + + + +The information from the crontab section (below and including the table) was taken (unedited, but with small additions) from the crontab manual pages. Type man 1 crontab and man 5 crontab to access the 2 different manual pages. + + + + + + +(14) <ulink url="http://www.ibm.com/developerworks/linux/">IBM Developerworks</ulink> + + +Some parts of the IBM Developerworks tutorials have been used in the creation of this document. IBM Developerworks frequently publishes new tutorials on a variety of subjects, visit the IBM Developerworks Linux site (see link above) for more information on their GNU/Linux tutorials. + + + + + + + +Banderas +(15) Suso + +<ulink url="http://suso.suso.org/programs/num-utils/">Num-utils homepage</ulink> + + +The num-utils manual pages were used in the creation of the maths section. In particular all the description of the num-utils tools are based off the manual pages on the num-utils homepage. + + + + + + + +Schroder +(16) Carla + +<ulink url="http://mailman.linuxchix.org/pipermail/courses/2004-February/001397.htm">Archive of the LinuxChix posting</ulink> + + +This particular LinuxChix posting was made through a mailing list discussion about cron under the TechTalk mailing list. The posters homepage is http://www.tuxcomputing.com. + + + + + + + +Barr +(17) Joe + +<ulink url="http://www.linux.com/article.pl?sid=04/02/22/227231">CLI for noobies: import, display, mogrify</ulink> + + +This particular article by Joe Barr was used in the description of the mogrify tool in particular the example on creating thumbnails. + + + + + + + +Rankin +(18) Kyle + +<ulink url="http://www.timesonline.co.uk/article/0,,2-1487674,00.html">Please, For the Love of All That's Recoverable, Shred Your Hard Drive!</ulink> + + +This particular article by Kyle Rankin was used (only a paragraph) for information on the shred command. + + + + + + + + + \ No newline at end of file diff --git a/LDP/guide/docbook/GNU-Linux-Tools-Summary/icon_smile.png b/LDP/guide/docbook/GNU-Linux-Tools-Summary/icon_smile.png new file mode 100644 index 0000000000000000000000000000000000000000..729df706c88b657983ac2cf17b6fccccf812b724 GIT binary patch literal 575 zcmV-F0>J%=P)?!=A6(SALVc#lN>$wM*i!#y!6aoXUt!{bP1ec-l!DA%S zsloIZJ<|Qf&iqbV?L`adf~p%RJ0~rYNDmCG?C1tG2^_2lbx5c2jIjaJI>1nNwPrhK zG}7r!@feN4uE2~QxZ+HBBOO`nJqkWr*PHf}%*(5abVf(2D_&c2*^`oVz3I;lP-lDb zB##Fm-k+J=auuu2mGn-G-t_ucxcLmK!%0ae=>)|7e*gCP