Skip to content

Persisting aliases using .bashrc #1

@jesusff

Description

@jesusff

During the lesson this morning, a student wondered whether our alias definition would persist in the future sessions once it was defined. Remember we did, as an example:

alias lt="ls -ltr"

I mentioned the ~/.bashrc. This (hidden) file is located in your home directory and contains instructions which are executed during the bash session start. Thus, the way to persist comands such as aliases is to add them to this file. You can edit the file with your preferred editor or, as we learned this morning, use some bash instructions to do it:

echo 'alias lt="ls -ltr"' >> ~/.bashrc

Once the file is modified, you will need to start a new bash shell session to take effect, or source it into the current session:

source ~/.bashrc

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions