home bbs files messages ]

Forums before death by AOL, social media and spammers... "We can't have nice things"

   alt.os.linux      Getting to be as bloated as Windows!      107,822 messages   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]

   Message 105,861 of 107,822   
   J.O. Aho to Bengt T   
   Re: How to set group:owner to all direct   
   16 Feb 24 22:13:49   
   
   From: user@example.net   
      
   On 16/02/2024 15.04, Bengt T wrote:   
   > Suppose that tmp_dir_1, tmp_dir_2 and tmp_dir_3 do not exist. With "mkdir -p   
   tmp_dir_1/tmp_dir_2/tmp_dir_3" the following is created:   
   >   
   > !-- tmp_dir_1   
   > ....!-- tmp_dir_2   
   > ........!-- tmp_dir_3   
   >   
   > The group:owner of all tmp_dir_...-s are set the group:owner of the user   
   generating the "mkdir..." the command.   
   >   
   > How to set group:owner to others, for all tmp_dir_...-s, directly in a   
   script with command(s), without having to manually   
   > do so afterwards?   
      
   one liner:   
      
   sudo find /path/to/where/the/temp/dirs/are/located -type d -name   
   "tmp_dir_*" -exec chown user:group "{}" \;   
      
      
   example:   
      
   mkdir -p root_dir/tmp_dir_1/{not_temp,tmp_dir_2,tmp_dir_3}/{dir_4,tmp_dir_5}   
   tree root_dir   
   ### output of tree ###   
   root_dir/   
   └── tmp_dir_1   
        ├── not_temp   
        │   ├── dir_4   
        │   └── tmp_dir_5   
        ├── tmp_dir_2   
        │   ├── dir_4   
        │   └── tmp_dir_5   
        └── tmp_dir_3   
            ├── dir_4   
            └── tmp_dir_5   
      
   11 directories, 0 files   
   ### end of tree output ###   
   sudo find root_dir -type d -name "tmp_dir_*" -exec chown user:group "{}" \;   
      
   If you want all directories regardless name, then remove the '-name   
   "tmp_dir_*"' part.   
   If you want to change all directories and files, then the simple one is just   
      
   sudo chown -R user:group root_dir/*   
      
   or if you want the root dir to change too   
      
   sudo chown -R user:group root_dir   
      
      
      
   Or you can do:   
      
   sudo -u user mkdir -p   
   root_dir/tmp_dir_1/{not_temp,tmp_dir_2,tmp_dir_3}/{dir_4,tmp_dir_5}   
      
   and all the directories are already owned by the user, if the user can   
   write to the directory where the command is run.   
      
   --   
     //Aho   
      
   --   
     //Aho   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]


(c) 1994,  bbs@darkrealms.ca