A photo of Mitesh Shah

Mitesh Shah

Linux Expert | Automation Enthusiast | Security Consultant

Email Skype Github Twitter Resume Hire Me Keybase LinkedIn Stackoverflow


  • Mostly While setting up web server, I was run multiple commands as root user.
  • After that I realize I’ve to change ownership of web root :(
  • By using following command we can directly create directory, copy files with given username instead of root user.


$ sudo -H -u <USERNAME> <COMMAND>


$ sudo -H -u mitesh mkdir ~mitesh/bin
$ sudo ls -ld ~mitesh/bin
drwxr-xr-x 2 mitesh mitesh 4096 Jul  8 20:32 /home/mitesh/bin

Post Navigation