zl程序教程

您现在的位置是:首页 >  系统

当前栏目

常用的shell命令汇总,夯实Linux基础

Linux基础命令shell 常用 汇总 夯实
2023-06-13 09:15:43 时间
lscpu                #查看CPU的统计信息

cat /proc/cpuinfo    #查看CPU详细信息,如每个CPU的型号等
2、内存相关
free -m              #概要查看内存情况,这里的单位是MB

cat /proc/meminfo    #查看内存详细信息
3、磁盘相关
lsblk                    #查看硬盘的分区分布,显示很值观

df -lh                   #查看各分区的情况

cat /proc/partitions     #查看硬盘和分区

mount | column -t        #查看挂接的分区状态
4、网卡相关
lspci | grep -i eth    #查看网卡硬件信息

ifconfig -a              #查看系统的所有网络接口

ethtool eth0             #如果要查看某个网络接口的详细信息,例如eth0的详细参数和指标
二、软件篇 1、内核相关
uname -a                 #查看版本当前操作系统内核信息

cat /proc/version        #查看当前操作系统版本信息

cat /etc/issue           #查看版本当前操作系统发行版本信息

cat /etc/redhat-release  #同上

cat /etc/SuSe-release    #suse系统下才可使用,同上

lsb_release -a           #用来查看Linux兼容性的发行版信息

lsmod                    #列出加载的内核模块
2、网络相关
ifconfig            #查看所有网络接口的属性

iptables -L         #查看防火墙设置

service iptables (start|stop|restart|status)    #服务管理内命令

route -n            #查看路由表

netstat -tnlp       #查看所有监听端口

netstat -antp       #查看所有已经建立的连接

netstat -s          #查看网络统计信息进程

netstat    -at      #列出所有tcp端口

netstat    -au      #列出所有udp端口

netstat -lt         #只列出所有监听tcp端口
3、系统管理
top                           #查看系统所有进程的详细信息,如CPU、内存等信息

mount                         #挂载远程目录、NFS、本地共享目录到Linux下

hostname                      #查看/修改计算机名

w                             #查看活动用户

id                            #查看指定用户信息

last                          #查看用户登录日志

cut -d: -f1 /etc/passwd       #查看系统所有用户

cut -d: -f1 /etc/group        #查看系统所有组

crontab -l                    #查看当前用户的计划任务

chkconfig --list              #列出所有系统服务

rpm -qa                       #查看所有安装的软件包

uptime                        #查看系统运行时间、用户数、负载
4、文件相关
ls -lht          #列出一个文件夹下所有文件及大小、访问权限

du -sh dir     #查看指定目录的大小

du -lh dir     #查看指定目录各文件的大小

ln -s            #建立软连接
5、进程相关
pstree -p pid            #查看一个进程的所有线程

pstree -a                #显示所有进程的所有详细信息,遇到相同进程名可以压缩显示

ps -ef                   #查看所有进程

kill -9 pid              #杀死进程

kill all test            #杀死进程

kill -9 `pgrep test`     #杀死进程

./test.sh              #使进程后台运行

nohup ./test.sh        #使进程后台运行
6、压缩解压缩相关
zip -r dir.zip dir file          #将目录dir、文件file等压缩到zip包

zip -re dir.zip dir file         #创建zip包,且加密

unzip dir.zip                    #解压

tar -zcvf dir.tar.gz dir file    #将目录dir、文件file等压缩到tar包

tar xf dir.tar.gz                #解压
7、screen命令
screen -S test        #创建一个名为test的screen

screen -r test        #打开名字为test的screen

screen -r pid         #打开进程号为pid的screen

screen -ls            #列出所有的screen

ctrl + a,d            #当在一个screen时,退出screen

ctrl + a,n            #当在一个screen时,切换到下一个窗口

ctrl + a,c            #当在一个screen时,创建一个新的窗口
8、scp命令
scp local_file remote_username@remote_ip:remote_dir        #拷贝本地文件到远程机器上

scp -r local_dir remote_username@remote_ip:remote_dir    #拷贝本地目录到远程机器上
9、软件包管理命令
//centos ,redhat系统

rpm -qa | grep app      #查找本机是否安装了app

rpm -ivh app.rpm        #安装app

yum install app         #在线安装app

yum update app          #更新app

rpm -e app              #删除已经安装的app

yum repolist            #列出可用的仓库

yum repolist all        #列出所有仓库

yum list all            #列出仓库中所有的软件包

yum make cache          #缓存远程仓库缓存信息

//suse,opensuse系统

zypper search app      #查找本机是否安装了app

zypper install app     #安装app

zypper update app      #更新app

zypper remove app      #删除app

zypper lr              #列出所有已定义的安装源

zypper ar              #添加新安装源

zypper rr              #删除指定的安装源

zypper mr              #修改指定的安装源

//ubuntu系统

apt-get install app    #安装

apt-get update app     #更新

apt-get remove app     #删除

apt-cache search app   #搜索软件包

dpkg -i app.deb        #假设你有app的deb包,直接安装

本文链接:http://www.yunweipai.com/8554.html

原创文章,作者:ItWorker,如若转载,请注明出处:https://blog.ytso.com/53234.html

centosiptablesjavalinuxUbuntu