Tips & Tricks for Power Users


This is a collection if various handy commands and shortcuts I’ve discovered while working with Ubuntu, Java, SVN, Maven, Git and other tools and applications at work and at home. They are usually tasks that I don’t do so often that I remember how, but do frequently enough to make it annoying to have to search Google every time. I’ve also discovered a few things that made me go “hey, that was really handy, why didn’t I know that years ago”. So I decided to create this page, partly to share the goodies and partly for my own sanity’s sake. It probably should have been a wiki, and maybe it will some day.

If you know a handy tip or trick for power-users, please get in touch. Thank you!

It’s worth noticing that all Ubuntu tips might work fine in other Linux distributions, but they are only tested on Ubuntu. Some of the commands and configuration changes mentioned below can seriously mess up your system. Always back up the files you plan to edit before you actually make any changes to them.

Ubuntu: Disable a startup of service

update-rc.d -f remove

Maven2: Get Jetty to load

I could not for the life of me get Jetty to load the file - even if it was available in the classpath. The solution was to set the location of the file as a system property when starting Maven.

mvn -Dlog4j.configuration=file:./target/classes/ jetty:run

Alternatively, you can configure this in your Jetty configuration on the Maven POM file inside the configuration element of the Jetty-plugin:


This way you will not have to add the -Dlog4j system property when starting Jetty from Maven.

Maven2: Debug web application running on Jetty

Handy when you have to debug a web application running on Jetty in Maven. First we need to export a few MVN_OPTS.

export MAVEN_OPTS="-Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,address=4000,server=y,suspend=n"

Then start Maven and Jetty in the normal way.

mvn jetty:run

SNV: View changes from a specific revision to the HEAD revision

(Yes, I’m this old.)

svn log -r  -v

For example

svn log -r 15384 -v

Linux: Check what graphics card is installed in the system

lspci | grep VGA

Ubuntu 10.04: Move the windows buttons back to the right

This tip is Ubuntu 10.04 specific, but it’s very likely that it will also work on 10.10 and any later releases with the windows buttons moved to the left. Here’s how to move them back to the right.


Find to the folder apps/metacity/general and change the button_layout item value to menu:maximize,minimize,close.

Ubuntu: Control screen brightness on a Lenovo T510

If you have a Lenovo T510 with a Quadro NVS 3100M graphics card, like me, you might have some serious issues with controlling the screen brightness - also just like me. Using the Fn key plus the brightness controls doesn’t do a thing, expect for showing you a screen indication that the brightness should change. To fix it, simply add the following line to the Device section in /etc/X11/xorg.conf:

Option "RegistryDwords" "EnableBrightnessControl=1"

Save and restart X (or simply restart your laptop if you don’t know how to restart X). It’s quite possible that you have to do this every time the NVIDIA drivers are updated, but that’s OK. We still love them for providing top notch drivers for Linux.

Maven2: Building without running tests

Of course you shouldn’t skip running the tests when you build a project, but sometimes you have no choice. Like when someone on your team checked in a code change that breaks the tests and left for a dentist appointment and you can’t figure out what the hell is going on. To skip the tests, add -Dmaven.test.skip=true, like this:

mvn -Dmaven.test.skip=true clean install

Linux: What version of my Linux distribution am I running?

lsb_release -a

Windows: How to modify the routing table

At work we’re currently buried knee deep in testing. During some of the manual tests, we want to simulate network connection problems to see how the application will behave. In a perfect world, this would be a matter of unplugging the network cable, but we’re using terminals connected to virtual Windows servers. So, how to simulate network problems in such an environment? Easy as pie! First, find the IP of the server the application will normally try to connect to. In this case, we use Then you manually corrupt Windows’ routing table with the following command.

route add MASK

Make sure the last IP address is an IP that is on the same subnet as the first IP and that it’s not in use, or at least a server that doesn’t have the same service running as the server your application would normally connect to - or else you will start to rip your hair out. All requests to will now be routed to and you have yourself a good old simulated network problem

To clear up the mess, simply remove the entry from the routing table with the following command.

route delete

Linux: How to batch resize images from the command line

For this neat trick, we’ll use ImageMagick. It’s mostly likely already installed on your system, if not you can install it by running this command:

sudo apt-get install imagemagick

When that is done, navigate to the directory containing the images you want to resize. The command below will overwrite the original images, so make sure you have backups before you start! Run the following command to resize all images with an JPG extension to 25% of their original size:

mogrify -resize 25% *.JPG

It should also be possible to substitute 25% with absolute pixel values if that is necessary, like this:

mogrify -resize 640x480 *.JPG

Maven2: Dependency Scopes

I can’t seem to ever remember all the Maven dependency scopes and what they mean. So here they are:

IntelliJ IDEA: Compilation fails with the message “Process terminated with exit code 3”

The solution to this problem is to give IntelliJ more heap memory for compiling. You can increase this value in Settings | Compiler (source)

Microsoft SQL Server: Removing -2 SPID locks

If you end up with threads in SQL Server that is blocked by another thread with SPID -2 you either have to restart the database server or kill the offending SPIDs with some SQL magic. The latter approach is preferred since it won’t terminate all connection to the database. Note that you need access to master..syslockinfo to do this. First, run the follow query:

SELECT req_transactionUOW
FROM master..syslockinfo
WHERE req_spid = -2
AND req_transactionUOW > '00000000-0000-0000-0000-000000000000'

This will give you the req_transactionUOW of every -2 SPID. Next, kill the transaction lock (I’m not sure what you are actually killing) with the following command:

KILL 'F600C62D-3FC4-4210-9EF2-74FE9DBEF5D6' --Replace the ID with one in your list.

This should release any locks in your database held by a -2 SPID.

Java: SEVERE: WSS1906: Invalid key provided for encryption/decryption

I got this error when working on connecting a Java client to a MCF webservice that required the use of a secure connection, but you might get a similar error when working on other cryptography-related tasks. To solve this you have to install the strong encryption JARs from Oracle. Download from the Java download page. I’ve not included a direct link to the download itself because Oracle tend to change the URLs.

Maven: Increase JVM Heap Size and PermGen Space (Windows)

Open a command line window and type the following:

set MAVEN_OPTS=%MAVEN_OPTS% -Xmx1024m -XX:MaxPermSize=512m

This will set the JVM heap size to 1024 megabytes. Modify the number based on your needs. The %MAVEN_OPTS%-part makes sure that other MAVEN_OPTS that you have defined are not removed.

Java: The Most Common Java Keytool Keystore Commands

Note: If you prefer to use a graphical user interface to edit the keystore, I recommend KeyStore Explorer.


Linux: Check disk space

df -h
ln -s

Windows: How to flush DNS cache

ipconfig /flushdns

DNSMasq: Routing DNS names to local IPs

This can be very convenient if you, like me, host a server on your local LAN and have Apache configured with virtual hosts on different domains. I have my router with DD-WRT and DNSMasq configure in such a way that if I do lookups for any of my domains while I’m on my local network, I get routed to the local IP and not the public IP, which would just screw tings up.


You can add as many domains as you wish (source).

Glassfish: How to prevent the damn admin console from hanging

This is caused by the admin console looking for updates when you log in. If your server is not connected to the internet, you’re behind a proxy that has not been configured or Oracle’s update servers are down, login in can take ages or never happen at all. Here’s how to get rid of this huge annoyance:

  1. In $GLASSFISH_HOME/glassfish/modules, rename the file console-updatecenter-plugin.jar to console-updatecenter-plugin.jar.old.
  2. Restart Glassfish.

You should now be able to log in quickly no matter the state of your internet connection and Oracle’s servers (source.)

Glassfish: How to enable secure admin

From the command line:

asadmin --host localhost --port 4848 enable-secure-admin

Glassfish: Admin REST services return 400 Bad Request

So, you had everything working in Glassfish 3.0, but after an upgrade to 3.1 all of your requests to the admin REST services return 400 Bad Request? Try to add the following header to your request:

X-Requested-By:GlassFish REST HTML interface


Maven: How to build a specific submodule and its dependencies

Example: You have a huge Maven project with plenty of modules that uses intricate internal dependencies but you only want to build parts of it (say, the web services, but not the thick client). Building the correct modules can be a pain and building the entire project to make sure all dependencies are built can take forever. Thankfully, the Maven reactor can analyze your POM files and automagically build only the necessary modules in your project:

mvn -pl -am


mvn clean install -pl submodule/another-module,submodule2/the-second-module -am


Maven: Continue on test failure

mvn -Dmaven.test.failure.ignore

Eclipse: Wipe all cached data from the command line on startup

Using Eclipse is a painful experience, but every now and then you’re forced into using it. Occasionally and without any warning, Eclipse tends to go full “I can’t let you do that, Dave” and refuses not work properly until you wipe its memory. Close Eclipse and run it again from the command line with the -clean flag (source) to get the application to behave again.

eclipse -clean

OpenWrt: Upgrade all packages

Log in to the router as root via SSH, and run the following two commands.

opkg update
opkg list-upgradable | cut -f 1 -d ' ' | xargs opkg upgrade

There’s a good chance the router has to be rebooted for some of the updated packages to be effective.

Quickly create favicons for your website

If you need to create favicons, a service like can be quite handy. Upload a picture, and it’ll generate a bunch of different favicons, and provide you with instructions on how to use them.



Setup a private Git server on Ubuntu 18.04

Read this article. Or use this link if the article is gone from the web.

Quickly Show/Hide Hidden Files on macOS Sierra, OS X El Capitan & Yosemite

CMD + SHIFT + . (source)

Set your own custom background during Microsoft Teams video call


Convert ASCII to Hex

…and other free text conversion tools. Binary, BASE64, decimal, ROT13, URL encoded, HTML entities:

Show the Emoji Keyboard on Mac

CTRL + CMD + SPACE aka control + command + SPACE aka ^ + ⌘ + SPACE depending on what keyboard you´re using.

Show the Emoji Keyboard on Windows

WIN + . or WIN + ;

See all URLs that has archived from a site

