Linux chown命令详解

chown将指定文件的拥有者改为指定的用户或组,用户可以是用户名或者用户ID;组可以是组名或者组ID;文件是以空格分开的要改变权限的文件列表,支持通配符。

chown常见命令参数

Usage: chown [OPTION]... [OWNER][:[GROUP]] FILE...
  or:  chown [OPTION]... --reference=RFILE FILE...
Change the owner and/or group of each FILE to OWNER and/or GROUP.
  -c, --changes          like verbose but report only when a change is made
      --dereference      affect the referent of each symbolic link (this is
                         the default), rather than the symbolic link itself
  -h, --no-dereference   affect each symbolic link instead of any referenced
                         file (useful only on systems that can change the
                         ownership of a symlink)
      --from=CURRENT_OWNER:CURRENT_GROUP
                         change the owner and/or group of each file only if
                         its current owner and/or group match those specified
                         here.  Either may be omitted, in which case a match
                         is not required for the omitted attribute.
      --no-preserve-root  do not treat `/‘ specially (the default)
      --preserve-root    fail to operate recursively on `/‘
  -f, --silent, --quiet  suppress most error messages
      --reference=RFILE  use RFILE‘s owner and group rather than
                         specifying OWNER:GROUP values
  -R, --recursive        operate on files and directories recursively
  -v, --verbose          output a diagnostic for every file processed

The following options modify how a hierarchy is traversed when the -R
option is also specified.  If more than one is specified, only the final
one takes effect.

  -H                     if a command line argument is a symbolic link
                         to a directory, traverse it
  -L                     traverse every symbolic link to a directory
                         encountered
  -P                     do not traverse any symbolic links (default)

      --help     display this help and exit
      --version  output version information and exit
Examples:
  chown root /u        Change the owner of /u to "root".
  chown root:staff /u  Likewise, but also change its group to "staff".
  chown -hR root /u    Change the owner of /u and subfiles to "root".

常用的命令展示

改变文件拥有者和群组

chown omc: h.txt 【默认是当前用户所在的属组】
chown omc:users h.txt

原文地址:https://www.cnblogs.com/ftl1012/p/9259936.html

时间: 2024-08-10 18:08:11

Linux chown命令详解的相关文章

linux rm 命令详解及使用方法实战【初级】

rm:删除命令 前言: windows中的删除命令大家都不陌生,linux中的删除命令和windows中有一个共同特点,那就是危险,前两篇linux mkdir 命令详解及使用方法实战[初级]中我们就提到了rm命令,现在我们来详细介绍一下linux中删除文件和目录的命令, rm命令,rm是常用的命令,该命令的功能为删除一个目录中的一个或多个文件或目录,它也可以将某个目录及其下的所有文件及子目录均删除.对于链接文件,只是删除了链接,原有文件均保持不变. 名称 rm - remove files o

Linux netstat命令详解

Linux netstat命令详解 简介 Netstat 命令用于显示各种网络相关信息,如网络连接,路由表,接口状态 (Interface Statistics),masquerade 连接,多播成员 (Multicast Memberships) 等等. 输出信息含义 执行netstat后,其输出结果为 Active Internet connections (w/o servers)Proto Recv-Q Send-Q Local Address Foreign Address State

linux sort 命令详解

原文:http://www.cnblogs.com/51linux/archive/2012/05/23/2515299.html linux sort 命令详解 sort是在Linux里非常常用的一个命令,管排序的,集中精力,五分钟搞定sort,现在开始! 1 sort的工作原理 sort将文件的每一行作为一个单位,相互比较,比较原则是从首字符向后,依次按ASCII码值进行比较,最后将他们按升序输出. [[email protected] programming]$ cat seq.txtba

linux dd 命令详解

1 磁盘管理 1.1 dd 1.1.1 功能说明 读取,转换并输出数据. 1.1.2 语法 dd [bs=<字节数>][cbs=<字节数>][conv=<关键字>][count=<区块数>][ibs=<字节数>][if=<文件>][obs=<字节数>][of=<文件>][seek=<区块数>][skip=<区块数>][--help][--version] 1.1.3 补充说明 dd可从标

linux screen 命令详解

linux screen 命令详解 一.背景 系统管理员经常需要SSH 或者telent 远程登录到Linux 服务器,经常运行一些需要很长时间才能完成的任务,比如系统备份.ftp 传输等等.通常情况下我们都是为每一个这样的任务开一个远程终端窗口,因为它们执行的时间太长了.必须等待它们执行完毕,在此期间不能关掉窗口或者断开连接,否则这个任务就会被杀掉,一切半途而废了. 二.简介 GNU Screen是一款由GNU计划开发的用于命令行终端切换的自由软件.用户可以通过该软件同时连接多个本地或远程的命

linux grep命令详解

linux grep命令详解 http://www.cnblogs.com/ggjucheng/archive/2013/01/13/2856896.html grep (global search regular expression(RE) and print out the line,全面搜索正则表达式并把行打印出来)是一种强大的文本搜索工具,它能使用正则表达式搜索文本,并把匹配的行打印出来. Unix的grep家族包括grep.egrep和fgrep.egrep和fgrep的命令只跟gr

[转]linux sort 命令详解

原文网址:http://www.cnblogs.com/51linux/archive/2012/05/23/2515299.html 1 sort的工作原理 sort将文件的每一行作为一个单位,相互比较,比较原则是从首字符向后,依次按ASCII码值进行比较,最后将他们按升序输出. [[email protected] programming]$ cat seq.txtbananaapplepearorange[[email protected] programming]$ sort seq.t

linux sar 命令详解

linux sar命令详解 sar(System Activity Reporter系统活动情况报告)是目前 Linux 上最为全面的系统性能分析工具之一,可以从多方面对系统的活动进行报告,包括:文件的读写情况.系统调用的使用情况.磁盘I/O.CPU效率.内存使用状况.进程活动及IPC有关的活动等. sar命令的格式: -bash-4.1# sar --help Usage: sar [ options ] [ <interval> [ <count> ] ] Options ar

linux 挂载命令详解

挂载文件系统与卸载文件系统 mount / umount NO1. 挂载光驱 [[email protected] root]# mount -t iso9660 /dev/cdrom /mnt/cdrom NO2. 挂载光驱,支持中文 [[email protected] root]# mount -t iso9660 -o codepage=936,iocharset=cp936 /dev/cdrom /mnt/cdrom NO3. 挂载 Windows 分区,FAT文件系统 [[email