Tomcat7 ubuntu 用户所有者 [英] Tomcat7 ubuntu user owner

查看:35
本文介绍了Tomcat7 ubuntu 用户所有者的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Ubuntu tomcat7 的默认设置在tomcat7"用户和组下运行.我想更改它,因为我无法通过 sftp 文件上传到由 'tomcat7' 进程创建的目录.

By default settings on Ubuntu tomcat7 runs under 'tomcat7' user and group. I want to change it, cause I can't upload via sftp files to the directories, which are created by 'tomcat7' process.

更改/etc/init.d/tomcat7 中的 TOMCAT7_USER TOMCAT7_GROUP 并重新启动服务没有帮助..

Changing TOMCAT7_USER TOMCAT7_GROUP in /etc/init.d/tomcat7 and restarting the service doesn't help..

推荐答案

我首先将您的/etc/init.d/tomcat7 文件恢复到原来的样子.只有在极少数情况下,您才希望手动编辑/etc 中与 init 相关的文件.如果有用于此目的的内置工具,请使用该工具.

I'd start by reverting your /etc/init.d/tomcat7 file back to what it originally was. Only in very rare cases do you want to manually edit files relating to init in /etc. If there's a built-in tool for that purpose, use the tool.

使用 chown 更改用户或您尝试上传到的目录的用户和组.

Use chown to change either the user or the user and the group of the directory you're trying to upload to.

例如,如果您尝试上传的目录类似于/home/tomcat7/new_directory,请执行以下操作:

For example, if the directory you're trying to upload to is something like /home/tomcat7/new_directory, do this:

cd /home/tomcat7
chown tomcat7:staff new_directory

那么 new_directory 仍将归 tomcat7 所有,但组中的任何用户现在都将拥有 new_directory 的组权限.

Then new_directory will still be owned by tomcat7, but any user in the group staff will now have group permissions for new_directory.

如果您需要将您的用户名添加到群组人员中,可以使用

If you need to add your username to the group staff, you can use

usermod -aG staff username

其中 username 是您要将文件上传到 new_directory 的用户名.

Where username is the name of the user you want uploading the files to new_directory.

如果之后它仍然不起作用,您可能还需要检查该目录的权限.

If it still doesn't work after that, you might also want to check permissions on that directory.

MtWoRw@WorkVM:/home/tomcat7$ ls -l
total 8
drwxr-xr-x 2 tomcat7 tomcat7 4096 Oct  2 17:02 new_directory
-rw-r--r-- 1 tomcat7 tomcat7    6 Oct  2 17:03 regular_file.txt
MtWoRw@WorkVM:/home/tomcat7$  

d 表示它是一个目录,接下来的三个点表示目录的用户/所有者可以做什么,后面三个点是组可以做什么(这个组部分是你想看的)和最后三个是世界可以做的.确保 new_directory 具有该组的读取、写入和执行权限(读取以便您可以看到内容,写入以便您可以向其中添加/上传新文件,并执行以便您能够打开目录(执行的行为有点目录与常规文件不同)).

The d indicates it's a directory, the next three spots indicate what the user/owner of the directory can do, the three spots after that are what the group can do (this group part is what you want to look at) and the last three are what the world can do. Make sure new_directory has permissions for the group to read, write and execute (read so you can see things, write so you can add/upload new files to it, and execute so you're able to open the directory (execute behaves a little differently on directories than on regular files)).

使用 chmod 更改目录或文件的权限.你会输入类似

Use chmod to change the permissions on a directory or file. You'd type something like

chmod 775 /home/tomcat7/new_directory

数字中的第一个数字对应于用户可以做什么,第二个数字对应组可以做什么,第三个数字对应世界可以做什么.这里有关于此问题所需的一切的很好解释.

The first digit in the number corresponds to what the user can do, the second digit to what the group can do and the third to what the world can do. There's a good explanation of everything you need for this issue here.

这篇关于Tomcat7 ubuntu 用户所有者的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