Skip to main content

How to create Bash aliases in Fedora

Creating your own Bash aliases is a relatively easy process. That said, I recently switched my desktop linux distribution from Debian to Fedora and there are subtle differences. On Debian, the default .bashrc file has the following entry:

# Alias definitions.
# You may want to put all your additions into a separate file like
# ~/.bash_aliases, instead of adding them here directly.
# See /usr/share/doc/bash-doc/examples in the bash-doc package.

if [ -f ~/.bash_aliases ]; then
    . ~/.bash_aliases
fi

The above tests as to whether or not the .bash_aliases file exists in the user's home directory and if it does exists, it loads any aliases held within it. I like the simplicity of this.

It works slightly differently with Fedora, where the default .bashrc file has this entry:

# User specific aliases and functions
if [ -d ~/.bashrc.d ]; then
	for rc in ~/.bashrc.d/*; do
		if [ -f "$rc" ]; then
			. "$rc"
		fi
	done
fi

The above tests for the existence of the .bashrc.d directory within the user's home directory, before attempting to load every file within that directory. I like this approach too.

So, to create a Bash alias under Fedora, first create the .bashrc.d directory in your home directory (it does not exist by default) and then create a new file in that directory. The file can be named anything, but you probably want to call it something relative, like aliases. This can be achieved with the following command.

mkdir -p ~/.bashrc.d && touch $_/aliases

Edit the newly created aliases file and write your aliases as required.

None of this is super important as you can edit your .bashrc file to load your aliases however you want, I just find these little nuances between Linux distros quite interesting.

View as: JSON Markdown

If you enjoyed this post or found it useful, you can subscribe to my RSS feed.

Similar posts

  1. My Z shell setup

    A quick walkthrough of my Z shell setup for Debian servers and macOS, including Pure prompt, autosuggestions, history search, npm completion, SSH host completion, aliases, and a few cross-platform helper commands.

    zsh linux macos fish
  2. Debian 13 (Trixie) server set-up

    A practical, production-ready guide to setting up a Debian 13 web server using Apache, PHP-FPM, and MariaDB. Covers installation, performance tuning, security basics, and modern best practices.

    debian apache mariadb php fail2ban ufw
  3. Upgrading from Fedora 41 to Fedora 42

    If someone were to ask me which Linux distro has provided the best desktop experience, I wouldn't hesitate to answer: Fedora Workstation 41. So of course I upgraded to Fedora 42.

    fedora linux
  4. How to install PHP extension for Microsoft SQL Server under Fedora

    I found myself needing to connect to a Microsoft SQL Server via a PHP application running under Fedora. Finding concise details about installing the necessary drivers and extensions was not easy, so here is a blog post detailing how I did it.

    php microsoft fedora mssql sql linux
  5. GNOME menu entries for Visual Studio Code projects

    I work on a large number of code projects and I wanted a quick way to open any of my projects in Visual Studio Code, my preferred code editor. I figured the quickest way to do this under GNOME would be to create a .desktop file for each project directory.

    gnome vscode linux
  6. How to set-up WatchGuard VPN with IKEv2 under Debian and Fedora

    A blog post detailing how to set-up WatchGuard VPN with IKEv2 under both Debian and Fedora Linux. This guide works for me under Debian 12 (bookworm) and Fedora 40/41, but your mileage may vary depending on how your VPN service is configured.

    debian vpn watchguard ikev2 fedora ipsec
  7. My Debian 12 (bookworm) server set-up

    I've been running Debian on my servers for years. It's dependable. I guess my server set-up is pretty common, consisting of Apache, PHP and MariaDB, but I figure it is still worth sharing details of how I provision my servers.

    php composer mariadb apache debian linux node fish
  8. My Debian 12 (bookworm) desktop set-up

    Creating a good Debian desktop experience is not too difficult, thanks to the excellent work of the Debian developers, but I thought it might be interesting to share how I set-up my Debian systems.

    debian linux
  9. Upgrading from Fedora 40 to Fedora 41

    A post describing my first experience of upgrading a Fedora installation. TLDR: The upgrade went smoothly and Fedora continues to impress me.

    fedora linux
  10. Calling Puppeteer via PHP

    A blog post detailing an issue where a Puppeteer screenshot script, triggered through a PHP application using CodeIgniter, stopped working due to Chromium not starting under the Apache www-data user on Debian.

    php javascript node debian apache
  11. Desktop Linux and compiling from source

    If anyone is in any doubt as to whether you need to compile any software from source in order to use desktop Linux, you really don't.

    linux
  12. Switching desktop Linux from Debian to Fedora

    Last week I switched the operating system on my daily driver (Lenovo ThinkPad T14s) from Debian 12 to Fedora 40. In this post I write a little about why I switched and how the switch went.

    debian linux fedora
  13. Firefox Nightly as a daily driver

    I believe that it's really important to support and use Firefox. Not only do I think that Mozilla understand/support user's privacy more than Google, but I also think it's important for the health of the web that more than one option exists when it comes to rendering engines. Also, it's a really good web browser.

    debian chrome firefox mozilla
  14. Single computing device lifestyle

    I've recently decided to simplify my life by moving away from using multiple computers to using a single laptop. What are the main advantages and disadvantages of using a single computer?

    debian thinkpad
  15. Redux

    As a web developer, I like to build and rebuild websites. My own website is no different.

    markdown fediverse mastodon codeigniter php bootstrap jquery debian
  16. How to set-up a crontab file

    In Linux, Cron is a daemon/service that executes shell commands periodically on a given schedule. Cron is driven by a crontab, a configuration file that holds details of what commands are to be run along with a timetable of when to run them. Knowing how to use Cron is key to mastering automation with Linux.

    cron automation linux