Essential tips to help you work smarter with Linux

Making sure your computer is running optimally is an essential task, but there's always more you can do to make it more efficient

Find forgotten files

Linux mostly looks after itself, but if you've spent the last 12 months downloading and installing one distribution after another, there's a good chance you've got a bunch of large files you've forgotten about – and removing these might keep your upgrade pangs at bay for another twelve months.

There are various methods for tracking down large files on your system, from simple command line tools to embedded file manager functions. But we've had the best results using a graphical application specifically designed for the task, and our favourite is called Filelight.

Filelight

FILELIGHT: Other file size comparison applications use area maps, but we much prefer the radial maps of Filelight

It's a KDE application, and when first run, Filelight displays a pie chart view of each partition connected to your system. The filled-in area of the chart represents the percentage of space currently being used. Double-click on any of these partitions and the chart bursts into colour. Each colour represents a directory tree, and the larger the block of colour, the more space that directory is taking.

Successively clicking on these blocks lets you find large files quickly, and holding the cursor over a block displays which folders that block contains. It's much easier to use than an area diagram, and you can even delete files using the right-click menu on the lowest level.

Logging Another aspect of our computers that we'd rather not spend too long with is the system log files. The trouble is that, despite being immensely useful, they're also rather tedious to wade through. The solution to this problem is to use a graphical log file viewer of some kind, and there are two we feel are particularly adept.

Gnome's System Log Viewer provides a single interface to the variety of log files you find on your system, and you can skip through a graphical calendar and search for any particular posts you're interested in.

But our favourite is KDE's KSystemLog. That's because it includes a very powerful filter and uses colour to highlight the severity of certain log entries. This means you can quickly skip through hundreds of lines of output in a few seconds, which in turn means you're more likely to look in the first place.

Command line

Even when you're using the shell, you can save time and be more productive

History lesson

One of the great features of Bash is that it remembers nearly everything you type – just type history to see what commands have been typed. It's this list that's used to populate the cursor up history on the command line, but you could easily use the history command in tandem with grep to find specific instances of commands you're looking for.

Another way to search through your history is to press Ctrl+R on a new line. This opens the reverse 'i-search' prompt. As you start typing, any command you've previously executed that starts with the same letters will appear to the right of the prompt, and you can execute this by pressing carriage return. If you don't like the fact that these commands are being stored, you can remove the history by deleting the .bash_history file located in your home directory.

iSearch

ISEARCH: There are many different ways of working more efficiently on the command line. i-search is one such way.

If you're looking for an alternative method of logging your command-line session, then give the script command a try. Type this before you start work, and the entire contents of the session will be saved to a file in the current working directory. But default, this file is called typescript, and you can finish the command logging by escaping from the current sessions with Ctrl+D.

Virtual terminals

Our favourite command line tool for efficiency is called screen. It's a fantastic utility that can transform the way you use the shell, especially if you often use remote connections. The best way to think of screen is like a set virtual desktops for the command line. Using a series of keyboard shortcuts, you can create a new session, switch between the current session and the next one, and drop back to the normal command line.

You can leave your screen session running in the background, and connect to the same session again at a later point. This enables you to start a long download, or compile the kernel, for example, and leave those tasks running in the background. To get started, just type screen. Your current session will reset and you'll see the screen intro text.

Press the Space bar and you'll be dropped to a command line that's identical to your original session, and you can use it in exactly the same way. Now press Ctrl+A followed by C. This will create a new session that runs in parallel to the previous one. You can test this by typing ls to list the contents of the current directory, followed by Ctrl+A and N.

This will switch to the next running session, which was the first we started with. It's from this point that you could start your download or your compilation. To drop back to the original command line leaving all your screen sessions running in the background, press Ctrl+A followed by D.

You can now close the current command line session, and even disconnect from the server if you wanted to. When you want to reconnect to the original screen session, just type screen -r. If more than one session is running, you'll see a list of PIDs, and you can manually choose which one to connect to.

-------------------------------------------------------------------------------------------------------

First published in Linux Format Issue 119

Liked this? Then check out 6 best orthodox file managers for Linux

Sign up for TechRadar's free Weird Week in Tech newsletter
Get the oddest tech stories of the week, plus the most popular news and reviews delivered straight to your inbox. Sign up at http://www.techradar.com/register

Follow TechRadar on Twitter