File permissions and attributes

2020-09-23 16

SkyBoy
Member

You do not have write permission

Hi Again
im going too install vscode with GIT So

git clone https://aur.archlinux.org/visual-studio-code-bin.git
[amirsky@skyboy Downloads]$ cd visual-studio-code-bin/
amirsky@skyboy visual-studio-code-bin]$ makepkg -s
==> ERROR: You do not have write permission for the directory $BUILDDIR (/home/amirsky/Downloads/visual-studio-code-bin).
    Aborting...

2020-09-23 16

ewaller
Administrator
File permissions and attributes
From: Pasadena, CA

Re: You do not have write permission

What are the permissions on /home/amirsky/Downloads/visual-studio-code-bin?   
Post the output of ls -l /home/amirsky/Downloads/visual-studio-code-bin


Nothing is too wonderful to be true, if it be consistent with the laws of nature — Michael Faraday
Sometimes it is the people no one can imagine anything of who do the things no one can imagine. — Alan Turing

How to Ask Questions the Smart Way

2020-09-23 16

SkyBoy
Member

Re: You do not have write permission

thanks for your attention

ls -l /home/amirsky/Downloads/visual-studio-code-bin
total 12
-rw-r--r-- 1 root root 1934 Sep 23 19:27 PKGBUILD
-rw-r--r-- 1 root root  512 Sep 23 19:27 visual-studio-code.desktop
-rw-r--r-- 1 root root  345 Sep 23 19:27 visual-studio-code-url-handler.desktop

2020-09-23 16

WorMzy
Forum Moderator
File permissions and attributes

Re: You do not have write permission

Why did you do the git clone as root?


Making lemonade from lemons since 2015.

2020-09-23 16

SkyBoy
Member

Re: You do not have write permission

Why did you do the git clone as root?

Shouldn’t I Have done That???

2020-09-23 16

Zod
Member
File permissions and attributes

Re: You do not have write permission

Why did you do the git clone as root?

Shouldn’t I Have done That???

Last edited by Zod (2020-09-23 16:37:10)

2020-09-23 17

ewaller
Administrator
File permissions and attributes
From: Pasadena, CA

Re: You do not have write permission


Nothing is too wonderful to be true, if it be consistent with the laws of nature — Michael Faraday
Sometimes it is the people no one can imagine anything of who do the things no one can imagine. — Alan Turing

How to Ask Questions the Smart Way

2020-09-23 20

SkyBoy
Member

Re: You do not have write permission

[amirsky@skyboy Programs]$ git clone https://aur.archlinux.org/nordvpn-bin.git
fatal: could not create work tree dir 'nordvpn-bin': Permission denied

then i use sudo too give permission so:

amirsky@skyboy Programs]$ sudo git clone https://aur.archlinux.org/nordvpn-bin.git
Cloning into 'nordvpn-bin'...

then i going too normal way

[amirsky@skyboy Programs]$ cd nordvpn-bin/
[amirsky@skyboy nordvpn-bin]$ sudo makepkg -si
==> ERROR: Running makepkg as root is not allowed as it can cause permanent,
catastrophic damage to your system.
[amirsky@skyboy nordvpn-bin]$ sudo makepkg -s
==> ERROR: Running makepkg as root is not allowed as it can cause permanent,
catastrophic damage to your system.

I do not know where I did this step wrong

2020-09-23 20

loqs
Member

Re: You do not have write permission

In the directory you executed those commands what is the output of

2020-09-23 20

SkyBoy
Member

Re: You do not have write permission

In the directory you executed those commands what is the output of

[amirsky@skyboy nordvpn-bin]$ stat .
  File: .
  Size: 4096            Blocks: 8          IO Block: 4096   directory
Device: 804h/2052d      Inode: 801153      Links: 3
Access: (0755/drwxr-xr-x)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2020-09-24 00:11:41.811461398 +0330
Modify: 2020-09-24 00:11:32.758127538 +0330
Change: 2020-09-24 00:11:32.758127538 +0330
 Birth: 2020-09-24 00:11:31.321460787 +0330

2020-09-23 20

loqs
Member

Re: You do not have write permission

Last edited by loqs (2020-09-23 21:02:39)

2020-09-23 21

SkyBoy
Member

Re: You do not have write permission

The directory is owned by root:root and other does not have write permission for it.

What should I do now?
do you mean i use

Last edited by SkyBoy (2020-09-23 21:03:43)

2020-09-23 21

loqs
Member

Re: You do not have write permission

See my edit.  What is the full path of that directory?

