Building Pyramids

Matt Polnik's blog

Linux Productivity Tricks and Tips


This article is a the collection of Linux customizations and productivity tricks. Instead of looking for relevant commands in my memory and in the internet every time I need them I decided to organize them here. I hope you will find them useful too.

The command line examples presented below were tested on Debian Jessie. They should be portable to Ubuntu and other Linux environments from Debian family.

I am going to keep this post updated, so you may consider subscribing to the RSS channel.

Disable sudo password question

How many times have you been asked your sudo password? Such question in this context does not considerably improve security of your system. You have already managed to login and you just have issued a command, so are staying active.

The sudo securicy policy plugin is configured using the sudoers configuration file, stored by default in the /etc/sudoers location.

The sudoers file must be edited by the visudo command executed as root.

sudo visudo

Add the following rule with your username to the sudoers file. After the successful update the user will be allowed to run any command as anyone without beging prompted for a password.


See the sudoers man pages to learn more about the sudo security policy plugin and configuration options available through the sudoers file.

man sudoers

Setup the SSH agent

Another workflow that often requires a password is accessing protected resources such as private Git repositories. Fortunately, service providers like GitHub or BitBucket support secure shell (SSH), a viable alternative that simplifies authentication process.

This tip explains how to add your SSH identity to the SSH agent automatically every time you open to the Bash shell and release it as soon as your session expires.

If you are new to SSH I strongly encourage you to read an excellent article An Illustrated Guide to SSH Agent Frowarding which explains principles behind secure shell that later will help you efficiently troubleshoot problems and avoid common pitfalls that breach security of your system.

This section assumes that you have already a SSH key pair: id_rsa and saved in ~/.ssh directory. If you have not generate it yet see the the GitHub tutorial which explains how to create a new SSH key pair.

Firstly, start the SSH agent and register your identity by adding the following snippet to the .bashrc file.

if [ -z "$SSH_AUTH_SOCK" ] ; then
    eval `ssh-agent`

Secondly, append the command below to the .bash_logout file. It kills the SSH agent associated with your terminal session as soon as you close it.


Finally, register the SSH public key in your service provider. It requires you to add the public SSH key fingerprint in your account.

Use the following command to print your public SSH fingerprint and refer to your service provider instructions where it should be saved.

ssh-keygen -lf ~/.ssh/

Enable autologin

This tip assumes your computer cannot be accessed by unauthorized person. You may consider it for your home PC. Applying it on an office workstation is certainly looking for trouble.

Automatic login is tightly coupled to your virtual desktop environment. The example below applies to Gnome 3. Other environments follow similar pattern, but use different locations for configuration files.

Open Gnome Desktop Manager (GDM) configuration file and enable automatic login for your username.

sudo vim /etc/gdm3/daemon.conf
# GDM configuration storage
# See /usr/share/gdm/gdm.schemas for a list of available options.

# Enabling automatic login
AutomaticLoginEnable = true
AutomaticLogin = username

Adjust dynamic scaling factor of CPU

It is unlikely that you are utilizing your CPU at full speed without changing default settings. Most common CPU power schemes are set to run at less-than-maximum frequency to conserve power and keep your fan silent. It is considered that this policy also increases hardware lifetime, though the actual savings are difficult to quantify.

If you are running CPU intensive calculations on your PC and want results as soon as possible adjusting effective CPU frequency temporarily should not hurt.

Firstly, try to asses if increasing CPU frequency makes sense in your context. If your calculation is IO intensive or the CPU is a few generations behind the game may not be worth the candle.

To see the detailed information of your CPU open the /proc/cpuinfo file or run the lscpu command.


cat /proc/cpuinfo

Proceed by installing the cpufrequtils package. It contains a collection of command line utilities that allow for a temporary adjustment of the effective CPU frequency.

sudo apt-get install cpufrequtils

Check current frequency of each core and the power saving scheme in use. The latter is also known a governor.


The output should include the current governor which may be powersave or ondemand and other available options.

Finally, switch temporarily all cores to the performance governor policy.

sudo cpufreq-set -r -g performance

The governor policy will fall back to the default option after reboot. For a persistent change edit the /etc/init.d/cpufrequtils file.

CPU frequency adjustment heavily depends on your Linux distribution. For more information on the topic search the system documentation using the CPU frequency scaling or CPU dynamic scaling keywords.

Check where the package is installed on the machine

StackOverflow is full questions where to find the location of particular binary or configuration file. Fortunately, one does not have to cut his teeth on maintaining a Linux repository to answer them.

Firstly, you may not have access to the operating system of your colleague or a StackOverflow user you are supporting. The fastest option in that case is searching the package repository for that Linux distribution. For example, Apache 2 HTTP server binaries and configuration files on Debian Jessie can be listed using the link:

If you have direct access to machine package manager should come to rescue.

Assuming that the Apache HTTP server is installed the following Debian package manager command lists its content.

dpkg --listfiles apache2

If you would like include all packages that start with apache name use the query below.

dpkg --listfiles 'apache*'

Another useful dpkg query options are printing all packages installed in the system and listing detailed information about a package.

dpkg --list
dpkg --status apache2

The list of all packages installed in the system is also stored in the /var/lib/dpkg/available file.

Some binaries though are not distributed using *.deb packages and therefore Debian package manager is clueless about them.

For finding their absolute paths use the whereis or which command. The former

In that case use the which command for binary utilities and locate for libraries. The former also prints location of source files and man pages.

whereis curl
which curl

On the other hand, if you are building a C or C++ project and would like to know which archive (.a) and shared object (.so) libraries are available list dynamic linker run-time bindings using the command below.

sudo ldconfig -v

Finally, let’s mention general purpose utilities for querying file system.

locate is a command line utility for querying filepaths by pattern. Instead of traversing filesystem directly is uses a file name database. It should return fast and does not negatively affect IO performance. The robustness is paid by accuracy. Results may not include file system items that have been removed or added recently. If you do not get results you expect to see refresh the file name database using the updatedb command or use a complement command - find.

sudo updatedb

locate --ignore-case libcurl

find runs the search in a file system. It consumes more IO resources than locate, but prints most up to date results. It also supports more sophisticate set parameters that limit the depth of a search tree, include time of modification or the file size. The example below runs a case insensitive search of the curl filename starting from the root of the filesystem. The command is expected to print access denied errors for protected directories therefore its error output is redirected. Refer to the man pages for the full description of the find command.

find / -iname 'curl' 2>/dev/null

I would be pleased to hear your comment if you spot an error in the article. More Linux-related articles are expected to appear in the following weeks. I am going to cover managing multiple Linux machines effectively, disaster recovery like loosing root password and useful commands that you may have missed.