Linux--day04\05

知识点和问题

1.Linux组基本介绍

在linux中的每个用户必须属于一个组,不能独立于组外。
在linux中每个文件
有所有者
所在组
其它组的概念

2.查看文件的所有者
[tom@localhost ~]$ ls -ahl
3.创建一个组police,再创建一个用户tom,将tom放在police中,然后使用tom来创建ok.txt文件,看看情况如何。
[root@localhost ~]# groupadd police
[root@localhost ~]# useradd -g police tom
[tom@localhost ~]$ touch ok.txt
[tom@localhost ~]$ ls -ahl
总用量 28K
drwx------. 4 tom  police 4.0K 63 10:20 .
drwxr-xr-x. 9 root root   4.0K 63 10:16 ..
-rw-r--r--. 1 tom  police   18 511 2016 .bash_logout
-rw-r--r--. 1 tom  police  176 511 2016 .bash_profile
-rw-r--r--. 1 tom  police  124 511 2016 .bashrc
drwxr-xr-x. 2 tom  police 4.0K 1112 2010 .gnome2
drwxr-xr-x. 4 tom  police 4.0K 529 03:08 .mozilla
-rw-r--r--. 1 tom  police    0 63 10:20 ok.txt
4.使用root创建一个文件apple.txt ,然后将其所有者修改成 tom
[root@localhost test]# touch apple.txt
[root@localhost test]# chown tom apple.txt
[root@localhost test]# ls -ahl
-rw-r--r--. 1 tom  root    0 63 10:23 apple.txt
5.使用root用户创建文件 orange.txt ,看看当前这个文件属于哪个组,然后将这个文件所在组,修改到 fruit组。
[root@localhost test]# touch orange.txt
[root@localhost test]# ls -ahl
-rw-r--r--. 1 root root    0 63 10:28 orange.txt
[root@localhost test]# chgrp police orange.txt
[root@localhost test]# ls -ahl
-rw-r--r--. 1 root police    0 63 10:28 orange.txt
6.将tom这个用户从原来所在组,修改到 bandit 组。

改变用户所在组

  1. usermod –g 组名 用户名
  2. usermod –d 目录名 用户名 改变该用户登陆的初始目录。
[root@localhost test]# groupadd bandit
[root@localhost test]# usermod -g bandit tom
[tom@localhost ~]$ id tom
uid=503(tom) gid=505(bandit)=505(bandit)
7.在root中创建一个test.txt文件,将其所有者改成tom,所在组改成bandit
[root@localhost test]# touch test.txt
[root@localhost test]# chown tom test.txt
[root@localhost test]# chgrp bandit test.txt
[root@localhost test]# ls -ahl
总用量 40K
-rw-rw-r--. 1 tom  bandit    0 63 10:36 test.txt
8.权限的基本介绍

ls -l 中显示的内容如下:
-rwxrw-r-- 1 root root 1213 Feb 2 09:39 abc
0-9位说明

  1. 第0位确定文件类型(d(目录), -(普通文件) , l(链接文件) , c(字符设备) , b(块文件,硬盘))
  2. 第1-3位确定所有者(该文件的所有者)拥有该文件的权限。—User
  3. 第4-6位确定所属组(同用户组的)拥有该文件的权限,—Group
  4. 第7-9位确定其他用户拥有该文件的权限 —Other
  5. 1 :文件:硬连接数或 目录:子目录数
    6)root 用户
    7)root 组
    8)1213 文件大小(字节),如果是文件夹,显示 4096字节
    9)Feb 2 09:39 最后修改日期
    10)abc 文件名
9.rwx权限详解

rwx作用到文件

  1. [ r ]代表可读(read): 可以读取,查看
  2. [ w ]代表可写(write): 可以修改,但是不代表可以删除该文件,删除一个文件的前提条件是对该文件所在的目录有写权限,才能删除该文件.
  3. [ x ]代表可执行(execute):可以被执行
    rwx作用到目录
  4. [ r ]代表可读(read): 可以读取,ls查看目录内容
  5. [ w ]代表可写(write): 可以修改,目录内创建+删除+重命名目录
  6. [ x ]代表可执行(execute):可以进入该目录
    注意:目录本身也占用空间
10.问题命令
  1. 给abc文件 的所有者读写执行的权限,给所在组读执行权限,给其它组读执行权限。
