change user id

classic Classic list List threaded Threaded
16 messages Options
Reply | Threaded
Open this post in threaded view
|

change user id

Ranjan Maitra-3
Hi,

I am on a single-account F27 system with an user id 1000. I want to change this user id. From what I understand, I should do the following:

sudo usermod -u 54321 <username>

However, when I do this, I get:

usermod: user <username> is currently used by process 866

I guess that this has to do with the fact that I am logged in (to do this). How do I get around this point? There is no root on the system but I do have sudo access.

Separately, I want all my files and directory owned by 1000 to move to this user id (so that I can have access)? Is this automatic or do I have to run chown -R <username> etc?

Many thanks and best wishes,
Ranjan

--
Important Notice: This mailbox is ignored: e-mails are set to be deleted on receipt. Please respond to the mailing list if appropriate. For those needing to send personal or professional e-mail, please use appropriate addresses.
_______________________________________________
users mailing list -- [hidden email]
To unsubscribe send an email to [hidden email]
Reply | Threaded
Open this post in threaded view
|

Re: change user id

Cameron Simpson-2
On 05Mar2018 18:38, Ranjan Maitra <[hidden email]> wrote:
>I am on a single-account F27 system with an user id 1000. I want to change
>this user id. From what I understand, I should do the following:
>
>sudo usermod -u 54321 <username>
>
>However, when I do this, I get:
>usermod: user <username> is currently used by process 866

usermod might have some kind of -f (force) option. Or maybe not, see the
manual.

>I guess that this has to do with the fact that I am logged in (to do this). How do I get around this point? There is no root on the system but I do have sudo access.

On a single user system the accounts are usually defined by the /etc/passwd
file (and /etc/shadow etc). So you could run:

  sudo vipw

and edit your user id in the passwd file directly.

>Separately, I want all my files and directory owned by 1000 to move to this user id (so that I can have access)? Is this automatic or do I have to run chown -R <username> etc?

I would run chown myself. You also need to look in the mail spool.

  chown -R 54321 ~your_username

Note the "~", you need to hand your home directory path to the chown command.  
Of course, after the "vipw" step you could just say:

  chown -R your_username ~your_username

because that should look up your new id.

There may be more files in a few places in the system (really, very few).  
/var/spool/mail might have a mail file.

Running:

  find /var -user 1000 -ls

might be illuminating.

If you have NFS mounted directories in which you have made files, you will need
to go after them also, and so forth.

Cheers,
Cameron Simpson <[hidden email]> (formerly [hidden email])
_______________________________________________
users mailing list -- [hidden email]
To unsubscribe send an email to [hidden email]
Reply | Threaded
Open this post in threaded view
|

Re: change user id

Bill Shirley
In reply to this post by Ranjan Maitra-3
I've done this many times but always from root.

With no root account, I would:
1) create a 2nd user 'test', set a password, and make 'test' a sudo user
2) logout and login as 'test'
3) let's say the user to change is 'bob' with id 1000
  grep bob /etc/passwd
  should yield:
    bob:x:1000:1000:Bob:/home/bob:/bin/bash
4) edit /etc/passwd and change the 1st number (the uid) for 'bob' from 1000 to 54321 and save
5) run:
  sudo find / -xdev -uid 1000 -exec chown bob {} \;
  -xdev says stay on this filesystem; don't descend into /proc or /sys or /cdrom and so on.
  This could take awhile.
6) logout from 'test' and login as 'bob'

HTH,
Bill

On 3/5/2018 7:38 PM, Ranjan Maitra wrote:
Hi,

I am on a single-account F27 system with an user id 1000. I want to change this user id. From what I understand, I should do the following:

sudo usermod -u 54321 <username>

However, when I do this, I get: 

usermod: user <username> is currently used by process 866

I guess that this has to do with the fact that I am logged in (to do this). How do I get around this point? There is no root on the system but I do have sudo access.

Separately, I want all my files and directory owned by 1000 to move to this user id (so that I can have access)? Is this automatic or do I have to run chown -R <username> etc?