Edit:
No you do not need to use chmod 777.

Last edited by loqs (2020-09-23 21:05:35)

2020-09-23 21

SkyBoy
Member

Re: You do not have write permission

See my edit.  What is the full path of that directory?

Edit:
No you do not need to use chmod 777.

That’s Work Thanks a lot<3
i use

2020-09-23 21

loqs
Member

Re: You do not have write permission

If the directory was under your home directory that was the wrong fix.

2020-09-23 21

SkyBoy
Member

Re: You do not have write permission

If the directory was under your home directory that was the wrong fix.

ahh how can i use

i dont know what is this sad

2020-09-23 21

Zod
Member
File permissions and attributes

Re: You do not have write permission

realpath . <===There is a period here

2020-09-23 22

Trilby
Inspector Parrot
File permissions and attributes

Re: You do not have write permission

There generally* should be no ouput from that command.  In your case, there will be some — the real question is how much (to see how pervasive of a problem there is).

The original source of the problem is almost certainly an indescriminate use of `sudo` when it should not be used.

Last edited by Trilby (2020-09-23 22:36:23)


2020-09-24 08

fukawi2
Ex-Administratorino
File permissions and attributes

Re: You do not have write permission

then i use sudo too give permission so:

amirsky@skyboy Programs]$ sudo git clone https://aur.archlinux.org/nordvpn-bin.git
Cloning into 'nordvpn-bin'...

2020-09-24 09

Khere
Member
File permissions and attributes

Re: You do not have write permission

sudo chown $USER ~/Downloads

But i don’t understand why you clone the repo with root permission despite it beign written everywhere that you must not do that.

Last edited by Khere (2020-09-24 09:43:23)


Fan of Giorgio Moroder & Mohammad Ammax enemy

File systems use permissions and attributes to regulate the level of interaction that system processes can have with files and directories.

Warning: When used for security purposes, permissions and attributes only defend against attacks launched from the booted system. To protect the stored data from attackers with physical access to the machine, one must also implement data-at-rest encryption.

Дополнительно:  Sql injection blind root me solution

Use the ls command’s -l option to view the permissions (or file mode) set for the contents of a directory, for example:

$ ls -l /path/to/directory
total 128
drwxr-xr-x 2 archie archie  4096 Jul  5 21:03 Desktop
drwxr-xr-x 6 archie archie  4096 Jul  5 17:37 Documents
drwxr-xr-x 2 archie archie  4096 Jul  5 13:45 Downloads
-rw-rw-r-- 1 archie archie  5120 Jun 27 08:28 customers.ods
-rw-r--r-- 1 archie archie  3339 Jun 27 08:28 todo
-rwxr-xr-x 1 archie archie  2048 Jul  6 12:56 myscript.sh

Tip: You can view permissions along a path with namei -l path.

Let us see some examples to clarify:

drwx------ 6 archie archie  4096 Jul  5 17:37 Documents

Archie has full access to the Documents directory. They can list, create files and rename, delete any file in Documents, regardless of file permissions. Their ability to access a file depends on the file’s permissions.

dr-x------ 6 archie archie  4096 Jul  5 17:37 Documents

Archie has full access except they can not create, rename, delete any file. They can list the files and (if the file’s permissions allow it) may access an existing file in Documents.

d-wx------ 6 archie archie  4096 Jul  5 17:37 Documents

Archie can not do ls in the Documents directory but if they know the name of an existing file then they may list, rename, delete or (if the file’s permissions allow it) access it. Also, they are able to create new files.

d--x------ 6 archie archie  4096 Jul  5 17:37 Documents

Archie is only capable of (if the file’s permissions allow it) accessing those files the Documents directory which they know of. They can not list already existing files or create, rename, delete any of them.

You should keep in mind that we elaborate on directory permissions and it has nothing to do with the individual file permissions. When you create a new file it is the directory that changes. That is why you need write permission to the directory.

Let us look at another example, this time of a file, not a directory:

-rw-r--r-- 1 archie web  5120 Jun 27 08:28 foobar

Here we can see the first letter is not d but -. So we know it is a file, not a directory. Next the owner’s permissions are rw- so the owner has the ability to read and write but not execute. This may seem odd that the owner does not have all three permissions, but the x permission is not needed as it is a text/data file, to be read by a text editor such as Gedit, EMACS, or software like R, and not an executable in its own right (if it contained something like python programming code then it very well could be). The group’s permissions are set to r--, so the group has the ability to read the file but not write/edit it in any way — it is essentially like setting something to read-only. We can see that the same permissions apply to everyone else as well.