[root@localhost test2]# touch abc
[root@localhost test2]# chmod u=rwx,g=rx,o=rw abc
  1. 给abc文件的所有者除去执行的权限,增加组写的权限
[root@localhost test2]# chmod u-x,g+w abc
  1. 给abc文件的所有用户添加读的权限
[root@localhost test2]# chmod a+r abc

第一种方式:+ 、-、= 变更权限
u:所有者 g:所有组 o:其他人 a:所有人(u、g、o的总和)

  1. chmod u=rwx,g=rx,o=x 文件目录名
  2. chmod o+w 文件目录名
  3. chmod a-x 文件目录名
11.要求:将 /home/aaa.txt 文件的权限修改成 rwxr-xr-x, 使用给数字的方式实现:

[root@localhost test2]# chmod 755 aaa.txt
第二种方式:通过数字变更权限
r=4 w=2 x=1 rwx=4+2+1=7
chmod u=rwx,g=rx,o=x 文件目录名
相当于 chmod 751 文件目录名

12.问题命令

1.请将 /home/abc .txt 文件的所有者修改成 tom

[root@localhost test2]# chown tom aaa.txt
[root@localhost test2]# ll
总用量 16
-rwxr-xr-x. 1 tom  test 1104 62 21:57 aaa.txt

2.请将 /home/kkk 目录下所有的文件和目录的所有者都修改成tom
注意:要使用root权限的用户来操作

[root@localhost test2]# chown -R tom bbb
[root@localhost test2]# cd bbb
[root@localhost bbb]# ll
总用量 0
-rw-rw-r--. 1 tom test 0 62 21:49 aaa.txt

基本介绍
chown newowner file 改变文件的所有者
chown newowner:newgroup file 改变用户的所有者和所有组
-R 如果是目录 则使其下所有子文件或目录递归生效

13.命令问题

1.请将 abc .txt 文件的所在组修改成 police

[root@localhost bbb]# touch abc.txt
[root@localhost bbb]# chgrp police abc.txt
[root@localhost bbb]# ll
总用量 0
-rw-rw-r--. 1 tom  test   0 62 21:49 aaa.txt
-rw-r--r--. 1 root police 0 63 12:15 abc.txt

2.请将 /home/bbb 目录下所有的文件和目录的所在组都修改成 police

[root@localhost test2]# chgrp -R police bbb
14.课后习题练习
15.crond任务调度

基本语法:
crontab [选项]
常用选项
在这里插入图片描述
任务调度:是指系统在某个时间执行的特定的命令或程序。
任务调度分类:1.系统工作:有些重要的工作必须周而复始地执行。如病毒扫描等
2.个别用户工作:个别用户可能希望执行某些程序,比如对mysql数据库的备份。
快速入门
设置任务调度文件:/etc/crontab
设置个人任务调度。执行crontab –e命令。
接着输入任务到调度文件
如:*/1 * * * * ls –l /etc/ > /tmp/to.txt
意思说每小时的每分钟执行ls –l /etc/ > /tmp/to.txt命令
参数细节说明
• 5个占位符的说明
在这里插入图片描述
特殊符号的说明
在这里插入图片描述

16.命令案例

案例1:每隔1分钟,就将当前的日期信息,追加到 /tmp/mydate 文件中
先编写脚本:

[root@localhost home]# touch mytask1.sh
[root@localhost home]# vim mytask1.sh

脚本内容为:
date>>/tmp/mydate
修改脚本权限:

[root@localhost home]# chmod 744 mytask1.sh

输入命令

[root@localhost home]# crontab -e

添加执行内容
*/1 * * * * /home/mytask1.sh
案例2:每隔1分钟, 将当前日期和日历都追加到 /home/mycal 文件中

[root@localhost test]# touch mytask2.sh
[root@localhost test]# vim mytask2.sh
[root@localhost test]# cat mytask2.sh
date>>/home/mycal
cal>>/home/mycal

开放脚本权限

[root@localhost test]# chmod 744 mytask2.sh
You have new mail in /var/spool/mail/root
[root@localhost home]# crontab -e

添加执行内容

*/1 * * * * /home/test/mytask1.sh
17.crond 相关指令
  1. conrtab –r:终止任务调度。
  2. crontab –l:列出当前有那些任务调度
  3. service crond restart [重启任务调度]
