Child pages
  • cPanel API 1 Functions - Fileman::changeperm
Skip to end of metadata
Go to start of metadata

Description

This function changes a file's permissions.

Warning:

cPanel API 1 is deprecated. We strongly recommend that you do not use cPanel API 1. However, no equivalent function exists in our newer APIs.

Important:

In cPanel & WHM version 76, the FileStorage role affects this function.

Examples


 LiveAPI PHP Class
$cpanel = new CPANEL(); // Connect to cPanel - only do this once.
$change_file_permissions = $cpanel->api1('Fileman', 'changeperm', array('account', 'my_file.txt', '4', '2', '1', '4', '2', '1', '4', '2', '1', '0') ); // Call the function.


Note:

For more information, read our Guide to the LiveAPI System.

 LiveAPI Perl Module
my $cpliveapi = Cpanel::LiveAPI->new(); # Connect to cPanel - only do this once.
my $change_file_permissions = $cpliveapi->api1('Fileman', 'changeperm', ['account', 'my_file.txt',  '4', '2', '1', '4', '2', '1', '4', '2', '1', '0']); # Call the function.


Note:

For more information, read our Guide to the LiveAPI System.

 cPanel Tag System (deprecated)


Warning:

In cPanel & WHM version 11.30 and later, cPanel tags are deprecated. We provide this example to help developers move from the old cPanel tag system to our LiveAPI system. We strongly recommend that you only use the LiveAPI system to call the cPanel APIs.

<cpanel Module="Fileman::changeperm ( $FORM('dir','file','userread','userwrite','userexecute','groupread','groupwrite','groupexecute','worldread','worldwrite','worldexecute','doubleencode'))">
 Command Line
cpapi1 --user=username Fileman changeperm public_html myfile.txt 4 2 1 4 2 1 4 2 1


Notes:

  • You must URI-encode these values.
  • username represents your account-level username.
  • For more information and additional output options, read our Guide to cPanel API 1 documentation or run the cpapi1 --help command.
  • If you run CloudLinux™, you must use the full path of the cpapi1 command:

    /usr/local/cpanel/bin/cpapi1

 Output (plaintext)
"Set permissions on index.html -> 0755"

Parameters

ParameterTypeDescriptionPossible valuesExample
dirstring

The file's directory.

This value defaults to the cPanel account's /home directory.

Any valid directory, relative to the account's /home directory.

public_html
filestring

Required

The file.

Any valid filename.

 

myfile.txt
userreadinteger

Required

The user's read permissions.

  • 4 — Grant read permissions.
  • 0 — Do not grant read permissions.
4
userwriteinteger

The user's write permissions.

This value defaults to 2.

  • 2 — Grant write permissions.
  • 0 — Do not grant write permissions.
2
userexecuteBoolean

The user's execute permissions.

This value defaults to 1.

  • 1 — Grant execute permissions.
  • 0 — Do not grant execute permissions.
1
groupreadinteger

Required

A group's read permissions.

  • 4 — Grant read permissions.
  • 0 — Do not grant read permissions.
4
groupwriteinteger

Required

A group's write permissions.

  • 2 — Grant write permissions.
  • 0 — Do not grant write permissions.
2
groupexecuteBoolean

Required

A group's execute permissions.

  • 1 — Grant execute permissions.
  • 0 — Do not grant execute permissions.
1
worldreadinteger

Required

Any system user's read permissions.

  • 4 — Grant read permissions.
  • 0 — Do not grant read permissions.
4
worldwriteinteger

Required

Any system user's write permissions.

  • 2 — Grant write permissions.
  • 0 — Do not grant write permissions.
2
worldexecuteBoolean

Required

Any system user's execute permissions.

  • 1 — Grant execute permissions.
  • 0 — Do not grant execute permissions.
1
doubleencodeBoolean

Whether to encode the file and dir values in a URL format.

This value defaults to 0.

  • 0 Do not encode the file and dir values in a URL format.
  • 1 Encode the file and dir values in a URL format.
0

Returns

This function returns a message of success or a reason for failure.