1

i need to map some path like /data/test 123 as home directory for user testuser, but it is not accepting space in home directory path ?

it is not allowing me to change path using usermod -m -d /new path username.

1
  • why is a space a requirement? Can't you use underscore or something like that?
    – thanasisk
    Feb 4, 2015 at 10:23

2 Answers 2

5

You can do it using the -d switch to useradd

useradd -d '/home/test 123' test123

Adding the single quotes ' also works for usermod but note that this will break all sorts of stuff that isn't expecting a space e.g.

su - test123
-bash: [: /home/test: binary operator expected

Similarly if you use something that isn't test e.g. tst 123

su - test123
-bash: [: /home/tst: binary operator expected

Save yourself a lot of pain and don't do that.

0

Or if you really need a home path with a space, create it as a link, i.e.

/data/test 123 > /data/test_123

That way, real work can be done with 'test_123', but you can make it look as 'test 123' when required?

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .