Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It's 100% free, no registration required.

I have installed java 8 on my bluehost VPS. I have followed http://tecadmin.net/install-java-8-on-centos-rhel-and-fedora/ instructions .

In order to add directories to PATH variable I have added

PATH=$PATH:/opt/jdk1.8.0_45/bin:/opt/jdk1.8.0_45/jre/bin
JAVA_HOME=/opt/jdk1.8.0_45
JRE_HOME=/opt/jdk1.8.0_45/jre

to etc/environment file.

After that I can't push upgrades to my git repository and when I login via ssh I can't run unix command.

My server OS is CentOS and its 64bit

EDIT :


Error shown in git :

git -c diff.mnemonicprefix=false -c core.quotepath=false push -v --tags origin master:master
Pushing to [email protected]:/home/darmanjo/darmanjoo.git

bash: git-receive-pack: command not found

fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

SSH Problem :

login as: root
[email protected]'s password:
Last login: Tue Apr 21 15:26:53 2015 from 109-110-182-162-dynamic.shabdiznet.com
-bash: id: command not found
-bash: tty: command not found
[email protected] [~]# ls
-bash: ls: command not found
[email protected] [~]#

Also my echo $PATH shows :

/usr/local/sbin:/usr/sbin:/sbin:$PATH:/opt/jdk1.8.0_45/bin:/opt/jdk1.8.0_45/jre/bin:/root/bin
share|improve this question

migrated from serverfault.com Apr 22 at 14:20

This question came from our site for system and network administrators.

    
What is the problem you are having? –  Michael Hampton Apr 21 at 16:49
    
The way your question is written it sounds as if you COULD have performed these tasks BEFORE you made these changes to PATH. In particular, your use of "after that". Also, if you're logging into a unix (linux) system, what "unix command" are you referring to - ANY command? The shell built-ins? Anything BUT the shell built-ins? –  Richard T Apr 21 at 17:00
    
@MichaelHampton I can't run unix command : ls. also I can't push my git upgrades , Error shown : bash: git-receive-pack: command not found fatal: Could not read from remote repository. –  Ramin Omrani Apr 21 at 17:04
    
@RichardT Please see my edits. thanks –  Ramin Omrani Apr 21 at 17:08
    
@MichaelHampton Please see my edits. thanks. –  Ramin Omrani Apr 21 at 17:08

1 Answer 1

up vote 2 down vote accepted

You can't use variable expansion in /etc/environment (which is why you see an unexpanded $PATH in the output from echo $PATH). /etc/environment is read by the pam_env module not a shell script so just simple assignments.

You probably want to add this stuff to /etc/profile or add a file under /etc/profile.d/.

See Can you use variables when editing /etc/environment in ubuntu 10.04? for more details.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.