Home >Operation and Maintenance >Linux Operation and Maintenance >Is there an access function in linux?
There is an access function in Linux; this function is used to check the user's permissions on a file. If the specified access method is valid, the function returns 0, otherwise the function returns "-1", and the syntax is " int access(const char* pathname, int mode);".
#The operating environment of this tutorial: linux7.3 system, Dell G3 computer.
Is there an access function in linux
access function header file: unistd.h Function: Determine the file or folder access rights. That is, check the access mode of a certain file, such as read-only mode, write-only mode, etc. If the specified access method is valid, the function returns 0, otherwise the function returns -1.
The syntax is:
#include<unistd.h> int access(const char* pathname, int mode);
Parameter introduction:
pathname is the path name of the file file name
mode: specifies the role of access, take The values are as follows
F_OK value is 0, determine whether the file exists
access("test",06); access("test",F_OK);are used to check the actual user pair respectively. Whether the test file has read and write permissions and whether the test file exists. Recommended learning:
The above is the detailed content of Is there an access function in linux?. For more information, please follow other related articles on the PHP Chinese website!