常用命令行

目录

记录一些常用命令行

Linux

  1. 查找包含关键字的进程
1
$ ps -ef | grep {关键字}
  1. 查看指定进程的相关信息
1
$ top -p pid
  1. 查看端口占用
1
$ lsof -i:80
  1. 离线安装rpm包
1
2
3
4
5
6
# 单个安装
$ rpm -Uvh xxxx.rpm --nodeps --force
$ yum localinstall -y xxxx.rpm
# 批量安装
$ rpm -Uvh *.rpm --nodeps --force
$ yum localinstall -y ./*
参数说明

-U:升级软件,若未软件尚未安装,则安装软件。

-v:表示显示详细信息。

-h:以"#“号显示安装进度。

–force:强制安装

–nodeps:不考虑相依属性的关系

rpm 命令安装,无法解决软件包的依赖关系。

yum 命令安装,自动解决相依性的问题。

  1. JVM堆内存dump
1
$ jmap -dump:live,format=b,file=xxxx.hprof pid
  1. Jconsole工具
1
$ jconsole
  1. 查看系统基础信息
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
$ hostnamectl
 Static hostname: leadmap-PC
       Icon name: computer-vm
         Chassis: vm 🖴
      Machine ID: ec0a8338c55e4ebba307350af965d2ac
         Boot ID: 69feb3b5a4414864bf5ddc3e8f99b081
  Virtualization: vmware
Operating System: Deepin 20.6
          Kernel: Linux 5.10.101-amd64-desktop
    Architecture: x86-64
 Hardware Vendor: VMware, Inc.
  Hardware Model: VMware Virtual Platform
  1. 杀死符合条件的所有进程
1
$ kill -9 $(ps -ef | grep "code-server" | grep -v grep | awk '{print $2}')
  1. 查看某软件的安装路径
1
2
3
$ whereis java
java: /usr/bin/java
$ ls -lrt /usr/bin/java
  1. Shell脚本自带sudo密码
1
2
# echo {密码} | sudo -S {Shell命令}
echo 123 | sudo -S service ssh start
0%