Linux常用指令

用户

#创建组
groupadd -g 1001 wls
#创建用户
useradd -u 1001 -g wls wls81
#创建服务用户
useradd -u 1001 -r -g wls -s /bin/false mongod
#删除用户
userdel wls81

Kernel limit

#max number of open file,默认1024
echo 'wls81            soft    nofile          65535' >> /etc/security/limits.conf
echo 'wls81            hard    nofile          65535' >> /etc/security/limits.conf
#verify
su wls81 -p -c 'ulimit -a'

#max number of processes,默认4096
echo 'wls81            soft    nproc           40960' >> /etc/security/limits.conf
echo 'wls81            hard    nproc           40960' >> /etc/security/limits.conf

#一个进程可以拥有的VMA(虚拟内存区域)的数量
sed -i '/vm\.max_map_count/d' /etc/sysctl.conf
echo 'vm.max_map_count=262144' >> /etc/sysctl.conf
sysctl -p
#verify
sysctl -a | grep vm.max_map_count

#Linux默认的15分钟超时,改成5次大约6秒
sed -i '/net\.ipv4\.tcp_retries2/d' /etc/sysctl.conf
echo 'net.ipv4.tcp_retries2=5' >> /etc/sysctl.conf
sysctl -p
#verify
cat /proc/sys/net/ipv4/tcp_retries2

禁用swap

#方案1. 直接禁用linux swap
#临时禁用swap
sudo swapoff -a
#永久禁用, 注释掉fstab文件swap的行
vim /etc/fstab

防火墙

#永久开放端口
firewall-cmd --zone=public --add-port=5601/tcp --permanent
#重新加载规则使其生效
firewall-cmd --reload
#查看所有开放的端口
firewall-cmd --zone=public --list-ports
#删除开放的端口
firewall-cmd --zone=public --remove-port=80/tcp --permanent
#启动
systemctl start firewalld.service
#关闭
systemctl stop firewalld.service
#禁用
systemctl disable firewalld
#重启
systemctl restart firewalld.service

debian

# 没安装则安装curl
dpkg -l | grep -q "^ii  curl" || (echo "curl not installed, installing curl..." && apt-get update && apt-get install -y curl)
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值