Get/set Unix file 'owner'? lazarus / 32-Linux ---------------------------------------------------------------------- AlexTP · 2021-06-17 19:12 CudaText runs 'pkexec /bin/cp old_filename new_filename'. It works OK but the owner of that file changes from 'root' to my name. Can I change the owner of a file? Can I read the owner of a file? ---------------------------------------------------------------------- winni · 2021-06-17 19:37 Hi! The unit BaseUnix has a wapper for the Unix command chown: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i Function  FpChown   (const path : RawByteString; owner : TUid; group : TGid): cInt; Winni ---------------------------------------------------------------------- AlexTP · 2021-06-17 20:00 To run the 'pkexec --user username' I need the string-user-name of file owner. How to get it? ---------------------------------------------------------------------- skalogryz · 2021-06-17 20:08 don't you need elevated rights (sudo) to assign "root" as the owner? ---------------------------------------------------------------------- winni · 2021-06-17 20:08 Hi Use the Unix command id: To get the UserID:Code: Bash  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i  id -u winni To get the GroupId: Code: Bash  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i id -g winni Winni ---------------------------------------------------------------------- winni · 2021-06-17 20:10 Quote from: skalogryz on June 17, 2021, 10:08:13 pmdon't you need elevated rights (sudo) to assign "root" as the owner? Yes Winni ---------------------------------------------------------------------- winni · 2021-06-17 20:36 Hi! Oops - you need it vice versa. For UserId 1000  you use: Code: Bash  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i grep - w 1000 /etc/passwd It returns in my case: Code: Text  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i winni:x:1000:100::/home/winni:/bin/bash which is: Code: Text  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i UserName:pwd:UserID:GroupID:comment:HomeDirectory:shell Winni ---------------------------------------------------------------------- AlexTP · 2021-06-17 21:21 Thanks. I found that 'pkexec /bin/mv' does NOT set root owner. But 'pkexec /bin/cp filename /etc/filename' does it! Solved.