linux常用指令(3)——进程、环境变量配置
2017-12-06 16:29
453 查看
进程
查看进程
ps -ef | grep 进程名 #显示和进程有关的进程
如:
[root@localhost ~]# ps -ef | grep ntp ntp 2607 1 0 23:13 ? 00:00:00 ntpd -u ntp:ntp -p /var/run/ntpd.pid -g root 2618 2502 0 23:14 pts/0 00:00:00 grep ntp
字段含义如下:
UID | PID | PPID | C | STIME | TTY | TIME | CMD |
---|---|---|---|---|---|---|---|
root | 2618 | 2502 | 0 | 23:14 | pts/0 | 00:00:00 | grep ntp |
- PID :这个程序的 ID
- PPID :这个程序上级父程序的ID
- C :CPU使用的资源百分比
- STIME :系统启动时间
- TTY :登入者的终端机位置
- TIME :使用掉的 CPU 时间。
- CMD :所下达的指令为何
终止进程
kill [参数] [进程名]
一般直接使用 kill -9 进程名 来结束进程, -9 表示强制终止
[root@localhost ~]# kill -9 2607 [root@localhost ~]# ps -ef | grep ntp root 2618 2502 0 23:14 pts/0 00:00:00 grep ntp
可以看出ntp这个进程已经被终止。
开启进程
开启ntp进程#检查ntp有无开启 [root@localhost ~]# service ntpd status ntpd is stopped #表示没有开启ntpd进程 #开启ntp [root@localhost ~]# service ntpd start Starting ntpd: [ OK] #检查ntp有无开启 [root@localhost ~]# service ntpd status ntpd (pid 2607)is running...
查看端口号
法一:直接查询[root@localhost ~]# netstat -nlp |grep 进程名
法二:pid查询
[root@localhost ~]# ps -ef | grep 进程名 #先得到进程的pid [root@localhost ~]# netstat -nlp |grep pid #利用pid得到端口号
如
[root@localhost ~]# netstat -nlp |grep ntp
#根据ps -ef | grep ntp得到的pid是2607 [root@localhost ~]# ps -ef|grep 2607
上述两种方法得到的结果都是:
udp 0 0 192.168.252.128:123 0.0.0.0:* 2607/ntpd udp 0 0 127.0.0.1:123 0.0.0.0:* 2607/ntpd udp 0 0 0.0.0.0:123 0.0.0.0:* 2607/ntpd udp 0 0 fe80::20c:29ff:fe25:1f0b:123 :::* 2607/ntpd udp 0 0 ::1:123 :::* 2607/ntpd udp 0 0 :::123 :::* 2607/ntpd
可以知道ntp的端口号是123
环境变量配置
权限 | 进入环境变量 | 生效配置 |
---|---|---|
全局 | vi /etc/profile | source /etc/profile |
个人 | vi ~/.bash_profile | source .bash_profile(.bashrc) |
vi ~/.bashrc | . .bash_profile(.bashrc) |
相关文章推荐
- linux下JDK环境变量的几种常用配置
- Linux常用便利工具 虚拟机安装jdk1.8 无需配置环境变量
- linux下配置jdk环境变量的几种常用方法
- Linux常用指令---$PATH (环境变量)
- linux下JDK环境变量的几种常用配置
- linux几个常用的环境变量配置文件
- linux进程中常用的全局数据之环境变量
- Linux下的Java局部与全局环境变量的配置
- Ubuntu Linux系统环境变量配置文件介绍
- Linux系统环境变量配置文件介绍
- Linux下配置java环境变量以及Eclipse配置
- Red Head Linux及Ununtu Linux下JDK环境变量配置
- Windows和Linux下的Java环境变量配置
- 在Linux系统环境下安装配置JDK常用方法
- linux下安装java jdk及环境变量配置
- linux配置java环境变量(详细)
- Java环境变量的常用配置
- Linux下配置Java环境变量,以及JNI调用权宜配置
- 配置Linux操作系统的环境变量
- linux中java环境变量的配置