apache restart command in linux? - linux

I restart my apache on centos,
I cd the apache bin dir
use
apachectl restart
It's no working
but
I use
/dir..../bin/apachectl restart
It's working ,why??

you type >which apachetl,
if result is such below
/usr/bin/which: no lsasd in (/usr/lib64/qt-3.3/bin:/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:/turkcell/wlsadmin/bin)
you have to add its full path to PATH enviroment in order to execute command at any directory.
PATH=$PATH:/usr/local/services/apache2-2/bin

apachectl may not be on your PATH so your OS doesn't know what that command is or where it is (even though you cd into the folder).
If you provide a path to the command Linux will know what to do with it.
If you cd into the folder and do ./apachectl restart it should work as well.

Related

How to run executables from terminal in Linux without entering the entire PATH

I'm trying to activate android studio directly from terminal (./studio.sh)
the installation dir is /usr/local/android-studio
and inside there's a bin folder with the script studio.sh
for that I've vi'd ~/.bashrc to include the following line:
export PATH=$PATH:/usr/local/android-studio/bin
When I do echo $PATH i do see the path above appended to the rest of the path
(/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games:/usr/local/android-studio/bin)
Yet when I run ./studio.sh it prompts me with No such file or directory
Needless to say, if i cd /usr/local/android-studio/bin and then ./studio.sh it works fine
running debian (jessie 'edition')
I simply needed to do studio.sh without the ./
Thanks for ZanCoul for providing the answer.

Ubuntu: hadoop command not found

I am trying to check my installation of hadoop. I did create the environment variables and when I call printenv, I do see my HADOOP_HOME and PATH variables printed and correct (home/hadoop and HADOOP_HOME/bin respectively).
If I go to home/hadoop in the terminal and call ls, I see the hadoop file there. If I try to run it by calling hadoop, it still tells me command not found.
First day on Linux, so there may be a stupid answer to this problem.
Your current working directory is probably not part of your path.
That is default on linux systems.
If you are in the same directory, where your hadoop file is, run that command with an relative path, like: ./hadoop
HOME DIRECTORY:
/home/hadoop is a home directory created by linux similar to Document and settings in windows.
Open your terminal and type:
ls -l /home/hadoop
Post your result for this command: ls -l /home/hadoop
SETTING GLOBAL PATH:
Go to /home/hadoop and open .bashrc in text editor.
Add these lines at the end:
export HADOOP_HOME=/path/to/your/hadoop/installation/folder
export PATH=$PATH:$HADOOP_HOME/bin
Save and exit. Now type, this in your teminal:
echo $PATH
echo $HADOOP_HOME
If these commands shows correct directories, try hadoop command. It should work.
Post your result for these command: echo $PATH and echo $HADOOP_HOME
Go to Hadoop-x.x.x/bin folder
check for hadoop folder there
run ./hadoop version
You must run “hadoop version” command.
If the hadoop setup is fine, then you should see the following result:
Hadoop 2.4.1
Subversion https://svn.apache.org/repos/asf/hadoop/common -r 1529768
Compiled by hortonmu on 2013-10-07T06:28Z
Compiled with protoc 2.5.0
From source with checksum 79e53ce7994d1628b240f09af91e1af4
For installation related guide you can refer here:
Hadoop Environment Setup
Link to my quora answer https://qr.ae/TWngHN
Hope this helps.
Thanks
Enter which hadoop in your terminal. If you see a path as an output, hadoop is set in PATH of your system. If you get something similar to this,
usr/bin/which: no hadoop in (/usr/local/hadoop.... you might not have setup everything properly. Modify the /etc/bash.bashrc with
export HADOOP_HOME = /path/to/hadoop/folder and add it to PATH using export PATH=$PATH:HADOOP_HOME/bin
You may be editing the wrong ~/.bashrc file.
Open terminal and run sudo gedit ~/.bashrc and edit these command
export HADOOP_HOME=/usr/local/hadoop
export PATH=$PATH:$HADOOP_HOME/bin
export PATH=$PATH:$HADOOP_HOME/sbin
Note: You must not use sudo gedit ~/.bashrc.sh these both work differently on newer OS

run jedit single command from terminal linux

I'm trying to run jedit from the terminal on fedora. its installed to the path /usr/local/share....
How do I get it to run "jedit" from the terminal rather than switching to the directory and typing java -jar jedit.jar to execute the program.
I created a sh file in that same direectory with "java -jar jedit.jar" and added that directory to ~/.bashrc. I'm aware that I need to type "sh file.sh" to run that file but I know there is a gap in my knowledge somewhere.
i want to use jedit as a commit editor for git and be able to change core.editor='jedit -w' in git config
someone please help
I assume you used the Java installer?
If this is the case, the installer should also have placed a jedit launch script in /usr/local/bin which should be in your PATH by default, so calling jedit from a terminal should instantly work after installation.
If it does not work, then please check whether the file jedit is available in /usr/local/bin and whether /usr/local/bin is in your PATH environment variable.

Open GTS build failed

Every thing is okay (Opengts dir & tomcat dir have permission 777) but i am getting this error again & again, why--
executing # sudo ant all then i get this error
BUILD FAILED
/usr/local/OpenGTS_2.4.5/build.xml:111: CATALINA_HOME environment variable has not been defined.
(make sure CATALINA_HOME is defined and exported to the list of environment variables)
I got the this msg when starting the tomcat
sudo ./startup.sh
Using CATALINA_BASE: /usr/local/apache-tomcat-6.0.36
Using CATALINA_HOME: /usr/local/apache-tomcat-6.0.36
Using CATALINA_TMPDIR: /usr/local/apache-tomcat-6.0.36/temp
Using JRE_HOME: /usr
Using CLASSPATH: /usr/local/apache-tomcat-6.0.36/bin/bootstrap.jar
Any one have the solution please tell me how to fix this error.
Try to configure OpenGTS in your home directory (rather than /usr/local/).
And use ant all command (not sudo ant all).
Good Lock.. :)
First run this command:
echo $CATALINA_HOME
It should give you the path to your tomcat directory, which I'm assuming is /usr/local/apache-tomcat-6.0.36, but if you see a different path, or if the response is blank, try running this command:
export CATALINA_HOME=/usr/local/apache-tomcat-6.0.36
If you read the OpenGTS Configuration Manual, it talks about the CATALINA_HOME environment variable for Linux in section 2.4a. There are other environment variables too that you must set to install OpenGTS successfully (All mentioned in the manual).
To solve this problem, ensure the OpenGTS2.6.x has all files and directories to user:group same as logged in user. then run / ant all command
Please note that "sudo ant all" doesn't work.
Use this command to change ownership of OpenGTS files/dir
/usr/local/OpenGTS2.6.2> cd ..
sudo chown -R ranjan:ranjan OpenGTS2.6.2
change ranjan to your username: group name
/usr/local/OpenGTS2.6.2> ant all
It will work.
Try to install tomcat7 rather than tomcat6 via command line
apt-get update
apt-get install tomcat7
Configure CATALINA_HOME by
export CATALINA_HOME=/usr/share/tomcat7

