Micro_Mart_-_January_7_2016_

(Barry) #1

ADVENTURES


IN TEXT


ModifyingCommandBehaviour
The way thatcommandsbehave can be altered by using
flags,argumentsand operators.Flagscan be a singleletter
precededby a dash,or a text stringprecededby two dashes
(e.g.-a or --all).
As an example,ls lists the contentsof the current directory,
but it’s mademore usefulby usinga flag (e.g.ls -a will list all
files,evenhiddenones.In Linux,any file precededby a dot is
normallyhidden).Theseare usuallyconfigfiles or directories
containingprogramdata).ls -l will showfiles withmore
detailedinformationin a formattedlist.

Flagscan be combined.For example,ls -la will showa
formattedlist of all files,including‘hidden’ones.
Argumentsare not heateddiscussions,but data,suchas a
file name.Theycan be usedto definea file to be altered in
someway or containinformationthataltersthe outputof the
command(e.g.cd has the targetdirectoryas an argument,as
in cd /Pictures). By default,commandsoperateon files in your
current directory, but you can also use the completepathto
a file in anotherdirectory(e.g.ls /etc/networkwill list the
contentsof the /etc/networkdirectory).
Operatorsare usedto manipulatethe outputfrom a
command.Theseare specialcharacters,suchas & = + > < ; |
etc. Thesecan be veryuseful,as we shallsee laterin
the series.
Nearlyall commandshavesomesort of associatedhelpfile.
The simplestis accessedby typingthe commandfollowedby
--help,whichgivesa basicguideto the command’s syntax
(e.g.ls --helpwill list all the availablecommandoptions).

If you wantmore in depthinformationtypingmanfollowed
by the command(e.g.manls will displaya scrollablemanual).
Manycommandsalso havea Texinfofile, whichcan be
calledup usingthe info command.ls is partof the coreutils,
so typinginfo coreutilswill showyou the full documentation
for thatcompletepackage,whichcan be navigatedwiththe
cursorkeys.
Whenyou’vefinishedwiththe terminal,you can closeit
by typingexit.If you wantto closedownthe computer, the
commandis shutdown-h now. If you get permissiondenied,
sudoshutdown-h nowshouldwork.Typingshutdown-r now
will restartthe PC.
As yourknowledgegrows,you will startto gain
understandingof howyouroperatingsystemworksand more
confidencewhendealingwithit. If you makea mistake,often
all that’s neededis to retraceyourstepsand you’llrealise
where you’vegonewrong.
In the nextarticle,we’lllookfurtherinto the commandline
to examinemore commandsand theiruses.mm

Once connected to a


remote sshterminal, you’re


logged in as if youwere sitting


at theother computer’s


terminal screen




iTheRaspberryPIis anidealdeviceforexploringtheLinuxshell

iTheVirtualboxinterfaceanda Xubuntuvirtualmachine
Free download pdf