Source Bashrc has no effect - bash

So I am extremely new to any kind of software development. Last week I installed Bash on Ubuntu on Windows to work on some coding for work. Unfortunately I did something wrong and had to reinstall everything.
I was almost done with reinstalling Bash on Ubuntu, when I accidentally closed the screen. Now I get exactly the same errors as previously, but I definately do not want to reinstall this again...
So what changed? Before my terminal was colored purple and green. Now, I only get white colors in the terminal. It looks something like this:
Image of terminal
Furthermore, after googling it said to apply
source ~/.bashrc
But then I get the error: "No such file or directory". Bash is installed because it does actually give
which bash -> /bin/bash
I also read that perhaps it could be my path, where $PATH gives me
bash: /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/mnt/c/Program: No such file or directory
I was hoping that you'd have an idea what could be wrong, and best how to resolve it. I definately do not want to reinstall it AGAIN, because it took me too long already.
Hope you can help me!
Cheers,
Wessel

As stated by Jack, the configuration for bash should be in ~/.bashrc or similar.
What files are listed if you enter this command?
ls -a ~/
If you see .bashrc, you can edit it.
Here some ideas on colouring your prompt
https://www.howtogeek.com/307701/how-to-customize-and-colorize-your-bash-prompt/

Related

Opening terminal in current directory

I am attempting to set up the behavior described in the title. For reference, there is an answer which solve this for emacs. I however use DWM/ST and Zsh.
The solutions I have clumsily tried to come um with include modifying the .zshrc file in the with the following lined:
cd $pwd
I have realized this does not make sense as the path displayed by this instance of pwd will in fact be the path in which the terminal itself is opened, which is $HOME. Maybe the solution is messing with ST, but I have not had any ideas of how to do do so. Any help would be appreciated.
it depends on the terminal emulator that you're using: for instance
$lxterminal --working-directory=./
Works for zsh in my manjaro distribution.
in Ubuntu i might use:
$x-terminal-emulator ./

Terminal -bash: command not found errors [duplicate]

This question already has an answer here:
How to restore .bash_profile on a mac? None of my unix terminal are working [closed]
(1 answer)
Closed 2 years ago.
I messed up something in my programming a few days ago that screwed up my terminal. My terminal now gives me the a bash error message with basic functions like ls, cd, or ssh. The error looks like this: -bash: ls: command not found , where the "ls" can be replaced with any shell command.
The only way I have found to make my terminal function, is by inputting: export PATH="/usr/local/bin:/usr/bin:/bin:/usr/sbin" into ever terminal window I open, which can get very tedious.
It also refuses to run Python or Jupyter unless I type the aforementioned command in the terminal window first.
Go files also fail to run in terminal, and gives me a similar error message: -bash: go: command not found. This can be overcome by inputting: export PATH=$PATH:/usr/local/go/bin into the terminal window first.
I'm really worried about what is going on in my computer, and need my terminal to keep functioning in order for me to finish and pass this course (introduction to computer programming). Does anyone have any ideas as to what the problem may be, and how I could go about solving it?
Any help/advice would be greatly appreciated!!!
EDIT: I'm not sure if it is relevant, but I am using a Mac, and these problems started to occur after I attempted to download pygame (I say "attempted" because I never got a working version of pygame installed, though I did download several things in the process (XQuartz and a bunch of stuff from homebrew).
Check your .profile or .bashrc: one of those files might initialize your PATH incorrectly.
Set your PATH manually, then cd ~, and edit those two files to fix your PATH.

-bash: /bin/bash:: No such file or directory

I am on Windows 10v1803, and i have WSL with Ubuntu installed and working well.
Recently, i was in vim, and appending some aliases to my .bashrc. After I finished editing, I wanted to exit without saving, did the usual Control-C, and instead of :q! I did !:q (Yes, silly typos). I realized my mistake, did the correct :q! and exited.
I came back ~1hr later, to make those 2 changes (below) and noticed that on startup, I got the error
-bash: /bin/bash:: No such file or directory
along with the normal startup
suda#suda:~$
Everything proceeds normally, but i'm concerned as to what that error means.
And, there is nothing that I could find on this apart from reinstall bash, which i have done 5 times, and makes no difference.
I proceeded to add the 2 aliases to my .bashrc, and everything works fine...
Some help as to what is happening here please?
And if you're wondering, these were what i was adding onto my .bashrc:
alias cls="clear"
alias md="mkdir"
Also, I feel that this won't go under askubuntu. If i'm wrong, please do tell me.
Edit: Here's an image
The error message is:
-bash: <file>: No such file or directory
Check that your script doesn't start with
#!/bin/bash:
and that you do not invoke /bin/bash: elsewhere, either.
(because, indeed, bash: should not exist in /bin)

Bash issue when open terminal [duplicate]

