Is there a shorter way to change username, home directory and move files at the same time

I intended to make use of and also have attempted

sudo usermod durrantm_test -mdl durrantm_test2

yet I get

Usage: usermod [options] LOGIN
...

However

sudo usermod durrantm_test -l durrantm_test2 -md durrantm_test2

does not offer a mistake yet appears recurring, can I reduce it?

1
2022-06-07 14:40:57
Source Share
Answers: 1
usrmodx() { sudo usermod "$1" -l "$2" -md "$2"; }
usrmodx durrantm_test durrantm_test2

But should not it be,

sudo usermod -l new_name -md new_dir old_name

so

sudo usermod -l durrantm_test2 -md durrantm_test2 durrantm_test

and also as a function,

moveuser() { sudo usermod -l "$2" -md "$2" "$1"; }
moveuser durrantm_test durrantm_test2

or am I missing out on something?

This thinks you are making use of a shell which sustains features (as an example bash), and also stays clear of pen names due to the fact that you can not make use of positional variables.

3
2022-06-07 15:09:11
Source