【问题标题】:Touch command. permission denied触摸命令。没有权限
【发布时间】:2016-12-30 08:45:05
【问题描述】:

我能够通过 SSH 连接到我的学校服务器。我有一个任务,我应该使用 touch 命令来创建一个新文件。然而,它一直返回被拒绝的权限。其他人也能做同样的事情。虽然为什么我不断收到此错误?

下面是终端输入的内容。

Last login: Tue Aug 23 09:16:18 on ttys000
Dominiks-Air:~ fsociety95$ ssh djaneka1@navajo.dtcc.edu
djaneka1@navajo.dtcc.edu's password: 
Last login: Tue Aug 23 09:16:35 2016 from pool-72-94-210-193.phlapa.fios.verizon.net

Navajo 是提供给教职员工和学生的 Linux shell 服务器。这 操作系统为 RedHat Enterprise Linux 5。

Alpine,Pine 的替代品,已作为邮件客户端提供。运行“松树” 在命令提示符下。

此服务器还为用户提供网络空间。网页可以存储在 ~/www 目录。这也可以通过在 Windows 中映射驱动器来访问 到\navajo\主页。您主页的 URL 是 http://user.dtcc.edu/~username/.

您的主目录也可以在 Windows 中通过映射到 \纳瓦霍\。

如果出现损坏或丢失,请发送电子邮件至 path@dtcc.edu。

无法 chdir 到主目录 /u/d/j/djaneka1:没有这样的文件或目录

-bash-3.2$ touch today
touch: cannot touch `today': Permission denied
-bash-3.2$ pwd
/
-bash-3.2$ touch today
touch: cannot touch `today': Permission denied
-bash-3.2$ 

编辑:这是ls -al的结果

-bash-3.2$ ls -al
total 204
drwxr-xr-x  25 root root  4096 Aug 22 16:50 .
drwxr-xr-x  25 root root  4096 Aug 22 16:50 ..
-rw-r--r--   1 root root     0 Aug  3 14:01 .autofsck
-rw-r--r--   1 root root     0 Jan 30  2009 .autorelabel
-rw-------   1 root root  2050 Aug  3 14:00 .bash_history
drwxr-xr-x   2 root root  4096 May  4 04:14 bin
drwxr-xr-x   4 root root  3072 Aug  3 13:57 boot
drwxr-xr-x  11 root root  4060 Aug  3 14:02 dev
drwxr-xr-x  87 root root 12288 Aug 23 10:05 etc
drwxr-xr-x   3 root root  4096 Oct  1  2009 home
drwxr-xr-x  13 root root 12288 Jun  1 04:09 lib
drwx------   2 root root 16384 Mar 24  2008 lost+found
drwxr-xr-x   3 root root  4096 Oct  1  2009 media
drwxr-xr-x   2 root root     0 Aug  3 14:02 misc
drwxr-xr-x   4 root root  4096 May 26  2012 mnt
drwxr-xr-x   2 root root     0 Aug  3 14:02 net
drwxr-xr-x   9 root root  4096 Jan  5  2009 nsr
drwxrwxr-x   3 root root  4096 Oct 12  2015 opt
dr-xr-xr-x 219 root root     0 Aug  3 14:01 proc
drwxr-x---  12 root root  4096 Apr 22 10:06 root
drwxr-xr-x   2 root root 12288 Aug  4 04:02 sbin
drwxr-xr-x   2 root root  4096 Oct  1  2009 selinux
drwxr-xr-x   2 root root  4096 Oct  1  2009 srv
drwxr-xr-x  11 root root     0 Aug  3 14:01 sys
drwxrwxrwt  38 root root  4096 Aug 23 10:07 tmp
drwxr-xr-x  34 root root  4096 Jun 21 08:29 u
drwxr-xr-x  14 root root  4096 Apr 16  2010 usr
drwxr-xr-x  24 root root  4096 Apr 16  2010 var
-rw-------   1 root root  2865 Dec 16  2008 .viminfo
-bash-3.2$ 

编辑:

Here 是我在/home 中尝试touch today 后看到的内容

【问题讨论】:

  • 您没有对根目录的写入权限。我想您已经创建了一个以您的名字命名的目录,您在该目录上拥有必要的权限吗?
  • 没有。我没有根目录的权限。虽然似乎确实有一个我的名字的文件夹。虽然我似乎无法访问它。
  • 你试过 cd 吗?
  • 请使用 ls -al 并在此处显示该命令的结果并编辑您的问题
  • 我尝试复制并粘贴 ls -al 的结果。所有目录都显示为根目录。

标签: linux ssh permissions permission-denied


【解决方案1】:

因此,要尝试在根目录中创建新文档,您需要被识别为 root。这意味着使用sudo 命令。 但是,为此,您需要一个您可能没有的密码。如果你做得很完美。但无论如何我都不建议将文件添加到根目录。 请尝试以下方法:

cd home
touch today

这应该可以很好地回答您的问题。

如果您需要/想要在您的根目录中创建 today,请尝试以下操作

sudo touch today

然后系统会提示您输入可以输入的 root 密码(如果您有明显的密码)

无论如何,我建议阅读this,这可能对你很有帮助。

【讨论】:

  • 我的权限一直被拒绝。看来我会有自己的文件夹,但它说它不存在。
  • @user6748110 您的主目录中的权限被拒绝?我相信你已经在你自己会话的根目录中,所以你不会找到任何有你名字的东西。您今天应该可以在 /home/ 中触摸。我今天尝试触摸我的根目录,但我的权限也被拒绝,但是在我的主目录中 cd 后,我今天可以轻松触摸。
  • 当我转到主目录时,它不会让我。其他人能够使用触摸创建文件,尽管我不确定我是否有问题。如果我能够使用我的电子邮件登录,我不应该有自己的文件夹吗?我只是不确定还能做什么。
  • 感谢您的帮助。
  • @user6748110 请用您刚刚尝试过的内容更新您的问题。请包括所有内容:所有命令及其所有结果。
【解决方案2】:

我想知道这是否真的得到了回答。
如果我正在查看它,我会尝试查看系统认为 djaneka1 的主目录是什么,因为它可能已在中途设置但未完成,留下了应该由 djaneka1 拥有的 root 拥有的东西。

如果您使用 pwd 命令并返回“/”(根)目录,则说明您的设置有问题。

消息:无法 chdir 到主目录 /u/d/j/djaneka1:没有这样的文件或目录 告诉你它找不到你的主目录。

-bash-3.2$ 密码 /

显示“/”的命令“pwd”只是系统无法找到您的主目录的产物。

要找到系统认为是一个人的主目录, 可以在名为“/etc/passwd”的文件中搜索自己的登录名。 如果您这样做,我希望这是一个可能的结果:

$ fgrep 'djaneka1' /etc/passwd djaneka1:x:1505:1506::/u/d/j/djaneka1:/bin/bash

因为它抱怨找不到那个目录。 这需要由对系统拥有更多权限的人(例如 root)来解决。 djaneka1 无能为力

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-11-13
    • 1970-01-01
    • 1970-01-01
    • 2019-07-06
    • 2019-06-18
    • 1970-01-01
    • 1970-01-01
    • 2022-01-01
    相关资源
    最近更新 更多