Recent

Author Topic: how to change drwxrwxr-x to -rwxrwxr-x (change the first left flag)  (Read 1798 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: 14373
  • Sensorship about opinions does not belong here.
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
Object Pascal programmers should get rid of their "component fetish" especially with the non-visuals.

lucamar

  • Hero Member
  • *****
  • Posts: 4219
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/FPC 2.0.8/3.0.4 & 2.0.12/3.2.0 - 32/64 bits on:
(K|L|X)Ubuntu 12..18, Windows XP, 7, 10 and various DOSes.

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11452
  • FPC developer.
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: 4219
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/FPC 2.0.8/3.0.4 & 2.0.12/3.2.0 - 32/64 bits on:
(K|L|X)Ubuntu 12..18, Windows XP, 7, 10 and various DOSes.

 

TinyPortal © 2005-2018