chmod is a command in Linux and other Unix-like operating systems that allows to change the permissions (or access mode) of a file or directory.

To change the permissions — or access mode — of a file, use the chmod command in a terminal. Below is the command’s general structure:

chmod who=permissions filename
  • u: the user that owns the file.
  • g: the user group that the file belongs to.
  • o: the other users, i.e. everyone else.
  • a: all of the above; use this instead of typing ugo.

The permissions are the same as discussed in #Viewing permissions (r, w and x).

Now have a look at some examples using this command. Suppose you became very protective of the Documents directory and wanted to deny everybody but yourself, permissions to read, write, and execute (or in this case search/look) in it:

Before: drwxr-xr-x 6 archie web 4096 Jul 5 17:37 Documents

$ chmod g= Documents
$ chmod o= Documents

After: drwx------ 6 archie web 4096 Jul 6 17:32 Documents

Here, because you want to deny permissions, you do not put any letters after the = where permissions would be entered. Now you can see that only the owner’s permissions are rwx and all other permissions are -.

This can be reverted with:

Before: drwx------ 6 archie web 4096 Jul 6 17:32 Documents

$ chmod g=rx Documents
$ chmod o=rx Documents

After: drwxr-xr-x 6 archie web 4096 Jul 6 17:32 Documents

You can simplify this to put more than one who letter in the same command, e.g:

$ chmod go=rx Documents

Note: It does not matter in which order you put the who letters or the permission letters in a chmod command: you could have chmod go=rx file or chmod og=xr file. It is all the same.

Before: -rw-r--r-- 1 archie web 5120 Jun 27 08:28 foobar

$ chmod g=rw foobar

After: -rw-rw-r-- 1 archie web 5120 Jun 27 08:28 foobar

This is exactly like the first example, but with a file, not a directory, and you grant write permission (just so as to give an example of granting every permission).

Text method shortcuts

The chmod command lets add and subtract permissions from an existing set using + or - instead of =. This is different from the above commands, which essentially re-write the permissions (e.g. to change a permission from r-- to rw-, you still need to include r as well as w after the = in the chmod command invocation. If you missed out r, it would take away the r permission as they are being re-written with the =. Using + and - avoids this by adding or taking away from the current set of permissions).

Let us try this + and - method with the previous example of adding write permissions to the group:

Before: -rw-r--r-- 1 archie web 5120 Jun 27 08:28 foobar

$ chmod g+w foobar

After: -rw-rw-r-- 1 archie web 5120 Jun 27 08:28 foobar

Another example, denying write permissions to all (a):

Before: -rw-rw-r-- 1 archie web 5120 Jun 27 08:28 foobar

$ chmod a-w foobar

After: -r--r--r-- 1 archie web 5120 Jun 27 08:28 foobar

A different shortcut is the special X mode: this is not an actual file mode, but it is often used in conjunction with the -R option to set the executable bit only for directories, and leave it unchanged for regular files, for example:

$ chmod -R a+rX ./data/

It is possible to tell chmod to copy the permissions from one class, say the owner, and give those same permissions to group or even all. To do this, instead of putting r, w, or x after the =, put another who letter. e.g:

Before: -rw-r--r-- 1 archie web 5120 Jun 27 08:28 foobar

$ chmod g=u foobar

After: -rw-rw-r-- 1 archie web 5120 Jun 27 08:28 foobar

$ chmod g=wu foobar

In that case chmod throw an error.

Дополнительно:  В безопасности нет root

chmod can also set permissions using numbers.

Using numbers is another method which allows you to edit the permissions for all three owner, group, and others at the same time, as well as the setuid, setgid, and sticky bits. This basic structure of the code is this:

$ chmod xxx filename

Where xxx is a 3-digit number where each digit can be anything from 0 to 7. The first digit applies to permissions for owner, the second digit applies to permissions for group, and the third digit applies to permissions for all others.

In this number notation, the values r, w, and x have their own number value:

r=4
w=2
x=1

To come up with a 3-digit number you need to consider what permissions you want owner, group, and all others to have, and then total their values up. For example, if you want to grant the owner of a directory read write and execution permissions, and you want group and everyone else to have just read and execute permissions, you would come up with the numerical values like so:

  • Owner: rwx=4+2+1=7
  • Group: r-x=4+0+1=5
  • Other: r-x=4+0+1=5
$ chmod 755 filename
$ chmod u=rwx filename
$ chmod go=rx filename

