1.给普通用户加sudo权限且不需要输入密码
vi /etc/sudoers
在配置文件中root 下一行加入
jepson ALL=(root) NOPASSWD:ALL
2.进程号
[root@hadoop001 ~]# ps -ef | grep tail
root 2048 1962 0 21:11 pts/1 00:00:00 tail -F tail.log
root 2053 1835 0 21:12 pts/0 00:00:00 grep tail
[root@hadoop001 ~]#
[root@hadoop001 ~]# ps -ef|grep tail | grep -v grep
root 2048 1962 0 21:11 pts/1 00:00:00 tail -F tail.log
进程用户 pid 父pid 进程的内容
杀死进程: kill -9 pid
[root@hadoop001 ~]# ps -ef|grep tail
root 2095 1962 0 21:17 pts/1 00:00:00 tail -F tail.log
root 2098 2075 0 21:17 pts/2 00:00:00 tail -F tail1.log1
root 2101 1835 0 21:17 pts/0 00:00:00 grep tail
[root@hadoop001 ~]#
[root@hadoop001 ~]#
[root@hadoop001 ~]# kill -9 2095 2098 和 kill -9 $(pgrep -f tail) 效果一样
- 提醒: 生产上假如非要执行kill杀进程,一定要确认清楚
- 1.该进程是否真的杀?需求确认清楚
- 2.杀的进程是否你想要杀?
3.端口号
netstat
[root@hadoop001 ~]# ps -ef|grep ssh
root 1460 1 0 20:17 ? 00:00:00 /usr/sbin/sshd
root 1831 1460 0 20:22 ? 00:00:00 sshd: root@pts/0,pts/1,pts/2
root 2364 1835 0 21:22 pts/0 00:00:00 grep ssh
找到ssh的进程的pid 1460,再通过pid找到该进程的端口号
[root@hadoop001 ~]# netstat -nlp|grep 1460
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1460/sshd
tcp 0 0 :::22 :::* LISTEN 1460/sshd
[root@hadoop001 ~]#
[root@hadoop001 ~]# netstat -nlp|grep ssh
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1460/sshd
tcp 0 0 127.0.0.1:6010 0.0.0.0:* LISTEN 1831/sshd
tcp 0 0 127.0.0.1:6011 0.0.0.0:* LISTEN 1831/sshd
tcp 0 0 127.0.0.1:6012 0.0.0.0:* LISTEN 1831/sshd
tcp 0 0 :::22 :::* LISTEN 1460/sshd
tcp 0 0 ::1:6010 :::* LISTEN 1831/sshd
tcp 0 0 ::1:6011 :::* LISTEN 1831/sshd
tcp 0 0 ::1:6012 :::* LISTEN 1831/sshd
[root@hadoop001 ~]#
注意:端口号对外服务的ip地址,假如为127.0.0.1或localhost,只能在这台的机器上访问这个服务。
一般这个地址为机器的ip或0.0.0.0 或 :::,表示对外的任意ip可以服务
[root@hadoop001 ~]# netstat -nlp|grep httpd
tcp 0 0 :::80 :::* LISTEN 2425/httpd
4.搜索
find / -name 'tail' 查看根目录是否有 tail文件
find / -name '*tail*'
abtail
abtailc
tailc
5.安装 rpm包
yum search http 查找包含有http名称的rpm包
yum intall -y httpd 安装httpd包
yum remove httpd 卸载httpd包
rpm -qa |grep httpd 查看是否已经安装httpd包
rpm -e mysql-5.1.73-8.el6_8.x86_64 卸载mysql-5.1.73-8.el6_8.x86_64 包,但如果有依赖关系,肯定卸载不掉
rpm -e --nodeps httpd-2.2.15-69.el6.centos.x86_64 卸载mysql-5.1.73-8.el6_8.x86_64 包,不会校验依赖性
6.which 查找普通命令路径
[root@localhost ~]# which pwd
/usr/bin/pwd
7.安装rz sz上传下载工具
[root@localhost ~]# yum install lrzsz -y