(The Internet Archive, The Wayback Machine)*/* (source)

Format USB Drive in Linux Command Line

df -h
sudo umount [device name]
sudo mkfs.vfat [device name]


Remap keys in Pop!_OS and Solus

This answer doesn’t really contain enough details to properly swap all keys, it’s more for my own future reference. I wanted to swap two keys, the key for | and Β§ with the key for < and >.

Add the following to ~/.xmodmap-keys:

keycode 0x31 =  less    greater less    greater onehalf threequarters   onehalf threequarters
keycode 0x5E =  bar     section grave   asciitilde      brokenbar       paragraph

Add the following to ~/.config/autostart/swap-keys.desktop:

[Desktop Entry]
Name=Swap keys
Exec=xmodmap /home/HOME_DIR/.xmodmap-keys

Replace HOME_DIR with your Pop!_OS username. The keys will now swap when Pop!_OS boots.

If this doesn’t work as expected, another possible solution is available in the Ubuntu Community Help Wiki. (Intern Archive mirror).

Change Function Key behavior in Pop!_OS, Ubuntu, and Solus

This section of the document describe how to change the behavior of ‘fn’ key to better match what user expect.

Here a description of each behavior :

  1. 0 = disabled : Disable the ‘fn’ key. Pressing ‘fn’+‘F8’ will behave like you only press ‘F8’
  2. 1 = fkeyslast : Function keys are used as last key. Pressing ‘F8’ key will act as a special key. Pressing ‘fn’+‘F8’ will behave like a F8.
  3. 2 = fkeysfirst : Function keys are used as first key. Pressing ‘F8’ key will behave like a F8. Pressing ‘fn’+‘F8’ will act as special key (play/pause).


The following command will change the behaviour of ‘fn’ key with immediate effect, but restarting will reset the configuration:

echo 2 | sudo tee /sys/module/hid_apple/parameters/fnmode

Permanently in Pop!_OS and Ubuntu

Methods described in this section will change the behavior permanently.

Run the following command to append the configuration line to the file /etc/modprobe.d/hid_apple.conf creating it if necessary:

echo options hid_apple fnmode=2 | sudo tee -a /etc/modprobe.d/hid_apple.conf

Trigger copying the configuration into the initramfs bootfile.

sudo update-initramfs -u -k all

Optionally, reboot.

sudo reboot

Upgrade Pi-hole

Pi-hole is a Linux network-level advertisement and Internet tracker blocking application which acts as a DNS sinkhole. You can read more about how it works and how to install and use it in my post How To Install Pi-hole on a Headless Raspberry Pi.

To upgrade your Pi-hole installaton to the most recent version, run the following command:

pihole -up

Change mouse wheel scroll speed in Firefox

  1. Open a new tab in your Firefox browser and type about:config.
  2. In the Search bar, type mousewheel.min_line_scroll_amount.
  3. Double click on the entry and change the value from 5 to 60.
  4. Refresh or open a webpage a check if you’re comfortable with the new scroll speed. If not, experiment with other values.


Disable zsh autocorrect entirely

Add this to your .zshrc:

unsetopt correctall

Manually install phpMyAdmin in Ubuntu

Manually Installing phpMyAdmin (Ubuntu 18.04) (Internet Archive mirror).

Extract from a dar archive

dar -x ARCHIVE_NAME.master

I can’t for the life of me figure out how to get dar to extract to a specific source directory, so everything is extracted in the same location as the archive. Source: Dar Manual.

Keychron keyboard on Manjaro: Enable Bluetooth fast connect config

If your Keychron keyboard takes too long to connect to your computer over Bluetooth (for example, when you press a key and wakes it up), you can enable the Bluetooth fast connect. This usually makes the keyboard connect in less than 1 second.

  1. Edit the file /etc/bluetooth/main.conf
  2. Uncomment FastConnectable config and set it to true: FastConnectable = true
  3. Uncomment ReconnectAttempts=7 (set the value to whatever number that you want)
  4. Uncomment ReconnectIntervals=1,2,4,8,16,32,64

Some users have reported issues with Bluetooth headphones such as popping audio and general instability. If that happens, just reverse what you did above.

This might also work for other Linux distributions.


Backup a Docker volume

Run the following command on the host:

docker run --rm --volumes-from SOURCE_CONTAINER -v $(pwd):/backup ubuntu tar cvf /backup/backup.tar /SOURCE_MOUNT


docker run --rm --volumes-from my_database_container -v $(pwd):/backup ubuntu tar cvf /backup/backup.tar /db_storage

When the command completes and the container stops, you are left with a backup of your db_storage volume. It’s located on the host, in the directory where you ran the command.


Restore a Docker volume

docker run --rm --volumes-from DESTINATION_CONTAINER -v $(pwd):/backup ubuntu bash -c "cd DESTIONATION_MOUNT && tar xvf /backup/backup.tar --strip 1"


docker run --rm --volumes-from my_new_database_container -v $(pwd):/backup ubuntu bash -c "cd /db_storage && tar xvf /backup/backup.tar --strip 1"


Firefox: Permanently turn off the carret browsing keyboard shortcut

In the address bar, type about:config, search for accessibility.browsewithcaret_shortcut.enabled and change the value to false.



It looks like you're using Google's Chrome browser, which records everything you do on the internet. Personally identifiable and sensitive information about you is then sold to the highest bidder, making you a part of surveillance capitalism.

The Contra Chrome comic explains why this is bad, and why you should use another browser.