How to Edit a User's Profile and Startup Files (.bashrc, .profile)

How to Edit a User's Profile and Startup Files in Linux

Hey there! Welcome to ProgramGuru.org. Today, we're going to understand what happens every time you open a terminal or log in to your Linux system. We'll take a beginner-friendly tour of two very important files: .bashrc and .profile.

These files live in your home directory and help customize your environment — things like setting aliases, environment variables, and more. Let’s get into it!

1. What are .bashrc and .profile?

  • .bashrc: This file runs every time you open a new terminal window. It’s perfect for adding aliases, prompt settings, or custom functions.
  • .profile: This file runs at login for login shells. You can set environment variables here that you want available across the entire session.

2. Locate the Files

First, open your terminal and go to your home directory:

cd ~

Then, list the hidden files:

ls -la

-rw-r--r--  1 user user   220 Jul  2 10:21 .bash_logout
-rw-r--r--  1 user user  3771 Jul  2 10:21 .bashrc
-rw-r--r--  1 user user   807 Jul  2 10:21 .profile

You'll see both .bashrc and .profile listed there.

3. Editing the .bashrc File

Let’s say you want to add a custom alias. You can open .bashrc with your favorite text editor. We'll use nano here:

nano ~/.bashrc

Scroll to the bottom and add a line like this:

alias ll='ls -la'

Save and exit:

  • Press Ctrl + O to write changes
  • Then Enter to confirm
  • And Ctrl + X to exit nano

To apply the changes without restarting your terminal, run:

source ~/.bashrc

4. Editing the .profile File

Now let’s look at .profile. This is ideal for environment variables that need to persist across terminal sessions.

nano ~/.profile

For example, to add a new path to your environment:

export PATH="$PATH:$HOME/my-scripts"

Save and exit as before, then load the file:

source ~/.profile

5. When to Use Which File?

  • Use .bashrc for things you want active in every terminal window (aliases, shell functions).
  • Use .profile for things that should be set once per session (PATH, LANG variables).

6. Pro Tip: Back Up Before Editing

It’s a good idea to back up these files before making changes:

cp ~/.bashrc ~/.bashrc.bak
cp ~/.profile ~/.profile.bak

7. Summary

🎯 That’s it! Now you know how to edit your Linux user profile and startup files to make your command-line experience truly yours. Try adding a few aliases or environment paths and see how much smoother things become.

Thanks for watching this tutorial on ProgramGuru.org. If you found this helpful, don’t forget to share and subscribe for more Linux how-tos!