I am using CentOS 6.5 version. I got sudo permissions and installed java, and set up JAVA_HOME this way .
$ cat /root/.bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
# User specific environment and startup programs
export JAVA_HOME=/usr/lib/jvm/jre-1.7.0-openjdk.x86_64
PATH=$PATH:$JAVA_HOME/bin
export PATH
And now when i did
$ echo $JAVA_HOME
/usr/lib/jvm/jre-1.7.0-openjdk.x86_64
But once i logout and do
$ echo $JAVA_HOME
/usr/local/jdk
Could you please tell me how do i set java_home for all users ??
vi /etc/profile
export JRE_HOME=/usr/lib/jvm/jre-1.7.0-openjdk.x86_64
export PATH=$PATH:$JRE_HOME/bin
export JAVA_HOME=/your-path-to-java
export JAVA_PATH=$JAVA_HOME
export PATH=$PATH:$JAVA_HOME/bin
System settings for java, CentOS ,,, for all users :
# /usr/sbin/alternatives --config java
Related
Every time I log in to oracle, I am given an error:
ORA-12162 TNS:net service name is incorrectly specified
So I am forced to run this:
ORACLE_SID=mydb; export ORACLE_SID
I'd like to set mydb to be the default ORACLE_SID. I have searched for ways to do this, but I'm too rusty on linux to pull this off. Here's what I've tried so far:
[oracle]$ --> in .profile add export ORACLE_SID=mydb
-bash: in: Permission denied
[root]$ chsh -s /bin/bash oracle
Changing shell for oracle.
Shell changed.
Here's what my tnsnames.ora looks like:
MYDB=
(DESCRIPTION=
(ADDRESS=(PROTOCOL=TCP)(HOST=localhost)(PORT=1521))
(CONNECT_DATA=
(SERVICE_NAME=mydb,
SID=mydb)
)
)
I had to define the ORACLE_SID and export it in the oracle user's .bash_profile. This means these two steps are run each time the oracle user logs in, so it's possibly more of a hack, but it works:
Here's the short version. If you're not sure what you're doing, go to the detailed section where I explain what's going on.
$ sudo -i
$ chsh /bin/bash oracle
$ sudo su - oracle
$ cd
$ vi .bash_profile
$ i
...
# User specific environment and startup programs
PATH=$PATH:$HOME/bin
export PATH
###### ADD YOUR SID STUFF HERE ######
ORACLE_SID=mydb
export ORACLE_SID
~
~
esc, :w! to save, :q to quit.
$ exit
$ sudo su - oracle
$ sqlplus / as sysdba
That's it.
Details
Defining the shell (Optional)
If you're like me, and the sys admins set up the oracle account to automatically disable the shell on logout, you'll need to first redefine the shell for the oracle user (as root):
$ sudo -i
$ chsh /bin/bash oracle
Edit the profile
Then you need to login as the oracle user and edit .bash_profile:
$ sudo su - oracle
$ cd
$ vi .bash_profile
$ i
You're now editing the .bash_profile in the VI editor. It should look something like this:
# .bash_profile
...
# User specific environment and startup programs
PATH=$PATH:$HOME/bin
export PATH
~
~
What you need to do is add your SID stuff after export PATH, so it should look like this:
# User specific environment and startup programs
PATH=$PATH:$HOME/bin
export PATH
###### ADD YOUR SID STUFF HERE ######
ORACLE_SID=mydb
export ORACLE_SID
~
~
OK, now you gotta save the file, and exit vi:
esc, :w! to save, :q to quit.
Troubleshooting Sidebar: If you have an issue saving the file because the oracle user doesn't have privileges, then you'll have to do it using the root user, which means you'll have to find oracle's .bash_profile file, which is probably in /home/oracle/ (Remember, it's a hidden file, so use ls -a to see it instead of ls)
OK, so assuming you're still logged in as the oracle user, you need to logout and log back in. That will activate the code you just added, and define the ORACLE_SID.
$ exit
$ sudo su - oracle
There is a script provided by Oracle called oraenv, that usually live in your local bin directory. In you bash_profile, you would do something like:
set ORAENV_ASK=N
. oraenv mydb
Note that it is "dot space oraenv"
So I'm currently working on an LLVM compiler project and I'm running Ubuntu 14.04.2 LTS in VirtualBox on top of my MacBook Air.
I was given a bash script that sets up the required environment variables for the project. The script functions correctly if I source it from a terminal within the VM. However, I have port-forwarding enabled, that I'm using to ssh into the VM from my Mac's default terminal. But when I ssh into the VM and then try to run the script and set the environment variables, they aren't set properly.
Here is the script-
BASESCRIPT=$(readlink -f "$0")
BASE=$(dirname "$BASESCRIPT")
PROJ="cse231"
if [ -n "${VTENV}" ]; then
if [ "${BASE}" = "${VTENV}" -a "${PROJ}" = "${VTENV_NAME}" ]; then
echo "${VTENV_NAME} Virtual Environment is already active."
else
echo "There is already ${VTENV_NAME} Virtual Environment activated."
echo "(at ${VTENV})"
echo "Deactivate it first (using command 'deactivate_vtenv'), to activate"
echo "test environment."
fi
return 1
fi
export VTENV="${BASE}"
export VTENV_NAME="${PROJ}"
export CSE231ROOT="${VTENV}"
export LLVMBIN="${VTENV}/llvm/build/Release+Asserts/bin"
export LLVMLIB="${VTENV}/llvm/build/Release+Asserts/lib"
export BENCHMARKS="${VTENV}/extra/benchmarks"
export INSTRUMENTATION="${VTENV}/extra/instrumentation"
export OUTPUTLOGS="${VTENV}/logs"
echo "Activating ${VTENV_NAME} Virtual Environment (at ${VTENV})."
echo ""
echo "To exit from this virtual environment, enter command 'deactivate_vtenv'."
export "VTENV_PATH_BACKUP"="${PATH}"
export "VTENV_PS1_BACKUP"="${PS1}"
deactivate_vtenv() {
echo "Deactivating ${VTENV_NAME} Virtual Environment (at ${VTENV})."
echo "Restoring previous environment settings."
export "PATH"="${VTENV_PATH_BACKUP}"
unset -v "VTENV_PATH_BACKUP"
export "PS1"="${VTENV_PS1_BACKUP}"
unset -v "VTENV_PS1_BACKUP"
unset -v VTENV
unset -v VTENV_NAME
unset -v CSE231ROOT
unset -v LLVMBIN
unset -v LLVMLIB
unset -v BENCHMARKS
unset -v INSTRUMENTATION
unset -v OUTPUTLOGS
unset -f deactivate_vtenv
if [ -n "$BASH" -o -n "$ZSH_VERSION" ]; then
hash -r
fi
}
export PATH="${VTENV}/llvm/build/Release+Asserts/bin:${PATH}"
export PS1="[${VTENV_NAME}]${PS1}"
if [ -n "$BASH" -o -n "$ZSH_VERSION" ]; then
hash -r
fi
The problem I have is that the environment variable $BASE should be set as
"/home/user/cse231-proj", which it is when I source the script from the VM. But when I source it after ssh'ing in from my Mac's terminal, the environment is simply set as "." and all corresponding environment variables are extended from that, fudging any further commands I want to run using the environment variables.
What's going on here and why can't the script read the correct absolute path? How can I go about fixing this? Any help would be appreciated. Thanks.
When you log on via SSH, $0 is -bash when you source the script (or something similar) because it's a login shell. readlink sees that as another command-line argument and fails, leaving BASESCRIPT set to an empty string in your example, which means dirname returns the . you see.
Don't source the script in your current shell, run it instead. Then $0 will be the name of the script, and readlink -f $0 will return its full canonical path, and dirname will then emit the path to the script like it's supposed to.
I am missing my basic unix commands on Yosemite 10.10
Here is my path from ~/.zshrc
export PATH="/Users/tims/.rbenv/shims:/usr/local/bin:/usr/bin:/usr/local/shared/bin:/usr
I will check my ~/.bash_profile
Very strange
$ type -a cd
cd is a shell builtin
cd is /usr/bin/cd
https://unix.stackexchange.com/questions/116955/where-is-cd-located
We are using linux on an embedded system that has busybox 1.20.2 for the various shell commands. We are having a very strange problem in that env does now show the value of LD_LIBRARY_PATH:
$ export LD_LIBRARY_PAT=/usr/bin
$ export LD_LIBRARY_PATH=/usr/bin
$ export LD_LIBRARY_PATH1=/usr/bin
$ env | sort
ENV=/etc/profile.environment
HISTFILE=/tmp/.ash_history.debug.357
HOME=/home/debug
LD_LIBRARY_PAT=/usr/bin
LD_LIBRARY_PATH1=/usr/bin
LOGNAME=debug
MAIL=/var/mail/debug
PATH=/home/debug/bin:/usr/bin:/bin:/usr/sbin:/sbin
PWD=/home/debug
PYTHONPATH=:/home/debug/tools/tools-0.0.0/common
SHELL=/bin/bash
SHLVL=1
SSH_CLIENT=10.10.10.22 58307 22
SSH_CONNECTION=10.10.10.22 58307 10.10.12.23 22
SSH_TTY=/dev/pts/0
TERM=xterm
USER=debug
_=/usr/bin/env
$
$ echo $LD_LIBRARY_PAT
/usr/bin
$ echo $LD_LIBRARY_PATH
/usr/bin
$ echo $LD_LIBRARY_PATH1
/usr/bin
As you can see, LD_LIBRARY_PATH is set, but it just doesn't show up in the output of env. AFAIK, it is the only environment variable that this happens.
Can anyone explain why this is happening? Thanks!
Linux won't let you mess with the LD_LIBRARY_PATH because busybox (probably) has its setuid bit turned on. Busybox has a bunch of common linux commands built into its binary, so it needs setuid.
https://aws.amazon.com/amazon-linux-ami/2012.03-release-notes/
-bash: warning: setlocale: LC_CTYPE: cannot change locale (UTF-8)
[ec2-user#ip-10-136-14-68 ~]$ vi ~/.bash_profile
[ec2-user#ip-10-136-14-68 ~]$
# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
# User specific environment and startup programs
PATH=$PATH:$HOME/bin
export PATH
export LC_CTYPE="en_US.UTF-8"
how do you solve this?
Another solution is to add these lines to /etc/environment
LANG=en_US.utf-8
LC_ALL=en_US.utf-8
The next time you log in the warning message should have disappeared.
Open your ssh_config file (in my case under Ubuntu it's located here : /etc/ssh/ssh_config), and comment this line:
SendEnv LANG LC_*
This means :
#SendEnv LANG LC_*