How to Change Your Application Icon from the Terminal in Linux

Change Icons From Terminal Featured

Previously, we showed you how you can easily change app icons in Gnome 3. However, some users still prefer to use their terminal for that. It’s doable, but, as expected, the process is a bit more complicated than a few mouse clicks. Let’s examine how you can change your application icon directly from your terminal.

Find Your Application’s Desktop Parameters

Each application that appears on our desktop has a .desktop configuration file. This comes in the form of a text file, filled with values that define how it should act, work, and look on the desktop. Among those, you can find a value for its icon.

Fire up your favorite terminal and move to the folder where you will find those settings files for all your applications, with:

cd /usr/share/applications/

Note that, depending on your distribution, this path can be different.

Change Icons From Terminal Cd To Folder

This folder may contain hundreds of entries. To find your way among them and locate the application you want to tweak, use grep to filter down the list. We wanted to check that a settings file for Firefox existed, so we used:

ls | grep firefox
Change Icons From Terminal Grep Program

Open the settings file in your favorite text editor – we used nano. Since the folder “/usr/share/applications” comes with restricted access, you will have to run your editor with sudo to edit any file. Our command was:

sudo nano /usr/share/applications/firefox.desktop
Change Icons From Terminal Sudo Nano

Swap the Icon

With the file open in your editor, it’s time to change the application’s icon. If you don’t already have an alternative icon, now’s the time to find one. Leave your editor window and jump for a while to your favorite browser.

Change Icons From Terminal Nano Settings

Search for a free-to-use icon in either PNG or JPG format. We used the query “firefox icon png” and went for the first result that came up.

Change Icons From Terminal Firefox New Icon

Save the file locally in a relatively simple path. Make sure to remember both the path and the filename, for you will need them soon. Our full path and filename is “/home/USERNAME/Pictures/icons/black_firefox.png”.

Change Icons From Terminal Download Locally

Move back to your editor and search for the string icon.

Change Icons From Terminal Search For String

Change Icon=CURRENT_ICON to point to the file you just downloaded. In our case, the original entry read Icon=firefox.

Change Icons From Terminal Original Icon Value

The updated version was:

Change Icons From Terminal Updated Icon Value

Save and Refresh

Save the changes (Ctrl + O), exit your editor (Ctrl + X), and wait. The next time your desktop updates, so will your application’s icon.

Change Icons From Terminal New Icon On Desktop

If it takes too long, you always have the option of logging out and then logging back in to force a full refresh.

Change Icons From Terminal Log Out

You can repeat the process for the rest of your applications to give your desktop a truly unique, personal look.

Now that you have changed the application icon from the terminal, it is also possible to manage your tasks or even search the Web from the terminal. And if your terminal is not working, try these fixes.

Odysseas Kourafalos
Odysseas Kourafalos

OK's real life started at around 10, when he got his first computer - a Commodore 128. Since then, he's been melting keycaps by typing 24/7, trying to spread The Word Of Tech to anyone interested enough to listen. Or, rather, read.

Subscribe to our newsletter!

Our latest tutorials delivered straight to your inbox