To view the existing permissions of a file or directory in numeric form, use the command:

$ stat -c %a filename

Where the %a option specifies output in numeric form.

Most directories are set to 755 to allow reading, writing and execution to the owner, but deny writing to everyone else, and files are normally 644 to allow reading and writing for the owner but just reading for everyone else; refer to the last note on the lack of x permissions with non executable files: it is the same thing here.

To see this in action with examples consider the previous example that has been used but with this numerical method applied instead:

Before: -rw-r--r-- 1 archie web 5120 Jun 27 08:28 foobar

$ chmod 664 foobar

After: -rw-rw-r-- 1 archie web 5120 Jun 27 08:28 foobar

If this were an executable the number would be 774 if you wanted to grant executable permission to the owner and group. Alternatively if you wanted everyone to only have read permission the number would be 444. Treating r as 4, w as 2, and x as 1 is probably the easiest way to work out the numerical values for using chmod xxx filename, but there is also a binary method, where each permission has a binary number, and then that is in turn converted to a number. It is a bit more convoluted, but here included for completeness.

Consider this permission set:

-rwxr-xr--

If you put a 1 under each permission granted, and a 0 for every one not granted, the result would be something like this:

-rwxrwxr-x
 111111101

You can then convert these binary numbers:

000=0	    100=4
001=1	    101=5
010=2	    110=6
011=3	    111=7

The value of the above would therefore be 775.

Consider we wanted to remove the writable permission from group:

-rwxr-xr-x
 111101101

You can also use the numeric method to set the setuid, setgid, and sticky bits by using four digits.

setuid=4
setgid=2
sticky=1

For example, chmod 2777 filename will set read/write/executable bits for everyone and also enable the setgid bit.

Generally directories and files should not have the same permissions. If it is necessary to bulk modify a directory tree, use find to selectively modify one or the other.

To chmod only directories to 755:

$ find directory -type d -exec chmod 755 {} +

To chmod only files to 644:

$ find directory -type f -exec chmod 644 {} +

chown changes the owner of a file or directory, which is quicker and easier than altering the permissions in some cases.

brw-rw---- 1 root disk 8,    9 Jul  6 16:02 sda9
drwxr-xr-x 5 root root    4096 Jul  6 16:01 Backup

Before: drwxr-xr-x 5 root root 4096 Jul 6 16:01 Backup

# chown archie /media/Backup

After: drwxr-xr-x 5 archie root 4096 Jul 6 16:01 Backup

Now the partition can have data written to it by the new owner, archie, without altering the permissions (as the owner triad already had rwx permissions).

  • chown always clears the setuid and setgid bits.
  • Non-root users cannot use chown to «give away» files they own to another user.

The umask utility is used to control the file-creation mode mask, which determines the initial value of file permission bits for newly created files.

Warning: By default, file attributes are not preserved by cp, rsync, and other similar programs.

The package contains the programs and that list and change a file’s attributes, respectively.

These are a few useful attributes. Not all filesystems support every attribute.

  • a — append only: File can only be opened for appending.
  • c — compressed: Enable filesystem-level compression for the file.
  • i — immutable: Cannot be modified, deleted, renamed, linked to. Can only be set by root.
  • j — data journaling: Use the journal for file data writes as well as metadata.
  • m — no compression: Disable filesystem-level compression for the file.
  • A — no atime update: The file’s atime will not be modified.
  • C — no copy on write: Disable copy-on-write, for filesystems that support it.
# chattr +i /path/to/file

To remove an attribute on a file just change + to -.

Warning: By default, extended attributes are not preserved by cp, rsync, and other similar programs, see #Preserving extended attributes.

Extended attributes are also used to set Capabilities.

$ setfattr -n user.checksum -v "3baf9ebce4c664ca8d9e5f6314fb47fb" foo.txt

Use getfattr to display extended attributes:

$ getfattr -d foo.txt
# file: foo.txt
user.checksum="3baf9ebce4c664ca8d9e5f6314fb47fb"

Finally, to remove an extended attribute:

$ setfattr -x user.checksum foo.txt

Preserving extended attributes

  1. mv silently discards extended attributes when the target file system does not support them.

Tips and tricks

I created a new EFS volume and mounted it with the EFS mount helper.

Here is the /etc/fstab:

LABEL=cloudimg-rootfs   /    ext4   defaults,discard    0 0
fs-deadbeef:/ /mnt/efs efs _netdev,tls 0 0

The mount completed successfully; however root does not have write permission for anything.

