目录

相关环境

问题描述

问题原因

解决方法

解决方法一

解决方法二

附录


相关环境


Ubuntu 20.04 

问题描述


在使用 Ubuntu 系统 root 用户创建一个普通用户后,发现 Shell 命令行显示很简单,不显示用户名、hostname等信息。
root@ecszjk:~# useradd test -m
root@ecszjk:~#
root@ecszjk:~#
root@ecszjk:~# su – test
$
$ id
uid=1001(test) gid=1001(test) groups=1001(test)
$

问题原因


这个问题是由于新创建的用户默认使用的是 /bin/sh 而不是 /bin/bash,两种不同规范的 Shell 不一样。
可以从 /etc/passwd 中查看账号的 Shell 命令,从 /etc/passwd 中可以看到默认创建的用户使用的是 /bin/sh,而 root 用户使用的是 /bin/bash。
$ cat /etc/passwd
root:x:0:0:root:/root:/bin/bash
…
test:x:1001:1001::/home/test:/bin/sh

解决方法

解决方法一

使用 root 用户编辑 /etc/passwd 文件,将对应用户的 Shell 改为 /bin/bash,并保存退出
root@ecszjk:/etc# vim /etc/passwd

使用 vim 的命令模式输入 :wq 保存并退出。

解决方法二

使用 root 用户执行 usermod 命令为对应用户更新 Shell
root@ecszjk:~#
root@ecszjk:~# usermod test -s /bin/bash
root@ecszjk:~# cat /etc/passwd
root:x:0:0:root:/root:/bin/bash
…
test:x:1001:1001::/home/test:/bin/bash

附录


