Why can't I access my vi folder? - mongodb

I keep getting this error on my terminal which stops me accessing the vi folder. I've been trying to set a path to the MongoDB bin and when experimenting on how to do this, I think I've broken the folder. Can someone please help?
Last login: Mon May 18 10:31:54 on console
-bash: export: `/Users/james.flan/Documents/Software/MongoDB/bin :/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin': not a valid identifier
AMAC02MX3APF8J3:~ james.flan$ cd
AMAC02MX3APF8J3:~ james.flan$ vi .bash_profile
-bash: vi: No such file or directory
AMAC02MX3APF8J3:~ james.flan$
Expanded:
AMAC02MX3APF8J3:~ james.flan$ cat ~/.bash_profile
-bash: cat: No such file or directory
AMAC02MX3APF8J3:~ james.flan$
AMAC02MX3APF8J3:~ james.flan$ /bin/cat ~/.bash_profile
export PATH= "/Users/james.flan/Documents/Software/MongoDB/bin :$PATH"
AMAC02MX3APF8J3:~ james.flan$

The problem is with your $PATH variable. You have broken it, so bash does not find any utility out of your current working directory.
To fix your issue you can execute vi directly with the absolute path:
$ /usr/bin/vi ~/.bash_profile
Then edit your $PATH declaration line:
export PATH="/Users/james.flan/Documents/Software/MongoDB/bin:$PATH"
Then you can either start a new Terminal session, or in the same session do:
$ /bin/bash -l

Related

VS Code: NoPermissions (FileSystemError): Error: EACCES: permission denied

I'm trying to save a file called app.js on a folder called js.
Vs Code pop up this:
Failed to save 'app.js': Unable to write file 'vscode-remote://wsl+ubuntu-18.04/js/app.js'
(NoPermissions (FileSystemError): Error: EACCES: permission denied, mkdir '/js')
I tried:
sudo chown -R user /mnt/c/Users/myUser/Documents/myFolder/proyectFolder
but I still can't save this file.
Try this, fixed it for me
sudo chown -R username path
Example:
sudo chown -R emanuel /home/emanuel/test/
In the SSH terminal:
Recommended :
sudo chmod -R 777 folder_name_where_your_file_exists
or
sudo chmod -R 755 folder_name_where_your_file_exists
this works for me
sudo chown -R $USER:$USER /home/
TLDR;
If you're using a docker container, avoid making files from within the container because the owner and group permissions may cause problems with your editor (in my case VS Code)
I was running docker container for a Django project from Windows Terminal and using VS Code to edit my code.
It is a Linux file (since everything in Linux is a file) permission problem that arises because the files don't have proper user and/or group permissions. So VS Code tries to tell us that.
The problem I found only happened when I created files from within my docker container.
I would run docker exec ... bash
make new files using touch /path/to/file from the container bash
then try to edit those files on VS Code (say urls.py) only to get the scary permissions error preventing the file from saving.
I suspect that making files from within the container embellishes those files with different owner and group settings than your system would default to if you just ran the commands locally (not in the container).
Changing the file permissions with chown -hR and chgrp -hR would do the trick but to avoid the error altogether I stopped making files from within the container.
Try activating polling:
This worked for me during I tried using wsl.
The below is for individual file:
sudo chown yourUserNAme filename
For an entire directory it will be (when you write ls to terminal, you should see your directory to execute this command):
sudo chown yourUserNAme dirName
For recursive (i.e files and folders inside a folder):
sudo chown -R yourUserNAme dirName
Note: yourUserNAme is, if you do pwd under any Documents, you will see the path: /home/jhon/Documents. Here user is jhon.
Run VS Code as administrator and it will fix the problem.
https://answers.microsoft.com/en-us/windows/forum/all/error-in-vs-code-destination-directory-and-says/e70dc626-6b12-4791-a960-8b704e57098d
Install the extension Save as Root in Remote SSH in VS code.
While saving press Ctrl + Shift + P.
This open the command palette.
Search Save as Root
It is a Linux user permissions problem.
you should use the command:
sudo chown -R $USER:$USER.

I removed Pyenv in MAC. How to initialize environment variable?

I have some problems about pyenv in my MAC so I removed it.
After that I open the terminal, always -bash: pyenv: command not found message appear.
I guess this is about environment problem.
How can I solve this?
Last login: Wed Jun 19 22:15:19 on ttys000
-bash: pyenv: command not found
-bash: pyenv: command not found
-bash: pyenv: command not found
-bash: pyenv: command not found
-bash: pyenv: command not found
-bash: pyenv: command not found
-bash: pyenv: command not found
ShinTaeyongui-iMac:~ shintaeyong$
A configuration file of your shell (bash) still contains a reference to the pyenv command. Depending on how you installed pyenv, this configuration file could be ~/.bashrc or ~/.bash_profile (or both).
The lines you are looking for are probably either (if installed via pipenv-installer):
export PATH="$HOME/.pyenv/bin:$PATH"
eval "$(pyenv init -)"
eval "$(pyenv virtualenv-init -)"
Or (if installed via the manual instructions):
export PYENV_ROOT="$HOME/.pyenv"
export PATH="$PYENV_ROOT/bin:$PATH"
eval "$(pyenv init -)"
You should be able to safely remove all lines containing pipenv. If you want to be safe, you can disable the lines instead of removing them by adding an # in front of them.

Using chmod for /usr directory

I used the following command to change the permissions of the usr directory from root
root> chmod -R 777 /usr
Now when I try to use the sudo command it gives the following error:
sudo: must be setuid root
On googling, I found that this error happens if /usr is chowned and I need to reinstall Ubuntu. But am I getting this error for chmod? Is there anyway to fix this problem without reinstalling?
To setuid /usr/bin/sudo: chmod +s /usr/bin/sudo.
But you changed ALL file/directory attributes in /usr recursivly (-R). You really should try some rescue mode. I don't think you'll have any chance to repair it.

PHP Command Line php.ini path error

I am trying to run some PHP pages on the command line but am running into a few problems with mysql and other PHP extensions.
Running php --ini produces the following output:
Configuration File (php.ini) Path: /usr/local/lib
Loaded Configuration File: (none)
Scan for additional .ini files in: (none)
Additional .ini files parsed: (none)
When I run php on the command line it cannot find my php.ini file. This is because the path is incorrect. My php.ini is actually located in /etc/php.ini as stated in my phpinfo(); file. PHP runs fine in the browser.
How do I change the path of my php.ini file for command line PHP?
I am running Apache2 (CentOS-5.5) and PHP 5.2.6.
Using the -c option, you can specify which php.ini file should be used :
php -c /etc/php.ini your-php-script.php
As a reference, see the output of php --help :
$ php --help
Usage: php [options] [-f] <file> [--] [args...]
php [options] -r <code> [--] [args...]
php [options] [-B <begin_code>] -R <code> [-E <end_code>] [--] [args...]
php [options] [-B <begin_code>] -F <file> [-E <end_code>] [--] [args...]
php [options] -- [args...]
php [options] -a
-a Run as interactive shell
-c <path>|<file> Look for php.ini file in this directory
-n No php.ini file will be used
-d foo[=bar] Define INI entry foo with value 'bar'
...
First update your sloacate database by using the command updatedb
Then try to locate php.ini file by using the command php --ini
I hope it'll update the slocate database and it will display the ini files loaded path.
[root#tamilan src]# php --ini
Configuration File (php.ini) Path: /etc
Loaded Configuration File: /etc/php.ini
Scan for additional .ini files in: /etc/php.d
Additional .ini files parsed: /etc/php.d/apc.ini,
To run php with customized or other php.ini file use the below method
php -c /etc/php.ini your-php-script-file.php

nib2objc: command not found

I've been trying to convert NIB files to Objective C code. I found the project NIB2OBJC on GitHub: https://github.com/akosma/nib2objc but when I type the command line:
nib2objc tab.xib > tab.m
I got the following error:
-bash: nib2objc: command not found
Could you tell me what am I missing?
Thanks
If you're in the folder where nib2objc is located, then you've to run ./nib2objc. Otherwise, if it's located in /bin/, /usr/bin/ or any other folder in $PATH, then make sure that it has execution permissions:
$ which nib2objc
/foo/bar/nib2objc
$ stat /foo/bar/nib2objc
$ chmod a+x /foo/bar/nib2objc
Good luck!