Gab*_*lli 7 linux apache-http-server www documents permissions
我是 Linux 新手,我正在尝试在运行 Ubuntu Server 的 VM 内设置一个小型测试服务器。我找到了 /var/www 文件夹,它应该是我存储 Apache 文档的文件夹,事实上,如果我访问我的 VM 的 IP,我会看到存储在那里的 index.html 页面。
我的问题是我无法写入该文件夹。
ls -l
返回:
d-w-r-xr-x 2 root root 4096 2011-12-28 16:08 ./
drwxr-xr-x 13 root root 4096 2011-12-28 17:02 ../
-rw-r--r-- 1 root root 177 2011-12-28 16:08 index.html
Run Code Online (Sandbox Code Playgroud)
我的用户叫gab
.
处理此文件夹以允许自己在此处编辑和创建文件时,最好的做法是什么?我应该创建一个新组还是将自己设置为文件夹的所有者?
那是一个受保护的文件夹。您需要成为 root 才能修改此目录。
您还可以通过执行以下操作使 gab 成为该目录的所有者
sudo chown -R gab /var/www
Run Code Online (Sandbox Code Playgroud)
sudo
将以chown -R gab /var/www
root(管理员)身份执行该命令,并提示您输入设置系统时使用的密码(很可能与 gab 的密码相同)。
一旦你这样做了,你也可以这样做
sudo chown -R 755 /var/www
Run Code Online (Sandbox Code Playgroud)
授予写入权限。
# Permission
7 full
6 read and write
5 read and execute
4 read only
3 write and execute
2 write only
1 execute only
0 none
Reference Class Description
u user the owner of the file
g group users who are members of the file's group
o others users who are not the owner of the file or members of the group
Run Code Online (Sandbox Code Playgroud)
755 意味着用户将具有完全访问权限,组将具有读取和执行访问权限,其他人将具有读取和执行访问权限。