Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bash alias: command not found

Tags:

I'm trying to setup a simple alias to move me into my Developer folder on my machine. However, after setting it up, I get a weird error:

-bash: dv: command not found

I setup my alias in .bashrc like so:

alias dv='cd Developer/'

I use it by just typing dv, and then get that error. Does anyone see any syntax errors or something I'm missing here for aliases?

like image 685
Bill L Avatar asked Oct 14 '15 21:10

Bill L


People also ask

How do I fix bash command not found?

Install a package Sometimes when you try to use a command and Bash displays the "Command not found" error, it might be because the program is not installed on your system. Correct this by installing a software package containing the command.

Does alias work in bash script?

BASH Alias is a shortcut to run commands using some mapping. It is a way to create some shortcut commands for repetitive and multiple tasks. We create an alias in a BASH environment in specified files.


2 Answers

Run bash and then try the command.

Alternatively, put it in ~/.bash_profile which should be loaded automatically.

like image 84
pushkin Avatar answered Oct 13 '22 05:10

pushkin


.bashrc is only read on startup. If you just modified your .bashrc then you need to get a new shell or get your current shell to see the changes applied:

  • source ~/.bashrc in your current shell (although this may cause some startup items to run twice, which could cause other issues)
  • exec bash to get a new shell
  • just open a new Terminal window
like image 21
nneonneo Avatar answered Oct 13 '22 03:10

nneonneo