[问题]如何更改默认shell

sh/bash/dash/ksh/zsh等Shell脚本
头像
xucm
帖子: 48
注册时间: 2005-12-23 13:48

[问题]如何更改默认shell

#1

帖子 xucm » 2006-03-16 16:55

我目前想出来两种方法
第一种是修改/etc/passwd文件相应帐户下的设置
第二种是useradd...
我觉得都不好 ..能否给我一个方法,可以更改当前用户下的 shell解释器的方法呢?
很菜的问题...呵呵
头像
eexpress
帖子: 58428
注册时间: 2005-08-14 21:55
来自: 长沙

#2

帖子 eexpress » 2006-03-16 23:38

个人帐号属性就有。菜单里面的用户组。
● 鸣学
头像
xucm
帖子: 48
注册时间: 2005-12-23 13:48

#3

帖子 xucm » 2006-03-20 14:40

对阿!呵呵 ...我怎么就没有想到这个功能呢!
用命令行用惯了..
头像
xucm
帖子: 48
注册时间: 2005-12-23 13:48

#4

帖子 xucm » 2006-03-20 14:43

不过..这个功能究竟是改了什么呢?是不是就单单改了/etc/passwd下的那行呢?
能否解释下实现的原理..让我心中有点数..呵呵
头像
eexpress
帖子: 58428
注册时间: 2005-08-14 21:55
来自: 长沙

#5

帖子 eexpress » 2006-03-20 15:07

应该是吧。你自己看看哦。
● 鸣学
头像
yang119345
帖子: 570
注册时间: 2005-06-19 14:22
来自: 上海
联系:

#6

帖子 yang119345 » 2006-03-20 15:31

/user/sbin/usermod -s shell路径 用户名


例如把oneleaf的默认shell换成csh

/user/sbin/usermod -s /bin/csh oneleaf

当然前提是要csh装好着的哦。嘿嘿
头像
xucm
帖子: 48
注册时间: 2005-12-23 13:48

#7

帖子 xucm » 2006-03-21 15:53

..谢谢六楼咯..上课时老师肯定讲过命令的...怪我当时没有认真听哦..呵呵
也很感谢eexpress..
LinuxPing
帖子: 47
注册时间: 2006-03-21 16:21

#8

帖子 LinuxPing » 2006-03-25 1:19

  Linux 上的命令解释程序(Shell)有很多种,默认的是 bash 。如果有人不喜欢用这种命令解释程序,他可以自己更换,不必经过超级用户的同意。
LinuxPing
帖子: 47
注册时间: 2006-03-21 16:21

#9

帖子 LinuxPing » 2006-03-25 1:20

chsh 就是要达成这个任务的
LinuxPing
帖子: 47
注册时间: 2006-03-21 16:21

#10

帖子 LinuxPing » 2006-03-25 1:20

问题是,如果我根本不知道系统现在有哪些 Shell 可以供选择,那怎么办?

  下面这个选项可以解决您的问题:

  l -l 列出现在系统现有的 Shell
LinuxPing
帖子: 47
注册时间: 2006-03-21 16:21

#11

帖子 LinuxPing » 2006-03-25 1:22

这是Linux教程上的 ~~~但我用-l选项时却出错~`是不是Ubuntu的问题~~版本问题~
头像
xucm
帖子: 48
注册时间: 2005-12-23 13:48

#12

帖子 xucm » 2006-04-03 11:01

/etc/shells 里有所有的shell
头像
feeling
帖子: 175
注册时间: 2006-04-29 20:10
来自: 北京·昌平
联系:

#13

帖子 feeling » 2006-05-09 17:33

xucm 写了:/etc/shells 里有所有的shell

代码: 全选

NAME
       shells - pathnames of valid login shells

DESCRIPTION
       /etc/shells  is  a  text  file  which  contains the full pathnames of valid login
       shells.  This file is consulted by chsh(1) and available to be queried  by  other
       programs.

       Be aware that there are programs which consult this file to find out if a user is
       a normal user. E.g.: ftp daemons traditionally  disallow  access  to  users  with
       shells not included in this file.

EXAMPLES
       /etc/shells may contain the following paths:

              /bin/sh
              /bin/csh

FILES
       /etc/shells

不过很遗憾,文件shells列出的未必是当前系统可用的,因为很多都没有安装。
头像
feeling
帖子: 175
注册时间: 2006-04-29 20:10
来自: 北京·昌平
联系:

#14

帖子 feeling » 2006-05-09 17:36

也许执行下面的命令可以成功,但是未必是正确的:

代码: 全选

 
chsh -s /bin/ksh feeling
chsh更改的就是文件/etc/passwd,用户feeling对于的SHELL会被更改为/bin/ksh,尽管/bin/ksh可能并不存在。
这样,在用户feeling登录系统时会收到没有对应SHELL的提示,然后退出,也就是说帐号feeling被禁用了。

于是,我们得到了一个禁用帐号的办法,就是修改他的SHELL ^_^
更多的办法是这样的:

代码: 全选

chsh -s /usr/bin/test feeling
RainyMao
帖子: 4
注册时间: 2010-06-03 21:20

Re:

#15

帖子 RainyMao » 2010-06-05 13:44

feeling 写了:
xucm 写了:/etc/shells 里有所有的shell
我输入了这个/etc/shells 但是提示我没有权限。我什么都看不到。而且我好像装的没有csh这个包。我下了csh.orig.tar.gz csh.diff.gz csh.dsc这三个。我不知道怎么装。麻烦大侠指导下。。。。 :em20
回复