[Linux]常用命令

1、查找进程

      命令:ps -ef |grep <查找内容>

      如:ETL-FW:[/ytxt/jboss/server/default/deploy]$ps -ef |grep java
            jyfx      6119 55252  0 11:33 pts/0    00:00:00 grep java
            jyfx     15300     1  0 Aug07 ?        00:00:00 /bin/sh ./run.sh


2、关闭进程

     命令:kill -9 <进程号>

     如:kill -9 15300


3、修改文件或目录的所属用户

基本语法:
chown [ -R]  账号名称  文件目录
chown [ -R账号名称: 用户组名称  文件目录
参数
-R : 进行递归( recursive )的持续更改,即连同子目录下的所有文件、目录
都更新成为这个用户组。常常用在更改某一目录的情况。
示例1
[root@localhost home]#  touch  testfile  //由 root 用户创建文件 
[root@localhost home]#  ls  testfile  –l 
-rw--w--w- 1 root root 0 Jun 7 19:35 testfile  //文件的拥有者及拥有者级均为 root 
[root@localhost home]#  chown  yangzongde  testfile  //修改文件拥有者为 yangzongde 
[root@localhost home]#  ls  testfile  -l 
-rw--w--w- 1 yangzongde root 0 Jun 7 19:35 testfile  //查看文件拥有者为 yangzongde,但组仍为 root 

4、修改文件或者目录的用户组
基本语法:
chgrp [ -R用户组名称  dirname/ filename ...
参数:
-R : 进行递归( recursive )的持续更改,即连同子目录下的所有文件、目录
都更新成为这个用户组。常常用在更改某一目录的情况。
示例3
[root@localhost home]#  ls  testfile  -l 
-rw--w--w- 1 yangzongde root 0 Jun 7 19:35 testfile  //查看文件拥有者为 yangzongde,但组为 root 
[root@localhost home]#  chgrp   yangzongde  testfile  //修改拥有者组为 yangzongde 
[root@localhost home]#  ls  testfile  -l 
-rw--w--w- 1 yangzongde yangzongde 0 Jun 7 19:35 testfile 
[root@localhost home]#  chown  root: root  testfile  // 使用 chown 一次性修改拥有者及组 
[root@localhost home]#  ls  testfile  -l 
-rw--w--w- 1 root root 0 Jun 7 19:35 testfile 
示例4
[root@linux ~]#  chgrp  users  install.log
[root@linux ~]#  ls  -l
-rw-r--r--  1 root users 68495 Jun 25 08:53 install.log
示例5
更改为一个   /etc/group 不存在的用户组
[root@linux ~]#  chgrp  testing  install.log
chgrp: invalid group name `testing' <== 出现错误信息~找不到这个用户组名~

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值