'usr/bin' is not included in the path environment [closed] - linux

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 6 years ago.
Improve this question
Whenever I start a new terminal and try to run a command, I get this error.
I have found out that it can be solved with export PATH=/usr/bin:/bin, but it has to be done for each terminal I open. In the etc/environment file, the path is correct, so hence I do not understand what is wrong.(But this error appeared after I added some lines to bashrc and paths to have some shortcuts for ruby, rails , git ; ( was following a course on Coursera )).
How can this be fixed?

What's happened here is you've clobbered your PATH variable. Your PATH is pretty important, whenever you enter a command your shell (usually bash), will check each of the directories specified in your PATH for a program of the same name.
Each directory specified in your path is separated by a colon :, and a minimal PATH variable usually looks something like /usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin.
When you have the line export PATH=/usr/bin/git at the end of your .bashrc you are telling your shell that you only want to search /usr/bin/git for commands.
Instead, the line export PATH="$PATH:/usr/bin/git" will tell your shell to search all of the directories previously specified in your shell, and then search /usr/bin/git.
Another thing to note is that your shell will search the directories in your PATH in the order they're specified, and use the first matching command found, so the order that directories are specified in the PATH can matter too.

Related

Readline does not read user config specified in INPUTRC variable [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 1 year ago.
Improve this question
I am trying to change the location of my inputrc. The docs say that it reads the config location from the INPUTRC environment variable
Readline is customized by putting commands in an initialization file (the inputrc file). The name of this file is taken from the value of the INPUTRC environment variable
I exported this variable in my ~/.bash_profile
export INPUTRC="~/.config/readline/inputrc"
and added the following lines to ~/.config/readline/inputrc
$include /etc/inputrc
# Case insensitive tab completion
set completion-ignore-case on
# Single tab partially completes and shows all options
set show-all-if-ambiguous on
# shift + arrows to go back and forth one word at a time
"\e[1;2D": backward-word
"\e[1;2C": forward-word
# Cycle through completions inline
Tab: menu-complete
"\e[Z": menu-complete-backward
Now if i try to open a new bash session, none of these options seem to have taken effect. It works as expected if I put them in ~/.inputrc with or without the INPUTRC variable exported. I've also tried exporting it from ~/.bashrc and ~/.profile, neither has worked.
I could add these lines to my bashrc using bind but that would mean that other programs that use readline wouldn't share these options.

Installed Go, but command go not found. Does work on one terminal linux [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 1 year ago.
Improve this question
I installed go on linux yesterday. It worked fine and downloaded some tools and they worked also. I left the terminal open and when I came back today go stopped working... In the left terminal go works and does everything... But when I open another terminal and type go it said "command go not found" (see screenshot).
Can anyone help me please? I don't know what I did wrong or what went wrong...
Go works on the left terminal, not right...
tl;dr
Add the export command you ran to the $HOME/.bashrc file (preferably at the end).
When you installed go you probably ran the export command to add the location of go binaries to the PATH variable. But here's the thing. The PATH variable is, effectively, reset to the previous value when you open the new terminal. To make it permanent you need to add the command to your shell's rc file.
What's an rc file?
When you open the terminal it uses a rc (short for run commands) file and runs the commands in this file. The name of the file depends on the shell you are using.
If you are using bash, the name would be .bashrc. If you are using zsh, the name would be .zshrc.
You can run echo $PATH in both the terminals and see the PATH variable in which go runs would have the location of go binaries and the other wouldn't.
So to make this permanent, add the export PATH=$PATH:{PATH_GO_BINARIES} to the rc file. And, then, whenever a new terminal is opened, the PATH variable would be updated to contain the location of go binaries.

How to change the username displayed within terminal window on Linux Mint? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 4 years ago.
Improve this question
I am trying to change my current username on Linux Mint that shows up when I open a terminal window.
Currently:
john#myLinux
I want to change to:
gary#myLinux
I have tried:
(1) Start -> Settings -> Account Detail and altered the 'name' field.
(2) The steps mentioned here: https://askubuntu.com/questions/34074/how-do-i-change-my-username
(3) Altering the passwd file: https://www.cyberciti.biz/faq/understanding-etcpasswd-file-format/
Option #3 seems to affect the username displaying in the terminal window but causes issues with logging in(my password becomes incorrect).
How can I successfully change the username that is displayed in my terminal window on Linux Mint OS?
This assumes you are using bash, and might not work for a different shell.
This will only change the terminal prompt text, it will not update your user account or change any other system files.
in a terminal type DEFAULT=$PS1
next type PS1='gary#\h\$ '
last of all, if you want to return to your default prompt type PS1=$DEFAULT
Note 1: Make sure to save these settings in your .bashrc file under the home directory to have changes persist across terminal sessions.
Note 2: In step 2, \h tells the bash prompt to print out the computer hostname, the \$ prints out show the (#) symbol if you're ROOT otherwise show the ($) symbol.
More information can be found here: https://www.howtogeek.com/307701/how-to-customize-and-colorize-your-bash-prompt/

:wq! results in E212: Can't open file for writing Press ENTER or type command to continue [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 5 years ago.
Improve this question
I am just trying to exit my vim file with :wq! but it gives me the error:
E212: Can't open file for writing
Press ENTER or type command to continue
I press enter or type anything and it goes back to editing the file. Is there something wrong?
I am now stuck in my text editor.
You can get more details about the error via :help E212:
For some reason the file you are writing to cannot be created or overwritten.
The reason could be that you do not have permission to write in the directory
or the file name is not valid.
If you don't need the changes any longer, just :q! and be done with it. For multiple Vim arguments, there's also :qall!.
If you do want to keep the changes, one approach is to investigate the permissions issue, e.g. in another terminal or via the file explorer, and fix the issue (e.g. via chmod / chown).
Alternatively, you can persist the changes elsewhere via :w /tmp/changes, then :quit Vim, and then resolve the problem outside of Vim.
To address the "I'm stuck in Vim" (assuming it's not possible / tedious to start another session on the system): :suspend puts Vim in the background, and drops you into the original shell you started Vim from. :shell starts a new shell from inside Vim, to which you return via exit.

creating a function to alias linux [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 6 years ago.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Improve this question
Background
I am pretty new to Linux and using aliases.
I understand that in order to add a permanent alias, I need to edit the .bashrc file and I've doing this a lot.
I was wondering if there is a way I could just add an alias permenantly
Without having to open the file and actually adding it.
Current knowledge
I did some research and learned I could give an alias to a function,
And that function could get parameters (the alias I want to add each time)
But I still don't know where I can write this function.
The question
My question is how exactly do I create an alias for a function, and where do I write it.
Also if you can explain to me the syntax of those functions I would be very happy.
function_name () { command1 command2 }
function_name () { command1 p1 command2 p1}
Example
nd () {
mkdir -p $1
cd $1
}
Add this to bashrc, and then nd <folder>
create a new folder and move into that.
Clarification
I decided to answer this old quiestion of mine
To contribute the solution I finally went with.
The solution
First thing I did after some research, was to move
My aliases to .bash_aliases file.
This helped my keep an organized and minimal .bashrc
And gather togeter all of my aliases.
Secondly, in order to achieve adding an alias permanently and without
having to reopen and edit .bashrc file I added a function in .bash_aliases
Function guidlines
Handle terminal arguments
This function received an argument of format:
'new_alias=commands'
Append the new alias received to .bash_aliases
Source .bash_aliases file to include new aliases added to the current terminal window.
Handle modification of aliases:
If an alias with the same name was received, sed was used to replace
The commands executed in 'alias'

Resources