Wednesday, September 28, 2016

Add or remove software sources

Ubuntu comes with pre-installed applications and accessories for
basic computing tasks and activities. Software & Updates lets you
customise the standard set of software sources, coni gure updates
and manage additional drivers. A software source is a general term
that includes both online repositories and local media. You can turn
standard Ubuntu software source on and of , manage third-party
source and authenticate them with signing keys. With Nvidia or
AMD graphics, you can install a proprietary driver, but it cannot be
included in Ubuntu right away due to license restrictions.
Install additional drivers
A common case when Ubuntu users turn to the Additional Drivers
tab in Software & Updates is graphics drivers. Computers with
Nvidia and AMD video chips are supported in Ubuntu out of the
box, but the system utilises open source drivers (‘nouveau’ and
‘radeon’ respectively), that still lag behind a proprietary driver for 3D
performance and gaming. To replace an open source driver with
a proprietary one, go to the Additional Drivers tab and wait for a
while before Ubuntu discovers if there is a proprietary driver for your
hardware. It will not necessarily be a video card: dozens of drivers
for wireless networks and various i rmware bits that improve system
performance cannot be shipped directly because of their licenses.
When you decide to go with one or several non-free drivers, simply
select them and press the Apply Changes button. Ubuntu will
download all required i les in the background and install drivers
automatically. You will then need to logout and log back in, or
better, restart the system.
Standard Ubuntu repositories can be managed on the Ubuntu
Software tab in Software & Updates. It lists the Main repository, for
which Canonical (the Ubuntu maker) provides oicial support; the
Universe repository, which is maintained by Ubuntu community;
the Multiverse repository with proprietary software; and the
Restricted one with closed-source device drivers. If you somehow
need to develop software in Ubuntu yourself, you can enable the
Source repository. Below are other helpful controls for selecting the
nearest mirror (this can boost a package’s download speed) and
the optional switch for Ubuntu CD/DVD with standard delivery
of packages. The ‘Other software’ tab lets you add third-party
repositories and by default lists entries within the Canonical Partners
repository and the extra Independent repository for even more
software (Fig 1). Press the ‘Add’ button to add a new repository, ‘Edit’
to change details and ‘Remove’ to delete a repository. There are
many additional repositories on the Internet, but always approach
with caution.

Get to grips with the Linux command line

If you think that’s a lot of typing, try hitting the Tab key after a couple of
letters of each word. Where there’s only a single possible completion, the
word will be automatically filled in. Two tab clicks brings up suggestions
where there are multiple possibilities.
If you want to know more about a command, they (almost) all have
manuals – or man pages (Fig 3). man ls will tell you all about options for ls;
ls will tell you about the manual command itself.
Looking inside a file is all very well, but often we need to quickly change
something inside it.
In this example, we’re going to use Nano, a command-line text editor (Fig
4). There are many more powerful editors – and many a little friendlier, too
– but Nano is included in Ubuntu, and many other flavours of Linux, so it’s
handy to know the basics.
We’ll edit the ~/.bashrc file, a collection of customisations for the shell
environment; don’t worry that much of it won’t yet make sense. To offset
the risk of damage to your command environment, back up the file first: cp
.bashrc .bashrc.bak – then nano .bashrc.
Find the section with the alias commands near the end. Note that the
ones with a # in front of them are inactive (said to be commented out)
– remove the # to get one to work next time you log in or open a new
terminal session.
You can use the arrows to navigate to the text you want to edit; delete
and type in new text as required. Nothing too strange so far, until you’ve
finished: note those two lines at the bottom of letters preceded by a ^
(caret). These are the keyboard commands – the ^ represents the Ctrl key –
type ^O (hold down the Ctrl key and hit O), and your work will be saved; hit
^X and you’ll exit Nano.
You can set a temporary alias directly, which will last until you close the
terminal down (Fig 5):
Ubuntu files are protected from alterations by other users on a shared
machine. All files and folders belong to a user – it doesn’t have to be a person,
it could be a piece of software, like a web server – and a group. Permissions
on each file relate to whether a user, group or anyone else can read, write
or execute the file; this is abbreviated as rwx permissions. For directories,
execute permission is just permission to open. Execute a file means run it as
a program – so a JPG picture file doesn’t have permission to run, nor does
a spreadsheet file, meaning the embedding inside one of malicious code is
much harder to accomplish for virus writers.
From whichever directory you are currently in, create an empty file –
touch testfile will do the trick – then ls -l. The long listing shows you
permissions (see opposite), and you can see the default permissions of a
newly created file. Enter mkdir testfolder and you can see the permissions
of a newly created directory. Remove the file with rm testfile – you’ll need
the recursive switch to remove a directory: rm -r testfolder.

