Can't put MongoDB in my PATH - mongodb

I'm trying to include MongoDB in my PATH on Ubuntu 14.04 by issuing this command:
export PATH=/home/<my-user-name>/mongodb-linux-x86_64-ubuntu1404-3.2.4/bin:$PATH
It seems OK but when I restart the terminal it can't find it again. Do you have any idea what's going on?

export commands only work for the current terminal window.
You should add this command to one of the files that run when you start your terminal session.
Your best choice would be to add this line to a file called ~/.profile, since it will run regardless of the shell you are using.

Related

Is there a reason the command 'mongo' works in VSCode terminal but not iTerm2 zsh terminal?

I just installed oh-my-zsh on iTerm2 and have been working on a project with MongoDB/node.
Now when I try to start the db with command 'mongo' I get a return 'zsh: command not found: mongo'
the command works perfectly fine in the built-in terminal for VSCode.
would like to be able to use iTerm exclusively instead of the vscode terminal.
Go to VSCode terminal and execute:
echo "$PATH"
Check where the mongo binary is located:
which mongo
brew info mongo
Go to your zsh and add to your .zshrc file the path where mongo is located:
export PATH="$PATH:/opt/homebrew/bin"
If you do not add the path you will still be able to run it like:
/opt/homebrew/bin/mongo
I'm not sure why, but when I went directly into the .zshrc file and added this line
export PATH="$PATH:/opt/homebrew/bin"
the command 'mongo' still didn't start the db.
BUT..
I figured it out. Instead of opening my .zshrc and editing it I just edited my path with this little line here with the path described by R2D2
path+=/opt/homebrew/bin/
Command 'mongo' is working perfectly now!

Swift on Ubuntu 20.04- Need to add a path every time

I am simply trying to install swift on linux
I have downloaded the files from swift.org, extracted .tar files and used export command to include the path after that when I use swift --version it correctly shows the version 5.3.3 but when I close the terminal and try to open the swift command terminal it says command not found.
What is happening here? I need to include the path every time I open the terminal.
The export command just adds the value to path for the current session. When you log out and in again, it will reset.
You need to add this to your shell resource file so that it gets added to the path every time you log in. The file you need to edit will be called .zshrc or .bash_profile or something similar. You should start by opening the command line on your computer and verifying what shell you are running by typing:
echo $SHELL
This will return something like /bin/ksh or /bin/bash or similar. Then do a little internet searching to find out what the resource file is called for that shell. Then edit your resource file to add the Swift path to your $PATH.

How to make custom global command in VS Code terminal?

I just installed MongoDB. Instead of writing annoying cd to mongod.exe every time I want to run MongoDB, I want this file to be available as a global command, so that it runs regardless of the directory I'm in, like node or npm or git. How do I accomplish this for VS Code terminal?
There are different approaches to start mongod.exe:
You could add mongod.exe to your system's PATH variable (like git, npm etc.)
You could create a script (for example a .bat) file in your workspace directory, that contains
Start "path/to/mongod.exe"
If you want to start the mongod.exe via a vscode command like Strg + P for the user settings, you need to write an extension and register a command.

How to execute shell script by double clicking in centos?

As the tile,I have a shell script needs to run every time I have to open a terminal and type "./ xxx.sh" .it is annoying when it gets too frequent now how do I execute by double clicking like the way you do it in windows?
I know there is an option just for that in Ubuntu but I can't see that here in CentOS.
I did a little bit of digging up and found these two links. Let me know if they were helpful
https://askubuntu.com/questions/286621/how-do-i-run-executable-scripts-in-nautilus
https://unix.stackexchange.com/questions/189777/how-to-launch-shell-script-with-double-click-in-centos-7
The first link is an askUbuntu link I know. But gnome uses nautilus as the file explorer program.
In my arch linux installation where I am running a cinnamon desktop environment, I just had to add a shebang (#!/usr/bin/bash) at the head of the file and use chmod to make the file an executable and I could run the script from by double clicking on it. I hope you have already tried this?
For the record this is how I do it:
In terminal
[youname#localhost ~]$ gedit ~/Desktop/YourApplication.desktop
In the file
[Desktop Entry]
Name=My Application
Comment=My Application run script
Exec=/AddressOfyourScript/yourscript.sh
Icon=/AddressOfyourIcon/youricon.png
Terminal=true
Type=Application
save and done.Apparently CentOS should give a GUI for this function.

How to add mongo commands to PATH on Mac OSX

I'm using MongoDb 2.6.1 following the material from https://university.mongodb.com/ (great material by the way) but I am not being able to add to my path the mongo commands.
I've followed this guide http://docs.mongodb.org/manual/tutorial/install-mongodb-on-os-x/ and I modified my .bashrc like this
export PATH=/Users/jonathancaballero/bin/mongodb/mongodb_2.6.1/bin:$PATH
And there is indeed where the binaries are (checked using the finder directly)
So my question is why I am not able to use mongod from any location in my terminal?
Please put the PATH export into .bash_profile:
export PATH=/path/to/your/mongo/bin:$PATH
Edit: The reason to put it into .bash_profile is that this file will usually get executed when bash is started as a login shell while .bashrc usually is exectuted for interactive non-login-shells. What usually happens is that .bashrc gets sourced in .bash_profile. This does not seem to be the case here. On MacOS X when you start a Terminal, .bashrc does not get executed. God knows why, as the shell opened should be an interactive non-login shell and therefor should execute .bashrc.
Another, albeit more "intrusive" solution would be to add the following to .bash_profile.
if [ -f ~/.bashrc ]; then
source ~/.bashrc
fi
For those who are interested in the details: take a look into the according sections of bash's manpage