Micro_Mart_-_January_7_2016_

(Barry) #1

ADVENTURES


IN TEXT


T


his began as an attemptto help my grandsonlearn the
Linux commandline. In the process, I was surprisedhow
many holes I filled in my own knowledge.To attemptan
in-depthstudy of the Linux commandline would require several
books. Some commandsare very powerfuland have many,
many options.There are even entire books dedicatedto single
commands,and there’s a huge amountof materialonline.
There is alwaysmore than one way to carry out a given task.
That is the fundamentalnature of Linux, and each user finds
their own favouritemethodsand short-cuts.
Hopefully, this series can give you a basic groundingin the
commandline environmentand give you the confidenceto
carry out commontasks. It will give you some tips about the
Linux commandline world and perhapswhet your appetite
for more.


WhyUseTheCLI?
Even Windows was originallybuilt on a commandline
interface.Once knownas DOS, it has a new incarnation called
PowerShell,which is increasinglyused for work on servers.
These days, a comparativelylow-powercomputercan run a
graphicalinterfaceor multiplesessionsat the same time, either
locally or across a network.While the GUI undoubtedlyled to a
revolutionin the spread of computeruse, there are sometimes
compellingreasons to avoid it.


1.Efficiency
GUIs use resources. Althoughmany modern computershave
powerfulprocessors,fast GPUs and plenty of memory, the
recent popularityof credit-card-sizedcomputerssuch as the
RaspberryPi and the new MicroBit mean that a new generation
of computerusers are findingthat the GUI is a little more
demandingthan they like. Removingthe need for a fancy
graphicscard or even a monitorcan also reduce electricitybills.
If a server is runningwithouta monitor, why run a GUI?


2.Speed
The added overheadof graphicsprocessingmakes GUI
applicationsslower. Even simple things like copyinga folder full
of files can take
three or four times as long using a drag and drop GUI
compared to a simple command.In the case of large file
transfersacross a network,/this can cause a transferto fail
becausethe process times out. Using text commandsis often
quickerthan findingthe required combinationof mouse-clicks
to carry out simple tasks. As an example,instructionsfor
complexoperationsusing a GUI often need pictures and can
run to a few pages, compared to a few of lines of text that can
be cut and pastedinto a terminal.


3.FlexibilityAndPower
Some operationsdo not have a GUI equivalentat all, and
commandline tools are often more powerfuland informative.
A simple text directory listing can be far clearer and easier to
read than a ‘prettified’GUI version.

4.RemoteAccess
For those of us with a narrow internet ‘pipe’, runninga GUI
over a slow internet connectionis a painfulexperience.A
terminallink via an SSH connectionis much more usable.

5.Security
A GUI introducesadditionalcomplexity. Applicationson the
desktopare often only a front end to one or more underlying
commands.This reduces security, as the more complexa
systemis, the more likely it is that somewhere a possible
vulnerabilityhas been overlooked.Such errors are commonly
exploitedto compromise a system.
To sum up, a text-basedenvironmentoffers the best
combinationof speed and power, coupledwith a low overhead
and better security.

TheBareBones
A CLI (commandline interface)runs in what is knownas a
terminalemulator. The ‘terminal’nomenclature harks back

WhiletheGUI undoubtedly


led to a revolution in the


spreadof computeruse,there


are sometimescompelling


reasons to avoid it




Roadmap
ThebasicfileLinuxhierarchyisshownbelow.Happily,the
Linuxfilesystemhierarchyisfairlywelldefined,andalthough
somedistrosmayvaryit,mostarefairlyconsistent.

/ root directorycontainingall other directories.
/bin Essentialsystem commands,neededfor all
users.
/boot The kernel and other files neededto boot
the PC.
/dev Files that containthe informationneededto
access and use devices.
/etc Global configurationfiles.
/home User’s home directoriescontaininguser files
and user-specificconfigurationfiles. Can be
abbreviatedto ~.
/lib Shared librariesrequiredfor binary
programsin /bin and /sbin.
/lib64 64-bit specific libraries(only in 64-bit distros;
no longer widely used).
/media Mount points for removablemedia (e.g.
CD-ROMsor USB drives.
/mnt Temporarilymountedfilesystems,such as
extra hard disks.
/opt Optionalapplicationsoftwarepackages.
/proc Virtual directoryfor runningprocesses.
/root Special home directoryfor the root user.
/sbin System commandsthat usually require sudo
rights to use.
/srv Specificfiles served by the system.
/tmp Temporaryfiles, often deletedat shutdown.
/usr Secondaryhierarchy, containinglocally
specific files and data.
/var Variable files (i.e. files that change a lot
during normal processes,logs, spool files, etc).
Free download pdf