Невозможно удалить файл с битами режима файла a+rw

Esto se puede hacer con lo siguiente:

¶ dividir registros en una coma

  perl -F'/,(?=0,|0$)/' -lane 'print if $#F < 4' csv.file 

° split on those commas to the right of whom we see either a 0, or a 0 at the end.

° the array formed by splitting up the record ($_) is (@F) and whose last index ($#) will have how many such commas were there.

¶ basado en sed

 sed -ne '
     h;1b print
     s/,/,,/g;s/$/,/;t reset
     :reset;s/,0,/&/4;t
     :print;g;p
 '  csv.file

°  we double the commas as this involves overlapping matches. Also provide a comma at the end for uniform matching. 
 ° a dummy t command is run first to clear the test flag, OTW the actual t command that follows misfires.
° a s/// command is run to do a fourth substitution. If it succeeds => there are at least four pure zero fields. We don't want this so the labelless t command shall take the conrol to end of any further processing. The -n sed option will prevent it from being printed.
° now when the substitution failed => there were three or less such pure zero fields and we want such lines.
° before making changes we had stored the original unmodified line in hold space so we get it back and print it.
7
13.03.2019, 11:22
2 ответа

Каталог /tmpобычно помечается флагом ограниченного удаления , который отображается как буква разрешения tили Tв выводе ls.

Ограниченное удаление подразумевает несколько вещей. В общем случае это означает, что только владелец файла или сам владелец /tmpможет удалить файл/каталог в /tmp.

Вы не можете удалить файл, так как вы не являетесь его владельцем, а это root. Попробуйте запустить rmс sudo, о котором вы, вероятно, забыли.

sudo rm /tmp/test

В частности, только для Linux, флаг ограниченного удаления (для мирового -доступного для записи каталога, такого как /tmp), а также включает protected_symlinks, protected_hardlinks, protected_regularи protected_fifos. ] ограничения, которые в таких каталогах соответственно не позволяют пользователям переходить по символическим ссылкам, которыми они не владеют,запрещает пользователям создавать жесткие ссылки на файлы, которыми они не владеют, запрещает пользователям открывать FIFO, которыми они не владеют, и запрещает пользователям открывать существующие файлы, которыми они не владеют, когда они ожидали их создания.

Это удивит вас ошибками прав доступа при выполнении различных действий, таких как rootкогда вы делаете используете sudo.

Подробнее об этом в таких вопросах, как «Различное поведение разрешений жестких ссылок между CentOS 6 и CentOS 7 », «Символическая ссылка не работает должным образом при смене пользователя » и «Групповые разрешения для root не работают в /tmp ".

13
27.01.2020, 20:14

Проблема, похоже, заключается в липкой части /tmp.

$ ls -ld /tmp
drwxrwxrwt⃝   1 root  root  1044 Mar 13 12:09 /tmp

https://en.wikipedia.org/wiki/Sticky_bit

When a directory's sticky bit is set, the filesystem treats the files in such directories in a special way so only the file's owner, the directory's owner, or root user can rename or delete the file. Without the sticky bit set, any user with write and execute permissions for the directory can rename or delete contained files, regardless of the file's owner. Typically this is set on the /tmp directory to prevent ordinary users from deleting or moving other users' files.

6
27.01.2020, 20:14

Теги

Похожие вопросы