Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between os.chmod, os.fchmod and os.lchmod

Tags:

python

I want to change file modes with Python.

The os module has three functions that seem functionally equivalent:

  • os.chmod
  • os.fchmod
  • os.lchmod

What are the differences between these three versions?

like image 294
smizzlov Avatar asked Apr 20 '26 15:04

smizzlov


1 Answers

chmod is used to change the file permissions of a file specified by path.

fchmod is used to change the file permissions of a file specified by file descriptor.

lchmod is similar to chmod() but does not follow symbolic links.

You can read more in the man page

like image 99
Jacques Gaudin Avatar answered Apr 23 '26 05:04

Jacques Gaudin



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!