Linux has always been celebrated for its flexibility, power, and robust command-line interface. One of the most significant advantages of any Linux system lies in its efficient and varied Linux package management options. Users can install, update, or remove Linux packages by typing commands without wrestling with complicated installation procedures.
However, no matter how efficient your workflow is, there are always ways to make it faster and less error-prone. Mastering shortcuts, especially for tasks like copying and installing packages, can substantially streamline your day-to-day operations. That’s precisely what this guide aims to do: help you become more productive in a Linux environment by exploring various shortcuts, aliases, scripts, and best practices related to the “pkg install” command or its equivalents in other distributions.
Whether you’re a seasoned system administrator, a developer, or a curious newcomer, the techniques outlined here will save you time, reduce mistakes, and lead to a more consistent setup process across multiple systems. We will explore how package managers operate and why understanding them is crucial. You’ll learn how to create your aliases for repetitive tasks, employ powerful keyboard shortcuts to copy and paste commands, and automate bulk installations with shell scripts.
Finally, we will cover best practices to maintain a secure and updated system. By the end of this guide, you’ll be able to quickly and confidently manage packages on any Linux or FreeBSD environment, share your workflow with others, and avoid the pitfalls that often come with manual typing and repeated prompts.
A package manager is the backbone of Linux software distribution. It keeps track of the software (or “packages”) installed on your system, manages dependencies between packages, and allows you to update or remove them consistently. When a user runs a command like pkg install vim, the package manager fetches the necessary files from a repository, ensures all needed dependencies are in place, and installs the software reliably.
Every Linux distribution has its preferred package manager, each with a slightly different syntax:
Although the command names and options vary, the underlying principles are similar: straightforward commands allow you to install, remove, update, and search for packages.
Package managers can be categorized into two main types:
Whatever manager you use, learning the basic install/remove/update/search commands will help you maintain your system efficiently.
The command pkg commonly refers to the native package manager on FreeBSD. Commands such as pkg install, remove, and update are standard there. However, some Linux users also create a custom alias called pkg for convenience, mapping it to their system’s package manager. This maintains a uniform workflow across different systems, particularly helpful if you switch between Linux and FreeBSD frequently.
Running a pkg install in a typical Linux distribution might result in an error if the pkg utility isn’t installed. That’s because “pkg” is a FreeBSD tool by default. If you prefer using “pkg install” on your Linux machine, creating an alias redirecting pkg to apt or dnf can help unify your command set. This choice often simplifies scripts or repetitive tasks, especially when working with multiple servers spanning different operating systems.
Almost every terminal emulator in Linux supports a set of default shortcuts that can speed up your workflow:
These shortcuts differ slightly depending on your terminal or desktop environment but remain consistent across significant distributions.
Shortcuts aren’t just about key combinations; they also include user-defined aliases and shell functions. With aliases, you can take a frequently used command like sudo pkg install -y yourpackage and turn it into a simple one-word command such as pkgi yourpackage. Shell functions enable you to incorporate multiple commands, logic, or arguments into a single, callable function.
If you frequently repeat the same tasks, you can go beyond aliases by writing scripts. Shell scripts are text-based files that house a set of commands for a shell to execute and automate multi-step processes. They can handle logic, accept command-line parameters, and manage workflows, making them invaluable for system administrators and power users who frequently need to provision or update multiple systems.
An alias is created with the syntax:
alias shortcut="full command"

When you type the shortcut in the shell, it runs the entire command. This alias remains active only in the current session unless you add it to a shell configuration file like ~/.bashrc, ~/.zshrc, or a dedicated ~/.bash_aliases.
If you use FreeBSD’s native pkg, you might add something like:
alias pki="sudo pkg install -y"

to your/.bashrc or/.zshrc. Then, typing PKI vim automatically expands to sudo pkg install—y vim. You can reload your shell configuration by running source ~/.bashrc or opening a new terminal.
If you frequently manage packages, you might add aliases for removing packages, updating your system, or searching:
alias pku="sudo pkg update"
alias pkr="sudo pkg remove -y"
alias pksearch="pkg search"

