面试常问的 25+ 个 Linux 命令
作者:HollisChuang 链接:http://www.hollischuang.com/archives/80
链接:http://www.hollischuang.com/archives/80
作为一个Java开发人员,有些常用的Linux命令必须掌握。即使平时开发过程中不使用Linux(Unix)或者mac系统,也需要熟练掌握Linux命令。因为很多服务器上都是Linux系统。所以,要和服务器机器交互,就要通过shell命令。
本文并不会对所有命令进行详细讲解,只给出常见用法和解释。具体用法可以使用
--help
查看帮助或者直接通过google搜索学习。1、查找文件
find / -name filename.txt
根据名称查找/目录下的filename.txt文件。find . -name "*.xml"
递归查找所有的xml文件find . -name "*.xml" |xargs grep "hello world"
递归查找所有文件内容中包含hello world的xml文件grep -H 'spring' *.xml
查找所以有的包含spring的xml文件find ./ -size 0 | xargs rm -f &
删除文件大小为零的文件ls -l | grep '.jar'
查找当前目录中的所有jar文件grep 'test' d*
显示所有以d开头的文件中包含test的行。grep 'test' aa bb cc
显示在aa,bb,cc文件中匹配test的行。grep '[a-z]\{5\}' aa
显示所有包含每个字符串至少有5个连续小写字符的字符串的行。2、查看一个程序是否运行
ps -ef|grep tomcat
查看所有有关tomcat的进程3、终止线程
kill -9 19979
终止线程号位19979的进程4、查看文件,包含隐藏文件
ls -al
5、当前工作目录
pwd
6、复制文件
cp source dest
复制文件cp -r sourceFolder targetFolder
递归复制整个文件夹scp sourecFile romoteUserName@remoteIp:remoteAddr
远程拷贝7、创建目录
mkdir newfolder
8、删除目录
rmdir deleteEmptyFolder
删除空目录rm -rf deleteFile
递归删除目录中所有内容9、移动文件
mv /temp/movefile /targetFolder
10、重命名
mv oldNameFile newNameFile
11、切换用户
su -username
12、修改文件权限
chmod 777 file.java
file.java 的权限-rwxrwxrwx
,r表示读、w表示写、x表示可执行13、压缩文件
tar -czf test.tar.gz /test1 /test2
14、列出压缩文件列表
tar -tzf test.tar.gz
15、解压文件
tar -xvzf test.tar.gz
16、查看文件头10行
head -n 10 example.txt
17、查看文件尾10行
tail -n 10 example.txt
18、查看日志类型文件
tail -f exmaple.log
这个命令会自动显示新增内容,屏幕只显示10行内容的(可设置)。19、使用超级管理员身份执行命令
sudo rm a.txt
使用管理员身份删除文件20、查看端口占用情况
netstat -tln | grep 8080
查看端口8080的使用情况21、查看端口属于哪个程序
lsof -i :8080
22、查看进程
ps aux|grep java
查看java进程ps aux
查看所有进程23、以树状图列出目录的内容
tree a
24、文件下载
wget http://file.tgz
curl http://file.tgz
25、网络检测
ping www.just-ping.com
26、远程登录
ssh userName@ip
27、打印信息
echo $JAVA_HOME
打印java home环境变量的值28、java 常用命令
java javac jps ,jstat ,jmap, jstack
29、其他命令
svn git maven
参考资料:
Linux端口被占用的解决(Error: JBoss port is in use. Please check)http://www.hollischuang.com/archives/239linux 中强大且常用命令:find、grephttps://linux.cn/article-1672-1.htmlLinux命令https://blog.csdn.net/tianshijianbing1989/article/details/40780463
官方站点:www.linuxprobe.com
Linux命令大全:www.linuxcool.com
刘遄老师QQ:5604922
Linux技术交流群:193666693
(新群,火热加群中……)
想要学习Linux系统的读者可以点击"阅读原文"按钮来了解书籍《Linux就该这么学》,同时也非常适合专业的运维人员阅读,成为辅助您工作的高价值工具书!
阅读原文 最新评论
推荐文章
作者最新文章
你可能感兴趣的文章
Copyright Disclaimer: The copyright of contents (including texts, images, videos and audios) posted above belong to the User who shared or the third-party website which the User shared from. If you found your copyright have been infringed, please send a DMCA takedown notice to [email protected]. For more detail of the source, please click on the button "Read Original Post" below. For other communications, please send to [email protected].
版权声明:以上内容为用户推荐收藏至CareerEngine平台,其内容(含文字、图片、视频、音频等)及知识版权均属用户或用户转发自的第三方网站,如涉嫌侵权,请通知[email protected]进行信息删除。如需查看信息来源,请点击“查看原文”。如需洽谈其它事宜,请联系[email protected]。
版权声明:以上内容为用户推荐收藏至CareerEngine平台,其内容(含文字、图片、视频、音频等)及知识版权均属用户或用户转发自的第三方网站,如涉嫌侵权,请通知[email protected]进行信息删除。如需查看信息来源,请点击“查看原文”。如需洽谈其它事宜,请联系[email protected]。