一些自己常用的linux命令笔记

  • firewall-cmd --list-all   //防火墙
  • yum search bash-com   //查看常用的shell脚本语言
  • yum install bash-completion bash-completion-extras   //安装自动补全
  • hostnamectl set-hostname %%     //修改hsotname%%
  • yum search maria   //查找maria数据库是否存在
  • yum install mariadb-server    //安装mariadb
  • yum search jdk   //查看jdk相关信息
  • java -version    //显示jdk版本
  • yum install java-1.8.0-openjdk-devel    //安装jdk
  • yum search tomcat     //查看tomcat信息
  • yum install tomcat      //下载tomcat
  • yum search nginx      //查看nginx信息
  • yum install nginx       //下载nginx
  • systemctl enable mariadb.service      //重启服务
  • systemctl enable nginx.service          //重启服务
  • systemctl enable tomcat.service         //重启服务
  • yum search unison        //查看文件同步工具
  • yum install unison240     //下载文件同步工具
  • yum search rsync    //查看数据镜像备份工具
  • yum install rsync    //下载数据镜像备份工具
  • systemctl status mariadb.service   //查看Mariadb状态
  • systemctl start mariadb.service    //启动Mariadb
  • mysql_secure_installation    //启动MySQL安全配置向导(按提示配置即可)
* Remove anonymous users? [Y/n] <– 是否删除匿名用户,回车
* Disallow root login remotely? [Y/n] <– 是否禁止 root 远程登录 , 回车 ,
* Remove test database and access to it? [Y/n] <– 是否删除test数据库,回车
* Reload privilege tables now? [Y/n] <– 是否重新加载权限表,回车
  • vim /etc/my.cnf.d/server.cnf    //配置MySQL信息
  • file dzfp_project.sql   //查看文件
  • mysql -u root -p    //登入MySQL
  • grant all privileges on *.* to root@"%" identified by "Aa123456Aa";  //设置MySQL可以远程
  • flush privileges;   //刷新
  • quit  //退出MySQL命令页
  • mv dzfp_project.war /var/lib/tomcat/webapps  //将运行包移动到tomcatwebapps
  • cd /etc/nginx   //nginx配置文件夹   
  • vim nginx.conf  //编辑nginx配置文件
  • vim编辑  i进入编辑模式;按:q不保存退出;按:wq保存退出 :wq! 强制保存后退出
    server {
        listen       80 default_server;
        listen       [::]:80 default_server;
        server_name  localhsot:8080_;
        root         /usr/share/nginx/html;
 
        # Load configuration files for the default server block.
        include /etc/nginx/default.d/*.conf;
 
        location / {
        proxy_pass http://localhost:8080;
        }
 
        error_page 404 /404.html;
            location = /40x.html {
        }
 
        error_page 500 502 503 504 /50x.html;
            location = /50x.html {
        }
    }
  • shutdown -h now 立刻关机
  • shutdown -r now 立刻重启
  • shutdown -h 5 5分钟后关机

     注意:
      linux是不允许秒级关机的,他是分钟级的,如果想设置5秒后关机,可以这样:
      sleep 5 && shutdown -h now ---休眠5秒,执行立即关机的指令


 查看进程
  • # ps -aux|grep java   //显示所有进程名中包含java字符串的进程
grep是查找字符串,把包含有匹配字符串的那行显示出来。
-aux 显示所有包含其他使用者的进程

杀进程
  • # kill pid    //根据进程id杀进程
  • # killall process_name    //kill掉所有进程名为指定参数值的进程
如果在前面加上-9表示强制kill,如:kill -9 2992
  • curl cip.cc 查看公网IP
ls -l或者是ls -l 文件名称 查看文件权限 read --表示可读 write ---表示可写入 execute 表示可执行 directory --- 表示他是一个目录

  • netstat –apn | more ----显示所有端口号
  • netstat -anp | grep 8080 ----显示端口

查找
  • find -name "*tomcat*" //我要查找带有tomcat 的文件
  • find /var -name test.file 如果已经知道了文件的具体目录
  • 快捷键 Ctrl+l(L的小写) //linux的清屏命令
  • 新建一个目录: mkdir name
  • 删除一个目录:rmdir name
  • useradd 新建一个用户
  • userdel 删除一个用户
  • su name 切换用户
  • cat /etc/passwd 可以查看所有用户的列表






猜你喜欢

转载自blog.csdn.net/weixin_36380516/article/details/79013286