linux环境搭建常用命令

mac2024-07-13  55

普通操作

[向上箭头][向下箭头]键可以滚动以前使用过的命令 Tab 键 #会把文件或路径名的剩余部分补全 . #代表此层目录 .. #代表上层目录 cd #进入root目录 cd / #进入根目录 cd 路径(绝对或者相对) #进入指定目录下 cd .. #进入上一层路径 pwd #显示当前目录 logout #注销当前系统登录用户 reboot #重启系统 shutdown #关机

包体安装与卸载

默认端口

8080 #tomcat的默认端口号 80 #apache与http的默认端口号 443 #https默认端口号 3306 #mysql默认端口号

进程查看

ps -ef | grep -i '进程关键字' #查看关键字相关进程状态 kill -9 进程号 #强制杀死进程 ps -auxf #相较于ps -ef还能查看进程所占用的资源

服务启停

redhat

service iptables status #查看防火墙状态 service iptables start/stop/restart #启动/关闭/重启防火墙服务 service mysql start/stop/restart #启动/关闭/重启mysql数据库服务 ./startup #先进入tomcat的bin目录下,重启tomcat ./shutdown #关闭tomcat service network start/stop/restart #启动/关闭/重启网卡 mysqladmin -u root password "123456" #设置数据库用户root的登录密码 mysql -h host -P port -u root -p #连接远程服务器,端口-P大写,密码-p小写 netstat -anp | grep '端口号' #查看端口状态

centos

ip add #查看ip地址 systemctl start/stop/restart firewalld.service #启动/关闭/重启防火墙 systemctl start/stop/restart mysqld.service #启动/关闭/重启数据库服务 systemctl start/stop/restart network.service #启动/关闭/重启网卡 mysql> GRANT ALL PRIVILEGES ON *.* TO ' username'@'%' IDENTIFIED BY 'password'; #进入数据库后授权远程登录

日志查看

/etc/httpd/logs #系统日志文件路径 tail -f 日志文件名 #查看日志文件

防火墙

/sbin/iptables -I INPUT -p tcp --dport 8080 -j ACCEPT #添加防火墙通过端口 修改/etc/sysconfig/iptables文件也可以添加
最新回复(0)