Linux [Command]

本文提供了一系列系统管理工具和性能监控技术,包括查看状态、内存使用、IO状态、CPU负载、网络统计等,帮助您深入理解系统运行状况并进行有效优化。

**查看状态**

top

说明: 查看当前的运行情况

相关参数:

H : 打开native thread线程信息,可以用于查看java进程下对应thread的执行情况,目前jvm的thread和native thread是1:1。
1 : 数字1,打开详细多cpu的使用情况
u : 选择指定用户进程
<Enter> or <Space> : 刷新记录
A : 打开top的4个视图
G : 选择top的1-4的其中一个视图

free 

-m

-g

dstat

说明:查看系统各种类型的运行状态

相关参数:

-c : cpu使用情况
-d : 文件系统读写情况
-g : 操作系统内存页换入/换出情况
-i : 查看系统中断情况,可查看到对应的中断id
-n : 网络传输情况
-p : 进程状态
-t : 打印系统时间
--tcp : 当前tcp状态
dstat -taf == vmstat -n 1

vmstat

说明:查看系统总体状态

vmstat -n 1

mpstat

说明:查看cpu状态

mpstat -P 0 deplay counts
mpstat -P ALL 1 #查看所有cpu的运行情况

iostat

说明:查看系统io状态

iostat -d 1


#3: w - Find Out Who Is Logged on And What They Are Doing 
#4: uptime - Tell How Long The System Has Been Running 
#5: ps - Displays The Processes 
#6: free - Memory Usage 
The command free displays the total amount of free and used physical and swap memory in the system, as well as the buffers used by the kernel. 
#7: iostat - Average CPU Load, Disk Activity 
#8: sar - Collect and Report System Activity 
#9: mpstat - Multiprocessor Usage 
The mpstat command displays activities for each available processor, processor 0 being the first one. mpstat -P ALL to display average CPU utilization per processor: 
#10: pmap - Process Memory Usage 
The command pmap report memory map of a process. Use this command to find out causes of memory bottlenecks. 
#11 and #12: netstat and ss - Network Statistics 
#13: iptraf - Real-time Network Statistics 
#14: tcpdump - Detailed Network Traffic Analysis 
#15: strace - System Calls 

**环境设置文件**
系统设置值

/etc/sysconfig/i18n

语系数据

/etc/profile

设置总体的 PATH 等信息,这个文件也规划出/etc/profile.d 和 /etc/inputrc

/etc/bashrc

确定 unmask 的功能,和提示符的内容

/etc/profile.d/*.sh

针对颜色、语系、 vim 及 which 等命令进行附加配置

/etc/man.config

Man 的系统变量位置

个人设置值

~/.bash_profile 、 ~/.bash_login 、 ~/.profile

这三个文件只要一个即可,一般是第一个存在。只在登陆时才读取

~/.bashrc

一般将自己的需要设置到这里,每次执行shell 脚本的时候,都会重新读取这个文件

~/.bash_history

每次登陆 bash , bash 会先读这个文件,将所有的历史命令读入内存

~/.bash_logout

离开 linux 时,执行一些操作

读取顺序

先读取系统设置值,然后读取 ~/.bash_* ,然后读取 ~/.bashrc 。所以登陆 bash 后,最终读取的配置文件是~/.bashrc, 在这此文件中的设置会是最终的设置值,可以把一些常用 alias 或 PATH 放入此文件。

source 和 . 都能将配置文件的内容读进当前 shell 环境中

source /etc/bashrc

.  /etc/bashrc


    Shell工具   

使用date命令创建日志

date +%Y/%m/%d/%H:%M

$date +%d%m%y

090699

$date +%d-%m-%y

09-06-99

$date +%A%e" "%B" "%Y

Wednesday 9 June 1999

$date +%R

10:07

$date +%T

10:29:41

$date +%A" "%T

Wednesday 10:31:19

cal [month] [year]

创建唯一的临时文件

$$ 进程号

搜索文件或目录

which   可执行文件位置

whereis 查看文件位置

locate 配合数据库查看  updatedb

      程序与资源管理      

^z  数据丢入背景中

jobs 查看背景中程序

bg %number将程序中的程序由stopped改为running

fg %number将代号number程序移动屏幕前操作

kill -single %number  -2 中断该工作  -9立即杀掉   -15停止一个工作



评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值