Get to grips with the Linux command line

The command line may be an older interface, but the reason
it’s survived is the power to tell the computer, in a few apposite
commands, exactly what you want. For example, a single command
can copy all of the MP3 and MP4 i les in a directory to a backup
disk or a machine elsewhere on the network – or anywhere else on
the Internet.
Many people’s i rst encounter with a computer – perhaps at
university in the 1970s or 1980s – was seated at a dumb terminal,
known as a console, connected to a distant, and very large,
computer. Nowadays, computers can be the size of a credit
card – like the Raspberry Pi – but the old-fashioned terminal is
remembered in the form of the terminal program that gives you a
command-line interface to Ubuntu.
Depending on which l avour of Ubuntu you are running, the
terminal may have a dif erent name, but type ‘term’ into the app
search of Unity Shell, or your menu, and you will bring up at least
one choice of terminal. Open this up and you should see a fairly
empty-looking window. Don’t be scared of that blinking cursor –
usually the ‘$’ sign, known as the ‘dollar prompt’. It’s waiting to do
whatever you tell it. You just need to know the right words – or
commands – to get it going.
Here’s an easy one for you to try i rst: type evince into the
terminal - we’ll put the instructions you need to type into bold, so
you can see commands more clearly; always press Enter afterwards,
to let Ubuntu know it’s now got to do something.
Provided you didn’t mistype, you’ll have just opened Ubuntu’s
PDF reader, without using a GUI menu or shortcut item.
o look inside your Documents folder, open a terminal and type ls Documents.
Don’t forget to press Enter. You’ll see a listing of all of the files in Documents. Type
ls and you’ll see a listing of the files in your home directory – that’s because
when you open a terminal, it places you in that directory. You can change by
using the change directory command – cd – like this: cd Documents . Now ls
alone will show you your files.
The cd- command will take you back, because the ‘ - ’ is a shortcut to tell cd to
go back to where you were before. You could also type cd ~, as ~ is short for your
home folder – /home/jo/ or whatever. pwd will remind you where you are now.
Configuration files – the ones called dotfiles, because their names are prefixed
by a dot – are normally hidden from listing. In most file managers you can toggle
them into view with Ctrl+H (on a few, it’s Ctrl+.). At the terminal, it’s ls -a.
The . and .. are shortcuts to ‘this directory’ and ‘parent directory’, or the one
above – hide them by using -A in place of -a. Those letters after the hyphen are
called command-line switches: try ls -l, for long listing. We’ll tell you about
some of that cryptic-looking info it displays later.

Create an image and restore from it

Drive settings can be sensitive to both desktop and laptop computers.
Putting a drive into standby mode not only helps save some watts but
also reduces heating, and even makes the system quieter. Regardless of the
default behaviour of your drive in Ubuntu, you can explicitly set it to go to sleep
after a certain length of time. Click on the ‘gear’ icon and go to Drive Settings,
where you can move the ‘Apply Standby Timeout Settings’ switcher to the ‘on’
position. Now you drag the slider and set the preferred timeout value, after which
the drive will go on to standby (Fig 2). Similarly, you can decide whether you want
to enable or disable write caching – just go to the ‘Write Cache’ tab and choose
the desired mode. When caching is enabled, your drive works faster but may get
corrupt your files in case of power outage.
A hard drive image is a very handy thing compared to plain file backups.
It stores all drive structure, bootloader records and all other drive details,
letting you replicate your setup onto another physical drive. Again, in case of an
ageing drive, which you feel can break at any time, there’s no better way to save
it other than create an image. Depending on what ‘gear’ button you use, you
can either create an image of the whole drive, or just the current partition. When
you choose the ‘Create Disk Image’ option, Disks will prompt you to choose a
destination directory for the image file. Note that it must be saved on another
physical drive. Later on you’ll be able to restore the drive form the image file using
the ‘Restore Disk Image’ option.