[Linux]常用命令

来源:互联网 发布:导出来的sql带双引号 编辑:程序博客网 时间:2024/04/27 06:40
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
原创粉丝点击