Ubuntu Command and Details.doc

Embed Size (px)

Citation preview

  • 8/10/2019 Ubuntu Command and Details.doc

    1/43

    Basic Commands

    Table of Contents

    Using this guide

    Starting a Terminal

    Commands

    sudo: Executing Commands with Elevated Privileges

    File & Directory Commands

    System n!ormation Commands

    "dding " #ew User

    $%tions

    'an and getting hel%

    Searching !or man !iles

    $ther Use!ul Things

    Pasting in commands

    Save on ty%ing

    Change the text

    'ore n!ormation

    "Under Linux there are GUIs (graphical user interfaces), where you can point

    and click and drag, and hopefully get work done without first reading lots of

    documentation. he traditional Unix en!ironment is a LI (command line

    interface), where you type commands to tell the computer what to do. hat

    is faster and more powerful, #ut re$uires finding out what the commands

    are." %% from man intro(1)

    https://help.ubuntu.com/7.04/basic-commands/C/ar01s01.htmlhttps://help.ubuntu.com/7.04/basic-commands/C/ar01s02.htmlhttps://help.ubuntu.com/7.04/basic-commands/C/ar01s03.htmlhttps://help.ubuntu.com/7.04/basic-commands/C/ar01s03.html#id2549409https://help.ubuntu.com/7.04/basic-commands/C/ar01s03.html#id2549442https://help.ubuntu.com/7.04/basic-commands/C/ar01s03.html#id2506304https://help.ubuntu.com/7.04/basic-commands/C/ar01s03.html#id2506691https://help.ubuntu.com/7.04/basic-commands/C/ar01s04.htmlhttps://help.ubuntu.com/7.04/basic-commands/C/ar01s05.htmlhttps://help.ubuntu.com/7.04/basic-commands/C/ar01s05.html#id2506933https://help.ubuntu.com/7.04/basic-commands/C/ar01s06.htmlhttps://help.ubuntu.com/7.04/basic-commands/C/ar01s06.html#id2507034https://help.ubuntu.com/7.04/basic-commands/C/ar01s06.html#id2507067https://help.ubuntu.com/7.04/basic-commands/C/ar01s06.html#id2520833https://help.ubuntu.com/7.04/basic-commands/C/ar01s07.htmlhttps://help.ubuntu.com/7.04/basic-commands/C/ar01s02.htmlhttps://help.ubuntu.com/7.04/basic-commands/C/ar01s03.htmlhttps://help.ubuntu.com/7.04/basic-commands/C/ar01s03.html#id2549409https://help.ubuntu.com/7.04/basic-commands/C/ar01s03.html#id2549442https://help.ubuntu.com/7.04/basic-commands/C/ar01s03.html#id2506304https://help.ubuntu.com/7.04/basic-commands/C/ar01s03.html#id2506691https://help.ubuntu.com/7.04/basic-commands/C/ar01s04.htmlhttps://help.ubuntu.com/7.04/basic-commands/C/ar01s05.htmlhttps://help.ubuntu.com/7.04/basic-commands/C/ar01s05.html#id2506933https://help.ubuntu.com/7.04/basic-commands/C/ar01s06.htmlhttps://help.ubuntu.com/7.04/basic-commands/C/ar01s06.html#id2507034https://help.ubuntu.com/7.04/basic-commands/C/ar01s06.html#id2507067https://help.ubuntu.com/7.04/basic-commands/C/ar01s06.html#id2520833https://help.ubuntu.com/7.04/basic-commands/C/ar01s07.htmlhttps://help.ubuntu.com/7.04/basic-commands/C/ar01s01.html
  • 8/10/2019 Ubuntu Command and Details.doc

    2/43

  • 8/10/2019 Ubuntu Command and Details.doc

    3/43

    Commands

    sudo: xecutin! Commands with levated

    rivile!es

    'ost o! the !ollowing commands will need to )e %re!aced with the

    sudocommand i! you will )e wor(ing with directories or !iles not owned )y

    your account- Please see 1ootSudo!or in!ormation on using sudo-

    #ile $ %irector& Commands

    pwd: The pwdcommand will allow you to (now in which directory

    you0re located 2 pwdstands !or %rint wor(ing directory3- Exam%le: "pwd"

    in the Des(to% directory will show 4+Des(to%- #ote that the *nome

    Terminal also dis%lays this in!ormation in the title )ar o! it0s window 5 see the

    exam%le screenshot at the to% o! this %age-

    ls: The lscommand will show you the !iles in your current directory-

    Used with certain o%tions. you can see si6es o! !iles. when !iles where made.

    and %ermissions o! !iles- Exam%le: "ls '"will show you the !iles that are in

    your home directory-

    o cd: The cdcommand will allow you to change directories- 7hen

    you o%en a terminal you will )e in your home directory- To move around the

    !ile system you will use cd- Exam%les:

    To navigate into the root directory. use "cd ("

    To navigate to your home directory. use "cd"or "cd '"

    To navigate u% one directory level. use "cd .."

    To navigate to the %revious directory 2or )ac(3. use "cd

    )"

    To navigate through multi%le levels o! directory at once.

    s%eci!y the !ull directory %ath that you want to go to- For exam%le. use.

    https://help.ubuntu.com/community/RootSudohttps://help.ubuntu.com/community/RootSudo
  • 8/10/2019 Ubuntu Command and Details.doc

    4/43

    "cd (var(www"to go directly to the +www su)directory o! +var+- "s

    another exam%le. "cd '(%es*top"will move you to the Des(to%

    su)directory inside your home directory-

    cp: The cpcommand will ma(e a co%y o! a !ile !or you- Exam%le: "cpfile foo"will ma(e a exact co%y o! !ile and name it !oo. )ut the !ile !ile

    will still )e there- 7hen you use mvthat !ile would no longer exist. )ut

    when you use cpthe original !ile stays and a new co%y is made-

    mv: The mvcommand will move a !ile to a di!!erent location or will

    rename a !ile- Exam%les are as !ollows: "mv file foo"will rename the !ile

    !ile to !oo- "mv foo '(%es*top"will move the !ile !oo to your

    Des(to% directory )ut will not rename it- 8ou must s%eci!y a new !ile name

    to rename a !ile-

    o To save on ty%ing. you can su)stitute 040 in %lace o! the home

    directory-

    o #ote that i! you are using mvwith sudoyou will not )e a)le to

    use the 4 shortcut. )ut will have to use the !ull %athnames to your !iles-

    This is )ecause when you are wor(ing as root. 4 will re!er to the root

    account0s home directory. not your own-

    rm: Use this command to remove or delete a !ile in your directory- t

    will not wor( on directories which have !iles in them 2use rmdirinstead3-

    m*dir: The m*dircommand will allow you to create directories-

    Exam%le: "m*dir music"will create a music directory-

    man: The mancommand is used to show you the manual o! other

    commands- Try "man man"to get the man %age !or manitsel!- See the

    +an& *etting 9el% section down the %age !or more in!ormation-

  • 8/10/2019 Ubuntu Command and Details.doc

    5/43

  • 8/10/2019 Ubuntu Command and Details.doc

    6/43

    $%tions

    The de!ault )ehavior !or a command may usually )e modi!ied )y adding a ))

    optionto the command- The lscommand !or exam%le has an )so%tion so

    that "ls )s"will include !ile si6es in the listing- There is also a )ho%tion to

    get those si6es in a human reada)le !ormat-

    $%tions can )e grou%ed in clusters so "ls )sh"is exactly the same command

    as "ls )s )h"- 'ost o%tions have a long version. %re!ixed with two dashes

    instead o! one. so even "ls ))si0e ))human)readable"is the same

    command-

  • 8/10/2019 Ubuntu Command and Details.doc

    7/43

    'an and getting hel%

    command))helpand man commandare the two most im%ortant tools at

    the command line-

    irtually all commands understand the )h2or ))help3 o%tion which will

    %roduce a short usage descri%tion o! the command and it0s o%tions. then exit

    )ac( to the command %rom%t- Try "man )h"or "man ))help"to see this in

    action-

    Every command and nearly every a%%lication in ,inux will have a man

    2manual3 !ile. so !inding them is as sim%le as ty%ing "man "command""to

    )ring u% a longer manual entry !or the s%eci!ied command- For exam%le.

    "man mv"will )ring u% the mv2'ove3 manual-

    'ove u% and down the man !ile with the arrow (eys. and ;uit )ac( to the

    command %rom%t with "q"-

    "man man"will )ring u% the manual entry !or the mancommand. which is

    a good %lace to startava5)ased tutorials

    https://help.ubuntu.com/community/AptGetHowtohttps://help.ubuntu.com/community/Repositories/CommandLinehttps://help.ubuntu.com/community/grephttps://help.ubuntu.com/community/findhttps://help.ubuntu.com/community/CommandlineHowtohttps://help.ubuntu.com/community/HowToReadlinehttp://linuxcommand.org/http://linuxsurvival.com/index.phphttps://help.ubuntu.com/community/AptGetHowtohttps://help.ubuntu.com/community/Repositories/CommandLinehttps://help.ubuntu.com/community/grephttps://help.ubuntu.com/community/findhttps://help.ubuntu.com/community/CommandlineHowtohttps://help.ubuntu.com/community/HowToReadlinehttp://linuxcommand.org/http://linuxsurvival.com/index.php
  • 8/10/2019 Ubuntu Command and Details.doc

    10/43

    htt%:++rute-?@A)ug-com+index-html-g65 a massive online )oo( a)out

    system administration. almost all !rom the command line-

    http://rute.2038bug.com/index.html.gzhttp://rute.2038bug.com/index.html.gz
  • 8/10/2019 Ubuntu Command and Details.doc

    11/43

    AptGet

    Howto

    This article applies to all supported versions of "buntu

    Package management with APT

    #ontents

    $. %ackage management withA%T

    $. Introduction to A%T&. #ommands

    $. Installationcommands

    $. auto

    apt&. aintenance

    commands(. )emoval

    commands*. Search

    commands

    (. Typical usagee+ample

    *. Setting up aptget touse a httppro+y

    $. Temporary

    pro+ysession

    &. A%Tconfigurationfile method

    (. AS- rcmethod

    *. -ow to logina pro+y user

    . "seful additionalpackages

    /. See also

    0. Additional links

    1. Troubleshooting aptget or aptitude orSynaptic packagemanager errors

    https://help.ubuntu.com/community/AptGethttps://help.ubuntu.com/community/AptGet/Howto?action=fullsearch&context=180&value=linkto%3A%22AptGet/Howto%22https://help.ubuntu.com/community/AptGet/Howto?action=show&redirect=AptGetHowto#Package%20management%20with%20APT%23Package%20management%20with%20APThttps://help.ubuntu.com/community/AptGet/Howto?action=show&redirect=AptGetHowto#Package%20management%20with%20APT%23Package%20management%20with%20APThttps://help.ubuntu.com/community/AptGet/Howto?action=show&redirect=AptGetHowto#Package%20management%20with%20APT%23Package%20management%20with%20APThttps://help.ubuntu.com/community/AptGet/Howto?action=show&redirect=AptGetHowto#Introduction%20to%20APT%23Introduction%20to%20APThttps://help.ubuntu.com/community/AptGet/Howto?action=show&redirect=AptGetHowto#Commands%23Commandshttps://help.ubuntu.com/community/AptGet/Howto?action=show&redirect=AptGetHowto#Installation%20commands%23Installation%20commandshttps://help.ubuntu.com/community/AptGet/Howto?action=show&redirect=AptGetHowto#Installation%20commands%23Installation%20commandshttps://help.ubuntu.com/community/AptGet/Howto?action=show&redirect=AptGetHowto#auto-apt%23auto-apthttps://help.ubuntu.com/community/AptGet/Howto?action=show&redirect=AptGetHowto#auto-apt%23auto-apthttps://help.ubuntu.com/community/AptGet/Howto?action=show&redirect=AptGetHowto#Maintenance%20commands%23Maintenance%20commandshttps://help.ubuntu.com/community/AptGet/Howto?action=show&redirect=AptGetHowto#Maintenance%20commands%23Maintenance%20commandshttps://help.ubuntu.com/community/AptGet/Howto?action=show&redirect=AptGetHowto#Removal%20commands%23Removal%20commandshttps://help.ubuntu.com/community/AptGet/Howto?action=show&redirect=AptGetHowto#Removal%20commands%23Removal%20commandshttps://help.ubuntu.com/community/AptGet/Howto?action=show&redirect=AptGetHowto#Search%20commands%23Search%20commandshttps://help.ubuntu.com/community/AptGet/Howto?action=show&redirect=AptGetHowto#Search%20commands%23Search%20commandshttps://help.ubuntu.com/community/AptGet/Howto?action=show&redirect=AptGetHowto#Typical%20usage%20example%23Typical%20usage%20examplehttps://help.ubuntu.com/community/AptGet/Howto?action=show&redirect=AptGetHowto#Typical%20usage%20example%23Typical%20usage%20examplehttps://help.ubuntu.com/community/AptGet/Howto?action=show&redirect=AptGetHowto#Setting%20up%20apt-get%20to%20use%20a%20http-proxy%23Setting%20up%20apt-get%20to%20use%20a%20http-proxyhttps://help.ubuntu.com/community/AptGet/Howto?action=show&redirect=AptGetHowto#Setting%20up%20apt-get%20to%20use%20a%20http-proxy%23Setting%20up%20apt-get%20to%20use%20a%20http-proxyhttps://help.ubuntu.com/community/AptGet/Howto?action=show&redirect=AptGetHowto#Temporary%20proxy%20session%23Temporary%20proxy%20sessionhttps://help.ubuntu.com/community/AptGet/Howto?action=show&redirect=AptGetHowto#Temporary%20proxy%20session%23Temporary%20proxy%20sessionhttps://help.ubuntu.com/community/AptGet/Howto?action=show&redirect=AptGetHowto#Temporary%20proxy%20session%23Temporary%20proxy%20sessionhttps://help.ubuntu.com/community/AptGet/Howto?action=show&redirect=AptGetHowto#Temporary%20proxy%20session%23Temporary%20proxy%20sessionhttps://help.ubuntu.com/community/AptGet/Howto?action=show&redirect=AptGetHowto#APT%20configuration%20file%20method%23APT%20configuration%20file%20methodhttps://help.ubuntu.com/community/AptGet/Howto?action=show&redirect=AptGetHowto#APT%20configuration%20file%20method%23APT%20configuration%20file%20methodhttps://help.ubuntu.com/community/AptGet/Howto?action=show&redirect=AptGetHowto#APT%20configuration%20file%20method%23APT%20configuration%20file%20methodhttps://help.ubuntu.com/community/AptGet/Howto?action=show&redirect=AptGetHowto#BASH%20rc%20method%23BASH%20rc%20methodhttps://help.ubuntu.com/community/AptGet/Howto?action=show&redirect=AptGetHowto#BASH%20rc%20method%23BASH%20rc%20methodhttps://help.ubuntu.com/community/AptGet/Howto?action=show&redirect=AptGetHowto#BASH%20rc%20method%23BASH%20rc%20methodhttps://help.ubuntu.com/community/AptGet/Howto?action=show&redirect=AptGetHowto#How%20to%20login%20a%20proxy%20user%23How%20to%20login%20a%20proxy%20userhttps://help.ubuntu.com/community/AptGet/Howto?action=show&redirect=AptGetHowto#How%20to%20login%20a%20proxy%20user%23How%20to%20login%20a%20proxy%20userhttps://help.ubuntu.com/community/AptGet/Howto?action=show&redirect=AptGetHowto#Useful%20additional%20packages%23Useful%20additional%20packageshttps://help.ubuntu.com/community/AptGet/Howto?action=show&redirect=AptGetHowto#Useful%20additional%20packages%23Useful%20additional%20packageshttps://help.ubuntu.com/community/AptGet/Howto?action=show&redirect=AptGetHowto#See%20also%23See%20alsohttps://help.ubuntu.com/community/AptGet/Howto?action=show&redirect=AptGetHowto#Additional%20links%23Additional%20linkshttps://help.ubuntu.com/community/AptGet/Howto?action=show&redirect=AptGetHowto#Troubleshooting%20apt-get%20or%20aptitude%20or%20Synaptic%20package%20manager%20errors%23Troubleshooting%20apt-get%20or%20aptitude%20or%20Synaptic%20package%20manager%20errorshttps://help.ubuntu.com/community/AptGet/Howto?action=show&redirect=AptGetHowto#Troubleshooting%20apt-get%20or%20aptitude%20or%20Synaptic%20package%20manager%20errors%23Troubleshooting%20apt-get%20or%20aptitude%20or%20Synaptic%20package%20manager%20errorshttps://help.ubuntu.com/community/AptGet/Howto?action=show&redirect=AptGetHowto#Troubleshooting%20apt-get%20or%20aptitude%20or%20Synaptic%20package%20manager%20errors%23Troubleshooting%20apt-get%20or%20aptitude%20or%20Synaptic%20package%20manager%20errorshttps://help.ubuntu.com/community/AptGet/Howto?action=show&redirect=AptGetHowto#Troubleshooting%20apt-get%20or%20aptitude%20or%20Synaptic%20package%20manager%20errors%23Troubleshooting%20apt-get%20or%20aptitude%20or%20Synaptic%20package%20manager%20errorshttps://help.ubuntu.com/community/AptGethttps://help.ubuntu.com/community/AptGet/Howto?action=fullsearch&context=180&value=linkto%3A%22AptGet/Howto%22https://help.ubuntu.com/community/AptGet/Howto?action=show&redirect=AptGetHowto#Package%20management%20with%20APT%23Package%20management%20with%20APThttps://help.ubuntu.com/community/AptGet/Howto?action=show&redirect=AptGetHowto#Package%20management%20with%20APT%23Package%20management%20with%20APThttps://help.ubuntu.com/community/AptGet/Howto?action=show&redirect=AptGetHowto#Introduction%20to%20APT%23Introduction%20to%20APThttps://help.ubuntu.com/community/AptGet/Howto?action=show&redirect=AptGetHowto#Commands%23Commandshttps://help.ubuntu.com/community/AptGet/Howto?action=show&redirect=AptGetHowto#Installation%20commands%23Installation%20commandshttps://help.ubuntu.com/community/AptGet/Howto?action=show&redirect=AptGetHowto#Installation%20commands%23Installation%20commandshttps://help.ubuntu.com/community/AptGet/Howto?action=show&redirect=AptGetHowto#auto-apt%23auto-apthttps://help.ubuntu.com/community/AptGet/Howto?action=show&redirect=AptGetHowto#auto-apt%23auto-apthttps://help.ubuntu.com/community/AptGet/Howto?action=show&redirect=AptGetHowto#Maintenance%20commands%23Maintenance%20commandshttps://help.ubuntu.com/community/AptGet/Howto?action=show&redirect=AptGetHowto#Maintenance%20commands%23Maintenance%20commandshttps://help.ubuntu.com/community/AptGet/Howto?action=show&redirect=AptGetHowto#Removal%20commands%23Removal%20commandshttps://help.ubuntu.com/community/AptGet/Howto?action=show&redirect=AptGetHowto#Removal%20commands%23Removal%20commandshttps://help.ubuntu.com/community/AptGet/Howto?action=show&redirect=AptGetHowto#Search%20commands%23Search%20commandshttps://help.ubuntu.com/community/AptGet/Howto?action=show&redirect=AptGetHowto#Search%20commands%23Search%20commandshttps://help.ubuntu.com/community/AptGet/Howto?action=show&redirect=AptGetHowto#Typical%20usage%20example%23Typical%20usage%20examplehttps://help.ubuntu.com/community/AptGet/Howto?action=show&redirect=AptGetHowto#Typical%20usage%20example%23Typical%20usage%20examplehttps://help.ubuntu.com/community/AptGet/Howto?action=show&redirect=AptGetHowto#Setting%20up%20apt-get%20to%20use%20a%20http-proxy%23Setting%20up%20apt-get%20to%20use%20a%20http-proxyhttps://help.ubuntu.com/community/AptGet/Howto?action=show&redirect=AptGetHowto#Setting%20up%20apt-get%20to%20use%20a%20http-proxy%23Setting%20up%20apt-get%20to%20use%20a%20http-proxyhttps://help.ubuntu.com/community/AptGet/Howto?action=show&redirect=AptGetHowto#Temporary%20proxy%20session%23Temporary%20proxy%20sessionhttps://help.ubuntu.com/community/AptGet/Howto?action=show&redirect=AptGetHowto#Temporary%20proxy%20session%23Temporary%20proxy%20sessionhttps://help.ubuntu.com/community/AptGet/Howto?action=show&redirect=AptGetHowto#Temporary%20proxy%20session%23Temporary%20proxy%20sessionhttps://help.ubuntu.com/community/AptGet/Howto?action=show&redirect=AptGetHowto#APT%20configuration%20file%20method%23APT%20configuration%20file%20methodhttps://help.ubuntu.com/community/AptGet/Howto?action=show&redirect=AptGetHowto#APT%20configuration%20file%20method%23APT%20configuration%20file%20methodhttps://help.ubuntu.com/community/AptGet/Howto?action=show&redirect=AptGetHowto#APT%20configuration%20file%20method%23APT%20configuration%20file%20methodhttps://help.ubuntu.com/community/AptGet/Howto?action=show&redirect=AptGetHowto#BASH%20rc%20method%23BASH%20rc%20methodhttps://help.ubuntu.com/community/AptGet/Howto?action=show&redirect=AptGetHowto#BASH%20rc%20method%23BASH%20rc%20methodhttps://help.ubuntu.com/community/AptGet/Howto?action=show&redirect=AptGetHowto#How%20to%20login%20a%20proxy%20user%23How%20to%20login%20a%20proxy%20userhttps://help.ubuntu.com/community/AptGet/Howto?action=show&redirect=AptGetHowto#How%20to%20login%20a%20proxy%20user%23How%20to%20login%20a%20proxy%20userhttps://help.ubuntu.com/community/AptGet/Howto?action=show&redirect=AptGetHowto#Useful%20additional%20packages%23Useful%20additional%20packageshttps://help.ubuntu.com/community/AptGet/Howto?action=show&redirect=AptGetHowto#Useful%20additional%20packages%23Useful%20additional%20packageshttps://help.ubuntu.com/community/AptGet/Howto?action=show&redirect=AptGetHowto#See%20also%23See%20alsohttps://help.ubuntu.com/community/AptGet/Howto?action=show&redirect=AptGetHowto#Additional%20links%23Additional%20linkshttps://help.ubuntu.com/community/AptGet/Howto?action=show&redirect=AptGetHowto#Troubleshooting%20apt-get%20or%20aptitude%20or%20Synaptic%20package%20manager%20errors%23Troubleshooting%20apt-get%20or%20aptitude%20or%20Synaptic%20package%20manager%20errorshttps://help.ubuntu.com/community/AptGet/Howto?action=show&redirect=AptGetHowto#Troubleshooting%20apt-get%20or%20aptitude%20or%20Synaptic%20package%20manager%20errors%23Troubleshooting%20apt-get%20or%20aptitude%20or%20Synaptic%20package%20manager%20errorshttps://help.ubuntu.com/community/AptGet/Howto?action=show&redirect=AptGetHowto#Troubleshooting%20apt-get%20or%20aptitude%20or%20Synaptic%20package%20manager%20errors%23Troubleshooting%20apt-get%20or%20aptitude%20or%20Synaptic%20package%20manager%20errors
  • 8/10/2019 Ubuntu Command and Details.doc

    12/43

    %ackage management via aptget runs handinhand with the/etc/apt/sources.listfile. 2or information on editing or updating your sources list seeSources3ist.

    Introduction to A%T"In the beginning there was the .tar.gz. Users had to compile each program that theywanted to use on their GNU/Linux systems. When ebian was created! it was deemed

    necessary that the system include a method o managing the pac#ages installed on the

    machine. $he name dp#g was gi%en to this system. $hus the amous &pac#age& irst cameinto being on GNU/Linux! a while beore 'ed (at decided to create their own &rpm&

    system.

    ) new dilemma *uic#ly too# hold o the minds o the ma#ers o GNU/Linux. $hey needed

    a rapid! practical! and eicient way to install pac#ages that would manage dependenciesautomatically and ta#e care o their coniguration iles while upgrading. (ere again!

    ebian led the way and ga%e birth to )+$! the )d%anced +ac#aging $ool! which has

    since been ported by ,onecti%a or use with rpm and has been adopted by some otherdistributions."

    2rom !ebian A%T -4WT4

    #ommands

    All of these commands must be run as root or with superuser privileges, see sudofor more information. )eplace 5package6name7 with the name of the package you areattempting to install.

    sudo apt-%et install ubuntu-des&top

    Installation commands

    apt-%et install 'pac&a%e_name(

    This command installs a new package.

    apt-%et build-dep 'pac&a%e_name(

    This command searches the repositories and installs the build dependencies for5package6name7. If the package is not in the repositories it will return an error.

    https://help.ubuntu.com/community/SourcesListhttps://help.ubuntu.com/community/SourcesListhttps://help.ubuntu.com/community/SourcesListhttps://help.ubuntu.com/community/RootSudohttps://help.ubuntu.com/community/SourcesListhttps://help.ubuntu.com/community/RootSudo
  • 8/10/2019 Ubuntu Command and Details.doc

    13/43

    aptitude install 'pac&a%e_name(

    Aptitude is a 8http9::en.wikipedia.org:wiki:;curses;curses< viewer of packagesinstalled or available. Aptitude can be used from the command line in a similarway to aptget. See man aptitudefor more information.

    A%T and aptitude will accept multiple package names as a space delimited list.2or e+ample9

    apt-%et install 'pac&a%e)_name( 'pac&a%e*_name( 'pac&a%e+_name(

    "se the s flag to simulate an action.=sudo aptget s install5package6name7= will simulate installing the package showing you whatpackages will be installed and configured.

    auto-apt

    auto-apt run 'command_strin%(

    When invoked, the autoapt command automatically installs packages uponmissing file access. If a program tries to access a file known to belong in anuninstalled package, autoapt will install that package using aptget. This featurere>uires aptandsudoto work.

    Autoapt keeps databases which need to be kept uptodate in order for it to be

    effective. This is achieved by calling the commands autoapt update, autoaptupdatedb and autoapt updatelocal.

    "sage e+ample

    o ?ou're compiling a program and, all of a sudden, there's an error

    because it needs a file you don't have. The program autoapt asks you toinstall packages if they're needed, stopping the relevant process andcontinuing once the package is installed.

    , auto-apt run .coni%ure

    It will then ask to install the needed packages and call aptgetautomatically. If you're running @, a graphical interface will replace thedefault te+t interface.

    Maintenance commands

    apt-%et update

    )un this command after changing/etc/apt/sources.listor/etc/apt/preerences. 2orinformation regarding/etc/apt/preerences, see %inning-owto. )un this commandperiodically to make sure your source list is uptodate. This is the e>uivalent of=)eload= in Synaptic or =2etch updates= in Adept.

    http://en.wikipedia.org/wiki/Ncurseshttps://help.ubuntu.com/community/PinningHowtohttp://en.wikipedia.org/wiki/Ncurseshttps://help.ubuntu.com/community/PinningHowto
  • 8/10/2019 Ubuntu Command and Details.doc

    14/43

    apt-%et up%rade

    This command upgrades all installed packages. This is the e>uivalent of =ark allupgrades= in Synaptic.

    apt-%et dist-up%rade

    The same as the above, e+cept add the =smart upgrade= checkbo+. It tells A%T touse =smart= conflict resolution system, and it will attempt to upgrade the mostimportant packages at the e+pense of less important ones if necessary.

    =aptget distupgrade= does not perform distribution upgrade. See8http9::www.ubuntu.com:getubuntu:upgradingupgrading< for more information.

    apt-%et c/ec&

    This command is a diagnostic tool. It does an update of the package lists andchecks for broken dependencies.

    apt-%et - install

    This command does the same thing as Edit->Fix Broken Packagein Synaptic.!o this if you get complaints about packages with =unmet dependences=.

    apt-%et autoclean

    This command removes .deb files for packages that are no longer installed onyour system. !epending on your installation habits, removing these files from/%ar/cache/apt/archi%esmay regain a significant amount of diskspace.

    apt-%et clean

    The same as above, e+cept it removes allpackages from the package cache. Thismay not be desirable if you have a slow internet connection, since it will causeyou to redownload any packages you need to install a program.

    o The package cache is in/%ar/cache/apt/archi%es. The command

    du -s/ varcac/eaptarc/ives

    will tell you how much space cached packages are consuming.

    dp&%-reconi%ure 'pac&a%e_name(

    )econfigure the named package. With many packages, youll be prompted withsome configuration >uestions you may not have known were there.

    http://www.ubuntu.com/getubuntu/upgradinghttp://www.ubuntu.com/getubuntu/upgrading
  • 8/10/2019 Ubuntu Command and Details.doc

    15/43

    o 2or e+ample9

    dp&%-reconi%ure ontconi%-coni%

    will present you with a =wiBard= on configuring fonts in "buntu.

    ec/o 0'pac&a%e_name( /old0 1 dp&% --set-selections

    This command places the desired package on hold. This is the same as Synaptic'sPackage->!ock "erion.

    o

    This command may have the unintended side effect of preventingupgrades to packages that depend on updated versions of the pinned

    package. apt-%et dist-up%radewill override this, but will warn youfirst. If you want to use this command with sudo, you need to useec/o 0'pac&a%e_name( /old0 1 sudo dp&% --set-selectionsnot

    sudo ec/o 0'pac&a%e_name( /old0 1 dp&% --set-selections.

    ec/o 0'pac&a%e_name( install0 1 dp&% --set-selections

    This command removes the =hold= or =locked package= state set by the abovecommand. The note above about sudo usage applies to this command.

    Removal commands

    apt-%et remove 'pac&a%e_name(

    This command removes an installed package, leaving configuration files intact.

    apt-%et pur%e 'pac&a%e_name(

    This command completely removes a package and the associated configurationfiles. #onfiguration files residing in C are not usually affected by this command.

    o D operator

    If you want to remove package$ and install package& in

    one step9apt-%et pur%e remove 'pac&a%e)( 'pac&a%e*(2

    .

  • 8/10/2019 Ubuntu Command and Details.doc

    16/43

  • 8/10/2019 Ubuntu Command and Details.doc

    17/43

    dp&% -S 'pac&a%e_name(

    This command does the same as dlocate, but does not re>uire the installation of

    any additional packages. It is slower than dlocatebut has the advantage of being

    installed by default on all !ebian and "buntu systems.

    apt-ile searc/ 'pac&a%e_name(

    This command acts like dlocate and dpkg S, but searches all available packages.It answers the >uestion, =what package provides this fileG=.

    o aptfile needs to be updated regularly like aptget. "se the command9

    apt-ile update

    In order to use this command, the package apt-$ilemust be installed on

    your system. apt-cac/e p&%names

    This command provides a listing of every package in the system

    A general note on searching9 If searching for a generates a list that is too long, you

    can filter your results by piping them through the command %rep. H+amples9

    o apt-cac/e searc/ ilename 1 %rep -4 ilename

    will show only the files that contain filename as a whole word

    o dp&% -L pac&a%e 1 %rep usrbin

    will list files located in the directory :usr:bin, useful if you're looking for aparticular e+ecutable.

    2or more information on aptget, aptcache and dpkg consult their manual pages by usingthe mancommand. These manuals will provide a wider scope of information in addition

    to all of the options that you can use with each program.

    H+ample9

    man apt-%et

    .

  • 8/10/2019 Ubuntu Command and Details.doc

    18/43

    Typical usage e+ample

    I want to feel the wind in my hair, I want the adrenaline of speed. So lets install a racinggame. ut what racing games are availableG

    apt-cac/e searc/ racin% %ame

    It gives me a lot of answers. I see a game named =torcs=. 3ets get some more informationon this game.

    apt-cac/e s/o4 torcs

    -mmm... it seems interesting. ut is this game not already installed on my computerGAnd what is the available versionG Is it from "niverse or mainG

    apt-cac/e polic5 torcs

    4k, so now, let's install it

    apt-%et install torcs

    What is the command I must type in the console to launch this gameG In this e+ample, it'sstraightforward E=torcs=F, but that's not always the case. 4ne way of finding the name ofthe binary is to look at what files the package has installed in =:usr:bin=. 2or games, thebinary will be in =:usr:games=. 2or administrative programs, it's in =:usr:sbin=.

    dp&% -L torcs 1 %rep usr%ames

    The first part of the command display all files installed by the package =torcs= Etry itF.With the second part, we ask to only display lines containing =:usr:games:=.

    -mmm, that game is cool. aybe there are some e+tra tracksG

    apt-cac/e searc/ torcs

    ut I'm running out of space. I will delete the apt cache

    apt-%et clean

    4h no, my mother asked me to remove all games from this computer. ut I want to keepthe configuration files so I can simply reinstall it later.

    apt-%et remove torcs

    If I want to also remove config files 9

    apt-%et pur%e torcs

  • 8/10/2019 Ubuntu Command and Details.doc

    19/43

    Setting up aptget to use a httppro+y

    These are three methods of using aptget with a httppro+y.

    Temporary proxy session

    This is a temporary method that you can manually use each time you want to use aptgetthrough a httppro+y. This method is useful if you only want to temporarily use a httppro+y.

    Hnter this line in the terminal prior to using aptget Esubstitute your details foryourpro+yaddress and pro+yportF.

    e6port /ttp_pro657/ttp:5ourpro65address:pro65port

    APT configuration file method

    This method uses the apt.conf file which is found in your %etc%apt%directory. This methodis useful if you only want aptget Eand not other applicationsF to use a httppro+ypermanently.

    4n some installations there will be no aptconf file set up. This procedure willeither edit an e+isting aptconf file or create a new aptconf file.

    %&sudo %edit etcaptapt.con

    Add this line to your/etc/apt/apt.confile Esubstitute your details for yourpro+yaddressand pro+yportF.

    8c9uire::/ttp::ro65 0/ttp:5ourpro65address:pro65port0;

    Save the apt.conf file.

    BAS rc method

    This method adds a two lines to your .bashrc file in your J-4H directory. This methodis useful if you would like aptget and other applications for instance wget, to use a httppro+y.

    %edit ~.bas/rc

    Add these lines to the bottom of your -/.bashrcfile Esubstitute your details foryourpro+yaddress and pro+yportF

    /ttp_pro657/ttp:5ourpro65address:pro65port

  • 8/10/2019 Ubuntu Command and Details.doc

    20/43

    e6port /ttp_pro65

    Save the file. #lose your terminal window and then open another terminal window orsource the -/.bashrcfile9

    source ~.bas/rc

    Test your pro+y with sudo aptget update and whatever networking tool you desire. ?oucan use firestarter or conky to see active connections.

    If you make a mistake and go back to edit the file again, you can close the terminal andreopen it or you can source -/.bashrcas shown above.

    source ~.bas/rc

    ow to login a proxy user

    If you need to login to the %ro+y server this can be achieved in most cases by using thefollowing layout in specifying the pro+y address in httppro+y. Esubstitute your details forusername, password, yourpro+yaddress and pro+yportF

    /ttp_pro657/ttp:username:pass4ord@5ourpro65address:pro65port

  • 8/10/2019 Ubuntu Command and Details.doc

    21/43

    The asics

    "buntu uses aptfor package management. Apt stores a list of repositories or software

    channels in the file

    etcaptsources.list

    y editing this file from the command line, we can add, remove, or temporarily disablesoftware repositories.

    &ote'It's always a good idea to backup a configuration file like

    ource(litbefore you edit it. To do so, issue the following command9

    sudo cp etcaptsources.list etcaptsources.list.bac&up

    Typically, the contents of the/etc/apt/sources.listlooks like this9

    , sources.list, deb cdrom:.) _?ard5 ?eron_ - #elease amd> *!!=!A!)C/ard5 main restricted

    ,deb cdrom:.) _?ard5 ?eron_ - #elease amd> *!!=!A!)C/ard5 main restricted, See /ttp:/elp.ubuntu.comcommunit5Up%radeNotes or /o4 to up%radeto

    , ne4er versions o t/e distribution.

    deb /ttp:us.arc/ive.ubuntu.comubuntu /ard5 main restricteddeb-src /ttp:us.arc/ive.ubuntu.comubuntu /ard5 main restricted

    ,, aEor bu% i6 updates produced ater t/e inal release o t/e,, distribution.deb /ttp:us.arc/ive.ubuntu.comubuntu /ard5-updates main restricteddeb-src /ttp:us.arc/ive.ubuntu.comubuntu /ard5-updates mainrestricted

    the above is not a complete sources.list

    !xplanation of the Repository "ormat

    All the lines beginning with one or two hashes EKF are comments and do not get

    read by apt or its frontends aptget, Synaptic, and Adept.

    The lines without hashes are apt repository lines. The first two apt lines in our

    e+ample are

    http://www.debian.org/doc/user-manuals#apt-howtohttp://www.debian.org/doc/user-manuals#apt-howtohttp://www.debian.org/doc/user-manuals#apt-howto
  • 8/10/2019 Ubuntu Command and Details.doc

    22/43

  • 8/10/2019 Ubuntu Command and Details.doc

    23/43

  • 8/10/2019 Ubuntu Command and Details.doc

    24/43

    ?ou can add custom software repositories by adding the apt repository line of

    your software source to the list of repositories. It should look something like this9

    deb /ttp:mirror+.ubuntulinu6.nl /ard5-seveas reen6

    Add the line at the end of your ource(litand save the file. ;e+t, make apt aware of the new software repositories by issuing the following

    command9

    sudo apt-%et update

    DoneThe new software repositories should now be available for use.

    Adding &aunchpad PPA Repositories

    "buntu M.$N, Oarmic Ooala, introduces a convenient new command for adding3aunchpad %%A E%ersonal %ackage ArchiveF repositories via the command line9 add-apt-

    repoitor*. This command is apparently the same as addrepo available on !ebian.

    The repository is registered with A%T and an entry is created in

    :etc:apt:sources.list and backs up to :etc:apt:sources.list.save EIt should probablybe creating a file in :etc:apt:sources.list.d folder this may be the case in thefutureF.

    If a public key is re>uired and available it is automatically downloaded and

    registered. ?ou must install pythonsoftwareproperties first

    sudo apt-%et install p5t/on-sot4are-properties

    sudo add-apt-repositor5 ppa:'repositor5-name(Example'sudo addaptrepository ppa9nhandler

    !na'ling Repositories with a (non)interactive* Script

    This section is directed at advanced users.

    Problem'?ou are looking for a way to enable the e+tra repositories without any userinput.

    Example'?ou are creating a custom install script for an application that needs softwarepackages from the "niverse or ultiverse repositories.What follows is a simple script that enables the e+tra repositories that are commented outon a default install of "buntu 1.N* 3TS.

    2irst, save your original sources.list file.

    sudo cp etcaptsources.list etcaptsources.list.bac&up

  • 8/10/2019 Ubuntu Command and Details.doc

    25/43

    ;ow make the changes to uncomment all repositories listed in the sources.list file.

    sudo sed -i -e 0s, debdeb%0 etcaptsources.list

    ake apt aware of the new software repositories by issuing the following

    command9

    sudo apt-%et update

    DoneThe new software repositories should now be available for use.

    Problem'?ou are looking for a way to enable a repository which you provide for usersof your software.

    2irst, save your original sources.list file.

    sudo cp etcaptsources.list etcaptsources.list.ori%

    ;ow create a new file ending in 'sources.list' in the ':etc:apt:sources.list.d'directory

    ec/o Fdeb /ttp:444.5ourdomain.compac&a%esubuntu F ((etcaptsources.list.d5ourdomain.sources.list

    ake apt aware of the new software repositories by issuing the following

    command9

    sudo apt-%et update

    %lease be aware that you should sign your packages and ask your users to import

    your %P% key. 4therwise they will have to confirm that they want to installuntrusted packages from your repository.

    Suggestions L )ecommendations

    It is always a good idea to back upconfiguration files like %etc%apt%ource(lit

    before you begin editing. ?ou can then revert your changes if needed.

    If you decide to add other repositories to sources.list, make sure that the

    repository is meant to work ,and known to workwith "buntu. )epositoriesthat are not deigned to work wit# *our )erion o$ Ubuntucan introduceinconsistencies in your system and might force you to reinstall. Also, make surethat you really need to add e+ternal repositories as the software packageEsF youare looking for may already have been introduced into the official repositories

    %lease keep in mind that it may not be legal to enable some nonUbuntusoftwarerepositories in some countries.

    ?ou may be asked enter a security key when adding a non"buntu repository to

    your sources. See anaging Authentication Oeysfor instructions.

    )emember to retrieve updated package lists by issuing a udo apt-get update

    when you're done editing ource(lit.

    https://help.ubuntu.com/community/Repositories/Ubuntu%3Faction%3Dshow#head-589d9639c60888f17e3d660b375340777b436077https://help.ubuntu.com/community/Repositories/Ubuntu%3Faction%3Dshow#head-589d9639c60888f17e3d660b375340777b436077https://help.ubuntu.com/community/Repositories/Ubuntu%3Faction%3Dshow#head-589d9639c60888f17e3d660b375340777b436077
  • 8/10/2019 Ubuntu Command and Details.doc

    26/43

    +hat Is grep,

    Grepis a command line tool that allows you to find a string in a file or stream. It can beused with )egular e+pression to be more fle+ible at finding strings.

    -ow To "se grep

    In the simplest case, grep can simply be invoked like this 9

    G %rep FS"#INHF ilename

    This is 4O but it does not show the true power of grep. 2irst this only looks at one file. Acool e+ample of using grep with multiple file would be to find all files in a directory thatcontains the name of a person. This can be easily accomplished using a grep in thefollowing way 9

    G %rep FNicolas assisF 3

    ;otice the use of single >uotesQ the >uotes are not essential, but in this e+ample they arere>uired because the name contains a space. !ouble >uotes could also have been used inthis e+ample.

    ;ow lets use some regular e+pressions...

    Prep )egular H+pression

    grep can search for complicated patterns to find what you need. -ere is a list of some ofthe special characters used to create a regular e+pression9

    Grep .egular Expreion

    R !enotes the beginning of a line

    J !enotes the end of a line

    . atches any one characters

    atches N or more of the previous characters

    . atches any number or type of characters

    8< atches on character for the one listed in the the S>uare brackets

    8R< !oes not match any characters listed

    5, 7

    !enotes the beginning and end ErespectivelyF of a word

  • 8/10/2019 Ubuntu Command and Details.doc

    27/43

    So an e+ample of a regular e+pression search would be

    G %rep 0J'

  • 8/10/2019 Ubuntu Command and Details.doc

    28/43

  • 8/10/2019 Ubuntu Command and Details.doc

    29/43

    This could be a slow search depending on the number of directories, subdirectories andfiles on your system. This highlights an important difference in the way that find operatesin that it e+amines the system directlyeach time unlike programs like locate or slocatewhich actually e+amine a regularly updated databaseof filnames and locations.

    3ocating 2iles by SiBeAnother possible search is to search for files bysize. To demonstrate this we can againsearch the home directory for 4gg Uorbis files but this time looking for those that are $NNmegabytes or larger9

    ind $?M -iname F3.o%%F -sie 2)!!

    There are several options with siBe, I have used '' for 'megabytes' here but 'k' for'kilobytes' can be used or 'P' for 'Pigabytes'. This search can then be altered to look forilesonly that are lessthan $NN megabytes9

    ind $?M -iname F3.o%%F -t5pe -sie -)!!

    Are you starting to see the power of find, and the thought involved in constructing afocused searchG If you are interested there is more discussion of these combinedsearchesin the Advanced "sage section below.

    3ocating 2iles by Access Time

    It is also possible to locate files based on their access time or the time that they were last

    used, or viewed by the system. 2or e+ample to show all files that have not been accessedin the J-4H directory for (N days or more9

    ind $?M -atime 2+!

    This type of search is normally more useful when combined with otherfind searches. 2ore+ample one could search for all ogg files in the J-4H directory that have an accesstime of greater than (N days9

    ind $?M -iname F3.o%%F -atime 2+!

    The synta+ works from left to right and by default find Voins the & e+pressions with animplied =and=. This is dealt with in more depth in the section below entitled =#ombiningSearches=.

  • 8/10/2019 Ubuntu Command and Details.doc

    30/43

    Advanced $sage

    The sections above detail the most common usage of find and this would be enough formost searches. -owever there are many more possibilities in the usage of find for >uiteadvanced searches and this sections discusses a few of these possibilities.

    #ombining Searches

    It is possible to combine searches when using find with the use of what is known in thefind man pages as operators. The classic e+ample is the use of a logical A;! synta+9

    ind $?M -iname F3.o%%F -sie 2*!

    This find search performs initially a case insensitive search for all the ogg files in yourJ-4H directory and for every true results it then searches for those with a siBe of &N

    megabytes and over. This contains and implied operator which could be written Voinedwith an a. This search can be altered slightly by use of an e+clamation point to signifynegation of the result9

    ind $?M -iname F3.o%%F O -sie 2*!

    This performs the same search as before but will look for ogg files that are notgreaterthan &N megabytes. It is possible also to use a logical 4) in your find search9

    ind $?M -iname F3.o%%F -o -iname F3.mp+F

    This will perform a case insensitive search in the J-4H directories and find all filesthat are either ogg 4) mp( files. There is great scope here for creating very comple+ andfinely honed searches and I would encourage a through reading of the find man pagessearching for the topic 4%H)AT4)S.

    Acting 4n The files

    4ne advanced but highly useful aspect of find usage is the ability to perform a userspecified action on the result of a find search. 2or e+ample the following search looks forall ogg vorbis files in the J-4H directory and then uses e+ec to pass the result to thedu program to give the siBe of each file9

    ind $?M -name F3.o%%F -t5pe -e6ec du -/ FPQF J;

    This synta+ is often used to delete files by using exec rm rbut this must be used withgreat caution, if at all, as recovery of any deleted files can be >uite difficult.

    "sing +args

  • 8/10/2019 Ubuntu Command and Details.doc

    31/43

    When using a really comple+ search it is often a good idea to use another member of thefindutils package9 +args. Without its use the message)rgument list too longcould beseen signalling that the kernel limit on the combined length of a commandline and itsenvironment variables has been e+ceeded. +args works by feeding the results of thesearch to the subse>uent command in batches calculated on the system capabilities Ebased

    on A)P6A@F. An e+ample9

    ind tmp -iname F3.mp+F -print! 1 6ar%s -! rm

    This e+ample searches the :tmp folder for all mp( files and then deletes them. ?ou willnote the use of both printandxargs which is a deliberate strategy to avoid problemswith spaces and:or newlines in the filenames. odern kernels do not have theA)P6A@ limitation but to keep your searches portable it is an e+cellent idea to use+args in comple+ searches with subse>uent commands.

    /ommandlineHowto

    #ontents

    $. Introduction$. What is itG&. -istory

    $. %4SI@(. Advantages of using

    the command line*. %rere>uisites. -ow to invoke it/. asic structure and

    concepts&. #ommand Synta+

    $. Single #ommand&. ultiple #ommands(. Wildcards

    $. Specifing asinglecharacter

    &. Specifyingmultiplecharacters

    (. Specifying a

    range*. #ontrol 2low

    $. )edirection&. %ipe

    (. 2urther reading

    https://help.ubuntu.com/community/CommandlineHowto?action=fullsearch&context=180&value=linkto%3A%22CommandlineHowto%22https://help.ubuntu.com/community/CommandlineHowto#Introduction%23Introductionhttps://help.ubuntu.com/community/CommandlineHowto#What%20is%20it?%23What%20is%20it?https://help.ubuntu.com/community/CommandlineHowto#History%23Historyhttps://help.ubuntu.com/community/CommandlineHowto#POSIX%23POSIXhttps://help.ubuntu.com/community/CommandlineHowto#Advantages%20of%20using%20the%20command%20line%23Advantages%20of%20using%20the%20command%20linehttps://help.ubuntu.com/community/CommandlineHowto#Advantages%20of%20using%20the%20command%20line%23Advantages%20of%20using%20the%20command%20linehttps://help.ubuntu.com/community/CommandlineHowto#Advantages%20of%20using%20the%20command%20line%23Advantages%20of%20using%20the%20command%20linehttps://help.ubuntu.com/community/CommandlineHowto#Prerequisites%23Prerequisiteshttps://help.ubuntu.com/community/CommandlineHowto#Prerequisites%23Prerequisiteshttps://help.ubuntu.com/community/CommandlineHowto#How%20to%20invoke%20it%23How%20to%20invoke%20ithttps://help.ubuntu.com/community/CommandlineHowto#Basic%20structure%20and%20concepts%23Basic%20structure%20and%20conceptshttps://help.ubuntu.com/community/CommandlineHowto#Basic%20structure%20and%20concepts%23Basic%20structure%20and%20conceptshttps://help.ubuntu.com/community/CommandlineHowto#Command%20Syntax%23Command%20Syntaxhttps://help.ubuntu.com/community/CommandlineHowto#Single%20Command%23Single%20Commandhttps://help.ubuntu.com/community/CommandlineHowto#Single%20Command%23Single%20Commandhttps://help.ubuntu.com/community/CommandlineHowto#Multiple%20Commands%23Multiple%20Commandshttps://help.ubuntu.com/community/CommandlineHowto#Multiple%20Commands%23Multiple%20Commandshttps://help.ubuntu.com/community/CommandlineHowto#Wildcards%23Wildcardshttps://help.ubuntu.com/community/CommandlineHowto#Wildcards%23Wildcardshttps://help.ubuntu.com/community/CommandlineHowto#Specifing%20a%20single%20character%23Specifing%20a%20single%20characterhttps://help.ubuntu.com/community/CommandlineHowto#Specifing%20a%20single%20character%23Specifing%20a%20single%20characterhttps://help.ubuntu.com/community/CommandlineHowto#Specifing%20a%20single%20character%23Specifing%20a%20single%20characterhttps://help.ubuntu.com/community/CommandlineHowto#Specifying%20multiple%20characters%23Specifying%20multiple%20charactershttps://help.ubuntu.com/community/CommandlineHowto#Specifying%20multiple%20characters%23Specifying%20multiple%20charactershttps://help.ubuntu.com/community/CommandlineHowto#Specifying%20multiple%20characters%23Specifying%20multiple%20charactershttps://help.ubuntu.com/community/CommandlineHowto#Specifying%20a%20range%23Specifying%20a%20rangehttps://help.ubuntu.com/community/CommandlineHowto#Specifying%20a%20range%23Specifying%20a%20rangehttps://help.ubuntu.com/community/CommandlineHowto#Control%20Flow%23Control%20Flowhttps://help.ubuntu.com/community/CommandlineHowto#Control%20Flow%23Control%20Flowhttps://help.ubuntu.com/community/CommandlineHowto#Redirection%23Redirectionhttps://help.ubuntu.com/community/CommandlineHowto#Pipe%23Pipehttps://help.ubuntu.com/community/CommandlineHowto#Further%20reading%23Further%20readinghttps://help.ubuntu.com/community/CommandlineHowto?action=fullsearch&context=180&value=linkto%3A%22CommandlineHowto%22https://help.ubuntu.com/community/CommandlineHowto#Introduction%23Introductionhttps://help.ubuntu.com/community/CommandlineHowto#What%20is%20it?%23What%20is%20it?https://help.ubuntu.com/community/CommandlineHowto#History%23Historyhttps://help.ubuntu.com/community/CommandlineHowto#POSIX%23POSIXhttps://help.ubuntu.com/community/CommandlineHowto#Advantages%20of%20using%20the%20command%20line%23Advantages%20of%20using%20the%20command%20linehttps://help.ubuntu.com/community/CommandlineHowto#Advantages%20of%20using%20the%20command%20line%23Advantages%20of%20using%20the%20command%20linehttps://help.ubuntu.com/community/CommandlineHowto#Prerequisites%23Prerequisiteshttps://help.ubuntu.com/community/CommandlineHowto#How%20to%20invoke%20it%23How%20to%20invoke%20ithttps://help.ubuntu.com/community/CommandlineHowto#Basic%20structure%20and%20concepts%23Basic%20structure%20and%20conceptshttps://help.ubuntu.com/community/CommandlineHowto#Basic%20structure%20and%20concepts%23Basic%20structure%20and%20conceptshttps://help.ubuntu.com/community/CommandlineHowto#Command%20Syntax%23Command%20Syntaxhttps://help.ubuntu.com/community/CommandlineHowto#Single%20Command%23Single%20Commandhttps://help.ubuntu.com/community/CommandlineHowto#Multiple%20Commands%23Multiple%20Commandshttps://help.ubuntu.com/community/CommandlineHowto#Wildcards%23Wildcardshttps://help.ubuntu.com/community/CommandlineHowto#Specifing%20a%20single%20character%23Specifing%20a%20single%20characterhttps://help.ubuntu.com/community/CommandlineHowto#Specifing%20a%20single%20character%23Specifing%20a%20single%20characterhttps://help.ubuntu.com/community/CommandlineHowto#Specifing%20a%20single%20character%23Specifing%20a%20single%20characterhttps://help.ubuntu.com/community/CommandlineHowto#Specifying%20multiple%20characters%23Specifying%20multiple%20charactershttps://help.ubuntu.com/community/CommandlineHowto#Specifying%20multiple%20characters%23Specifying%20multiple%20charactershttps://help.ubuntu.com/community/CommandlineHowto#Specifying%20multiple%20characters%23Specifying%20multiple%20charactershttps://help.ubuntu.com/community/CommandlineHowto#Specifying%20a%20range%23Specifying%20a%20rangehttps://help.ubuntu.com/community/CommandlineHowto#Specifying%20a%20range%23Specifying%20a%20rangehttps://help.ubuntu.com/community/CommandlineHowto#Control%20Flow%23Control%20Flowhttps://help.ubuntu.com/community/CommandlineHowto#Redirection%23Redirectionhttps://help.ubuntu.com/community/CommandlineHowto#Pipe%23Pipehttps://help.ubuntu.com/community/CommandlineHowto#Further%20reading%23Further%20reading
  • 8/10/2019 Ubuntu Command and Details.doc

    32/43

    Introduction

    Hven though "buntu is the newbie friendly and polished graphical distribution, there arestill situations where a significant amount of time and mouseclicking can be spared bytyping a bit. I don't think this is a bad thing at allQ no matter what you do, 3inu+ has one

    of its real strengths in the #ommand 3ine

    What is itG

    A #ommand 3ine is, in all simplicity, a user interface based on lines of commands. ?oucan say that it is a textual direct erial proceor. ost commonly, the user interactsdirectly with the computer by typing one line Ealthough it can be more than oneF, whichtriggers actions from the computer based on the synta+ of the current processor.efore everything gets too complicated, we can >uite simply move on. The impatientcan move right on to the /ommand 0*ntaxsection.

    -istory

    In the early days of computers, there was only the #ommand 3ine. The concept of aPraphical "ser Interface EP"IF after which most P"I are modeled was developed byengineers at 1erox2 Palo Alto .eearc# /enter ,PA./. A bit later, Apple paid awhole bunch of money to be allowed to =study= their P"I idea. And, after a while, Applehad their own P"I.

    ;ot until $M1/ did ";I@ get its first P"I, developed by the 345 Pro6ect. They named it

    @. 3inu+, however, had to wait ten more years before @2ree1/ was released. @2ree1/was, and is even today, a free adaptation of the original @ server.

    As mentioned earlier, the #3I E#ommand 3ine InterfaceF was the only way tocommunicate with computers before the P"I was invented. In $M/M, Bell 5elep#one!aboratoriereleased U$ of the ";I@ Timeshare System. ";I@ had a shell called sh,which was the only means of communicating with the computer, and it would stay thatway for >uite some time.

    3ater on, there came derivatives of ";I@9 -%"@, $S!, Solaris, 4penUS, I)I@,S#4 @H;I@, etc. As time progressed, P;":3inu+ emerged. -owever, the history of

    3inu+ itself is way off the scope of this -4WT4. Suffice to say that alternative #3I to shemerged9 Bsh, ksh, bourne shell, etc.

    P%SI-

    The Wikipedia defines %4SI@ as the following9

  • 8/10/2019 Ubuntu Command and Details.doc

    33/43

  • 8/10/2019 Ubuntu Command and Details.doc

    34/43

    Ubuntu

    )pplications 0 )ccessories 0 $erminal

    7ubuntu

    12 3enu 0 4ystem 0 1onsole $erminal +rogram

    1ubuntu5.6)pplications 0 4ystem 0 $erminal

    An alternative way to invoke the command line, only using keyboard shortcuts Esince onthe command line! you would mostly be interacting only through the #eyboardF is9

    4n P;4H E"buntuF9 8ltD R*7 E$ype within the text boxF gnometerminal E%ress

    returnF4n O!H EOubuntuF9 8ltD R*7 E$ype within the text boxF konsole E%ress returnF

    asic structure and concepts

    The first thing that you should notice is something like9

    dud@s/ado4pla5:~ $or

  • 8/10/2019 Ubuntu Command and Details.doc

    35/43

    .ommand Syntax

    This section will try to give you a good rundown of the basic usage for the bash shell,which is the default user shell in "buntu.

    Single #ommand

    The command synta+ will vary with each command. -ere are some of the basics.

    The simplest way to use some commands is to type Vust the command.

    command

    H+ample9

    dud@s/ado4pla5:~ $ lsile).t6tile*.pdile+.mp+ile).pdanot/er_ile.t6tet-8not/er_ile.t6tile-4it/_ot/er-N8."T"

    The above e+ample displays the contents of the current working directory, while othercommands may re>uire one or more arguments.

    command 9argument>

    H+ample9

    dud@s/ado4pla5:~ $ cat ile).t6t#oses are red.iolets are blueVand 5ou /ave t/e bird-luO

    The above e+ample shows you the content of the file$.t+t file by adding the filename asthe argument for the catcommand. Almost all commands, whether they have arguments

    or not, have options.

    command -option

    H+ample9

    dud@s/ado4pla5:~ $ ls -rile-4it/_ot/er-N8."T"et-8not/er_ile.t6t

  • 8/10/2019 Ubuntu Command and Details.doc

    36/43

  • 8/10/2019 Ubuntu Command and Details.doc

    37/43

    dud@s/ado4pla5:~ $ %rep red ile).t6t 11 %rep blue ile).t6t#oses are redVdud@s/ado4pla5:~ $ %rep purple ile).t6t 11 %rep blue ile).t6tiolets are blueVdud@s/ado4pla5:~ $

    In the e+ample above, you will notice command& was only e+ecuted when command$failed.

    Wildcards

    Wildcards are a useful feature that allows an unknown value or values to be used withanother command. This becomes very useful with commands such as =ls= allowing only arange of filenames to be displayed.

    There are three operators used with wildcards ==, =G= and =8+y

  • 8/10/2019 Ubuntu Command and Details.doc

    38/43

    #ontrol 2low

    #ommands read input from the keyboard Estandard input, or stdinF and write to outputEstandard out, or stdoutF. There is also a special output category for error messages called

    standard error Eor stderrF. These three locations are created automatically for eachprogram.

    We can redirect input and output to and from a command.

    Redirection

    If you wanted the output of a command to go to a file instead of the terminal, then youwould use the following synta+9

    command > $ilename

    H+ample9

    dud@s/ado4pla5:~ $ ls ( ile>.t6tdud@s/ado4pla5:~ $ cat ile>.t6tile).t6tile*.pdile+.mp+ile).pdanot/er_ile.t6tet-8not/er_ile.t6tile-4it/_ot/er-N8."T"ile>.t6t

    The above e+ample will create file*.t+t if it is not found. &?5E'If file*.t+t e+istsalready, the above command will overwrite its contents. If you want to add to the end of ae+isting file, then you would use the following synta+9

    command >> $ilename

    H+ample9

    dud@s/ado4pla5:~ $ ls (( ile>.t6tdud@s/ado4pla5:~ $ cat ile>.t6tile).t6t

    ile*.pdile+.mp+ile).pdanot/er_ile.t6tet-8not/er_ile.t6tile-4it/_ot/er-N8."T"ile>.t6tile).t6tile*.pd

  • 8/10/2019 Ubuntu Command and Details.doc

    39/43

    ile+.mp+ile).pdanot/er_ile.t6tet-8not/er_ile.t6tile-4it/_ot/er-N8."T"ile>.t6t

    In the e+ample, you will notice the file was appended with the new information. ;ow weare going to do a different redirection9 We are going to take the input from a file for thecommand to be e+ecuted. -ere is the synta+ for this redirection9

    command 9 $ilename

    H+ample9

    dud@s/ado4pla5:~ $ sort ' ile>.t6tanot/er_ile.t6tanot/er_ile.t6t

    ile).t6tile).t6tile*.pdile*.pdile+.mp+ile+.mp+ile>.t6tile>.t6tile-4it/_ot/er-N8."T"ile-4it/_ot/er-N8."T"et-8not/er_ile.t6tet-8not/er_ile.t6t

    As you can see from this e+ample, we used the file*.t+t as input into the sort command.

    Pipe

    When you need the output from command $ for the input into command &, then youwould use pipe character ''. -ere is the synta+ for the pipe character9

    command command

    H+ample9

    dud@s/ado4pla5:~ $ ls 1 sortanot/er_ile.t6tile).pdile).t6tile*.pdile+.mp+ile-4it/_ot/er-N8."T"et-8not/er_ile.t6t

  • 8/10/2019 Ubuntu Command and Details.doc

    40/43

    The above e+ample is using the output from ls as input to the sort command. ?ou willnotice the list has been sorted.

    As you can see, the command line is an easy and powerful way of completing manytasks. If you want more information on using the command line, then look at the further

    reading section of this document.

    How5o.eadline

    /ontent /leanup .e@uired'This article should be cleanedup tofollow the content standards in the Wiki Puide. ore info...

    0t*le /leanup .e@uired'This article does not follow the stylestandards in the Wiki Puide.ore info...

    If you use a ash shell, you might know it uses the )eadline library for editing commandlines. any other programs use it too. The )eadline configuration supplied with "buntuand Oubuntu allows you to use some obvious keys, such as the left:right arrow keys, formoving around and editing the command line, but you might want a few features beyondthose provided. In fact, )eadline has a rich set of default key bindings, but they can bedifficult to remember or awkward to use. 2or instance, 5Alt7d deletes the word to theright of the cursor. Hnter the ash builtin command bind -for a complete list of the

    bindings.

    This article describes how to add some keys and key combinations to the repertoire. Anew )eadline configuration file is attached which defines the following keys9

    5#trl75arrow7 ove forwards and backwards a word at a time$

    5#trl75!elete7 !elete word to right of cursor

    5#trl75ackspace7 !elete word to left of cursor

    5Shift75!elete7 !elete from cursor to end of line

    5Shift75ackspace7 !elete from cursor to start of line

    5Insert7 Toggle overwrite:insert mode&

    $

    This has been part of the default configuration since Oubuntu release /.N/, but isincluded here for completeness.&Hach call to )eadline starts in insert modeQ the Insert key doesn't =stick= between calls.

    A wordis defined by )eadline to be a se>uence of letters or numbersQ it is not possible tochange this definition. 4ther parts of "buntu might define a word differently. 2orinstance, Oonsole by default defines the characters in '-(%8to be part of a word whendouble clicking Esee 0etting%/on$igure 7onoleF.

    https://help.ubuntu.com/community/HowToReadline?action=fullsearch&context=180&value=linkto%3A%22HowToReadline%22https://help.ubuntu.com/community/Tag#ContentCleanuphttps://help.ubuntu.com/community/Tag#StyleCleanuphttps://help.ubuntu.com/community/Tag#StyleCleanuphttps://help.ubuntu.com/community/HowToReadline?action=fullsearch&context=180&value=linkto%3A%22HowToReadline%22https://help.ubuntu.com/community/Tag#ContentCleanuphttps://help.ubuntu.com/community/Tag#StyleCleanup
  • 8/10/2019 Ubuntu Command and Details.doc

    41/43

    /ey'oard map

    efore installing the new )eadline configuration file, it is necessary to configure theterminal emulator to emit a uni>ue byte se>uence for each re>uired key combination.Oonsole needs only a small change9 with the default 15erm ,1Free C(x(xkeyboard

    table, it emits the same byte se>uence for 5#trl75ackspace7 as for5Shift75ackspace7, which is Vust the same as for 5ackspace7 on its own.

    Attached to this article is myOubuntu.keytab,which configures Oonsole to emit there>uired byte se>uences. The simplest way to install it is to put it in~.&des/areapps&onsoleE8is the conventional notation for =my home directory=F.

    Alternatively, you could make a systemwide change by putting the keytab inusrs/areapps&onsole.

    )ather than downloading the entire table, you could download the patch indefault.keytab.patchand apply it to the default keyboard table. The default keyboard table

    doesn't e+ist as a .keytab file since it's built into OonsoleQ instead, it's available inusrs/aredoc&onsole#8D.deault.e5tab.% . To create the new keytab,

    issue these commands9

    %ip -cd usrs/aredoc&onsole#8D.deault.e5tab.% (m5ubuntu.&e5tabpatc/ m5ubuntu.&e5tab deault.&e5tab.patc/

    After installing myOubuntu.keytab as outlined above, start a new Oonsole session andselect 0etting%7e*board%15erm ,m*7ubuntu. If you're happy with this after testing,select 0etting%0a)e a De$ault.

    If you don't use the default Oonsole keyboard table, and need to modify a different keytabfile, a useful techni>ue during development is to start Oonsole with the command&onsole --&e5tab m5ubuntuEor whatever name you chooseF. This allows you to see

    any error messages from Oonsole, for instance those that say a key combination has beendefined earlier in the keytab file. To verify a key combination, a useful techni>ue is tostart vim, enter Insert mode with i, and enter 5#trl7v followed by the key combination.See usrs/aredoc&onsole#8D.e5"ab for details of the format of the keytab

    file.

    82I@H9 not described are the P;4H terminal emulator, the 3inu+ tty console, orclassic +term.uired byte se>uences, it's timeto configure )eadline. !ownload the fileinputrcand install it either in your homedirectory as .inputrcor as a replacement for the e+isting file etcinputrc.

    https://help.ubuntu.com/community/HowToReadline?action=AttachFile&do=view&target=myKubuntu.keytabhttps://help.ubuntu.com/community/HowToReadline?action=AttachFile&do=view&target=myKubuntu.keytabhttps://help.ubuntu.com/community/HowToReadline?action=AttachFile&do=view&target=default.keytab.patchhttps://help.ubuntu.com/community/HowToReadline?action=AttachFile&do=view&target=default.keytab.patchhttps://help.ubuntu.com/community/HowToReadline?action=AttachFile&do=view&target=inputrchttps://help.ubuntu.com/community/HowToReadline?action=AttachFile&do=view&target=inputrchttps://help.ubuntu.com/community/HowToReadline?action=AttachFile&do=view&target=myKubuntu.keytabhttps://help.ubuntu.com/community/HowToReadline?action=AttachFile&do=view&target=default.keytab.patchhttps://help.ubuntu.com/community/HowToReadline?action=AttachFile&do=view&target=inputrc
  • 8/10/2019 Ubuntu Command and Details.doc

    42/43

    Again, you might prefer to apply a patch instead of installing a complete replacement.!ownload inputrc.patchEsay, to tmpF and with root privilege issue the command9

    patc/ --bac&up etcinputrc tmpinputrc.patc/

    ;ote this creates a backup file, most likely called etcinputrc.ori%Esee patc/)fordetailsF.

    )emember to start a new session before testing and, if necessary, change the keyboardtable.

    %ther terminal emulators

    The following line in :etc:inputrc makes the P;4H terminal emulator use5#trl75!elete7 to delete the word in front of the cursor9

    0Jeuences re>uired by yourcustom )eadline configuration file. ;ow ash and other commandline programs can usethe keys defined in the table above, as well as -ome, Hnd, etc.

    https://help.ubuntu.com/community/HowToReadline?action=AttachFile&do=view&target=inputrc.patchhttps://help.ubuntu.com/community/HowToReadline?action=AttachFile&do=view&target=inputrc.patch
  • 8/10/2019 Ubuntu Command and Details.doc

    43/43