Essential Linux Commands Every Java Developer Should Master
A concise reference of the most useful Linux shell commands—from file searching and process management to networking and file compression—explains syntax, common options, and practical examples to help developers interact efficiently with Linux servers.
Java developers often need to work with Linux servers, so mastering a core set of shell commands is essential. This guide provides practical examples and explanations for frequently used commands without exhaustive detail; users can consult --help or search online for deeper options.
1. Find Files
find / -name filename.txt– locate filename.txt from the root directory. find . -name "*.xml" – recursively list all XML files. find . -name "*.xml" | xargs grep "hello world" – find XML files containing the phrase “hello world”. grep -H 'spring' *.xml – show XML files that contain the word “spring”. find ./ -size 0 | xargs rm -f & – delete zero‑byte files.
2. Check If a Program Is Running
ps -ef | grep tomcat– list processes related to Tomcat.
3. Terminate a Process
kill -9 19979– force‑kill the process with PID 19979.
4. List Files (including hidden)
ls -al5. Show Current Directory
pwd6. Copy Files
cp source dest– copy a single file. cp -r sourceFolder targetFolder – recursively copy a directory. scp sourceFile remoteUser@remoteIp:remotePath – copy a file to a remote host.
7. Create and Delete Directories
mkdir newfolder– create a new directory. rmdir deleteEmptyFolder – remove an empty directory. rm -rf deleteFile – recursively delete a directory and its contents.
8. Move or Rename Files
mv /temp/movefile /targetFolder– move a file. mv oldNameFile newNameFile – rename a file.
9. Switch User
su -username10. Change File Permissions
chmod 777 file.java– set read/write/execute for everyone (displayed as -rwxrwxrwx).
11. Archive and Compress
tar -czf test.tar.gz /test1 /test2– create a gzipped tarball. tar -tzf test.tar.gz – list contents of the tarball. tar -xvzf test.tar.gz – extract the archive.
12. View File Head/Tail
head -n 10 example.txt– show the first 10 lines. tail -n 10 example.txt – show the last 10 lines. tail -f example.log – follow a log file, displaying new lines as they appear.
13. Network Utilities
netstat -tln | grep 8080– check if port 8080 is listening. lsof -i :8080 – identify the process using port 8080. ping www.just-ping.com – test connectivity to a host. wget http://file.tgz or curl http://file.tgz – download a file. ssh userName@ip – log into a remote machine via SSH.
14. Display Environment Variables
echo $JAVA_HOME– print the value of the JAVA_HOME variable.
15. Common Java Commands
Utilities such as java, javac, jps, jstat, jmap, and jstack are frequently used for compiling, monitoring, and debugging Java applications.
16. Other Useful Tools
Version control and build tools like svn, git, and maven are also essential in daily development workflows.
Reference Links
Linux port conflict resolution: http://www.hollischuang.com/archives/239
Powerful find/grep usage: https://linux.cn/article-1672-1.html
General Linux command guide: https://blog.csdn.net/tianshijianbing1989/article/details/40780463
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.
Liangxu Linux
Liangxu, a self‑taught IT professional now working as a Linux development engineer at a Fortune 500 multinational, shares extensive Linux knowledge—fundamentals, applications, tools, plus Git, databases, Raspberry Pi, etc. (Reply “Linux” to receive essential resources.)
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.
