linux 常用相关命令

查看系统中有哪些用户

cut -d : -f 1 /etc/passwd

查看可以登录系统的用户

cat /etc/passwd | grep -v /sbin/nologin | cut -d : -f 1

查看系统中有哪些用户组

cut -d : -f 1 /etc/group

查看可以登录系统的用户组

cat /etc/group | grep -v /sbin/nologin | cut -d : -f 1

查看用户操作:w命令(需要root权限)

查看某一用户:w 用户名

查看登录用户:who

查看用户登录历史记录:last

修改root用户密码:passwd

root用户修改其他用户密码:passwd <user_name>

添加用户:adduser [用户名]

删除用户:userdel [用户名]

添加用户组:groupadd [组名]

删除用户组:groupdel [组名]

查看某个程序进程

ps -aux|grep java

杀死进程 kill -9  pid号

查看端口  lsof -i:端口号

查看某个文件  tail -f  xxx

删除某个文件  rm xx

删除文件夹 rm -rf xxx

centos 7  更改时区

# 删除当前时区文件

rm -f /etc/localtime

# 创建新的时区文件

ln -s /usr/share/zoneinfo/UTC /etc/localtime

# 时区信息

timedatectl

# 当前时间

date

设置时间

hwclock --set  --date '04/12/2021  11:37'
hwclock --hctosys
clock -w

系统重启 

shutdown -r now 
systemctl  stop  firewalld.service  关闭防火墙
systemctl  start  firewalld.service   启动
systemctl  status  firewalld.service  查看状态
# 开放tcp端口 
firewall-cmd --zone=public --add-port=6379/tcp --permanent
# 开放端口段 
firewall-cmd --zone=public --add-port=3000-4000/tcp --permanent
# 查看所有开放端口
firewall-cmd --zone=public --list-ports
# 启动
systemctl start firewalld
# 重启 设置端口后一定要重庆防火墙!!!
systemctl reload firewalld

查看磁盘大小

df -h
# 查找超过 800M的文件
find . -type f -size +800M
# 查找超过 800M的文件 以及文件信息
find . -type f -size +800M  -print0 | xargs -0 ls -l
# 查找超过 800M的文件 以及文件信息具体位置
find . -type f -size +800M  -print0 | xargs -0 du -h
# 查找超过 800M的文件 以及文件信息具体位置  按照大小排序
find . -type f -size +800M  -print0 | xargs -0 du -h | sort -nr

查找文件

find / -name *.cookie

授权 chmod +x 文件名

chmod +x install-prepare.sh

zip 命令

1、把/home目录下面的data目录压缩为data.zip
zip -r data.zip data #压缩data目录
2、把/home目录下面的data.zip解压到databak目录里面
unzip data.zip -d databak
3、把/home目录下面的a文件夹和3.txt压缩成为a123.zip
zip -r a123.zip a 3.txt
4、把/home目录下面的t.zip直接解压到/home目录里面
unzip t.zip
5、把/home目录下面的a1.zip、a2.zip、a3.zip同时解压到/home目录里面
unzip a*.zip
6、把/home目录下面w.zip里面的所有文件解压到第一级目录
unzip -j wt.zip

nc 命令

1、检测端口是否通
nc -vz IP 地址或域名 端口
nc -vz 172.168.30.131 28201

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值