'Bash alias: command not found
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?
Solution 1:[1]
Run bash and then try the command.
Alternatively, put it in ~/.bash_profile which should be loaded automatically.
Solution 2:[2]
.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 ~/.bashrcin your current shell (although this may cause some startup items to run twice, which could cause other issues)exec bashto get a new shell- just open a new Terminal window
Solution 3:[3]
Error:
-bash: alias: cd /opt/logs: not found alias log= "cd /opt/logs"
Solution :
Ensure there is no space after the = symbol
log="cd** /opt/logs"
Solution 4:[4]
Make sure the following line is present inside .bash_profile
test -f ~/.bashrc && . ~/.bashrc
If not then add it to the beginning. This code is used by .bash_profile to load up .bashrc.
If this line is not present inside .bash_profile then anything you type inside .bashrc will not be loaded.
Solution 5:[5]
Another solution is to call your command with bash using -i -c option:
bash -i -c my_alias
Solution 6:[6]
I had the same issue but the weirdest solution. I was copying it from Windows machine to OS X and for some reason, the spaces used were different and when I replaced them with normal spaces, it worked. It was not tabs, I have no idea what it was.
Solution 7:[7]
i had a similar issues while creating an alias for mongoDB; You can try putting the whole path inside .bash_profile in your home directory like so :
alias mongo="/c/Program\ Files/MongoDB/Server/5.0/bin/mongo.exe",
as i had done in my case; it worked perfectly after this
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | |
| Solution 2 | nneonneo |
| Solution 3 | Divyang Desai |
| Solution 4 | Sparkzz |
| Solution 5 | Lucas Coelho |
| Solution 6 | Ev0oD |
| Solution 7 | Abhronil Adhikari 5097_ece-6 |
