Try to execute linux commands such as "chown", "chggrp" and so on.Note: Make sure your program is running with root's identity.
解决方案 »
- DataOutputStream 问题?
- 公司开发java 一般用的IDE是什么啊
- for(String item : this)是什么意思?
- 有关抽象类的问题请教大家
- how to get the current Time?
- java实现文件检索功能(在线等待)
- 关于Netty4怎么实现服务发送数据之后等待返回结果,谢谢!!急急
- 字符型变量如何转化为整型
- 高手请进!!!!!!!!
- 关于PKCS#12如何构造的问题
- 谁有<<JAVA 2 核心技术 卷1:基础知识>>英文电子版,谢谢[email protected] / [email protected]
- 请大家回答一下我的问题吧!!多谢了!!
# shell begin
chown myAccount $1
chgrp myAccount $1
# shell end其中$1就是命令行参数,这里应该是文件名。
如果要改变一个目录下所有文件的权限可以加上参数 -R
chown -R myAccount $1
chgrp -R myAccount $13.编辑以后用chmod +x shell_file_name 加上可执行权限
-rwxr-xr-x 1 root root 20 Apr 3 09:49 t*
# chown dureek.admin t
# ls -alF t
-rwxr-xr-x 1 dureek admin 20 Apr 3 09:49 t*
import java.io.InputStreamReader;public class ExecTest {
public static void main(String[] args) {
StringBuffer cmd = new StringBuffer(); if ((args != null) && (args.length > 0)) {
for (int i=0; i<args.length; i++)
cmd.append(args[i]).append(' ');
} else {
System.out.println("You forgot to specify parameters ;]");
System.exit(1);
} try {
Process proc = Runtime.getRuntime().exec(cmd.toString())
;
BufferedReader br = new BufferedReader(new InputStreamRe
ader(proc.getInputStream()));
String s = null;
while ((s = br.readLine()) != null) {
System.out.println(s);
}
} catch (Exception e) {
e.printStackTrace();
} }
}
-rw-r--r-- 1 root root 1269 May 29 10:58 ExecTest.class
-rw-r--r-- 1 root root 781 May 29 10:58 ExecTest.java
# java ExecTest /bin/chown nobody.nobody ExecTest.class
# ls -alF
-rw-r--r-- 1 nobody nobody 1269 May 29 10:58 ExecTest.class
-rw-r--r-- 1 root root 781 May 29 10:58 ExecTest.java
I believe you can solve it perfectly by yourself =)* If these words made you feeling unhappy, I apologize ...
MY OICQ:446065
mail: [email protected]