linux 常用相关命令

编程入门 行业动态 更新时间:2024-10-12 20:23:46

linux 常用相关<a href=https://www.elefans.com/category/jswz/34/1771323.html style=命令"/>

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

更多推荐

linux 常用相关命令

本文发布于:2023-12-07 09:18:58,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1670814.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:命令   常用   linux

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!