Micro_Mart_-_January_7_2016_

(Barry) #1

RunningHeadless
If you wantto run yourterminalon a headlesscomputer
overthe network,it will meana littlepreparation.
The targetmachinewill be bestwitha fixedIP
address.Howyou go aboutthis will dependon
yourcircumstances,but you will needthe following
information:
The IP address thatyou wantthe serverto have:It
will haveobtainedone automaticallyfromyourrouter
via DHCP(DynamicHostControlProtocol),but thatcould
change.It is possibleto allocatea fixedIP for a device
fromsomerouters,or you can set it on the PC. Mine
obtained192.168.0.14automatically, but I changedit to
192.168.0.95,whichput it welloutsidemy router’s range
of automatedaddresses.
The subnetmask:This will needto be the same
as otherdeviceson the samenetwork.Mineis
255.255.255.0,whichis verycommon,and meansthatthe
first threenumbersin all localnetworkaddressesmustbe
the same.It allowsa maximumof 254 localdevices.The
last numbermustbe between1 and 254,and it mustbe
differentfor eachdeviceon the network.For example,
my devicesare 192.169.0.1(my router)192.168.0.2,
192.168.0.3,192.168.0.4,and so on.
The gatewayaddress, if you wantaccessto the
internet:This will be the addressof yourrouter. Mineis
192.168.0.1.
The DNSserveraddress:Mostroutersact as DNS
relays,so this will usuallybe the addressof yourrouter.
AnotherusefulDNSserveris Google’s, whichis 8.8.8.8.
If you’-reusinga WindowsPC on the samenetwork,
typingipconfig/all in a DOSterminalwill giveyou most
of this information.
The followingexamplewill workwithmostDebian-
baseddistros,includingUbuntuon a PC and Rasbian
on the RaspberryPi. I will use my settingsin the text,so
you’llneedto adjustthemto suit yournetworkrange.
Althoughsomecommandline fanaticswill insist
thatthereare no text editorsotherthanvi or emacs,
they’rebothmorethana littledauntingfor a beginner.
My favouritetext editoris nano,a nice user-friendly
program,whichhas the advantageof displayingthe
mostcommoncommandsat the bottomof the screen.
It’s installedby defaulton manyDebiandistros,but there
are manyothereditors,and you’llprobablyfind your
ownfavourite.
We will also use the sudocommandto temporarily
takerootuserprivileges.To start,typesudonano/etc/
network/interfacesin a terminal.This will openthe
networkinterfaceconfigurationfile in the nanotext
editor. It will looksomethinglike this on Ubuntu(the
first line beginningwith# is just a comment):


# interfaces(5)file usedby ifup(8)and ifdown(8)
autolo
ifacelo inet loopback

On Rasbianon a RaspberryPiit will looklike this:

autolo
ifacelo inet loopback
ifaceeth0inet dhcp

You will needto edit it. The examplebelowwill give the
computera staticaddressof 192.168.0.95,and will work
for eitherdistro.
Of course,you’llhaveto makeentriesappropriatefor
yourownnetwork.

autolo
ifacelo inet loopback
autoeth0
ifaceeth0inet static
address192.168.0.95
netmask255.255.255.0
gateway192.168.0.1
dns-nameservers192.168.0.18.8.8.8

PressCtrl + O to saveit, pressEnterto confirm,thenCtrl
+ X to exit.Restartingthe systemwill applythe changes.
You will also needto makesure that SSH is installed
and running.SSH standsfor ‘secureshell’and providesan
encryptedconnectionbetweentwo PCs. On Ubuntuand
otherDebian-baseddistros,you can installit by typing
sudoapt-getinstallssh in a terminal.The SSH server
shouldrun automatically, and listenon port22. You can
thenconnectto it fromanotherPC usingan SSH client.
Froma terminalon anotherLinuxPC, you can typethe
followingcommand:ssh username@ipaddress
(e.g.ssh [email protected])and you will be askedfor
yourpasswordto connect.

For Windows,PuTTYis an excellentgraphicaltool for
bothstandardTelnet and SSH connections.It will also
run on Linux.The Windowsversioncan be downloaded
from tinyurl.com/2r4wand the Linuxversionis already
in manyrepositories.
It doesn’t evenneedto be installed;you can just run the
.exe file or launchit, and you’llsee a windowlike this:

iThePuTTYlaunchdialogue
Free download pdf