Linux常用命令

reboot                                                                       

重启机器

poweroff                                                        

关闭系统

useradd tiantian                     

添加用户tiantian

password 123456                                         

设置密码为123456

su - username                                               

切换用户 -代表完全切换到新用户(包含环境变量)

whoami                                                          

查当前登录人

echo '11' > 11.txt                                            

清空11.txt文件内容后再输入11

echo '11' >> 11.txt                                          

不清空11.txt文件内容直接在文件最后追加11

systemctl status firewalld                               

查看防火墙状态

systemctl stop firewalld                                  

关闭防火墙

systemctl start firewalld                  

启动防火墙

systemctl disabled firewalld                            

关闭防火墙开机自启

systemctl is-enabled firewalld.service                                         

查看防火墙是否开机自启

systemctl enable firewalld                                                           

设置防火墙开机自启

systemctl restart firewalld                                                           

重启防火墙

mv 11.txt 11.log                     

修改文件11.txt 为11.log

mv -i 11.txt 22.txt                        

修改文件11.txt 为22.txt并询问是否覆盖内容

touch 11.txt                                                   

创建文件11.txt 

cat filename                                                                                 

一次性完整显示整个文件

cat file1 file2 > file3                                                                     

file1和file2合并成file3 显示   可以不指定file3

more 11.txt                        

11.txt已显示屏适应的页数进行显示  此状态下按space 表示下一页,按B键代表返回上一页

more +3 11.txt                                                                             

11.txt从第三行开始显示

less 11.txt                        

查看11.txt文件,可以使用shift+g获取当前最新数据

tail -f 11.txt                                                                                   

实时输出11.txt

head 11.txt -n 10                                                                         

输出11.txt文件前10行

head -n -10 11.txt                     

输出11.txt文件后10行

which mysql                       

查询mysql执行文件位置

whereis mysql                                                                             

查询mysql文件位置

ps -ef | grep tomcat                                                                     

查询tomcat进程

ps -ef|greo tomcat -c                                                                   

查询tomcat进程个数

cat 11.txt |grep 1                                                                         

正则匹配11.txt中包含1的地方

df -h                                                                                             

易读的方式显示目前磁盘空间和使用情况

du -h --max-depth=1                     

输出当前目录下各个子目录所使用的空间

history                           

列出历史命令

ps -aux|grep tomcat                      

显示所有包含其它使用的进程

top                           

显示当前系统正在执行的进程的相关信息,包括进程ID、内存占用率、CPU占用率等

kill -9 1221                       

杀掉PID为1221的进程

netstat -tunlp |grep tomcat                 

查看tomcat端口是否存活

lsof -i:8000

查看8000端口使用情况

posted @ 2018-03-09 11:53  十二A~  阅读(132)  评论(0)    收藏  举报