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| grep tomcatView 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
cp source destCopy a file
cp -r sourceFolder targetFolderRecursively copy an entire directory
scp sourceFile remoteUserName@remoteIp:remoteAddrCopy a file to a remote host
7. Create a directory
mkdir newfolder8. Delete a directory
rmdir deleteEmptyFolderDelete an empty directory
rm -rf deleteFileRecursively delete all contents of a directory
9. Move a file
mv /temp/movefile /targetFolder10. Rename a file
mv oldNameFile newNameFile11. Switch user
su -username12. Change file permissions
chmod 777 file.javaSet permissions to rwxrwxrwx (read, write, execute for all)
13. Compress files
tar -czf test.tar.gz test1 test2Create a gzipped tar archive of test1 and test2
14. List contents of a compressed file
tar -tzf test.tar.gzList files inside the archive
15. Extract a compressed file
tar -xvzf test.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
sudo rm a.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
ps aux| grep javaShow Java processes
ps auxShow 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.tgzDownload using curl
On macOS, install wget if needed.
25. Network testing
ping www.just-ping.comPing a host to test connectivity
26. Remote login
ssh userName@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
svn git maven
Source: 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!
Qunar Tech Salon
Qunar Tech Salon is a learning and exchange platform for Qunar engineers and industry peers. We share cutting-edge technology trends and topics, providing a free platform for mid-to-senior technical professionals to exchange and learn.
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.