Common Linux Commands for Java Developers
This article provides Java developers with a concise reference of essential Linux shell commands, covering process inspection, file manipulation, permission changes, compression, networking checks, remote access, and other common operations needed for interacting with Linux servers during development and deployment.
As a Java developer, certain common Linux commands must be mastered. Even if you usually develop on Windows or macOS, you need to be proficient with Linux commands because many servers run Linux, and interacting with those servers requires shell commands.
This article does not explain every command in detail; it only presents common usage and explanations. For full usage, you can view help with --help or search online.
2. Check if a program is running
ps-ef|greptomcatView all processes related to tomcat
3. Terminate a process
kill-9 19979Terminate the process with PID 19979
4. List files, including hidden ones
ls-al5. Show current working directory
pwd6. Copy files
cpsourcedestCopy a file
cp-r sourceFolder targetFolderRecursively copy an entire directory
scpsourceFile remoteUserName@remoteIp:remoteAddrCopy a file to a remote host
7. Create a directory
mkdirnewfolder8. Delete a directory
rmdirdeleteEmptyFolderDelete an empty directory
rm-rf deleteFileRecursively delete all contents of a directory
9. Move a file
mv/temp/movefile/targetFolder10. Rename a file
mvoldNameFile newNameFile11. Switch user
su-username12. Change file permissions
chmod777file.javaSet permissions to rwxrwxrwx (read, write, execute for all)
13. Compress files
tar-czftest.tar.gztest1 test2Create a gzipped tar archive of test1 and test2
14. List contents of a compressed file
tar-tzftest.tar.gzList files inside the archive
15. Extract a compressed file
tar-xvzftest.tar.gzExtract the gzipped tar archive
16. View first 10 lines of a file
head-n 10 example.txt17. View last 10 lines of a file
tail-n 10 example.txt18. Monitor a log file
tail-f example.logContinuously display new content appended to the log (default shows last 10 lines)
19. Execute a command as superuser
sudorma.txtDelete a.txt with administrator privileges
20. Check port usage
netstat-tln | grep 8080Show whether port 8080 is in use
21. Identify which program uses a port
lsof-i :808022. View processes
psaux| grep javaShow Java processes
psauxShow all processes
23. List directory contents as a tree
tree aDisplay directory a in a tree format (available on macOS)
24. Download files
wget http://file.tgzDownload using wget curl http://file.tgz Download using curl
On macOS, install wget if needed.
25. Network testing
ping www.just-ping.comPing a host to test connectivity
26. Remote login
sshuserName@ipConnect to a remote host via SSH
27. Print information
echo$JAVA_HOMEPrint the value of the JAVA_HOME environment variable
28. Common Java commands
java, javac, jps, jstat, jmap, jstack
29. Other useful commands
svngitmavenSource: java一日一条
Long press the QR code to open in a browser.
Download the online course app instantly.
Supports Android and iOS.
Qunar’s latest and hottest video courses are all here!
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
