Recent

Author Topic: how to change drwxrwxr-x to -rwxrwxr-x (change the first left flag)  (Read 545 times)

creatxr

  • New Member
  • *
  • Posts: 13
how to change drwxrwxr-x to -rwxrwxr-x (change the first left flag)

change flag to d , - , or l

to treat directory as file
or
to mark back as directory

thanks.

Thaddy

  • Hero Member
  • *****
  • Posts: 9189
Re: how to change drwxrwxr-x to -rwxrwxr-x (change the first left flag)
« Reply #1 on: April 07, 2019, 05:15:33 pm »
man chmod
also related to equus asinus.

lucamar

  • Hero Member
  • *****
  • Posts: 2084
Re: how to change drwxrwxr-x to -rwxrwxr-x (change the first left flag)
« Reply #2 on: April 07, 2019, 06:01:48 pm »
man chmod

You can not change the directory flag with chmod, only the permission bits.*

@creatxr: Let me make a little search in my info sources; I remember having seen something related some time or other but I don't remember whether it can be done or not--although I think it can.


* In case there is any doubt:
Quote from: man chmod
[... discussion of UGO-RWXS options omitted ...]

A numeric mode is from one to four octal digits (0-7), derived by adding up  bits  with  values 4, 2, and 1.  Omitted digits are assumed to be leading zeros.
  • The first digit selects the set user ID (4) and set group ID (2), and  restricted deletion or sticky (1) attributes.
  • The second digit selects permissions for the user who owns the file: read (4), write (2), and execute (1);
  • The third  selects permissions  for  other users in the file's group, with the same values; and
  • the fourth for other users not in the file's group, with the same values.
[...etc...]

(Re-formated by myself)
« Last Edit: April 07, 2019, 06:50:09 pm by lucamar »
Turbo Pascal 3 CP/M - Amstrad PCW 8256 (512 KB !!!) :P
Lazarus 2.0.2/2.0.4  - FPC 3.0.4 on:
(K|L)Ubuntu 12..16, Windows XP SP3, various DOSes.

marcov

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 7507
Re: how to change drwxrwxr-x to -rwxrwxr-x (change the first left flag)
« Reply #3 on: April 07, 2019, 06:07:40 pm »
Note that you can afaik open directories as files using normal FPC I/O.

lucamar

  • Hero Member
  • *****
  • Posts: 2084
Re: how to change drwxrwxr-x to -rwxrwxr-x (change the first left flag)
« Reply #4 on: April 07, 2019, 09:24:21 pm »
I don't know if the URL still works but I found a "note to myself" about this:
Quote from: superuser.com
linux - How to remove directory flag? - Super User
https://superuser.com/questions/855212/how-to-remove-directory-flag

Changing the inode type would give you a corrupt filesystem, nothing else. (You would do that with filesystem debugging tools, which are filesystem specific and pretty dangerous - backup what you can before attempting anything like that. Example for the Linux ext filesystems: debugfs.)
Turbo Pascal 3 CP/M - Amstrad PCW 8256 (512 KB !!!) :P
Lazarus 2.0.2/2.0.4  - FPC 3.0.4 on:
(K|L)Ubuntu 12..16, Windows XP SP3, various DOSes.