18.分区的方式
  1. mbr分区:
    1.最多支持四个主分区
    2.系统只能安装在主分区
    3.扩展分区要占一个主分区
    4.MBR最大只支持2TB,但拥有最好的兼容性
  2. gtp分区:
    1.支持无限多个主分区(但操作系统可能限制,比如 windows下最多128个分区)
    2.最大支持18EB的大容量(1EB=1024 PB,1PB=1024 TB )
    3.windows7 64位以后支持gtp
19.Linux分区
  1. Linux来说无论有几个分区,分给哪一目录使用,它归根结底就只有一个根目录,一个独立且唯一的文件结构 , Linux中每个分区都是用来组成整个文件系统的一部分。
  2. Linux采用了一种叫“载入”的处理方法,它的整个文件系统中包含了一整套的文件和目录,且将一个分区和一个目录联系起来。这时要载入的一个分区将使它的存储空间在一个目录下获得。
20.Linux分区硬盘说明
  1. Linux硬盘分IDE硬盘和SCSI硬盘,目前基本上是SCSI硬盘
  2. 对于IDE硬盘,驱动器标识符为“hdx”,其中“hd”表明分区所在设备的类型,这里是指IDE硬盘了。“x”为盘号(a为基本盘,b为基本从属盘,c为辅助主盘,d为辅助从属盘),“”代表分区,前四个分区用数字1到4表示,它们是主分区或扩展分区,从5开始就是逻辑分区。例,hda3表示为第一个IDE硬盘上的第三个主分区或扩展分区,hdb2表示为第二个IDE硬盘上的第二个主分区或扩展分区。
  3. 对于SCSI硬盘则标识为“sdx~”,SCSI硬盘是用“sd”来表示分区所在设备的类型的,其余则和IDE硬盘的表示方法一样。
21.查看分区命令
[root@localhost home]# lsblk -f
NAME   FSTYPE LABEL UUID                                 MOUNTPOINT
sda                                                      
├─sda1 ext4         a62c3aaa-dac5-4289-ab59-7c593196fa77 /boot
├─sda2 swap         7d61c95c-4d1a-498b-ac78-dbfc08164782 [SWAP]
└─sda3 ext4         1a3945f0-a01a-4283-9729-4ce5d09c7d46 /
sr0 

说明:
分区情况 分区类型 唯一标志分区的40位不重复的字符串 挂载点

[root@localhost dev]# lsblk
NAME   MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda      8:0    0   20G  0 disk 
├─sda1   8:1    0  200M  0 part /boot
├─sda2   8:2    0    2G  0 part [SWAP]
└─sda3   8:3    0 17.8G  0 part /
sr0     11:0    1 1024M  0 rom   
22.给我们的Linux系统增加一个新的硬盘,并且挂载到/home/newdisk

1.创建虚拟化硬盘
虚拟机->设置->硬盘->下一步,重启机器
2.分区

[root@localhost ~]# fdisk /dev/sdb
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel with disk identifier 0x3fe24f57.
Changes will remain in memory only, until you decide to write them.
After that, of course, the previous content won't be recoverable.

Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)

WARNING: DOS-compatible mode is deprecated. It's strongly recommended to
         switch off the mode (command 'c') and change display units to
         sectors (command 'u').
Command (m for help): m
Command action
   a   toggle a bootable flag
   b   edit bsd disklabel
   c   toggle the dos compatibility flag
   d   delete a partition
   l   list known partition types
   m   print this menu
   n   add a new partition
   o   create a new empty DOS partition table
   p   print the partition table
   q   quit without saving changes
   s   create a new empty Sun disklabel
   t   change a partition's system id
   u   change display/entry units
   v   verify the partition table
   w   write table to disk and exit
   x   extra functionality (experts only)

Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-261, default 1): 1
Last cylinder, +cylinders or +size{K,M,G} (1-261, default 261): 
Using default value 261

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.

3.格式化

[root@localhost ~]# mkfs -t ext4 /dev/sdb1
mke2fs 1.41.12 (17-May-2010)
文件系统标签=操作系统:Linux
块大小=4096 (log=2)
分块大小=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
131072 inodes, 524112 blocks
26205 blocks (5.00%) reserved for the super user
第一个数据块=0
Maximum filesystem blocks=536870912
16 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks: 
 32768, 98304, 163840, 229376, 294912
 
正在写入inode表: 完成                            
Creating journal (8192 blocks): 完成
Writing superblocks and filesystem accounting information: 完成

This filesystem will be automatically checked every 36 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.