Many thanks and best wishes,
Ranjan



_______________________________________________
users mailing list -- [hidden email]
To unsubscribe send an email to [hidden email]
Reply | Threaded
Open this post in threaded view
|

Re: change user id

Joe Zeff
In reply to this post by Ranjan Maitra-3
On 03/05/2018 04:38 PM, Ranjan Maitra wrote:
> I guess that this has to do with the fact that I am logged in (to do this). How do I get around this point? There is no root on the system but I do have sudo access.

Part of installing Fedora is setting the root password, and anaconda
won't let you install until you've done it.  How did you manage to work
around this?
_______________________________________________
users mailing list -- [hidden email]
To unsubscribe send an email to [hidden email]
Reply | Threaded
Open this post in threaded view
|

Re: change user id

Ranjan Maitra-3
On Mon, 5 Mar 2018 19:20:42 -0800 Joe Zeff <[hidden email]> wrote:

> On 03/05/2018 04:38 PM, Ranjan Maitra wrote:
> > I guess that this has to do with the fact that I am logged in (to do this). How do I get around this point? There is no root on the system but I do have sudo access.
>
> Part of installing Fedora is setting the root password, and anaconda
> won't let you install until you've done it.  How did you manage to work
> around this?

Thanks! If you don't fill in the Root section, then root is not set. I do that since the time we have had this option and set myself up as a superuser.

Best wishes,
Ranjan
_______________________________________________
users mailing list -- [hidden email]
To unsubscribe send an email to [hidden email]
Reply | Threaded
Open this post in threaded view
|

Re: change user id

Joe Zeff
On 03/05/2018 07:41 PM, Ranjan Maitra wrote:
> Thanks! If you don't fill in the Root section, then root is not set. I do that since the time we have had this option and set myself up as a superuser.


I had no idea it would let you do that, and personally, I consider it a bug.
_______________________________________________
users mailing list -- [hidden email]
To unsubscribe send an email to [hidden email]
Reply | Threaded
Open this post in threaded view
|

Re: change user id

Cameron Simpson-2
On 05Mar2018 19:45, Joe Zeff <[hidden email]> wrote:
>On 03/05/2018 07:41 PM, Ranjan Maitra wrote:
>>Thanks! If you don't fill in the Root section, then root is not set. I do that since the time we have had this option and set myself up as a superuser.
>
>I had no idea it would let you do that, and personally, I consider it a bug.

Not if it an intended supported behaviour. Plenty of systems are set up with no
explicit root password, but access for "admin" users via sudo.

You can always give root a password if this disturbs you, but it immediately
closes off the whole "I log in as root all the time" issue that plagues naive
users on home systems, and also closes off the whole "ssh in as root on a shiny
new system which accepts root-login-with-password".

If you've ever spent much time on a Mac you'll discover that they're all like
this: "admin" users who can use sudo and ordinary/guest users who can't. And
normally no direct root login. (Yes, they're proper UNIX systems and you can
boot single user etc.) It is actually a pretty good setup for consumer UNIX
systems.

Cheers,
Cameron Simpson <[hidden email]> (formerly [hidden email])
_______________________________________________
users mailing list -- [hidden email]
To unsubscribe send an email to [hidden email]
Reply | Threaded
Open this post in threaded view
|

Re: change user id

Ranjan Maitra-3
In reply to this post by Joe Zeff
On Mon, 5 Mar 2018 19:45:48 -0800 Joe Zeff <[hidden email]> wrote:

> On 03/05/2018 07:41 PM, Ranjan Maitra wrote:
> > Thanks! If you don't fill in the Root section, then root is not set. I do that since the time we have had this option and set myself up as a superuser.
>
>
> I had no idea it would let you do that, and personally, I consider it a bug.

Actually, it may well be a security feature. Note that all systems used to be expected to have a root, an account name that is easy to guess with 100% accuracy. Not having root removes the surest account on any system.



> _______________________________________________
> users mailing list -- [hidden email]
> To unsubscribe send an email to [hidden email]


--
Important Notice: This mailbox is ignored: e-mails are set to be deleted on receipt. Please respond to the mailing list if appropriate. For those needing to send personal or professional e-mail, please use appropriate addresses.
_______________________________________________
users mailing list -- [hidden email]
To unsubscribe send an email to [hidden email]
Reply | Threaded
Open this post in threaded view
|

Re: change user id

Joe Zeff
In reply to this post by Cameron Simpson-2
On 03/05/2018 08:05 PM, Cameron Simpson wrote:
> You can always give root a password if this disturbs you, but it
> immediately closes off the whole "I log in as root all the time" issue
> that plagues naive users on home systems, and also closes off the whole
> "ssh in as root on a shiny new system which accepts
> root-login-with-password".

You shouldn't ever need to log in as root under a GUI, but it does allow
you to log in at a CLI console as root if you need to.
_______________________________________________
users mailing list -- [hidden email]
To unsubscribe send an email to [hidden email]
Reply | Threaded
Open this post in threaded view
|

Re: change user id

Joe Zeff
In reply to this post by Ranjan Maitra-3
On 03/05/2018 08:07 PM, Ranjan Maitra wrote:
> Actually, it may well be a security feature. Note that all systems used to be expected to have a root, an account name that is easy to guess with 100% accuracy. Not having root removes the surest account on any system.

There's nothing stopping you from changing the superuser's name from
root to whatever you want, because it's not the name that has the
special meaning (as Administrator does under Windows) as the account
number of 0.
_______________________________________________
users mailing list -- [hidden email]
To unsubscribe send an email to [hidden email]
Reply | Threaded
Open this post in threaded view
|

Re: change user id

Juan Martinez
On Tue, Mar 06, 2018 at 12:42:33AM -0800, Joe Zeff wrote:
>On 03/05/2018 08:07 PM, Ranjan Maitra wrote:
>>Actually, it may well be a security feature. Note that all systems used to be expected to have a root, an account name that is easy to guess with 100% accuracy. Not having root removes the surest account on any system.
>
>There's nothing stopping you from changing the superuser's name from
>root to whatever you want, because it's not the name that has the
>special meaning (as Administrator does under Windows) as the account
>number of 0.
>_______________________________________________

There's nothing special about the Administrator account name under
Windows. It can be renamed because the SID is what identifies it just as
UID 0 identifies the root account in Linux.

--
Juan Martinez
[hidden email]
_______________________________________________
users mailing list -- [hidden email]
To unsubscribe send an email to [hidden email]
Reply | Threaded
Open this post in threaded view
|

Re: change user id

Rick Stevens-3
In reply to this post by Bill Shirley
On 03/05/2018 06:30 PM, Bill Shirley wrote:
> I've done this many times but always from root.

I've not tried it for this sort of thing, but "sudo bash -l" SHOULD make
a non-root user behave as root (including root's environment).

> With no root account, I would:
> 1) create a 2nd user 'test', set a password, and make 'test' a sudo user
> 2) logout and login as 'test'
> 3) let's say the user to change is 'bob' with id 1000
>   grep bob /etc/passwd
>   should yield:
>     bob:x:1000:1000:Bob:/home/bob:/bin/bash
> 4) edit /etc/passwd and change the 1st number (the uid) for 'bob' from
> 1000 to 54321 and save
> 5) run:
>   sudo find / -xdev -uid 1000 -exec chown bob {} \;
>   -xdev says stay on this filesystem; don't descend into /proc or /sys
> or /cdrom and so on.
>   This could take awhile.
> 6) logout from 'test' and login as 'bob'

Don't forget that many people have /home as a separate filesystem, so
an additional "find /home -xdev -uid 1000 -exec chown bob {} \;"
wouldn't be out of place. Perhaps superfluous, perhaps very necessary.
Couldn't hurt. Belt and suspenders, don't you know.
----------------------------------------------------------------------
- Rick Stevens, Systems Engineer, AllDigital    [hidden email] -
- AIM/Skype: therps2        ICQ: 22643734            Yahoo: origrps2 -
-                                                                    -
-   "Do you suffer from long-term memory loss?"  "I don't remember"  -
-                            -- Chumbawumba, "Amnesia" (TubThumping) -
----------------------------------------------------------------------
_______________________________________________
users mailing list -- [hidden email]
To unsubscribe send an email to [hidden email]
Reply | Threaded
Open this post in threaded view
|

