Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

chown(2) [v7 man page]

CHOWN(2)							System Calls Manual							  CHOWN(2)

NAME
chown - change owner and group of a file SYNOPSIS
chown(name, owner, group) char *name; DESCRIPTION
The file whose name is given by the null-terminated string pointed to by name has its owner and group changed as specified. Only the super-user may execute this call, because if users were able to give files away, they could defeat the (nonexistent) file-space accounting procedures. SEE ALSO
chown(1), passwd(5) DIAGNOSTICS
Zero is returned if the owner is changed; -1 is returned on illegal owner changes. ASSEMBLER
(chown = 16.) sys chown; name; owner; group CHOWN(2)

Check Out this Related Man Page

CHOWN(2)							System Calls Manual							  CHOWN(2)

NAME
chown - change owner and group of a file SYNOPSIS
chown(path, owner, group) char *path; int owner, group; fchown(fd, owner, group) int fd, owner, group; DESCRIPTION
The file that is named by path or referenced by fd has its owner and group changed as specified. Only the super-user may change the owner of the file, because if users were able to give files away, they could defeat the file-space accounting procedures. The owner of the file may change the group to a group of which he is a member. On some systems, chown clears the set-user-id and set-group-id bits on the file to prevent accidental creation of set-user-id and set- group-id programs. Fchown is particularly useful when used in conjunction with the file locking primitives (see flock(2)). One of the owner or group id's may be left unchanged by specifying it as -1. If the final component of path is a symbolic link, the ownership and group of the symbolic link is changed, not the ownership and group of the file or directory to which it points. RETURN VALUE
Zero is returned if the operation was successful; -1 is returned if an error occurs, with a more specific error code being placed in the global variable errno. ERRORS
Chown will fail and the file will be unchanged if: [ENOTDIR] A component of the path prefix is not a directory. [EINVAL] The pathname contains a character with the high-order bit set. [ENAMETOOLONG] A component of a pathname exceeded 255 characters, or an entire path name exceeded 1023 characters. [ENOENT] The named file does not exist. [EACCES] Search permission is denied for a component of the path prefix. [ELOOP] Too many symbolic links were encountered in translating the pathname. [EPERM] The effective user ID is not the super-user. [EROFS] The named file resides on a read-only file system. [EFAULT] Path points outside the process's allocated address space. [EIO] An I/O error occurred while reading from or writing to the file system. Fchown will fail if: [EBADF] Fd does not refer to a valid descriptor. [EINVAL] Fd refers to a socket, not a file. [EPERM] The effective user ID is not the super-user. [EROFS] The named file resides on a read-only file system. [EIO] An I/O error occurred while reading from or writing to the file system. SEE ALSO
chown(8), chgrp(1), chmod(2), flock(2) 4th Berkeley Distribution May 22, 1986 CHOWN(2)
Man Page

15 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Frontpage extensions

Hi everyone. I'm trying to install Frontpage extensions capacity on my web server and getting this error: ./fp_install.sh: line 59: 6763 Segmentation fault /usr/local/frontpage/version${VERSION}/bin/fpsrvadm.exe -o install -p $port $web $config -u $admin $server $chown -m "" ERROR: /... (6 Replies)
Discussion started by: alwayslearningunix
6 Replies

2. UNIX for Dummies Questions & Answers

Setuid root and chown

I am trying to run chown and chmod from a script owned by root. The permissions are set to 4755 so that users can execute the script as root. However, when I run the script as a user other than root, I get "Operation not permitted" for both chown and chmod. Any ideas as to why this is? (6 Replies)
Discussion started by: johnmsucpe
6 Replies

3. UNIX for Advanced & Expert Users

chown doesn't work

Hi unix gurus, I am facing problem with chown command. I am not able to change the owner of any file in my home. It gives error "not owner", though I own the file(as ls shows). What could be the reason? Is it possible that usage chown can be disabled for users. $ $ ls -l total 2... (10 Replies)
Discussion started by: shriashishpatil
10 Replies

4. UNIX for Advanced & Expert Users

chown issue

I have a strange problem in my Linux box (Suse). Recently I took over this box as admin even though I have no prior admin experience. Following is my issue I had following users under 'root' group initially user1 user2 user3 Since I did not like user ids under root group. I modifed these... (9 Replies)
Discussion started by: praveenkumar_l
9 Replies

5. Shell Programming and Scripting

cp, chown, untar

hello i want shell script. i have a source.txt /home/user409/public_html/test/ /home/user09876/public_html/xdsss/ /home/user9765/public_html/320xxx/ . . . maybe 1000 lines i want . 1.read a source.txt 2.untar special.tar.gz into these directory in source.txt 3.i want to... (14 Replies)
Discussion started by: topic32428285
14 Replies

6. Solaris

NFS Share - chown problem

Hi all, I had share the server Gemini /u10 to the server Centaurus. /etc/dfs/dfstab share -F nfs -o root=centaurus /u10 My problem is: in the server Gemini the the owner for /U10 is oracle:dba but when in the server Centaurus, I am not able to change the owner become oracle:dba, it show... (8 Replies)
Discussion started by: SmartAntz
8 Replies

7. Web Development

ftp: missing chown command

hi, I'm connecting to a web server with ftp protocol and I would like to change some folders and files owner. I tried chown but it is not available. I typed "help" and this is the list I got. Is possible that the chown command is not installed on the server ? Or I don't have permissions ?... (8 Replies)
Discussion started by: aneuryzma
8 Replies

8. Cybersecurity

Change file owner

What i did: - logged in with acc1 and created a new user acc2 commands used: useradd and passwd. - Then i logged in acc2. but all the files are owned by acc1. Issue: I try to change the owner of the files using chown command . But it gives me a error message. All i want to do is... (13 Replies)
Discussion started by: TotallyConfused
13 Replies

9. UNIX for Dummies Questions & Answers

chown: Operation not permitted as root

Hi Expert, I am trying to change ownership of one file to another user that is exist in the system but getting operation not permitted error what could be the correct way? # ls -lh .Xauthority_ori -rw------- 1 maxim atlas 2.8K Jul 27 17:18 .Xauthority_ori # id -a uid=0(root)... (8 Replies)
Discussion started by: regmaster
8 Replies

10. OS X (Apple)

sudo chown -R `whoami` /usr/local

I was following a tutorial on installing Homebrew and I changed the ownership of /usr/local/ to me. Now McAfee Security won't start This is the exact line I typed: sudo chown -R `whoami` /usr/local Then I tried to fix it with: sudo chown -R root /usr/local I still can't start mcafee. It say... (7 Replies)
Discussion started by: chancho
7 Replies

11. UNIX for Dummies Questions & Answers

How to log all file that has been move,chmod,chown?

Hi All, Seeking for your assistance on how to log that has been chmod,mv,chown,chgrp and how to prevent script running while chmod,mv,chown,chgrp are still running? Ex: a/b/c-folder file1.txt file2.txt file3.txt chmod 777 * chown owner owner group mv what i did was(please see... (6 Replies)
Discussion started by: nikki1200
6 Replies

12. UNIX for Dummies Questions & Answers

Pls help. can't do chown ????

I am trying to change the directory to owner of Sybase. But I get permission denied. I did login as root. newd1> ls -l total 58 drwxr-xr-x 2 prod develop 5 Oct 17 06:51 bin drwxr-xr-x 2 prod develop 7 Oct 17 07:18 etc dr-xr-xr-x 1 root root 1... (15 Replies)
Discussion started by: samnyc
15 Replies

13. Red Hat

Apache chown on its files not working

Hello, My apache user generate one file : # ls -lsa /tmp/reference_file.csv 76 -rwxrwxrwx 1 apache apache 69921 Aug 16 14:14 tmp/reference_file.csv the user and the group belong to apache, but when i am trying to change it : su -l apache -s /bin/bash -bash-3.00$ whoami apache... (7 Replies)
Discussion started by: cterra
7 Replies

14. UNIX for Beginners Questions & Answers

File group issues

Hi All, I have a script which called by user id (mftp) . The set up is working on two server and not working one server. Working Server : -rw-rw-r-- 1 mftp csp 0 Jan 17 00:14 117001.log Non working server -rw-rw-r-- 1 mftp mftp 0 Jan 17 00:14 117001.log from the above... (18 Replies)
Discussion started by: arunkumar_mca
18 Replies

15. Shell Programming and Scripting

Using chown command.

I am working on a test machine. I just discovered that I have misunderstood the way the following command is run. chown -Rv some_user:users /some_folder/*This command do exactly what I want. Change the owner of every things from the named folder and in all child folders. But of course it leave... (13 Replies)
Discussion started by: jcdole
13 Replies