How can I change the working directory when I run a script with ant sshexec in Jenkins?

I have a ant target where I successfully use a sshexec-task to install a server using tomcat on OpenSuse 11.
My problem comes when I try to run a script that start the newly installed server.
I need to do this as root, so I use a task as this:
<sshexec host="${tss.hostname}"
username="${username}"
password="${password}"
trust="true"
Command="/usr/local/bin/foo/bar/tomcat/bin/startup.sh"
failonerror="false"/>
The problem with this is that I need to run the script from the folder where it is located, as it finds CATALINA_HOME and JAVA_HOME from that location. And the path "foo/bar" will change over time so I do not want to set it permanently.
I just want to change my running path to the correct one.
As I failed to start the server like that, I wanted to investigate a bit and changed the script so I used "CommandResource="cmd.txt" instead of a direct command. I thought I could use this to set CATALINA_HOME before I started the server and go around the problem that way.
This is the outcome when using cmd.txt:
[sshexec] Connecting to foo-bar:22
[sshexec] cmd :
[sshexec] cmd : cd /usr/local/bin/foo/bar/tomcat/bin
[sshexec] cmd : pwd
[sshexec] /root
[sshexec] cmd : echo $PATH
[sshexec] /usr/java/jdk1.6.0_27/bin:/sbin:/usr/sbin:/usr/local/sbin:/root/bin:/usr/local/bin:/usr/bin:/bin:/usr/bin/X11:/usr/X11R6/bin:/usr/games:/opt/kde3/bin:/usr/lib/mit/bin:/usr/lib/mit/sbin
[sshexec] cmd : export CATALINA_HOME=$PATH:/usr/local/bin/tibco/tss/4.5.0/tomcat
[sshexec] cmd : echo $PATH
[sshexec] /usr/java/jdk1.6.0_27/bin:/sbin:/usr/sbin:/usr/local/sbin:/root/bin:/usr/local/bin:/usr/bin:/bin:/usr/bin/X11:/usr/X11R6/bin:/usr/games:/opt/kde3/bin:/usr/lib/mit/bin:/usr/lib/mit/sbin
This shows that neither the cd nor export command have any effect.
I suspect I need to change the rights for ssh. I have read that I may need to change in .ssh/config. But I do not know how or where...
So, to sum this long question up short:
What do I need to do to be able to run my startup.sh as root from the correct tomcat/bin folder with a ant script that is run in Jenkins?
I've found that "cd" works when done on the same line...
<sshexec host="${tss.hostname}"
username="${username}"
password="${password}"
trust="true"
Command="(cd /usr/local/bin/foo/bar/tomcat/bin; startup.sh)"
failonerror="false"/>
I haven't actually used this to run a shell script but I'll often have ant change directories and then run GIT commands.
Yeah I also faced the same problem. The cd command doesnot work from sshexec. Alternative is to put all the commands in some install.sh file and scp it to the remote machine. And then use sshexec commandresource to execute this file on the remote machine. Hope this helps.

Resources