This question already has an answer here:
How to restore .bash_profile on a mac? None of my unix terminal are working [closed]
(1 answer)
Closed 2 years ago.
I receive this error message each time I launch terminal:
-bash: =/usr/local/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin: No such file or directory
You have recently edited one of your shell's startup files and introduced an error.
Probably, ls -lart ~/.bashrc ~/.bash_profile ~/.profile will indicate which one -- if one or more is missing, that's no concern, we just want to see which one out of these you have edited recently. Examine the time stamps and try to remember what you did to change one of these files.
The error probably looks something like
$oopsPATH=/usr/local/bin:$PATH
where you meant to say
PATH=/usr/local/bin:$PATH
but without access to your files, we can't know what exactly is supposed to be there, or how you messed it up.
See also https://askubuntu.com/questions/198730/how-to-restore-bashrc-file/198740#198740
In the common case where you have messed up your PATH so that ls and other commands are unavailable (bash: ls: command not found), you can use the full path (/bin/ls pro ls, etc; though obviously, you have to know the correct path) at least until you can restore your configuration.
PATH=/usr/local/bin:/usr/bin:/bin
is probably a good crutch until you can find the correct default for your OS. You can type that at the prompt, or put it in one of your shell's startup files and start a new shell.
On many platforms, you can find the default user dot files in /etc/skel so if that's present (which unfortunately will not be true for Mac OS, but should be there on most Linuxes):
cp -b /etc/skel/.bash_profile $HOME/
will replace your (presumably broken beyond repair) .bash_profile with the system default one. (Omit the -b option if your OS doesn't have it, but then you'll want to back up your file manually before replacing it.)
Update: This fragment near the top of your .bash_profile is erroneous:
#loginPath
=/usr/local/bin:$PATH
Just take it out; it doesn't seem to do anything useful. There seem to be multiple additional fragments from the MacPorts installer which look wrong, too, but they are just comments. (Perhaps somehow they shouldn't be?)
It seems that you are missing a necessary PATH and that is why it is saying no such file or directory. If, for example, you get this error message when typing in python, it would mean either that (1) python isn't installed; or (2) python isn't on your system path.

In Mac OSX 10.5, it can't find my Terminal commands sudo, find, etc

I don't know what has happened, but in my Terminal on Mac OSX 10.5 it can no longer find my sudo command, or find command, etc. They are there because if I put /usr/bin/sudo or /usr/bin/find it works fine...
My .bash_login file looks like this:
export PATH="/usr/local/bin:/usr/local/sbin:/usr/local/mysql/bin:/usr/bin$PATH"
My .bash_profile file looks like this:
export PATH="/Library/Frameworks/Python.framework/Versions/Current/bin:/Library/Python/2.5/site-packages/django_trunk/django/bin:/usr/local/mysql/bin:/usr/bin/sudo$PATH"
I'll say now, I don't really know what I'm doing with the Terminal. I'm just a beginner to it all, and I must of done something for the environment variables (is that what they're called?) to be lost. I presumed I'd just have to make sure the /usr/bin/ path is in my bash files, but they are, and it doesn't seem to work. Please help!
Also, when I do use the /usr/bin/find command, it says "Permission denied" to me, even though I am logged into Mac OSX as the System Administrator account. I don't understand.
Any help would be grand. Thank you - James
It looks like both of your PATH exports are malformed:
export PATH="/usr/local/bin:/usr/local/sbin:/usr/local/mysql/bin:/usr/bin$PATH"
The end bit there won't work. It should be:
export PATH=/usr/local/bin:/usr/local/sbin:/usr/local/mysql/bin:/usr/bin:$PATH
Notice the colon before '$PATH'? It's important ;)
Also, the double quotes are not necessary.
If this doesn't work, we will need more information. It is possible that something else is modifying your path even after your shell configurations are loaded.
Can you post the results of:
$ echo $PATH
Configuration files are not always a good indication of the current environment variables, since they are modified by many programs and files, all across your system. To see all of your environment variables, you can run:
$ env
This should fix the problem completely and permanently.
first, export environment paths by using below command in the terminal.
export PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/b‌​in
now you have the commands you want. (eg. try ls. You'll see the command is working). But this is only for the current session. If you close the terminal and open a new one, you will have the previous issue. To make this change permanent, use below command,
go to home directory
cd ~
open .bash_profile file in nano / vim (I'm using nano here)
nano .bash_profile
This will open up nano editor. In a new line, paste the following;
export PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin:$PATH
press 'control'+'o' to save (WriteOut) and 'control'+'x' to exit nano.
All done ! Now try the commands.
Check out --- http://www.sweeting.org/mark/blog/2008/05/26/mac-os-x-tip-setting-path-environment-variables
I went trough the same issue and here is how I solved it.
First of all I reverted the file to its original doing this way
/usr/bin/nano ~/.bash_profile
In my case I was not able to make work any command alias. Even vi or vim didnt work without specifying the full path of that command.
If nano is not installed just replace nano in the command by the editor installed
After that just restart the computer. In my case as I said bellow I could not use any command. When trying to do /usr/bin/source ~/.bash_profile
that command failed. So I had to restart the OS and it worked

Resources