{"id":1257,"date":"2018-08-14T08:45:54","date_gmt":"2018-08-14T13:45:54","guid":{"rendered":"http:\/\/blog.ls-al.com\/?p=1257"},"modified":"2018-08-14T08:45:54","modified_gmt":"2018-08-14T13:45:54","slug":"sudo-and-home-folder","status":"publish","type":"post","link":"https:\/\/blog.ls-al.com\/sudo-and-home-folder\/","title":{"rendered":"Sudo and home folder"},"content":{"rendered":"
I suspect behavior of setting $HOME when using sudo may differ between Linux flavors. As most modern Unix operating systems discourage using the root account and promote using sudo, I have mostly always used \"sudo -s\". I expect that my shell then will reference \/root as my home folder($HOME).<\/p>\n
I have a backup script I run in the root crontab but I had a tricky issue with restic\/rclone where running the script from the command line worked but from cron failed silently. After some debugging I noticed rclone was using the rclone.conf from my regular user home folder when run in the command line and not from root account's home folder.<\/p>\n
So I noticed that \"sudo -i\" was working as opposed to \"sudo -s\" failing. In this Ubuntu 18.04 client I am working on the behavior of sudo differed from what I was used to. See below:<\/p>\n
\r\nrrosso@u1804:~$ sudo -i\r\nroot@u1804:~# echo $HOME\r\n\/root\r\n\r\nroot@u1804:~# logout\r\nrrosso@u1804:~$ sudo -s\r\nroot@u1804:~# echo $HOME\r\n\/home\/rrosso\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"I suspect behavior of setting $HOME when using sudo may differ between Linux flavors. As most modern Unix operating systems<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[102],"tags":[],"class_list":["post-1257","post","type-post","status-publish","format-standard","hentry","category-sudo"],"_links":{"self":[{"href":"https:\/\/blog.ls-al.com\/wp-json\/wp\/v2\/posts\/1257","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.ls-al.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.ls-al.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.ls-al.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.ls-al.com\/wp-json\/wp\/v2\/comments?post=1257"}],"version-history":[{"count":0,"href":"https:\/\/blog.ls-al.com\/wp-json\/wp\/v2\/posts\/1257\/revisions"}],"wp:attachment":[{"href":"https:\/\/blog.ls-al.com\/wp-json\/wp\/v2\/media?parent=1257"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.ls-al.com\/wp-json\/wp\/v2\/categories?post=1257"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.ls-al.com\/wp-json\/wp\/v2\/tags?post=1257"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}