Check if the configuration file is read in an easy-to-understand manner

After installing nodenv as a general user and passing it through the path When I was a little root and had a need

[ec2-user@ip-xxx-xxx-xxx-xxx ~]$ sudo su 
[root@ip-xxx-xxx-xxx-xxx ec2-user]# su shindev

[shindev@ip-xxx-xxx-xxx-xxx ec2-user]# cd
[shindev@ip-xxx-xxx-xxx-xxx ~]# git clone nodenv〜
[shindev@ip-xxx-xxx-xxx-xxx ~]# vi ~/.bash_profile
#PATH=$PATH:$HOME/.local/bin:$HOME/bin:$HOME/.nodenv/bin
#export PATH
#eval "$(nodenv init -)"
#I added this and passed the path of nodenv
[shindev@ip-xxx-xxx-xxx-xxx ~]# source ~/.bash_profile
[shindev@ip-xxx-xxx-xxx-xxx ~]# nodenv -v
nodenv 1.4.0+3.631d0b6 #Passed
[shindev@ip-xxx-xxx-xxx-xxx ~]# exit

[root@ip-xxx-xxx-xxx-xxx ec2-user]# 
#Get a little done
[root@ip-xxx-xxx-xxx-xxx ec2-user]# su shindev
#Switch to general user again
[shindev@ip-xxx-xxx-xxx-xxx ec2-user]# 
[shindev@ip-xxx-xxx-xxx-xxx ~]# nodenv -v
bash: nodenv:Command not found#Oh? ??

I should have put a command to pass the bus in bash_profile, but it is not loaded ~ By the way, I'm not sure under what conditions bashrc and bash_profile are read. I will investigate it seriously.

Confirmation method

Add echo command to each file though it's not a mess.

bashrc


# .bashrc
echo "~/.bashrc loaded" #Add this
# Source global definitions
if [ -f /etc/bashrc ]; then
        . /etc/bashrc
fi

bash_profile


# .bash_profile
echo "~/.bash_profile loaded" #Add this
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
        . ~/.bashrc
fi

# User specific environment and startup programs

PATH=$PATH:$HOME/.local/bin:$HOME/bin:$HOME/.nodenv/bin
export PATH
eval "$(nodenv init -)"

At last, become root and switch with the su command.

[root@ip-XXX-XXX-XXX-XXX ~]# su shindev
~/.bashrc loaded #Only bashrc was read
[shindev@ip-XXX-XXX-XXX-XXX root]$ 

What about your profile? ??

[root@ip-XXX-XXX-XXX-XXX ~]# su - shindev #Switch with hyphen
Last login: 2020/10/11 (Day) 17:12:21 JSTDay時 pts/0
~/.bash_profile loaded #It was read!
~/.bashrc loaded
[shindev@ip-XXX-XXX-XXX-XXX ~]$ 

It was that. With or without hyphen in su command, the current path after switching is It was recognized as it was or moved to the home directory of the switching user, It was a story that I had to think about properly.

No hyphen is an impersonal paste In my usual work, I should do it with a basic hyphen.

**end. ** **

Recommended Posts

Check if the configuration file is read in an easy-to-understand manner
Check if the string is a number in python
Check if it is Unix in the scripting language
Determine if an attribute is defined in the object
Check if it is Unix in the scripting language
[Golang] Check if a specific character string is included in the character string
Check if the URL exists in Python
Read the file line by line in Python
Read the file line by line in Python
[Python] Read the specified line in the file
[Python] I tried to summarize the set type (set) in an easy-to-understand manner.
Comparing the basic grammar of Python and Go in an easy-to-understand manner
Check if there is a specific symbol in the executable file and its dependent libraries (simplified version)
I want to receive the configuration file and check if the JSON file generated by jinja2 is a valid JSON
Check if the characters are similar in Python
In bash, "Delete the file if it exists".
View logs in an easy-to-understand manner with Ansible
Introduction to Deep Learning (1) --Chainer is explained in an easy-to-understand manner for beginners-
I created a script to check if English is entered in the specified position of the JSON file in Python.
Check if the expected column exists in Pandas DataFrame
Read the csv file and display it in the browser
Read logging settings from an external file in Flask
Check if the LAN cable is disconnected on Linux
How to check in Python if one of the elements of a list is in another list
When reading an image with SimpleITK, there is a problem if there is Japanese in the path
[For beginners] I want to explain the number of learning times in an easy-to-understand manner.
[Deep Learning from scratch] I tried to explain the gradient confirmation in an easy-to-understand manner.
Solution if the module is installed in Python but you get an error in Jupyter notebook
[Machine learning] Let's summarize random forest in an easy-to-understand manner
[python] How to check if the Key exists in the dictionary
[Pandas] If the first row data is in the header in DataFrame
How to check if a value exists in an enum
Download the file in Python
[Short note] In matplotlib, nothing is displayed even if I show it → Check the backend setting
In the python dictionary, if a non-existent key is accessed, initialize it with an arbitrary value
I made a function to check if the webhook is received in Lambda for the time being
[Blender] Script to check if the selected one is a mesh
Check if the password hash generated by PHP matches in Python
Loop the For statement in reverse in an HTML file on Django
Anyway, the fastest serial communication log is left in a file
How to make a command to read the configuration file with pyramid
Delete a particular character in Python if it is the last
Read a file in Python with a relative path from the program
[Django] How to read variables / constants defined in an external file
Read the config file in Go language! Introducing a simple sample
I will explain how to use Pandas in an easy-to-understand manner.
The solution when an empty object is returned in go's json.Marshal
Get the formula in an excel file as a string in Python
Trial of writing the configuration file in Python instead of .ini etc.
I tried to display the analysis result of the natural language processing library GiNZA in an easy-to-understand manner
Save the binary file in Python
Determine if the string is formatable
The story of the "hole" in the file
Determine if the library is installed.
Check the data summary in CASTable
Python in is also an operator
Configuration file best practices in Flask
[LPIC 101] How to specify the disk partition number in the GRUB configuration file
I tried to summarize Cpaw Level1 & Level2 Write Up in an easy-to-understand manner
Open an Excel file in Python and color the map of Japan
I tried to summarize Cpaw Level 3 Write Up in an easy-to-understand manner