{"id":1644,"date":"2024-12-09T15:31:22","date_gmt":"2024-12-09T15:31:22","guid":{"rendered":"\/blog\/?p=1644"},"modified":"2025-02-23T04:55:18","modified_gmt":"2025-02-23T04:55:18","slug":"copy-permissions-and-owners-from-another-unix","status":"publish","type":"post","link":"\/blog\/index.php\/copy-permissions-and-owners-from-another-unix\/","title":{"rendered":"copy permissions and owners from another unix"},"content":{"rendered":"\n<p>this script will generate 2 scripts &#8220;chown_cmds.bash&#8221; and &#8220;chmod_cmds.bash&#8221; from a find -ls output, those 2 scripts can be used to set permissions and ownership to files copied to another server<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>!\/bin\/sh\n\n>\/root\/chown_cmds.bash\n>\/root\/chmod_cmds.bash\necho \"set -x \" >> \/root\/chown_cmds.bash\necho \"set -x\" >> \/root\/chmod_cmds.bash\n\nfind \/interfacestst -ls | grep -i '\/' > \/tmp\/lsf\n\ncat \/tmp\/lsf | awk '{ print \"chown \"$5\":\"$6\" \\\"\"$NF \"\\\"\" }' > \/root\/chown_cmds.bash\n\n(\ncat \/tmp\/lsf | while read l;do\nperms=echo $l | awk '{ print $3 }'\nf=echo $l | awk '{ print $NF }'\nOWNER=$(echo $perms | sed -e \"s\/.(\u2026).\/\\1\/\" | sed -e \"s\/&#91;-]\/\/g\" ) GROUP=$(echo $perms | sed -e \"s\/\u2026.(\u2026).\/\\1\/\" | sed -e \"s\/&#91;-]\/\/g\" )\nOTHER=$(echo $perms | sed -e \"s\/\u2026\u2026.(\u2026).*\/\\1\/\" | sed -e \"s\/&#91;-]\/\/g\" )\necho \"chmod u=${OWNER},g=${GROUP},o=${OTHER} ${f}\"\ndone\n) |tee \/root\/chmod_cmds.bash<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>this script will generate 2 scripts &#8220;chown_cmds.bash&#8221; and &#8220;chmod_cmds.bash&#8221; from a find -ls output, those 2 scripts can be used to set permissions and ownership to files copied to another server<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-1644","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"\/blog\/index.php\/wp-json\/wp\/v2\/posts\/1644","targetHints":{"allow":["GET"]}}],"collection":[{"href":"\/blog\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"\/blog\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"\/blog\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"\/blog\/index.php\/wp-json\/wp\/v2\/comments?post=1644"}],"version-history":[{"count":4,"href":"\/blog\/index.php\/wp-json\/wp\/v2\/posts\/1644\/revisions"}],"predecessor-version":[{"id":1652,"href":"\/blog\/index.php\/wp-json\/wp\/v2\/posts\/1644\/revisions\/1652"}],"wp:attachment":[{"href":"\/blog\/index.php\/wp-json\/wp\/v2\/media?parent=1644"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"\/blog\/index.php\/wp-json\/wp\/v2\/categories?post=1644"},{"taxonomy":"post_tag","embeddable":true,"href":"\/blog\/index.php\/wp-json\/wp\/v2\/tags?post=1644"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}