4.挂载
先创建一个目录

[root@localhost home]# mkdir newdisk
挂载(临时挂载)
[root@localhost home]# mount /dev/sdb1 /home/newdisk
[root@localhost home]# lsblk -f
NAME   FSTYPE LABEL UUID                                 MOUNTPOINT
sdb                                                      
└─sdb1 ext4         c6589edc-cea8-4f8b-95f3-3db860379977 /home/newdisk
sda                                                      
├─sda1 ext4         a62c3aaa-dac5-4289-ab59-7c593196fa77 /boot
├─sda2 swap         7d61c95c-4d1a-498b-ac78-dbfc08164782 [SWAP]
└─sda3 ext4         1a3945f0-a01a-4283-9729-4ce5d09c7d46 /
sr0  

5.设置永久挂载

[root@localhost home]# vim /etc/fstab

修改文件,添加一行

/dev/sdb1                                 /home/newdisk           ext4    defaults        0 0
设置自动挂载
[root@localhost home]# mount -a
[root@localhost home]# lsblk -f
NAME   FSTYPE LABEL UUID                                 MOUNTPOINT
sdb                                                      
└─sdb1 ext4         c6589edc-cea8-4f8b-95f3-3db860379977 /home/newdisk
sda                                                      
├─sda1 ext4         a62c3aaa-dac5-4289-ab59-7c593196fa77 /boot
├─sda2 swap         7d61c95c-4d1a-498b-ac78-dbfc08164782 [SWAP]
└─sda3 ext4         1a3945f0-a01a-4283-9729-4ce5d09c7d46 /
sr0                 
23.查询系统整体磁盘使用情况
[root@localhost home]# df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/sda3        18G  3.3G   14G  20% /
tmpfs           996M   80K  996M   1% /dev/shm
/dev/sda1       190M   37M  144M  21% /boot
.host:/         384G  111G  273G  29% /mnt/hgfs
/dev/sdb1       2.0G  3.0M  1.9G   1% /home/newdisk
24.卸载磁盘
[root@localhost home]# umount /home/newdisk
需要修改自动挂载文件
[root@localhost home]# vim /etc/fstab
25.查询指定目录/home的磁盘占用情况
[root@localhost home]# du -h /home

基本语法
du -h /目录
查询指定目录的磁盘占用情况,默认为当前目录
-s 指定目录占用大小汇总
-h 带计量单位
-a 含文件
–max-depth=1 子目录深度
-c 列出明细的同时,增加汇总值

26.查询 /opt 目录的磁盘占用情况,深度为1
[root@localhost home]# du -ach --max-depth=1 /opt
100K /opt/tmp
214M /opt/vmware-tools-distrib
69M /opt/VMwareTools-10.0.5-3228253.tar.gz
136K /opt/tmp2
283M /opt
283M 总用量
27.磁盘情况–工作使用指令
  1. 统计/home文件夹下文件的个数
[root@localhost home]# ls -l /home | grep "^-" | wc -l
11
  1. 统计/home文件夹下目录的个数
[root@localhost home]# ls -l /home | grep "^d" | wc -l
6
  1. 统计/home文件夹下文件的个数,包括子文件夹里的
[root@localhost home]# ls -lR /home | grep "^d" | wc -l
9
  1. 统计文件夹下目录的个数,包括子文件夹里的
[root@localhost home]# ls -lR /home |grep "^-" |wc -l
28
  1. 以树状显示目录结构
[root@localhost ~]# tree /
27.网络配置

在这里插入图片描述

28.查看网络IP和网关

1.查看虚拟网络编辑器
编辑->虚拟网络编辑器
2.修改ip
编辑->虚拟网络编辑器->更改设置
3.查看网关
编辑->虚拟网络编辑器->更改设置->NAT模式->NAT设置

29.Windows和VM和CentOs的关系说明

在这里插入图片描述

30.虚拟机网络连接三种形式的说明

在这里插入图片描述

31.linux网络环境配置

第一种方式(自动连接)
系统->首选项->网络连接->编辑->选上自动连接
缺点:Linux启动后会自动获取ip,但是每次自动获取的ip地址可能不一样
第二种方式
直接修改配置文件来指定IP,并可以连接到外网(程序员推荐),编辑 vi /etc/sysconfig/network-scripts/ifcfg-eth0
要求:将ip地址配置的静态的,ip地址为192.168.184.130

