How to kill tomcat server?

This is the similar way to kill any responsive or unresponsive server/executable.

On MAC:

Step 1)

ps -awwef | grep tomcat

This gets the process identifier aka pid (3rd from the list when you run the command)

Step 2)

sudo kill -15 <pid>

Kills the given process

On WINDOWS:

Step 1)

netstat -o -n -a | findstr 8080

Step 2)

taskkill /F /PID 4184

 

Advertisements

UNIX/DOS Commands that I often use…

Command Description
sudo dscl . list /Users uid Lists all the users ids
sudo dscl . list groups gid Lists all the group ids
id -u
id -u RakeshChouhan
Gives the UID (user id) of username RakeshChouhan — Output is 502
nl Gives the number of lines the file has.
export Used to Set Environmental variables
sudo Execute a command as another user
sudo -i OR sudo sh Log in as root
exit switch back to RakeshChouhan
ssh-keygen -R localhost Removes latest added ssh key and retains the old one.
ssh localhost Shows the last ssh login
ssh-keygen -t rsa -P “” Generates a SSH key (id_rsa.pub)
sudo chmod 700 /etc/ssh_host_dsa_key Changing permissions to ssh_host_dsa_key
cat $HOME/.ssh/id_rsa.pub >> $HOME/.ssh/authorized_keys copies the generated id_rsa.pub to authorized_keys in .ssh folder
cp copies a file from source and pastes in the destination folder.
ln -s Sets the link for the given fileName to the destination folder where the given
filename exists
ps aux | less Shows all current running process ids, with % of memory usage
ps Shows all current running process ids at current instance
ps -ef Shows all running process and as well monitor and refreshes the result in each
interval
lsof Shows all processes and PID’s
mkdir Creates a directory for the given name.
kill 12345 Kills the process id
jps Shows all current running Java Processes
man Shows the manual page that you want to see
echo $JAVA_HOME Shows the current mapped JAVA_HOME environment variable
echo $HADOOP_HOME Shows the current mapped HADOOP_HOME environmental variable
echo $PATH Shows the system PATH variable
clear clears the current working terminal screen
java -version Gives the java version
hadoop version Gives the Hadoop Version
pwd Shows the current working directory
exit Ends the Terminal’s process
find -f macos Finds the file named macos in the HardDisk
find . -type d | grep {directoryName}
OR
find / -name {directoryName} -type d
Finds the directory named {directoryName} in the HardDisk
rm -R -i Removes/Deletes each file and each sub directory from the given directory Name
with a prompt for each file and sub directory
rm -rf Removes/Deletes all files and sub directories without a prompt.
rmdir Deletes the given directory
ls Lists out the Non hidden files and directories in the current folder
ls -a Lists out all the hidden and non hidden files and directories in the current
folder
ls -l Lists out all non hidden files and folders alphabetically, and shows the file
and directory permissions,user,created date.
ls -help Lists out all the non hidden files and folders with more details (Users,
Groups, Access levels)
ls -l file.txt; echo $? Check if the file.txt is present or not in a particular directory.
wc Displays the Counts of lines, words, bytes in this order for the given
fileName
cd Change Directory
cd ~ Go to previous directory
du -sh | grep G Determines the Disk Usage in GB.
tar -xvfz Un-tars filename
vi Opens file with vi editor tool.
jar -cvf WAR_NAME.war * Creates a war for the given folder (Note that you should be in that folder for
that folder to be war)
grep ‘{WORD_TO_FIND}’ ‘{IN_FILE}’ Searches a text in the file. Ex: grep boo /etc/passwd. See grep for more
options.
grep {GREP_OPTIONS} ‘{WORD_TO_FIND}’ ‘{IN_FILE}’ Searches a text in the file. If using grep option

a). -A 10
Displays 10 more lines after (from the line where the text was found).
Ex: grep -A 10 boo /etc/passwd.

b). -B 10
Displays 10 more lines before (from the line where the text was found).
Ex: grep -B 10 boo /etc/passwd.

c). -C 10
Displays 10 more lines before and after (from the line where the text was found).
Ex: grep -C 10 boo /etc/passwd.

See grep for more options.

