I am facing a problem with bash alias in Kali linux. Let me tell from the beginning.

I want to set some command to save time from writing it again and again. So, I used

nano /.bash_aliases

and set a command line

alias up='sudo apt update && sudo apt full-upgrade'

then I press Ctrl+V and hit y then hit Enter. I closed the terminal and open it. When I put up and press enter it shows:

up: command not found

Then I searched for solution and find one telling to do this.

gedit .bashrc

In the .bashrc file this is written without any '#'

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

Then I get into bash_aliases file with this command

gedit bash_aliases

And write this and save...

alias up='sudo apt update && sudo apt full-upgrade'

and close the terminal. In new terminal that same error happens. No command found. I have also do these in order to solve this problem:

  • reboot my pc

  • totally turned off and again turn on my pc

  • Try some random solutions like

     source ~/.bashrc
     bash -i -c my_alias

But I found the problem again and again. Here is a screen shot if I forgot to add any details. Thanks in advance. Screen Shot of error

  • 4
    Did you really edit /.bash_aliases or did you mean ~/.bash_aliases? What user did you edit the file as? You show a terminal where you are logged in as root. If you want this alias for root, why did you use sudo? Did you maybe not want it for root but for your regular user?
    – terdon
    Nov 8, 2021 at 11:53
  • 2
    You might want to read unix.meta.stackexchange.com/q/5360/4667 Nov 8, 2021 at 15:19
  • Kali Linux does not use bash by default. It uses zsh, which has its own set of initialization files. The file ~/.zshrc would be the one most relevant to this question.
    – Kusalananda
    Nov 8, 2021 at 17:20
  • 3
    let's start by noting that /.bash_aliases, ~/.bash_aliases, and bash_aliases (in any directory) are three different files. It's seldom useful to try a similar but different filename, or the same filename from a different directory. And based on the above comment, you might want to double-check which shell you're running. try echo "bash=$BASH_VERSION zsh=$ZSH_VERSION" and see what you get.
    – ilkkachu
    Nov 8, 2021 at 20:58

1 Answer 1



if [ -f ~/.bash_aliases ]; then
    . ~/.bash_aliases
  • this means if there's a file with the name of .bash_aliases then source that file. The . in bash is the same as source, example: . .bash_aliases or source .bash_aliases,the same just a shortcut.
  • ~/ is a shortcut for your home directory, meaning, /home/agent/.You're sourcing in the root directory. That's why you are logged as root in the terminal. When you source ~/.bash_aliases nothing happens because you are sourcing a file that doesn't have your alias up.
source /home/agent/.bash_aliases


don't do it as root, do it as your user[agent]
a. remove the .bash_aliases from the root / directory

sudo rm /.bash_aliases 

b. open with gedit your file .bash_aliases at HOME DIRECTORY and notice the . in front of .bash_aliases

gedit /home/agent/.bash_aliases` #and add your alias
alias up='sudo apt update && sudo apt full-upgrade'

c. source file .bashrc and this will automatically source the .bash_aliases
(remember the if [-f ~/.bash_aliases]; then at the beginning?)

source /home/agent/.bashrc

d. you can check your aliases with the command alias -p

  • 1
    Just FYI: in general, . is preferred over source since . is the standard, portable, POSIX name for the command and source is a bashism. Of course, this isn't a problem here since we're discussing bash-specific files, but just so you know, source is the alias, and . the main command.
    – terdon
    Nov 10, 2021 at 11:34

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .