Sponsored Content
Full Discussion: Using chown command.
Top Forums Shell Programming and Scripting Using chown command. Post 303008856 by MadeInGermany on Thursday 7th of December 2017 02:06:31 AM
Old 12-07-2017
Attention: the SysV chown changes the target of symbolic links; normally you want to change the owner of the symbolic links so you need the -h option
(old Linux chown was different, like BSD chown).
In a shell glob the [!.] is any character but a dot. (A few shells have [^.] in addition, that is not portable).
Code:
chown -hRv some_user:users /some_folder/* /some_folder/.[!.]*

Perhaps you can include the parent directory? Then it becomes simple:
Code:
chown -hRv some_user:users /some_folder

 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

chown and permissions

how i could give to user permission(delete,execute and so on) and ownership to files? Thanks (1 Reply)
Discussion started by: ithost
1 Replies

2. AIX

chown

hello chown not change ownership before: 205:system ~kuku chown kuku:system ~kuku after no change 205:system ~kuku aix box can someone help me? ariec (2 Replies)
Discussion started by: ariec
2 Replies

3. 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

4. UNIX for Dummies Questions & Answers

reg chown

hi i wrote a script to run 'C' executable which will create a new file, after that util is completed, i have to change the file ownership to some other user. for that i used "chown" for changing the file permission in Korn script :confused:but it is throwing error is "operation... (2 Replies)
Discussion started by: ilayans
2 Replies

5. UNIX for Dummies Questions & Answers

chown

is there a difference in chown on a file or a directory? how do i chown a directory and all the contents? (2 Replies)
Discussion started by: BG_JrAdmin
2 Replies

6. 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

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. AIX

Trouble in chown

I'm a owner of directories or files why I can't deliver the ownership of them up to other users? (1 Reply)
Discussion started by: kang
1 Replies

9. Solaris

chown

Hello My oracledatabase creats some xmlfiles. this files has the owner hugo. now I've a script (how runs als hugo2) and this script will insert this XMLFile into the database. But that doesn't work, because the owner of the files is wrong, and hugo has not the rights to insert this files into... (3 Replies)
Discussion started by: Street
3 Replies

10. Shell Programming and Scripting

chown of a Directory

Hi All, I need your help in changing the owner of a directory. I have a created a direcotry TEST with user "abc"....for the group "ftp". Now i wnated to change the owner of the directory TEST. i used the below command to do so: chown abc:sftp TEST This is giving me an error... (5 Replies)
Discussion started by: ch33ry
5 Replies
CHOWN(2)						      BSD System Calls Manual							  CHOWN(2)

NAME
chown, fchown, lchown -- change owner and group of a file SYNOPSIS
#include <unistd.h> int chown(const char *path, uid_t owner, gid_t group); int fchown(int fildes, uid_t owner, gid_t group); int lchown(const char *path, uid_t owner, gid_t group); DESCRIPTION
The owner ID and group ID of the file named by path or referenced by fildes is changed as specified by the arguments owner and group. The owner of a file may change the group to a group of which he or she is a member, but the change owner capability is restricted to the super- user. The chown() system call clears the set-user-id and set-group-id bits on the file to prevent accidental or mischievous creation of set-user-id and set-group-id programs if not executed by the super-user. The chown() system call follows symbolic links to operate on the target of the link rather than the link itself. The fchown() system call is particularly useful when used in conjunction with the file locking primitives (see flock(2)). The lchown() system call is similar to chown() but does not follow symbolic links. One of the owner or group id's may be left unchanged by specifying it as -1. RETURN VALUES
Upon successful completion, the value 0 is returned; otherwise the value -1 is returned and the global variable errno is set to indicate the error. ERRORS
The chown() and lchown() system calls will fail if: [EACCES] Search permission is denied for a component of the path prefix. [EFAULT] The path argument points outside the process's allocated address space. [ELOOP] Too many symbolic links are encountered in translating the pathname. This is taken to be indicative of a looping symbolic link. [ENAMETOOLONG] A component of a pathname exceeded 255 characters, or an entire path name exceeded 1023 characters. [ENOENT] A component of path does not exist. [ENOTDIR] A component of the path prefix is not a directory. The fchown() system call will fail if: [EBADF] The fildes argument does not refer to a valid descriptor. [EINVAL] The fildes argument refers to a socket, not a file. Any of these calls will fail if: [EINTR] Its execution is interrupted by a signal. [EIO] An I/O error occurs while reading from or writing to the file system. [EPERM] The effective user ID does not match the owner of the file and the calling process does not have appropriate (i.e., root) privileges. [EROFS] The named file resides on a read-only file system. SEE ALSO
chgrp(1), chmod(2), flock(2), chown(8) STANDARDS
The chown() system call is expected to conform to ISO/IEC 9945-1:1990 (``POSIX.1''). HISTORY
The chown() function appeared in Version 7 AT&T UNIX. The fchown() system call appeared in 4.2BSD. The chown() and fchown() system calls were changed to follow symbolic links in 4.4BSD. The lchown() system call was added in FreeBSD 3.0 to compensate for the loss of functionality. BSD
April 19, 1994 BSD
All times are GMT -4. The time now is 01:57 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy