How to get only the process ID for a specified process name on Linux? November 12, 2023 by Tarik You can use: ps -ef | grep '[j]ava' Or if pgrep is available then better to use: pgrep -f java