LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 06-06-2019, 01:34 PM   #1
gjoshi
LQ Newbie
 
Registered: Mar 2019
Posts: 15

Rep: Reputation: Disabled
How to change home of root directory


Actually I have to install vsftp and FTP user will be root and the home directory of root should be #/var/www/
And I want that when ever I will login as a root I should go directly on the /var/log not on the /root.

I used below command to change root home directory but error came that /root is busy.
#usermod -d /var/www root

Please support. Thanks
 
Old 06-06-2019, 01:41 PM   #2
scasey
LQ Veteran
 
Registered: Feb 2013
Location: Tucson, AZ, USA
Distribution: CentOS 7.9.2009
Posts: 5,727

Rep: Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211
To have root's home directory in the web space is a really, really bad idea.

(Using ftp instead of sftp is also a really bad idea, but...)

ftp as root, if you wish (another bad idea)

Then just
Code:
cd /var/www
from the ftp> prompt
-- there's no need to change root's home directory.
 
1 members found this post helpful.
Old 06-06-2019, 01:46 PM   #3
sevendogsbsd
Senior Member
 
Registered: Sep 2017
Distribution: FreeBSD
Posts: 2,252

Rep: Reputation: 1011Reputation: 1011Reputation: 1011Reputation: 1011Reputation: 1011Reputation: 1011Reputation: 1011Reputation: 1011
Concur with scasey - running this as root is a bad idea. Your server though so up to you.
 
1 members found this post helpful.
Old 06-06-2019, 01:49 PM   #4
scasey
LQ Veteran
 
Registered: Feb 2013
Location: Tucson, AZ, USA
Distribution: CentOS 7.9.2009
Posts: 5,727

Rep: Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211
Quote:
Originally Posted by gjoshi View Post

I used below command to change root home directory but error came that /root is busy.
#usermod -d /var/www root
I'm thinking "/root is busy" because you're logged in as root; and you have to be root to change root's home dir, so, I'm guessing, it's not possible to do what you want, anyway.
 
Old 06-06-2019, 02:05 PM   #5
crts
Senior Member
 
Registered: Jan 2010
Posts: 2,020

Rep: Reputation: 757Reputation: 757Reputation: 757Reputation: 757Reputation: 757Reputation: 757Reputation: 757
As others have already pointed out, probably not a good idea. If you still insist then
you could try to edit /etc/passwd manually and change root's entry from:

Code:
root:x:0:0::/root:/bin/bash
to

Code:
root:x:0:0::/var/www:/bin/bash
Afterwards logout and log back in again. I have not tried it myself so I do not know if it will work. Let us know how it goes.

Update

I just tried in inside a container and it worked! I manually changed root's home directory to /var and after I logged out and back in I was in /var.
Code:
# echo $HOME
/var
When I first read the thread my initial thought was that root's home might be hard coded. As it seems you can choose it to be something else. Still not sure why anyone would want to do that.

Last edited by crts; 06-06-2019 at 02:15 PM. Reason: Update
 
Old 06-06-2019, 04:31 PM   #6
Shadow_7
Senior Member
 
Registered: Feb 2003
Distribution: debian
Posts: 4,137
Blog Entries: 1

Rep: Reputation: 874Reputation: 874Reputation: 874Reputation: 874Reputation: 874Reputation: 874Reputation: 874
When you add a user you can specify /home/... --home=... on adduser. Not so sure about root. It might be easier to have /root ALSO be the other place with mount. Which you could add to /etc/fstab while NOT running the install.

# mount --rbind /var/www /root

Assuming root contents are moved to the other place so it doesn't exist in both locations (or tries to). Doing that to root and while running the distro, a very bad idea as basically everything before userspace is run as root, implicating that root is ALWAYS logged in. So changing root would not be easy on a "live" system (or advised). So have that mount equivalent in /etc/fstab before booting, and the files moved, and things should be "okay" before root "officially" logs in. And /root/ would basically be another mount point, mounted at boot. Still a very bad idea though.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Login Error- Could not chdir to home directory /home/UserID: No such file or directory abhi_jais Linux - Newbie 1 03-24-2018 12:01 PM
[SOLVED] How do I change change the home directory to be owned by me and not root? Slackware theif519 Linux - Newbie 4 06-24-2011 12:21 PM
"Home directory already exists. Please enter another home directory path." Daravon Ubuntu 2 02-15-2009 10:26 PM
contents of 'home' directory found at sda5: mounted as /home, and also on sda6:/home leswatson Linux - Newbie 4 04-18-2008 04:02 PM
home directory under a home directory GEEXTER Linux - General 4 04-03-2003 09:17 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 01:57 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration