使用网上的方法
dba@mklmi:~$ sudo su - postgres
[sudo] password for dba:
su: warning: cannot change directory to /home/postgres: No such file or directory
$ ls -la
total 40
drwxr-xr-x 4 dba dba 4096 Jul 23 03:10 .
drwxr-xr-x 3 root root 4096 Jul 21 09:49 ..
-rw------- 1 dba dba 385 Jul 23 01:54 .bash_history
-rw-r--r-- 1 dba dba 220 Feb 25 2020 .bash_logout
-rw-r--r-- 1 dba dba 3771 Feb 25 2020 .bashrc
drwx------ 2 dba dba 4096 Jul 21 09:49 .cache
-rw-r--r-- 1 dba dba 807 Feb 25 2020 .profile
drwx------ 2 dba dba 4096 Jul 21 09:49 .ssh
-rw-r--r-- 1 dba dba 0 Jul 21 09:52 .sudo_as_admin_successful
-rw------- 1 dba dba 1064 Jul 21 09:52 .viminfo
-rw------- 1 dba dba 102 Jul 23 03:10 .Xauthority
$ exit
dba@mklmi:~$ cd /home
dba@mklmi:/home$ sudo su - root
root@mklmi:~# cd /home
root@mklmi:/home# ls -la
total 12
drwxr-xr-x 3 root root 4096 Jul 21 09:49 .
drwxr-xr-x 21 root root 4096 Jul 21 10:40 ..
drwxr-xr-x 4 dba dba 4096 Jul 23 03:10 dba
root@mklmi:/home# exit
logout
dba@mklmi:/home$ sudo mkdir /home/postgres
dba@mklmi:/home$ sudo cp -a /etc/skel/. /home/postgres
dba@mklmi:/home$ sudo chmod 755 /home/postgres
以上操作还不行
发想起默认ubuntu创建的普通帐号,默认shell为/bin/sh,同时也不支持tab等键
用root修改/etc/passwd 调用/bin/sh为/bin/bash
root@mklmi:/home/postgres# su - postgres
postgres@mklmi:~$