import
os
path
=
"./file.txt"
symlink
=
"./file(symlink).txt"
os.symlink(path, symlink)
print
(
"Owner id of the file:"
, os.stat(path).st_uid)
print
(
"Group id of the file:"
, os.stat(path).st_gid)
print
(
"Owner id of the symlink:"
, os.stat(symlink).st_uid)
print
(
"Group id of the symlink:"
, os.stat(symlink).st_gid)
uid
=
1000
gid
=
1000
os.chown(symlink, uid, gid)
print
(
"\nOwner id and group id changed"
)
print
(
"\nOwner id of the file:"
, os.stat(path).st_uid)
print
(
"Group id of the file:"
, os.stat(path).st_gid)
print
(
"Owner id of the symlink:"
, os.stat(symlink).st_uid)
print
(
"Group id of the symlink:"
, os.stat(symlink).st_gid)
uid
=
4000
gid
=
4000
os.chown(symlink, uid, gid, follow_symlinks
=
False
)
print
(
"\nOwner id and group id not changed"
)
print
(
"\nOwner id of the file:"
, os.stat(path).st_uid)
print
(
"Group id of the file:"
, os.stat(path).st_gid)
print
(
"Owner id of the symlink:"
, os.stat(symlink).st_uid)
print
(
"Group id of the symlink:"
, os.stat(symlink).st_gid)