{
    "title": "How to create Bash aliases in Fedora",
    "slug": "how-to-create-bash-aliases-in-fedora",
    "excerpt": "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.",
    "body": "Creating your own [Bash aliases](https://tldp.org/LDP/abs/html/aliases.html) is a relatively easy process. That said, I recently switched my desktop linux distribution from [Debian](https://debian.org) to [Fedora](https://getfedora.org/en/workstation/) and there are subtle differences. On Debian, the default `.bashrc` file has the following entry:\n\n```\n# Alias definitions.\n# You may want to put all your additions into a separate file like\n# ~/.bash_aliases, instead of adding them here directly.\n# See /usr/share/doc/bash-doc/examples in the bash-doc package.\n\nif [ -f ~/.bash_aliases ]; then\n    . ~/.bash_aliases\nfi\n```\n\nThe 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.\n\nIt works slightly differently with Fedora, where the default <code>.bashrc</code> file has this entry:\n\n```\n# User specific aliases and functions\nif [ -d ~/.bashrc.d ]; then\n\tfor rc in ~/.bashrc.d/*; do\n\t\tif [ -f \"$rc\" ]; then\n\t\t\t. \"$rc\"\n\t\tfi\n\tdone\nfi\n```\n\nThe 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.\n\nSo, 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.\n\n```\nmkdir -p ~/.bashrc.d && touch $_/aliases\n```\n\nEdit the newly created aliases file and write your aliases as required.\n\nNone 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.",
    "tags": [],
    "published_at": "2022-06-14 11:48:00",
    "url": "https://blog.philipnewborough.co.uk/posts/how-to-create-bash-aliases-in-fedora"
}