If you have ever downloaded a portable Linux application or needed to create a custom launcher, you might have come across directories like /opt, files ending in .desktop, or the sudo tee command. Many users run into these concepts without knowing what they mean or how they fit into a normal Linux workflow. This article explains these three topics in a clear and beginner friendly way so you can confidently manage third party applications on your system.
What the /opt Directory Is Used For
The /opt directory is a standard location in Unix based systems. Its name stands for "optional". It is used for installing software that is not part of the core operating system and not managed by your package manager.
Here is why software is placed in /opt:
- It keeps third party applications separate from system installed packages.
- It prevents files from interfering with
/usr/bin,/usr/lib, or other system directories. - It makes uninstalling easier. You can remove the entire application by deleting its folder.
A typical application stored in /opt looks like this:
/opt
application-name
application-binary
resources/
icons/
To move an extracted application to /opt, you usually run:
sudo mv extracted-folder /opt/application-name
This keeps your system clean and helps avoid permission related problems.
What a .desktop File Does
A .desktop file is what makes an application appear in your Linux system menu or launcher. It serves the same purpose as a shortcut on Windows or a dock item on macOS. Without a .desktop file, the system has no way of knowing how to start your application or what icon to display.
A .desktop file contains metadata and instructions, such as:
- The name shown in the application menu
- The command used to launch the program
- The icon image to use
- The type of application
- Optional categories to help organize menu entries
Here is a simple example:
[Desktop Entry]
Name=Sample Application
Exec=/opt/sample-app/start.sh
Icon=/opt/sample-app/icon.png
Type=Application
Terminal=false
Categories=Utility
Once this file is placed in /usr/share/applications/, it becomes available in the system launcher for all users. If you only want it for your user account, place it in ~/.local/share/applications/.
Why the sudo tee Command Is Useful
Most system directories are write protected. If you try using a normal redirection like:
echo "content" > /usr/share/applications/app.desktop
the operation fails because the redirection happens before sudo is applied.
This is where sudo tee helps. The tee command reads input and writes it to a file. When combined with sudo, it writes with elevated permissions, making it perfect for creating system files such as .desktop entries.
Example:
sudo tee /usr/share/applications/sample-app.desktop > /dev/null <<EOF
[Desktop Entry]
Name=Sample Application
Exec=/opt/sample-app/start.sh
Icon=/opt/sample-app/icon.png
Type=Application
Terminal=false
Categories=Utility
EOF
Why this works:
-
sudorunsteewith root privileges. -
teewrites to the protected file. - The
<<EOFsyntax feeds the file content directly from your terminal. - Redirecting output to
/dev/nullkeeps the terminal clean.
This approach avoids opening a text editor and is useful when providing installation instructions or automating setup steps.
Summary
The /opt directory is a safe place for storing third party or portable applications.
.desktop files integrate these applications into your desktop environment so they appear in your system menu.
The sudo tee command allows you to create system level files even when normal redirection is blocked by permissions.
If you’ve ever struggled with repetitive tasks, obscure commands, or debugging headaches, this platform is here to make your life easier. It’s free, open-source, and built with developers in mind.
👉 Explore the tools: FreeDevTools
👉 Star the repo: freedevtools

Top comments (0)