Re: change user id

Tony Nelson
In reply to this post by Bill Shirley
On 18-03-05 21:30:17, Bill Shirley wrote:
  ...
> 5) run:
>   sudo find / -xdev -uid 1000 -exec chown bob {} \;
  ...

I've done (something like) as root:

     chown --recursive --no-dereference --from=1000 bob /home/bob/
     chown --recursive --no-dereference --from=:1000 :bob /home/bob/

--
____________________________________________________________________
TonyN.:'                       <mailto:[hidden email]>
       '                              <http://www.georgeanelson.com/>
_______________________________________________
users mailing list -- [hidden email]
To unsubscribe send an email to [hidden email]
Reply | Threaded
Open this post in threaded view
|

Re: change user id

George N. White III

> On Mar 6, 2018, at 2:19 PM, Tony Nelson <[hidden email]> wrote:
>
>> On 18-03-05 21:30:17, Bill Shirley wrote:
>> ...
>> 5) run:
>>   sudo find / -xdev -uid 1000 -exec chown bob {} \;
> ...
>
> I've done (something like) as root:
>
>    chown --recursive --no-dereference --from=1000 bob /home/bob/
>    chown --recursive --no-dereference --from=:1000 : ...

I’ve done this many times using Tony’s two account approach. At work we have assigned user and group IDs. Users often install Linux using defaults and wonder why NFS won’t let them see their files.


George N
_______________________________________________
users mailing list -- [hidden email]
To unsubscribe send an email to [hidden email]
Tim
Reply | Threaded
Open this post in threaded view
|

Re: change user id

Tim
On Wed, 2018-03-07 at 07:33 -0400, George White wrote:
> At work we have assigned user and group IDs. Users often install
> Linux using defaults and wonder why NFS won’t let them see their
> files.

I had another dabble with Ubuntu, the other day.  Its user add GUI
configurator didn't have any way of setting UID or GID, nor did it even
display them.  I *had* to go into the command line to get NFS to work.

--
 
[tim@localhost ~] -rsvp
Linux 4.13.16-100.fc25.x86_64 #1 SMP Mon Nov 27 19:52:46 UTC 2017 x86_64
 
Boilerplate:  All mail to my mailbox is automatically deleted, there is
no point trying to privately email me, I only get to see the messages
posted to the mailing list.
_______________________________________________
users mailing list -- [hidden email]
To unsubscribe send an email to [hidden email]
Reply | Threaded
Open this post in threaded view
|

Re: change user id

Tom H
In reply to this post by Ranjan Maitra-3
On Mon, Mar 5, 2018 at 7:38 PM, Ranjan Maitra <[hidden email]> wrote:

>
> I am on a single-account F27 system with an user id 1000. I want to
> change this user id. From what I understand, I should do the following:
>
> sudo usermod -u 54321 <username>
>
> However, when I do this, I get:
>
> usermod: user <username> is currently used by process 866
>
> I guess that this has to do with the fact that I am logged in (to do
> this). How do I get around this point? There is no root on the system
> but I do have sudo access.
>
> Separately, I want all my files and directory owned by 1000 to move to
> this user id (so that I can have access)? Is this automatic or do I
> have to run chown -R <username> etc?

Create a different sudo-able account and run "sudo usermod ..." from it.

From "man usermod":

You must make certain that the named user is not executing any processes
when this command is being executed if the user's numerical user ID, the
user's name, or the user's home directory is being changed. usermod
checks this on Linux. On other platforms it only uses utmp to check if
the user is logged in.
_______________________________________________
users mailing list -- [hidden email]
To unsubscribe send an email to [hidden email]