Monday 22 June 2015

Linux secrets

Linux secrets

Linux has more secrets hiding in its delectable depths than in the collective belly of a colony of rotund and affable penguins. Ashton Mills couldn't catch any penguins to divulge their secrets, so here's some of his instead!

MIRROR MIRROR


Ubuntu and Ubuntu-based distributions have a neat little feature in the software updater that lets you not only choose a closer mirror for updates, but benchmark to find the fastest.thereby saving you precious time when it comes to updating. For Ubuntu head to 'System Settings > Software & Updates' and then in the 'Download from' box select Other. You can select Australia or click on 'Choose Best Server' to allow Ubuntu to ping the fastest. This will bring up a list where you can manually select a server in Australia, or optionally click 'Select Best Server' and Ubuntu will ping to find the best.


TRIM THE FAT


SSDs are a modern marvel, and while they don't need to be defragmented they do need to be trimmed to keep them in good order. Under Linux this can be done with the fstrim command. Simply run fstrim -v / to TRIM your root filesystem, just as in Windows (through the Optimise panel on a drive's Properties). You can also add the 'discard' flag to your /etc/fstab file to have the Linux kernel automatically TRIM on the fly. Just nano -w /etc /fstab and add it after the re-mount flag so it reads 'remount-ro,discard'.

PRIVACY, PLEASE


As Ubuntu gained in popularity, its also succumbed to the corporate juggernaut somewhat — parts of it have been monetised, such as the inclusion of the Amazon link as well as sending your search results from the Dash to third parties (and why you may see paid products under 'Suggestions'). If this bothers you it can all be easily removed thanks to a helpful script from fixubuntu.com. Check out the site for more info, or fetch and run it with the following command: wget -q -0 -https://fixubuntu.com/fixubuntu.sh | bash

FIREWALL WITH FLAIR


Linux comes with its own firewall built into the kernel, and distributions like Ubuntu make it easier to configure with ufw, aka Uncomplicated Firewall. However this is a command-line utility. For an easier GUI version, try apt-get install gufw.

SPRING CLEANING


The apt program manager can clean-up downloaded and unnecessary packages with sudо apt-get autoremove && sudo apt-get clean, but for more fine-grained control there’s Linux's answer to CCleaner: sudo apt-get install bleachbit.

CHECK PLEASE, WAITER


By default your distribution will be set up to check the drive once every 30 reboots or so. But being Linux, you may not reboot that often or you may have other reasons to force a check, like a sudden power loss to the system. You can't check and fix errors on a mounted root filesystem, however, so how do you go about forcing a disk check? There are many ways but perhaps the easiest is simply this: open up a terminal and type sudo touch /forcefsck && sudo reboot.

KEEPING UP TO SPEED


All devices need to be identified so that they can be properly configured. In Linux, databases for PCI and USB unique identifiers are often updated when a distribution packages a new release. However, you can update them for your devices with the latest definitions sooner by running sudо update - pciids && sudo update-usbids.

OINK OINK


Short on disk space? Just type 'disk' into Ubunutu's Dash to find the Disk Usage Analyser to reveal your disk-hungry data directories, and for finding phat packages you've installed run dpigs in a terminal. You may need to install it first with apt-get install debian-goodies.

FASTER, PUSSYCAT!


Speed up your application loading with the wonderfully helpful preload. This little gem will analyse your usage and over time automatically load your most used programs into memory at boot. Great for older systems still using HDDs, but even SSD users can benefit. It's fire and forget with apt-get install preload.

MORE OR LESS


If you've spent any time at the command-line on Linux or even Windows, you'll know about piping output via mоre to let you browse through output one page at a time. But in a case where less is more, using the less command instead is more versatile allowing you to scroll back and forth as well one page or one line at a time.

YOU HAVE MESSAGES


Sometimes you might see some text fly past during boot, or want to see exactly what's happening before and after Linux loads. For kernel messages, simply type dmesg at a terminal (perhaps paired with a |less or a grep). For system-wide messages, try cat /var/log/syslog |less. Alternatively, enter 'log' into Ubuntu's Dash for the System log viewer.

GET TWEAKING


There are a variety of tweak tools available including gnome-tweak-tool for Gnome 3 based distributions, but for Ubuntu there’s only one you need to get, the aptly-named Unity Tweak Tool. Install it with apt-get install unity-tweak-tool and go wild!

GET GRUBBY


The GRUB boot menu is not a beast to be tamed easily. Sporting a complex configuration file that's auto-updated (meaning, you shouldn't edit it by hand) it can be a hassle making changes or removing old entries. Fear not, for there is always Grub Customizer! Install it like so:

sudo add-apt-repository ppa:danielrichter2007/grub-customizer && sudo apt-get update && sudo apt-get install grub-customizer

RECOVERING ROOT


Sometimes, it happens — you've managed to forget the root password and you can't update your system or get in to fix it. But there are ways! When you reboot at the GRUB menu - you may need to hold down shift during boot to see it — select the '(recovery mode)' version of your Ubuntu boot from the Advanced Options menu. Then select 'root' from the subsequent menu to drop to a terminal with root access. Now type passwd to set a new password for the root account. You can also set a new password for your main user account with passwd <your username>.

JUST BECAUSE COWS


Linux is nothing if not... mooo! Hey, calm down Cow, we're getting to you. Many a distribution will bundle the programs fortune and, sometimes, cowsay (if you don't have them, apt-get install them). Combine these as fortune |cowsay and add it to the end of your ~/.bashrc file and you can marvel at a bovine waxing wisdom every time you launch a terminal. Use the '-l' flag on cowsay alone to see its alternative forms which include borg, stoned, koala, heliokitty, tux and more! For more cowage, try running apt-get moo.