---
title: "用java在linux下修改文件权限"
author: "geshenyi"
date: "2011-09-20T13:00:09Z"
tags: []
categories: ["编程语言"]
slug: "java-linux"
draft: false
lastmod: "2011-09-20T13:00:09Z"
id: 1175797
url: "https://geshenyi.iteye.com/blog/1175797"
---

String cmdStrs\[] = new String\[]{ "chmod","-R","775", "/var/www/userweb2/" + companyId + "/" + Constants.BBSFILE }; public static boolean execCmd( String\[] cmdStrs ){ try { Process child = Runtime.getRuntime().exec(cmdStrs); BufferedReader in = new BufferedReader(new InputStreamReader(child .getInputStream())); String c = null; while ((c = in.readLine()) != null) { System.out.println(c + "  
"); } child.waitFor(); in.close(); } catch (Exception e) { System.out.println("\\n===执行linux命令出错"); e.printStackTrace(); return false; } return true; }