Which user is running the tomcat on Amazon EC2? - linux

I have a Tomcat 7 server running on Amazon EC2 (OS - Ubuntu 12 LTS). How can I find out which user is running Tomcat on Amazon EC2?

Try this command:
ps auxwww | grep tomcat | grep -v grep
you will get output like this
$ ps auxwww | grep tomcat | grep -v grep
root 1941 0.2 1.7 419224 35208 ? Sl Aug12 0:06 /usr/lib/jvm/java-6-sun/bin/java -Djava.util.logging.config.file=/usr/local/tomcat/conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Djava.endorsed.dirs=/usr/local/tomcat/endorsed -classpath /usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar -Dcatalina.base=/usr/local/tomcat -Dcatalina.home=/usr/local/tomcat -Djava.io.tmpdir=/usr/local/tomcat/temp org.apache.catalina.startup.Bootstrap start
there you get the process owner name and process id..

Related

Command `docker` can not work with pipeline. Do not work with `|`, `>`, `>>` [duplicate]

This question already has answers here:
How can I pipe stderr, and not stdout?
(11 answers)
Closed 3 years ago.
I want to search some text output by command docker, but it seems not work with pipeline.
My expected result of docker > a should write all output in the terminal to file a. And expected result of docker | grep info should print something that contains info Display system-wide information.
I added myself to the group docker.
The following is test cases.
lala#ubu:~/projects/docker 14:19:42
$ grep docker /etc/group
docker:x:999:lala
lala#ubu:~/projects/docker 14:19:47
$ ls -al
总用量 8
drwxr-xr-x 2 lala lala 4096 1月 10 14:15 .
drwxr-xr-x 10 lala lala 4096 1月 10 10:21 ..
lala#ubu:~/projects/docker 14:19:57
$ ls -al | grep x
drwxr-xr-x 2 lala lala 4096 1月 10 14:15 .
drwxr-xr-x 10 lala lala 4096 1月 10 10:21 ..
lala#ubu:~/projects/docker 14:20:01
$ docker
Usage: docker [OPTIONS] COMMAND
A self-sufficient runtime for containers
Options:
...... unnecessary output
Run 'docker COMMAND --help' for more information on a command.
lala#ubu:~/projects/docker 14:20:03
$ docker | grep x
Usage: docker [OPTIONS] COMMAND
A self-sufficient runtime for containers
Options:
...... the same as above. unnecessary output
Run 'docker COMMAND --help' for more information on a command.
lala#ubu:~/projects/docker 14:20:15
$ docker > a
Usage: docker [OPTIONS] COMMAND
A self-sufficient runtime for containers
Options:
...... the same as above again. unnecessary output
Run 'docker COMMAND --help' for more information on a command.
lala#ubu:~/projects/docker 14:21:26
$ cat a
lala#ubu:~/projects/docker 14:21:28
$ file a
a: empty
lala#ubu:~/projects/docker 14:21:30
$
docker >> a did not work, either.
that is because , docker command need some arguments that is it returing errors, you can use this:
docker 2>&1| grep info
output:
-l, --log-level string Set the logging level ("debug"|"info"|"warn"|"error"|"fatal") (default "info")
-v, --version Print version information and quit
info Display system-wide information
inspect Return low-level information on Docker objects
version Show the Docker version information
Run 'docker COMMAND --help' for more information on a command.
anyway the correct way is just to type:
docker info --help
output:
Usage: docker info [OPTIONS]
Display system-wide information
Options:
-f, --format string Format the output using the given Go template

SSH doesn't run commands following sudo

I'm trying to execute multiple commands on a remote server. The issue I'm having is that after the sudo command is ran, the ssh connection gets closed automatically.
The main test that is failing:
ssh -i "/path/to/key/id_rsa" user#server << EOF
sudo ls -la "/etc/redhat-release"
cat "/etc/redhat-release"
EOF
Returns only the ls result
-rw-r--r-- 1 root root 55 Jan 29 2013 /etc/redhat-release
While if I put both commands on the same line, i.e.
ssh -i "/path/to/key/id_rsa" user#server << EOF
sudo ls -la "/etc/redhat-release"; cat "/etc/redhat-release"
EOF
I will get the result of both commands
-rw-r--r-- 1 root root 55 Jan 29 2013 /etc/redhat-release
Red Hat Enterprise Linux Server release 6.4 (Santiago)
Now for the weirdest part:
the main test does work on an other server with identical configuration. There are sets of servers where it works, and other sets where it doesn't.
if I remove the sudo from the test, I will get the result from both commands, so it's not an ssh limitation
e.g.
ssh -i "/path/to/key/id_rsa" user#server << EOF
ls -la "/etc/redhat-release"
cat "/etc/redhat-release"
EOF
-rw-r--r-- 1 root root 55 Jan 29 2013 /etc/redhat-release
Red Hat Enterprise Linux Server release 6.4 (Santiago)
Additional information:
Both commands have the NOPASSWD flag in the sudoers file so no password is asked.
requiretty is commented out.
ssh version: OpenSSH_5.3p1, OpenSSL 1.0.0-fips 29 Mar 2010
SELinux is disabled
the ssh -vvv option doesn't show any significant difference in the logs between a working and non-working server
sshd_config are the same between a working and non-working server
I'm assuming here that there must be some configuration difference between the sets of servers because they are consistent with each-other, but I can't figure out what.
One possible workaround:
ssh -i "/path/to/key/id_rsa" user#server sudo bash << EOF
ls -la "/etc/redhat-release"
cat "/etc/redhat-release"
EOF
Check your sudo version (sudo -V).
Turns out one server was running Sudo version 1.8.6p3 while the other was on Sudo version 1.8.21p2 and a was running in a bug which was fixed in sudo 1.8.20:
Fixed an issue where sudo would consume stdin if it was not connected to a tty even if log_input is not enabled in sudoers. Bug #786.
Updating the sudo version fixed the issue.

