How to Run Shell Commands via PHP File in cPanel?

You can run shell commands via PHP file in cPanel by following the below mentioned steps.
  • Login to your cPanel account.
  • Navigate to your root directory (public_html) and create a new File
  • Type any suitable name with the .php extension, and hit the Create New File button. 
  • Right click over the created PHP file and then Edit.
  • Copy the below given code and paste it there.
<?php 
$output = shell_exec('df -h'); 
echo "<pre>$output</pre>"; 
?>

*You can use any shell command in the bracket().

  • Click over Save Changes to save the code.
  • Now, visit the file from the outside as URL as, www.domainname.com/file.php
You can also check the blog to run various shell commends using php file in cPanel.
  • how to run commands in cPanel, how to execute linux commands in cpanel itself, how to run SSH from cpanel, php script to run linux command in cpanel, run tar command without linux access, how to run shell commands in php file, tar command in php script, how to run SSH commands in PHP file, without SSH access, How to run SSH commands using php script, tar file from cpanel, run ssh commands from php file, linux commands execute in cpanel, use tar command without SSH, how to tar/untar in cpanel using php script, how to use tar and untar command in cpanel, ssh command via php script
  • 0 Users Found This Useful
Was this answer helpful?

Related Articles

How to Install WordPress in Sub-Directory?

Login to cPanel. Select Softaculous Apps Installer from Software section. Select WordPress...

How to Restore Backups Using JetBackup 4 in cPanel?

Login to cPanel and get inside JetBackups section. Here, you will find multiple features which...

How to Suspend Outgoing Emails of a cPanel Account as WHM Reseller?

To manage the bulk mailing that occurred from a cPanel account hosted within your WHM Reseller,...

How Can You Create/Install WordPress On Sub-Domains?

#1. Create a subdomain of your main domain Log into your cPanel and go to the Subdomains...

How to disallow a particular directory from being crawled by Google?

Login to your cPanel Go inside File Manager Click on public_html Create a robots.txt file....