[root@localhost ~]# vi /etc/sysconfig/network-scripts/ifcfg-eth0
[root@localhost ~]# cat /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
TYPE=Ethernet
UUID=f6d947fa-3b89-4162-96c9-da4c647e8e39
ONBOOT=yes
NM_CONTROLLED=yes
BOOTPROTO=static
DEFROUTE=yes
IPV4_FAILURE_FATAL=yes
IPV6INIT=no
NAME="System eth0"
HWADDR=00:0C:29:97:74:79
PEERDNS=yes
PEERROUTES=yes
LAST_CONNECT=1591193017
IPADDR=192.168.44.128
GATEWAY=192.168.44.2
DNS1=192.168.44.2

其中重要的地方如下:
ONBOOT=yes ##启用boot
BOOTPROTO=static ##以静态的方式获取IP
IPADDR=192.168.44.128 ##指定IP
GATEWAY=192.168.44.2 ##dns和网关保持一致即可
DNS1=192.168.44.2
重启网络服务

[root@localhost ~]# service network restart
32.linux进程基本概念
  1. 在LINUX中,每个执行的程序(代码)都称为一个进程。每一个进程都分配一个ID号。
  2. 每一个进程,都会对应一个父进程,而这个父进程可以复制多个子进程。例如www服务器。
  3. 每个进程都可能以两种方式存在的。前台与后台,所谓前台进程就是用户目前的屏幕上可以进行操作的。后台进程则是实际在操作,但由于屏幕上无法看到的进程,通常使用后台方式执行。
  4. 一般系统的服务都是以后台进程的方式存在,而且都会常驻在系统中。直到关机才才结束。
33.显示系统执行的进程的基本命令

ps命令是用来查看目前系统中,有哪些正在执行,以及它们执行的状况。可以不加任何参数.显示当前终端所有进程信息

[root@localhost ~]# ps -a
   PID TTY          TIME CMD
  4763 pts/2    00:00:00 ps

以用户的格式显示进程信息

[root@localhost ~]# ps -u
Warning: bad syntax, perhaps a bogus '-'? See /usr/share/doc/procps-3.2.8/FAQ
USER        PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
root       2602  0.0  0.0   4064   592 tty2     Ss+  20:43   0:00 /sbin/mingetty /dev/tty2
root       2604  0.0  0.0   4064   588 tty3     Ss+  20:43   0:00 /sbin/mingetty /dev/tty3
root       2606  0.0  0.0   4064   592 tty4     Ss+  20:43   0:00 /sbin/mingetty /dev/tty4
root       2608  0.0  0.0   4064   584 tty5     Ss+  20:43   0:00 /sbin/mingetty /dev/tty5
root       2610  0.0  0.0   4064   592 tty6     Ss+  20:43   0:00 /sbin/mingetty /dev/tty6
root       2636  0.1  3.9 226848 79724 tty1     Ss+  20:43   0:07 /usr/bin/Xorg :0 -br -verbose -audit 4 -auth /var/run/gdm/auth-for-gdm-YODgMh/d
root       3268  0.0  0.0 108312  1932 pts/0    Ss+  20:45   0:00 /bin/bash
root       3284  0.0  0.0 108312  1968 pts/1    Ss+  20:45   0:00 -bash
root       3983  0.0  0.0 108312  1932 pts/2    Ss   21:48   0:00 -bash
root       4764  0.0  0.0 110236  1184 pts/2    R+   22:26   0:00 ps -u

显示后台进程运行的参数

[root@localhost ~]# ps -x

在这里插入图片描述
列表说明:
• System V展示风格
• USER:用户名称
• PID:进程号
• %CPU:进程占用CPU的百分比
• %MEM:进程占用物理内存的百分比
• VSZ:进程占用的虚拟内存大小(单位:KB)
• RSS:进程占用的物理内存大小(单位:KB)
• TT:终端名称,缩写 .
• STAT:进程状态,其中S-睡眠,s-表示该进程是会话的先导进程,N-表示进程拥有比普通优先级更低的优先级,R-正在运行,D-短期等待,Z-僵死进程,T-被跟踪或者被停止等等
• STARTED:进程的启动时间
• TIME:CPU时间,即进程使用CPU的总时间
• COMMAND:启动进程所用的命令和参数,如果过长会被截断显示

34.查看有没有指定的服务在运行

指令:ps –aux|grep xxx ,比如我看看有没有sshd服务