$ cd /mnt/efs
$ ls -al
total 8
drwxr-xr-x 2 root root 6144 May  4 15:28 .
drwxr-xr-x 3 root root 4096 Jun  2 19:56 ..
$ sudo mkdir temp
mkdir: cannot create directory ‘temp’: Permission denied
$ sudo touch test
touch: cannot touch 'test': Permission denied

I went to the AWS EFS console for this volume and verified that the option for «Disable root access by default» is unchecked.

I have what I think is an identical volume on an identical system (the nightly build) for which root has totally normal write access to the volume. The base image is the standard Ubuntu 18.04 AMI.

What can cause root to have no write access to an EFS volume?

asked Jun 2, 2020 at 20:38

Дополнительно:  Microsoft публикует исправление для ошибки BSOD в Windows 10 «APC_INDEX_MISMATCH» » MSReview

drhagen's user avatar

As of June 2020, it is not enough to look at the «Policy Settings» tab in Elastic File System > File systems > Manage file system permissions. This tab does not show the current settings. The current settings are only displayed in the «JSON» tab.

You should click «Set Policy» in the «Policy Settings» tab and then «Save policy» when it switches you to the «JSON» tab.

Alternatively, you can click «Delete policy» in the «JSON» tab, which reverts the permissions to the default, which also allows for root access.

answered Jun 5, 2020 at 12:17

drhagen's user avatar

2 silver badges8 bronze badges

[root@hostname ~]# write
write: you have write permission turned off.
[root@hostname ~]# mesg y
[root@hostname ~]# mesg
is y
[root@hostname ~]# write
write: you have write permission turned off.

What else needs to be enabled/corrected for this to work?

asked Oct 1, 2013 at 16:38

Steve Robbins's user avatar

Steve Robbins

5 gold badges23 silver badges26 bronze badges

Testing strace write and strace mesg reveals a slight difference in how they identify your tty.

Notice that they also look at different file descriptors 0 vs 1. Normally an interactive shell will have file descriptors 0, 1, and 2 all referencing the same tty. If you have somehow gotten your shell running with 0 and 1 referencing something different for example if you had redirected one of them, that could explain the discrepancy between the output from mesg and write.

If the file descriptors are both referencing the same tty, another possible reason for the discrepancy could be that your /proc mount is not behaving as expected or the character device inode for your tty has been replaced.

answered Nov 26, 2017 at 0:29

kasperd's user avatar

There are multiple utilities that provide the write functionality. All of them will need to be able to write to terminals. However, as you are running as root permissions should not be an issue.

answered Sep 7, 2016 at 4:04

BillThor's user avatar

3 gold badges37 silver badges69 bronze badges

I had to edit /etc/login.defs and change TTYPERM 0600 to TTYPERM 0620.

answered Oct 23, 2021 at 19:24

ergohack's user avatar

mount -t cifs -o username=myuser,domain=mydomain //server/share /mount/path

asked Sep 9, 2021 at 16:43

R-obert's user avatar

sudo mount -t cifs -o username=myuser,password=yourpassword,domain=mydomain,uid=yourUID,gid=yourGID,forceuid,forcegid //server/share /mount/path

Also you can use id command to get uid and gid automatically like below.

sudo mount -t cifs -o username=myuser,password=yourpassword,domain=mydomain,uid=$(id -u),gid=$(id -g),forceuid,forcegid //server/share /mount/path

answered Sep 9, 2021 at 16:52

Vaibhav Panmand's user avatar

Все операционные системы семейства Linux имеют четко разграниченные права доступа. В своей домашней директории пользователь может делать все, что ему угодно, до тех пор, пока укладывается в отведенные рамки. Попытка выйти за них приводит к появлению ошибки «Permission Denied».

Изменение прав в терминале

Рассмотрим вариант, в котором необходимо прочесть текстовый документ, созданный другим пользователем. Файлы TXT в Linux можно просматривать непосредственно в терминале с помощью команды «cat».

  1. Заходим в каталог с интересующим нас документом. Набираем команду «cat filename», подставляя вместо «filename» имя нужного файла. На скриншоте показана ошибка «Permission Denied», выглядящая в русской локализации как «Отказано в доступе».

    Ошибка «Permission Denied»

    Получаем ошибку «Permission Denied» при попытке просмотреть содержимое файла

  2. Проверяем права доступа к содержимому каталога, набрав «ls -l». Результат, полученный для текстового документа, выделен рамкой. Разрешение на чтение и запись имеет только его владелец.

    Просмотр прав доступа командой «ls»

    Проверяем права доступа к документу используя команду «ls -l»

  3. Набираем команду «sudo chmod 755 filename». С ее помощью мы от имени администратора системы даем разрешение на чтение документа себе и любому другому пользователю. Проверяем результат выполнения и убеждаемся, что права доступа изменились нужным образом.

    Изменение прав доступа командой «chmod»

    Используем команду «chmod» и административные права для получения доступа

  4. Повторно используем «cat» и читаем ранее недоступное содержимое.

    Просмотр текстового файла командой «cat»

    Просматриваем содержимое текстового документа командой «cat»

