diff --git a/apps/files_external/lib/config.php b/apps/files_external/lib/config.php
index b2109e5eacde2290d786502e1c1a7ccef964ebdf..9bc06bbbcccdc93b09262fb79a5b45ee791059dc 100755
--- a/apps/files_external/lib/config.php
+++ b/apps/files_external/lib/config.php
@@ -438,7 +438,7 @@ class OC_Mount_Config {
 	 */
 	public static function checksmbclient() {
 		if(function_exists('shell_exec')) {
-			$output=shell_exec('which smbclient 2> /dev/null');
+			$output=shell_exec('command -v smbclient 2> /dev/null');
 			return !empty($output);
 		}else{
 			return false;
diff --git a/lib/private/installer.php b/lib/private/installer.php
index 11633a4d4a19ff27ddf59f58f6361a0be784b859..64e8e3a5e7a24f58b50c4d4035b5de780f8f0677 100644
--- a/lib/private/installer.php
+++ b/lib/private/installer.php
@@ -464,7 +464,7 @@ class OC_Installer{
 		// is the code checker enabled?
 		if(OC_Config::getValue('appcodechecker', true)) {
 			// check if grep is installed
-			$grep = exec('which grep');
+			$grep = exec('command -v grep');
 			if($grep=='') {
 				OC_Log::write('core',
 					'grep not installed. So checking the code of the app "'.$appname.'" was not possible',
diff --git a/lib/private/preview/movies.php b/lib/private/preview/movies.php
index 71cd3bae0573d299ffc9806be234d76b0ec5a4bd..7e0ff51ad2e8aab10a5ddcaba43db88b637bc7b3 100644
--- a/lib/private/preview/movies.php
+++ b/lib/private/preview/movies.php
@@ -9,7 +9,7 @@
 namespace OC\Preview;
 
 function findBinaryPath($program) {
-	exec('which ' . escapeshellarg($program) . ' 2> /dev/null', $output, $returnCode);
+	exec('command -v ' . escapeshellarg($program) . ' 2> /dev/null', $output, $returnCode);
 	if ($returnCode === 0 && count($output) > 0) {
 		return escapeshellcmd($output[0]);
 	}
diff --git a/lib/private/preview/office-cl.php b/lib/private/preview/office-cl.php
index b11fed13ba1ad5c145a8fb293b191e895aaea309..6e4d4321eb7e4276d338a1e407803ef85dcb3a4b 100644
--- a/lib/private/preview/office-cl.php
+++ b/lib/private/preview/office-cl.php
@@ -64,12 +64,12 @@ if (!\OC_Util::runningOnWindows()) {
 				$cmd = \OC_Config::getValue('preview_libreoffice_path', null);
 			}
 
-			$whichLibreOffice = shell_exec('which libreoffice');
+			$whichLibreOffice = shell_exec('command -v libreoffice');
 			if($cmd === '' && !empty($whichLibreOffice)) {
 				$cmd = 'libreoffice';
 			}
 
-			$whichOpenOffice = shell_exec('which openoffice');
+			$whichOpenOffice = shell_exec('command -v openoffice');
 			if($cmd === '' && !empty($whichOpenOffice)) {
 				$cmd = 'openoffice';
 			}
diff --git a/lib/private/preview/office.php b/lib/private/preview/office.php
index 02bb22e9b9479b0f9816cd6c39aa51fd4f475295..131bc9a0dc423f76b7c6ea770b458fc508a987d0 100644
--- a/lib/private/preview/office.php
+++ b/lib/private/preview/office.php
@@ -11,9 +11,9 @@ if (extension_loaded('imagick') && count(@\Imagick::queryFormats("PDF")) === 1)
 
 	// LibreOffice preview is currently not supported on Windows
 	if (!\OC_Util::runningOnWindows()) {
-		$whichLibreOffice = ($isShellExecEnabled ? shell_exec('which libreoffice') : '');
+		$whichLibreOffice = ($isShellExecEnabled ? shell_exec('command -v libreoffice') : '');
 		$isLibreOfficeAvailable = !empty($whichLibreOffice);
-		$whichOpenOffice = ($isShellExecEnabled ? shell_exec('which libreoffice') : '');
+		$whichOpenOffice = ($isShellExecEnabled ? shell_exec('command -v libreoffice') : '');
 		$isOpenOfficeAvailable = !empty($whichOpenOffice);
 		//let's see if there is libreoffice or openoffice on this machine
 		if($isShellExecEnabled && ($isLibreOfficeAvailable || $isOpenOfficeAvailable || is_string(\OC_Config::getValue('preview_libreoffice_path', null)))) {