[root@localhost ~]# ps -aux | grep sshd
Warning: bad syntax, perhaps a bogus '-'? See /usr/share/doc/procps-3.2.8/FAQ
root       2323  0.0  0.0  66236  1200 ?        Ss   20:43   0:00 /usr/sbin/sshd
root       3280  0.0  0.2 102232  4212 ?        Ss   20:45   0:01 sshd: root@pts/1 
root       3974  0.0  0.2 102084  4136 ?        Ss   21:47   0:00 sshd: root@pts/2 
root       4808  0.0  0.0 103328   908 pts/2    S+   22:32   0:00 grep sshd
35. 以全格式显示当前所有的进程,查看进程的父进程
[root@localhost ~]# ps -ef | more
UID         PID   PPID  C STIME TTY          TIME CMD
root          1      0  0 20:43 ?        00:00:01 /sbin/init
root          2      0  0 20:43 ?        00:00:00 [kthreadd]
root          3      2  0 20:43 ?        00:00:00 [migration/0]
36.查看sshd进程的父进程是多少?
[root@localhost ~]# ps -ef | grep sshd
root       2323      1  0 20:43 ?        00:00:00 /usr/sbin/sshd
root       3280   2323  0 20:45 ?        00:00:01 sshd: root@pts/1 
root       3974   2323  0 21:47 ?        00:00:00 sshd: root@pts/2 
root       4846   3983  0 22:38 pts/2    00:00:00 grep sshd
37.终止进程

案例1:踢掉某个非法登录用户

[root@localhost 桌面]# ps -aux | grep sshd
Warning: bad syntax, perhaps a bogus '-'? See /usr/share/doc/procps-3.2.8/FAQ
root       2323  0.0  0.0  66236  1200 ?        Ss   20:43   0:00 /usr/sbin/sshd
root       3280  0.0  0.2 102232  4212 ?        Ss   20:45   0:01 sshd: root@pts/1 
root       4868  0.1  0.1 102084  4044 ?        Ss   22:42   0:00 sshd: test [priv]
test       4872  0.0  0.0 102084  1840 ?        S    22:42   0:00 sshd: test@pts/2 
root       4918  0.0  0.0 103328   912 pts/0    S+   22:44   0:00 grep sshd
[root@localhost 桌面]# kill 4872

案例2: 终止远程登录服务sshd, 在适当时候再次重启sshd服务

[root@localhost 桌面]# kill 2323

案例3: 终止多个gedit 编辑器

[root@localhost 桌面]# killall gedit

案例4:强制杀掉一个终端

[root@localhost 桌面]# ps -aux | grep bash
Warning: bad syntax, perhaps a bogus '-'? See /usr/share/doc/procps-3.2.8/FAQ
root       3268  0.0  0.0 108392  2004 pts/0    Ss+  20:45   0:00 /bin/bash
root       3284  0.0  0.0 108312  1968 pts/1    Ss+  20:45   0:00 -bash
root       4944  0.0  0.0 108312  1932 pts/2    Ss   22:48   0:00 /bin/bash
root       4964  0.0  0.0 103324   904 pts/2    S+   22:49   0:00 grep bash
[root@localhost 桌面]# ps -aux | grep bash
Warning: bad syntax, perhaps a bogus '-'? See /usr/share/doc/procps-3.2.8/FAQ
root       3268  0.0  0.0 108392  2004 pts/0    Ss+  20:45   0:00 /bin/bash
root       3284  0.0  0.0 108312  1968 pts/1    Ss+  20:45   0:00 -bash
root       4944  0.0  0.0 108312  1940 pts/2    Ss   22:48   0:00 /bin/bash
root       4971  0.0  0.0 103324   904 pts/2    S+   22:50   0:00 grep bash
[root@localhost 桌面]# kill -9 3268

基本语法:
kill [选项] 进程号(功能描述:通过进程号杀死进程)
killall 进程名称 (功能描述:通过进程名称杀死进程,也支持通配符,这在系统因负
载过大而变得很慢时很有用)
常用选项:
-9 :表示强迫进程立即停止

38.查看进程树

案例1:请你树状的形式显示进程的pid

[root@localhost 桌面]# pstree -p

案例2:请你树状的形式进程的用户id

pstree -u

基本语法:
pstree [选项] ,可以更加直观的来看进程信息
常用选项:
-p :显示进程的PID
-u :显示进程的所属用户

  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值