After changing path nano doesn't work - linux

After i did change server ~bash_profile for PATH to my Java i cannot use nano or vip anymore.
I actully don't know how to change it back, while i cannot edit it with nano or vi anymore.
What can i do?
-bash: ano: command not found
root#s [~]# nano
-bash: nano: command not found
root#s [~]# pacstrap -i /mnt base base-devel
-bash: pacstrap: command not found
root#s [~]# nano /etc/timezon
-bash: nano: command not found
root#s [~]# nano /etc/timezone
-bash: nano: command not found
root#s [~]# vi
-bash: vi: command not found
root#s [~]# vi
-bash: vi: command not found
root#s [~]# nano ~/.bash_profile
-bash: nano: command not found
root#s [~]# vi ~/.bash_profile
-bash: vi: command not found
root#s [~]#

You most likely overrode your path to just java instead of appending to it.
WRONG:
export PATH=/opt/somewhere/java/bin
RIGHT:
export PATH=$PATH:/opt/somewhere/java/bin
to fix this, do
export PATH=/bin:/usr/bin:/usr/local/bin
...and you should have vi and nano back in your path.

Related

how to fix the locale when input gitlab-ctl reconfigure

When I input gitlab-ctl reconfigure, it shows:
gitlab-ctl reconfigure it shows DETAIL:
The database was initialized with LC_COLLATE "zh_CN.UTF-8",
which is not recognized by setlocale().
The system is centos7: how can I fix the problem?
The content of .bashrc
# User specific aliases and functions
alias rm='rm -i'
alias cp='cp -i'
alias mv='mv -i'
# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi
and the content of profile
unset i
unset -f pathmunge
export PKG_CONFIG_PATH=/usr/local/lib64/pkgconfig:$PKG_CONFIG_PATH
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib64
export JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.252.b09-2.el7_8.x86_64/jre/bin/java
export JRE_HOME=$JAVA_HOME/jre
export CLASSPATH=$JAVA_HOME/lib:$JRE_HOME/lib:$CLASSPATH
export PATH=$JAVA_HOME/bin:$JRE_HOME/bin:$PATH
export M2_HOME=/usr/local/maven3
export PATH=$PATH:$JAVA_HOME/bin:$M2_HOME/bin
export PATH=$PATH:/usr/local/gcc-linaro-4.9-2016.02-x86_64_arm-linux-gnueabihf/bin
export PATH=$PATH:/usr/local/mysql/bin
I also tried to install postgresql, when I login, it shows below.
[root#0c-5b-8f-27-9a-64 ~]# su - postgres
Last login: Tue Jun 22 14:30:01 CST 2021 on pts/0
-bash: warning: setlocale: LC_ALL: cannot change locale (zh_CN.UTF-8): Permission denied
-bash: warning: setlocale: LC_ALL: cannot change locale (zh_CN.UTF-8)
-bash: warning: setlocale: LC_ALL: cannot change locale (zh_CN.UTF-8)
-bash: export: `=': not a valid identifier
-bash: export: `en_US.UTF-8': not a valid identifier
/bin/sh: warning: setlocale: LC_ALL: cannot change locale (zh_CN.UTF-8)
-bash: warning: setlocale: LC_ALL: cannot change locale (zh_CN.UTF-8)
-bash: export: `=': not a valid identifier
-bash: export: `en_US.UTF-8': not a valid identifier
Check if, as in this thread, you can regenerate the right locale
In your case, as in here:
localedef -i zh_CN -c -f UTF-8 zh_CN.UTF-8
export LANG=zh_CN.UTF-8
gitlab-ctl reconfigure
And change /etc/locale.conf to:
LANG=zh_CN.UTF-8
LC_COLLATE=zh_CN.UTF-8
See if the issue persists then.

/etc/environment in Linux EC2

I wanted to set Path for JAVA_HOME for systemwide (all users) in in linux EC2 machine so i tried below
vi /etc/environment
JAVA_HOME=/usr/local/java/jdk1.8.0_221
PATH=$JAVA_HOME/bin:$PATH
When i logout and logged in again i am unable to run any commands in the linux machine and now only Java command is working now.
Below are the message i am getting.How to correct this?
If you need a GUI type startx at the prompt. -bash: id: command not found
-bash: id: command not found
-bash: id: command not found
-bash: tty: command not found
-bash: ls: command not found
/usr/libexec/grepconf.sh: line 5: grep: command not found
-bash: TMOUT: readonly variable
-bash: expor: command not found
[user1#XXXXX ~]$ java -version
java version "1.8.0_221"
Java(TM) SE Runtime Environment (build 1.8.0_221-b11)
Java HotSpot(TM) 64-Bit Server VM (build 25.221-b11, mixed mode)
[user1#XXXXX ~]$ echo $JAVA_HOME
/usr/local/java/jdk1.8.0_221
[user1#XXXXX ~]$ cat /etc/environment
-bash: cat: command not found
[user1#XXXXX ~]$
I am not able to run any Linux command.
It appears that you have overwriten or omitted the base system path. Try this:
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
JAVA_HOME="/usr/local/java/jdk1.8.0_221"
PATH="$PATH:$JAVA_HOME/bin"

zookeeper_server.pid: Permission denied FAILED TO WRITE PID

Sorry, if there are the same question. I'll do project on hbase that need to install zookeeper. So I follow the instruction on youtube : https://www.youtube.com/watch?v=ZoYteLiNHNc
Finally I want to start zkServer.sh but
ardias#Arif-Satellite-C800D:~$ zkServer.sh start
ZooKeeper JMX enabled by default
Using config: /usr/local/hadoop/zookeeper-3.4.9/bin/../conf/zoo.cfg
Starting zookeeper ... /usr/local/hadoop/zookeeper-3.4.9/bin/zkServer.sh: line 149: /usr/local/hadoop/zoo_data/zookeeper_server.pid: Permission denied
FAILED TO WRITE PID
I think the problem is I am not superuser so I use sudo but
ardias#Arif-Satellite-C800D:~$ sudo zkServer.sh start
[sudo] password for ardias:
sudo: zkServer.sh: command not found
I've been search any solutions on
FAILED TO WRITE PID installing Zookeeper and also
Zookeeper: FAILED TO WRITE PID
but it doesn't work on me. There's file myid in /usr/local/hadoop/zoo_data contains character "1".
Anybody have solutions?
This is my zoo.cfg and my ubuntu version is 14.04.
tickTime=2000
initLimit=10
syncLimit=5
dataDir=/usr/local/hadoop/zoo_data
clientPort=2181
server.1=localhost:2888:3888
If someone is still facing this issue on MAC, then find below
ZOO_DATADIR="$(echo -e "${ZOO_DATADIR}" | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')"
in zkServer.sh file and remove option -e from echo command.
The final command should be ZOO_DATADIR="$(echo "${ZOO_DATADIR}" | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')"
Restart zookeeper after this.
Two solutions:
1. change dataDir to a directory that ardias have permission.
2. find the absolute path of zkServer.sh and use sudo /$absolutePath/zkServer.sh start
Please check the zoo_sample.cfg
[hadoop#localhost conf]$ vi zoo_sample.cfg
[hadoop#localhost conf]$ ls
configuration.xsl log4j.properties zoo_sample.cfg
[hadoop#localhost conf]$ mv zoo_sample.cfg zoo.cfg
change the zoo_sample.cfg to zoo.cfg

bash/zsh cd command not found

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

BASH and/or .BASHRC not working properly after SU or SSH login unless run "bash" command

I have an Amazon EC2 Machine running Ubuntu 10.04.
The default user, ubuntu's .bashrc seems to be behaving properly, but if I ssh or su to the second user, mikey, it doesn't display properly until I run bash:
Ex 1.) Changing user with su
mikey#home ~$ ssh ubuntu#EC2
ubuntu#EC2:~$
ubuntu#EC2:~$ su mikey
$
$ bash
mikey#EC2: $
Ex 2.) SSH-ing in directly as the user
mikey#home ~$ ssh mikey#EC2
/home/mikey/.bashrc: 13: shopt: not found
/home/mikey/.bashrc: 21: shopt: not found
/home/mikey/.bashrc: 99: shopt: not found
/etc/bash_completion: 33: [[: not found
/etc/bash_completion: 39: [[: not found
/etc/bash_completion: 52: Bad substitution
\[\e]0;\u#\h: \w\a\]\u#\h:\w$
\[\e]0;\u#\h: \w\a\]\u#\h:\w$ bash
mikey#EC2:~$
I've tried playing around with ~/.profile and ~/.bash_login to include
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
but so far, nothing has seemed to do the trick.
any pointers would be greatly appreciated. thanks!
If, in fact, your shell isn't bash, you can try to change it like so:
usermod -s /bin/bash mikey
If /bin/bash is the location of bash on that system.
I think your default shell is dash or sh and not bash in this case. echo $SHELL should show it, should it show /bin/sh, it might be a link, so check that ls -l /bin/sh doesn't link to some other shell.
Can't you use chsh to change shell? instead of hacking /etc/passwd?
In order to fix this on the permanent basis, change /etc/passwd
From:
kwilson:x:3042:3042::/home/jjson:/bin/sh
Change it to:
kwilson:x:3042:3042::/home/jjson:/bin/bash

Resources