在 Linux 中,可以使用 df
命令来查看磁盘使用情况。该命令会显示各个文件系统的总容量、已使用容量、可用容量以及挂载点等信息。例如:
$ df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda1 100G 80G 20G 80% /
tmpfs 16G 80M 16G 1% /run
/dev/sdb1 500G 250G 250G 50% /data
需要查看某个特定目录或文件的磁盘使用情况,可以使用 du
命令。该命令会递归地显示指定路径下各个文件和目录的磁盘使用情况。例如:
$ du -h /var/log
4.0K /var/log/btmp
16K /var/log/wtmp
128M /var/log
在 Linux 中,可以使用 ps
命令来查找进程。该命令可以显示当前系统上运行的进程列表。例如:
$ ps aux
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
root 1 0.0 0.1 18240 3752 ? Ss 11:21 0:01 /sbin/init
root 2 0.0 0.0 0 0 ? S 11:21 0:00 [kthreadd]
root 3 0.0 0.0 0 0 ? I< 11:21 0:00 [rcu_gp]
root 4 0.0 0.0 0 0 ? I< 11:21 0:00 [rcu_par_gp]
需要查找特定的进程,可以使用 grep
命令配合 ps
命令来过滤结果。例如:
$ ps aux | grep nginx
root 789 0.0 0.4 43976 8960 ? Ss 11:21 0:00 nginx: master process /usr/sbin/nginx -g daemon on; master_process on;
www-data 790 0.0 0.2 44424 4956 ? S 11:21 0:00 nginx: worker process
www-data 791 0.0 0.2 44424 4960 ? S 11:21 0:00 nginx: worker process