Изменение прав в файловом менеджере

Разберемся, как выполнить рассмотренную выше операцию в графическом интерфейсе, используя файловый менеджер из дистрибутива.

  1. Как видно на скриншоте, значок файла изначально имеет дополнительные символы, указывающие на то, что доступ у нему ограничен. При попытке посмотреть содержимое получаем графический вариант ошибки «Permission Denied».

    Графический вариант ошибки «Permission Denied»

    При попытке открыть текстовый документ получаем ошибку «Permission Denied»

  2. Разворачиваем меню «Файл». Выбираем в списке действий «Открыть как Администратор».

    Переключение файлового менеджера в режим root

    Открываем меню «Файл» и перезапускаем файловый менеджер от имени root

  3. Вводим в отмеченное стрелкой поле пароль root. Нажимаем кнопку «Аутентификация» или клавишу Enter.

    Окно аутентификации root

    Набираем пароль root в окне аутентификации

  4. В новом окне файлового менеджера вызываем контекстное меню для нужного файла. Выбираем в нем пункт «Параметры».

    Контекстное меню файлового менеджера

    Открываем параметры файла с помощью контекстного меню

  5. Переключаемся на вкладку «Права». Меняем разрешения для группы и остальных пользователей. Для последних выберем в качестве примера «Только чтение». Внеся изменения, закрываем окно параметров.

    Вкладка «Права» в свойствах файла

    На вкладке «Права» разрешаем доступ для группы root и остальных пользователей

  6. Теперь текстовый документ будет открываться в выбранном нами режиме «Только чтение», без возможности редактировать содержимое.

    Файл, открытый в режиме чтения

    Открываем ранее недоступный файл в режиме чтения и изучаем содержимое

В заключение

Как видим, избавиться от ошибки Permission Denied достаточно просто. Решив изменить правда доступа к системным файлам, лишний раз убедитесь, что полностью уверены в своих действиях и понимаете последствия вносимых изменений.

sudo mkfs.btrfs /dev/sdb /dev/sdc

Seems that the new btrfs filesystem was successfully created:

$ sudo btrfs filesystem show /dev/sdb 
[sudo] password for dwayne:  
Label: none  uuid: ada8b4f3-f4a8-4a9d-a078-2149f5d7fd0c     
Total devices 2 FS bytes used 896.00KiB     
devid    1 size 4.55TiB used 2.01GiB path /dev/sdb  
devid    2 size 4.55TiB used 2.01GiB path /dev/sdc

Mounted it using (as shown in the article)

sudo mount /dev/sdb /mnt

But I cannot write to it:

$ cd /mnt   
$ touch helloworld.txt  
touch: cannot touch 'helloworld.txt': Permission denied  
$ sudo touch helloworld.txt  
$ ls -al  
total 20  
drwxr-xr-x  1 root root   28 Mar  1 00:27 .  
drwxr-xr-x 24 root root 4096 Feb 27 21:27 ..
-rw-r--r--  1 root root    0 Mar  1 00:27 helloworld.txt  
$ df -h .  
Filesystem      Size  Used Avail Use% Mounted on  
/dev/sdb        9.1T 17M  9.1T   1% /mnt

Why does root have permission to write, but no one else does? What have I done wrong?

muru's user avatar

53 gold badges469 silver badges719 bronze badges

asked Mar 1, 2017 at 5:55

Dwayne Moore's user avatar

That’s the normal state of affairs after creating a new partition and mounting it as root. You have to grant permissions and ownerships using chowm, chmod, setfacl, etc. before anybody other than root can write to it.

When you mount a partition which supports POSIX permissions and ownerships, the mount point is set to be owned by whoever mounted it — usually, root (sudo mount). GUI mounting, which uses udisks, takes care of setting you as the owner of the mountpoint itself.

answered Mar 1, 2017 at 6:21

muru's user avatar

53 gold badges469 silver badges719 bronze badges

Оцените статью
Master Hi-technology
Добавить комментарий