1、useradd 用法
root@ecszjk:/etc# useradd –help
Usage: useradd [options] LOGINuseradd -Duseradd -D [options]
Options:–badnames                do not check for bad names-b, –base-dir BASE_DIR       base directory for the home directory of thenew account–btrfs-subvolume-home    use BTRFS subvolume for home directory-c, –comment COMMENT         GECOS field of the new account-d, –home-dir HOME_DIR       home directory of the new account-D, –defaults                print or change default useradd configuration-e, –expiredate EXPIRE_DATE  expiration date of the new account-f, –inactive INACTIVE       password inactivity period of the new account-g, –gid GROUP               name or ID of the primary group of the newaccount-G, –groups GROUPS           list of supplementary groups of the newaccount-h, –help                    display this help message and exit-k, –skel SKEL_DIR           use this alternative skeleton directory-K, –key KEY=VALUE           override /etc/login.defs defaults-l, –no-log-init             do not add the user to the lastlog andfaillog databases-m, –create-home             create the user’s home directory-M, –no-create-home          do not create the user’s home directory-N, –no-user-group           do not create a group with the same name asthe user-o, –non-unique              allow to create users with duplicate(non-unique) UID-p, –password PASSWORD       encrypted password of the new account-r, –system                  create a system account-R, –root CHROOT_DIR         directory to chroot into-P, –prefix PREFIX_DIR       prefix directory where are located the /etc/* files-s, –shell SHELL             login shell of the new account-u, –uid UID                 user ID of the new account-U, –user-group              create a group with the same name as the user-Z, –selinux-user SEUSER     use a specific SEUSER for the SELinux user mapping–extrausers              Use the extra users database

2、/bin/sh 与 /bin/bash 的区别
#!/bin/sh与#!/bin/bash的区别 - myhesir - 博客园

Ubuntu 新建用户 Shell 命令行显示异常相关推荐

  1. Ubuntu系统新建用户时终端只显示$符号

    Ubuntu系统新建用户时终端只显示$符号 问题:在新建用户的时候切换到新建用户的终端,只是显示$符号. 解决方法: 1.使用命令切换到root用户: $ su root 2.然后使用命令绑定bash ...

  2. linux shell 宏定义_Linux系统和Shell命令行简介,走上数据分析之路

    122Linux系统和Shell命令行简介,走上数据分析之路 本节作者:刘永鑫 中国科学院遗传与发育生物学研究所 版本1.0.2,更新日期:2020年8月31日 本项目永久地址:https://git ...

  3. 122.Linux系统和Shell命令行简介,走上数据分析之路

    122Linux系统和Shell命令行简介,走上数据分析之路 本节作者:刘永鑫 中国科学院遗传与发育生物学研究所 版本1.0.2,更新日期:2020年8月31日 本项目永久地址:https://git ...

  4. ubuntu 新建用户到指定的目录

    一.新建用户 ubuntu新建用户有两个命令,adduser 和 useradd: 1.其中adduser比较方便,直接使用命令:sudo adduser "用户名", 然后设置密 ...

  5. 快乐的shell命令行

    快乐的shell命令行 PART1--基础 1.权限 #超级用户权限 $普通用户 2.复制粘贴 复制:鼠标左键沿着文本拖动高亮的文本被复制到X管理的缓冲区(或者双击一个单词) 粘贴:鼠标中键 3.简单 ...

  6. 2021年大数据Hadoop(八):HDFS的Shell命令行使用

    2021大数据领域优质创作博客,带你从入门到精通,该博客每天更新,逐渐完善大数据各个知识体系的文章,帮助大家更高效学习. 有对大数据感兴趣的可以关注微信公众号:三帮大数据 目录 HDFS的Shell命 ...

  7. 操作系统课设之简单 shell 命令行解释器的设计与实现

    前言 课程设计开始了,实验很有意思,写博客总结学到的知识 白嫖容易,创作不易,学到东西才是真 本文原创,创作不易,转载请注明!!! 本文链接 个人博客:https://ronglin.fun/arch ...

  8. shell 清楚空格_Cygwin系列(五):Shell命令行初体验

    ► 本文共5700余字,预计阅读时间15分钟,本文知乎链接:Cygwin系列(五):Shell命令行初体验,本文同步发布于微信公众号. 前一篇文章Cygwin系列(四):一步一步搭建Cygwin最小系 ...

  9. hbase shell 命令行从入门到放弃

    1.启动hbase 进入 hbase bin 目录 ./start-hbase.sh ./当前目录下的start-hbase.sh文件启动 退出hbase  shell 命令行 ctrl+c 补充: ...

最新文章

  1. 读小学的宝宝人缘好,收到同学赠送的小瓶茅台酒!
  2. [转载]C#中各种计时器
  3. SAP Spartacus Unit List树形数据的加载
  4. Chrome 浏览器创建网站快捷方式(加入收藏夹)代码
  5. java link 使用_Java数据结构之简单的连接点(link)实现方法示例
  6. linux定时器的实现方法
  7. 全网首发:成功在loongarch64上编译成功jogamp(提供下载库)
  8. 计算一条3d空间直线和一个3d空间平面的交点
  9. Unity3D 退出游戏应用的代码
  10. JetsonNano跑YoloV3速度评测
  11. 麦子学院深度学习视频课程(中文授课、代码讲解为主)
  12. 自动白平衡(AWB)基础
  13. git 使用过程遇到的问题
  14. mysql alter index rebuild_Oracle alter index rebuild 说明
  15. COGS 2815. 天黑请闭眼
  16. B端页面——详细表格设计流程
  17. 基于Scala设计简易的会员卡管理系统
  18. [附源码]计算机毕业设计Python校园运动会管理系统(程序+源码+LW文档)
  19. 一文看懂用word制作电子公章,2分钟就能搞定!
  20. 小程序云开发,学习总结

热门文章

  1. ROS学习笔记(一)——ROS Melodic的安装
  2. 第四讲 Django编程填空题的测评
  3. Mac苹果电脑虚拟机是什么?虚拟机有什么用
  4. ssh远程控制服务—linu
  5. 人民币有1元,5元,10元,20元,50元,100元的面值。
  6. 教你如何在虚拟机上安装Linux
  7. .kux转mp4(youku客户端视频转mp4)
  8. 【无标题】记录nginx多域名配置,浏览器访问提示:无法访问此网站 连接已重置。
  9. pve 导入 ova
  10. 组合递推公式证明(杨辉三角)