ubuntu does not show username in ps -ef command

I have a wildfly server which is running on Ubuntu as a service. I've done all steps at this site: WildFly as a Service on Linux. But the running server can not reach(get permission errors) some root owned files, although I have given root authority to wildfly9_test(adding it sudo and admin group) user. After start service with sudo and then when I run command:
ps -ef |grep java
the output is:
999 27945 27859 9 07:27 pts/1 00:03:08 /usr/local/java/jre1.7.0_79/bin/java -D[Standalone] -server -XX:+UseCompressedOops -server -XX:+UseCompressedOops -Xms2048m -Xmx4096m -XX:MaxPermSize=512m -Djava.net.preferIPv4Stack=true -Djboss.modules.system.pkgs=org.jboss.byteman -Djava.awt.headless=true -Dorg.jboss.boot.log.file=/opt/wildfly-9.0.0.Final_test/standalone/log/server.log -Dlogging.configuration=file:/opt/wildfly-9.0.0.Final_test/standalone/configuration/logging.properties -jar /opt/wildfly-9.0.0.Final_test/jboss-modules.jar -mp /opt/wildfly-9.0.0.Final_test/modules org.jboss.as.standalone -Djboss.home.dir=/opt/wildfly-9.0.0.Final_test -Djboss.server.base.dir=/opt/wildfly-9.0.0.Final_test/standalone -c standalone.xml
root 28736 27788 0 08:02 pts/1 00:00:00 grep --color=auto java
Here is lsb_release -a command output:
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 11.10
Release: 11.10
Codename: oneiric
Why is ps command gets 999(userid) instead of username(wildfly9_test)?
Because of the same problem, does wildfly9_test user not have sudo privileges?
ps only shows the user names up to a certain length, for longer user names it shows the numeric id instad, I guess wildfly9_test is simply too long. And adding a user to the sudo and admin groups doesn't give them automatic access to root owned files but only to files accessible by those groups (and the ability to use sudo).
– mata

puppet: puppetDB and templatedir

I installed some puppet server and puppetDB:
[root#her code]# puppet master --version
4.3.1
[root#her code]# uname -a
Linux her 3.10.0-327.3.1.el7.x86_64 #1 SMP Wed Dec 9 14:09:15 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux
[root#her code]# cat /etc/centos-release
CentOS Linux release 7.2.1511 (Core)
[root#her code]# rpm -qa | grep pupp
puppetlabs-release-pc1-1.0.0-1.el7.noarch
puppet-agent-1.3.2-1.el7.x86_64
puppetserver-2.2.1-1.el7.noarch
[root#her code]# puppet module list
/etc/puppetlabs/code/environments/production/modules
+-- puppetlabs-apt (v2.2.1)
+-- puppetlabs-concat (v1.2.5)
+-- puppetlabs-firewall (v1.7.2)
+-- puppetlabs-inifile (v1.4.3)
+-- puppetlabs-postgresql (v4.6.1)
+-- puppetlabs-puppetdb (v5.0.0)
L-- puppetlabs-stdlib (v4.10.0)
/etc/puppetlabs/code/modules (no modules installed)
/opt/puppetlabs/puppet/modules (no modules installed)
this man
and now i have some questions:
How to know than puppetDB is work? I can't see it in 'ps ax' output, that's ok?
[root#her code]# ps ax | grep pupp | grep -v grep
23423 ? Ssl 1:41 /usr/bin/java -Xms2g -Xmx2g -XX:MaxPermSize=256m -XX:OnOutOfMemoryError=kill -9 %p -Djava.security.egd=/dev/urandom -cp /opt/puppetlabs/server/apps/puppetserver/puppet-server-release.jar clojure.main -m puppetlabs.trapperkeeper.main --config /etc/puppetlabs/puppetserver/conf.d -b /etc/puppetlabs/puppetserver/bootstrap.cfg
[root#her code]# ps ax | grep sql | grep -v grep
Where i can set templatedir? In puppet 3.8 it's done in /etc/puppet/puppet.conf, but in this version i dunno where is this set...
Concerning templatedir, that is a concept that was actually deprecated in Puppet 3.8. It did not carry over to Puppet 4.x.
You want to switch to directory environments where each module has its own stash of templates. It's not a good practice to use templates outside of modules.

Unable to execute docker command while docker is running

I am trying to run the following docker commmand:
docker run --name my_postgres -d -p 127.0.0.1:5432:5432 -v /volumes/data:/var/lib/postgresql/data postgres
But I receive the following error:
2015/09/15 20:57:57 Cannot connect to the Docker daemon. Is 'docker -d' running on this host?
This is odd since I have docker up and running on my computer:
~ ps aux | grep docker
root 31083 0.1 0.0 355636 15420 ? Ssl 20:58 0:00 /usr/bin/docker.io -d
Use sudo docker run .... or read the following page to enable non-sudo run for your docker
https://askubuntu.com/questions/477551/how-can-i-use-docker-without-sudo

Resources