what is Gives What is What. What Does What ????
touch Creates a text file
cat > {fileName} Creates a fileName and opens it for edit/writing. “control + z” saves the file
and returns.
mv Moves a file from Source location and drops in destination location
rmr Removes the mentioned file from the destination location
ifconfig Gives the ip, mac addresses
netstat Gives the network status
netstat – a | grep “10123” Determines which remote hosts are connecting to your host on a particular port
say 10123
nslookup Determines your hostname and IP and viceversa
uptime Determines from how many days your server is up
stat Displays the fileName attributes/properties
sudo -s launchctl load -w /System/Library/LaunchDaemons/ftp.plist Loads FTP Server
sudo -s launchctl unload -w /System/Library/LaunchDaemons/ftp.plist UnLoads FTP Server
sudo apachectl start Starts MacOSX default Apache Server
sudo apachectl stop Stops MacOSX default Apache Server
sudo apachectl restart ReStarts MacOSX default Apache Server
httpd -v Gives the current Apache version
head -5

test.txt

Prints/Displays the first 5 lines of file test.txt
sed ‘5,$d’ test.txt Prints/Displays the first 4 lines of file test.txt — sed is the text editor
same as vi editor.
tail -5

test.txt

Prints/Displays the last 5 lines of file test.txt
sed -n ‘$p’ test.txt Prints/Displays the last 4 lines of file test.txt — sed is the text editor
same as vi editor.
head -5
test.txt | tail -1
Displays/Prints the 5th line from file test.txt
sed -n ‘4
p’ test
Displays/Prints the 5th line from file test.txt using sed editor
grep -c “Unix” Counts the number of times the word ‘Unix’ occurs in the given file
sed s/Unix/UNIX/g Replaces the word containing ‘Unix’ with ‘UNIX for the given filename
cut -f3 Gives only phone numbers, if my filename has tab separated Name, Address and
Phone numbers.
awk -f3 Gives only phone numbers, if my filename has tab separated Name, Address and
Phone numbers.
exit -1 Logout and Fail a Shell Script programatically.
chown Change file owner to the given userName of a given filePath
chgrp Change file groupName for the given fileName
sudo chattr +i/-i Change advanced file attributes.
/usr/sbin/system_profiler SPHardwareDataType | grep Memory Shows RAM memory (16GB)
df -h Determines how much space is left in current drive. Determines Configured SWAP
space. Swap files are created in (/private/var/vm) directory.
uname -p or arch Displays the processor type. (Current Processor architecture type is i386)
uname -a Displays the type of OS running on top of UNIX. (Here Darwin)
sw_vers Shows the Operating Systems version.
gcc -v Determines whether the required version of gcc is installed
ping or telnet Determines if a remote host is alive or not
top Determines which process is taking how much CPU
telnet hostname port Check if a particular process is listening on a particular port on remote
host.
sudo scutil –set HostName rakeshchouhan.com Sets the hostname (HostName is case sensitive)
hostname Gives you the hostname (case-sensitive). This is the same command in Windows. Also, you can “echo %COMPUTER_NAME%” in Windows to get the hostname.
sudo lsof -i -P | grep 8001 gives the process id of the application which is using port 8001 (PID is 3rd
from the left)
unzip -t file.zip Determines if a Zip file is corrupted.
unzip -j file.zip Unzips a Zip file.
echo “unix” | rev Reverses a string. From unix to xinu
echo “C for Cat” | rev | cut -f1 -d’ ‘ | rev Gets the last word from a line in Unix file. Explanation: The entire line is
reversed (taC rof C), then we cut the first word, we get (taC) and reverse it again.
sysctl -n machdep.cpu.brand_string Gives Processor information
ex: Intel(R) Core(TM) i7-3820QM CPU @ 2.70GHz
system_profiler Gives all the information related to PC (Camera, Bluetooth, Processor, Memory,
Wireless, etc..)
sytem_profiler SPHardwareDataType Gives Hardware Overview Informations.
sysctl -a | grep machdep.cpu Gives all CPU related information
find / -name .DS_Store -delete This deletes all .DS_Store files from all folders of MAC OSX file system.
curl -O
http://www.interior-dsgn.com/apache/maven/maven-3/3.1.1/source/apache-maven-3.1.1-src.tar.gz
Downloads apache-maven-3.1.1-src.tar.gz
sudo ln -s /Library/Java/JavaVirtualMachines/jdk1.7.0_45.jdk
/System/Library/Java/JavaVirtualMachines/1.6.0.jdk
Set a different Java Virtual Machine
sudo apachectl start Starts apache2 server (verify http://localhost)
sudo apachectl stop Stops apache2 server
brew update Use brew to install packages. This command updates brew formulae’s
brew install {packageName} Installs brew packages. Ex: brew install apache-spark
watch -n1 ls Watches the folder every one second. This is useful to keep a continuous watch on any folder, instead of typing ls -l on the folder every time. In order to watch for every 5 seconds for a given folder, use “watch -n5 ls”
Note that ‘watch’ command isn’t available implicitly. So we need to brew it before.
Ex: brew install watch