Any distribution can leverage similar aliases by replacing pkg with the relevant package manager (apt, dnf, pacman, etc.). This approach keeps your workflow consistent and efficient, whether on Linux or FreeBSD.
Most graphical terminals support the following:
Alternatively, Shift + Insert may also paste, depending on your configuration. However, always review what you’re pasting and never unquestioningly trust code blocks from unverified sources.
In many Linux desktop environments, highlighting text is automatically copied to the clipboard in X11 systems, and a middle-click (mouse wheel) in the terminal pastes it. Right-clicking might show copy/paste options in a context menu. These features may vary based on your desktop environment or terminal emulator.
If you need more advanced clipboard functionality or work in a purely command-line environment:
For example, to copy the text “sudo pkg install vim” with xclip, you might do the following:
echo "sudo pkg install vim" | xclip -sel clip

You can then paste it into your terminal or any GUI application.
Shell scripts are files that contain a series of shell commands. A script often begins with a shebang line like #!/bin/bash, telling the system which interpreter to use. Use the following command to grant the file executable chmod +x filename.sh, permissions. You can then run it with ./filename.sh, automating tasks like installing multiple packages or running maintenance routines.
Consider this plain script setup.sh:
#!/bin/bash
echo "Updating package repository..."
sudo pkg update
echo "Installing essential packages..."
sudo pkg install -y vim git curl htop
echo "All done!"

Executing ./setup.sh updates the repository and installs the listed packages in one shot. This approach is especially valuable when repeatedly setting up new environments.
Scripts can include conditionals (if, then, else), loops (for, while), and command-line arguments to adapt to various scenarios. For example, you could iterate through a list of packages from a file, check if a package is installed before trying to install it or handle errors gracefully if a download fails.
Shell functions allow you to encapsulate more complex sequences of commands or logic right in your shell session or configuration file. A function looks like this:
myfunction() {
# commands go here
}
If you place this definition in ~/.bashrc or ~/.zshrc, it becomes permanently available whenever you open a terminal.
Suppose you frequently install multiple packages and update the system beforehand. You could define a function like:
pkgi() {
if [ $# -eq 0 ]; then
echo "Usage: pkgi package1 package2 ..."
return 1
fi
sudo pkg update
for package in "$@"; do
sudo pkg install -y "$package"
done
echo "Installation complete for: $@"
}
Typing pkgi vim git curl would then run a repository update and install vim, git, and curl in one go. You can expand such functions to include notifications or post-install scripts.
You can also customize the behavior of your functions with environment variables. For example, you might define a DEFAULT_PKGS variable containing a list of your favorite programs. The function can then read from that variable if no arguments are given, simplifying your workflow across different machines.
Linux allows chaining commands with &&, which executes the following command only if the previous one succeeds. For instance:
sudo pkg update && sudo pkg install -y vim

The install command won’t run if the update fails, preventing partial or botched installations.
Sometimes, you need to install numerous packages at once:
sudo pkg update && sudo pkg install -y vim git curl wget htop tmux
If you have an even more extensive list, place package names in a file:
vim
git
curl
wget
htop
tmux

Then run:
xargs -a packages.txt sudo pkg install -y
This reads each package from packages.txt and installs them automatically.
While installing packages is essential, so is maintaining them. You can create a simple alias that updates everything:
alias pkgupdate="sudo pkg update && sudo pkg upgrade -y"

Typing pkgupdate then quickly ensures you’re always on the latest versions of your installed software.
Using sudo for individual commands is often safer than operating as root full-time. If you issue many privileged commands in succession, you might temporarily switch to a root shell but always do so cautiously. Operating as root dramatically increases the risk of accidental system damage.
The process of mastering Linux is a process of continually becoming perfect. This way, you turn a sometimes lengthy and sometimes complicated package installation process into a solid, fast, correct, and reusable series of shortcuts, aliases, scripts, and functions. Whether a single application or a whole deployment, these tips help you save time and ensure minimal mistakes.
You’ve learned how Linux package managers work, how to use alias repetitive commands, harness powerful copy-paste shortcuts in the terminal, and build scripts that automate multi-step processes. You’ve also seen best practices for troubleshooting, handling permissions, and ensuring system security.
Here are some suggested next steps:
Eventually, they build up into personal sets of keys and applications that help increase efficiency in all the computers used. Sharing such information with teammates or other Linux community members can be beneficial in avoiding pitfalls. Use these methods to get the best results and arguably enjoy the best package management speed, and then one can enjoy a more robust and improved Linux.

Vinayak Baranwal wrote this article. Use the provided link to connect with Vinayak on LinkedIn for more insightful content or collaboration opportunities