论坛风格切换切换到宽版
  • 1243阅读
  • 0回复

[问题求助]Linux command : newgrp [复制链接]

上一主题 下一主题
离线妖童.
 
发帖
2015
C币
-235496
威望
383
贡献值
1
银元
-2
铜钱
4444
人人网人气币
0
只看楼主 倒序阅读 使用道具 楼主  发表于: 2009-05-01
******************.********.***Change group temporary**********.***************** .

# Le.t's. check the description of newgrp:电脑

$ newgrp -h
Usage: newgrp [-] [gro.up]学习

$ m.an -f newgrp.
newgrp  .             (1)  .- log in to a new group    外汇
newgrp               (1p)  - change to .a new. group.

# From the man. page,we know .this:<性病>

newgrp is .us.ed to change the current group ID during a login session.
I.f the optional - flag is given,the user'.s environment will be reinitialized .as though the user had logged in (just like the su .-),otherwise the current--- 印刷
environment, includi.ng curren.t working directory,remains unchanged.(        游戏          )

# The /etc/gshadow s.tore.s the password infromation of groups教育

$ .man -f gshadow<性病>
gshadow              (5)  - shadowed.. group file虚拟主机

$ grep .lrc /etc/group           鲜花
lrc::500:

[root]# grep lrc /etc/.g.shadow.
lrc:::
# group name:encrypted p.a.ssword:group administrators:group members             汽车

$ su - oracle
[or.acle]$ newgrp lrc.
Sorry.
# Because if not root,the user will be promted fo.r a password if she does not have a pa.sswor.d,or if the user is not listed as a member,the .user will be denied..


# If we us.e root域名
[root@server ~].# id            女人
uid=0(root) gid=0(root) .groups=0(root),1(bi.n),2(daemon),3(sys),4(a.dm),6(disk),10(wheel) context=user_u:system_r:unconfined_t(        游戏          )
[r.o.ot@server ~]# newgrp lrc           鲜花
[root@server ~]# id.             电子
uid=0(root) gid=500(lrc.) groups=0(root),1(bin),2(daemon),3(sys),4(adm),6(disk),10(wheel),5.00(lrc). cont.ext=user_u:system_r:unconfined_t<性病>

# we can find that the .root user can change gid succes.s,and the gid. has been changed to lrc.

# If we want the oracle user to change gid to lrc succes..s,we can use gp.asswd by root privilege.健康
$ man -f .gpasswd域名
gp.asswd              (1)  - .administer the /etc/group file.
$ su -

[root@server ~].# grep l.rc /etc/gshadow教育
lrc:::
[ro.ot@serve.r ~]# gpasswd -a oracle lrc<性病>
Adding user orac.le t.o group lrc(广告)
[root@s.erver ~]# grep lrc /etc/gsh.adow域名
lrc:::oracle
[root@server ~].# s.u - oracle--------------彩票
[oracle@server ~]$ id.电影
uid=501(oracle) gid=501(or.ac.le) g.roups=500(lrc),501(oracle) context=user_u:system_r:unconfined_t<性病>
[oracle@serve..r ~]$ newgrp lrc.
[oracle@s.erver ~]$ id            杀毒
uid=501(oracle). gid=500(lrc) group.s=500(lrc),501(oracle) contex.t=user_u:system_r:unconfined_t           鲜花

# Obviously.,We change use gpasswd -a to add .oracle to lrc .group as a member.But健康
# there is another way t.o grant oracle to use n.ewgrp    外汇

$ su -
[root@server ~]# gp.asswd -d oracle .lrc--- 印刷
R.emoving user oracle from. group lrc服务器
[root@server ~]# g.rep lrc. /etc/gshadow.
lrc:::
[.roo.t@server ~]# gpasswd lrc健康
Ch.an.ging the password for group lrc.
New Password:
Re-enter new pass.word: (广告)
[.root@server ~]# grep lrc /etc/gs.hadow          婚庆
lrc:$1$Vqzun/qK$eEjNvYuP7AxNslwNxo.4.if.::             汽车
[.root@server ~]#. su - oracle             电子
[oracle@serv.er ~]$ id(广告)
uid.=501(ora.cle) gid=501(oracle) groups=501(oracle) context=user_u:system_r:unconf.ined_t             电子
[or.acle@server ~]$ newgrp lr.c.
Password:
[oracle@serv.er ~]$ id.
uid=501(o.racle) gid=500(lrc) groups=500(lrc),501(oracle) context=user_u:system_r.:unconfined_t.服务器

# We ch.anged the. password of group lrc,then input the corre.ct password oracle           女人
# can change the gi.d of lr.c.服务器

# If we want to delete the password of g.roup,we can use. gpasswd -r             电子
[.root@server ~]# grep lrc. /etc/gshadow.
lrc:$1.$Vqzun/qK$.eEjNvYuP7AxNslwNxo4if.::服务器
[root@server ~]# gpassw..d -r lrc.
[root@.server ~]# grep lrc /.etc/gshadow           鲜花
lrc:::
[root@serv.er ~]# su - or.acle电影
[o.racle@server ~]$ id教育
uid=501(oracle) gid=501(oracle) groups=501(oracle) contex.t=user_u:system_r:un.con.fined_t             电子
[oracle.@server ~]$ newgrp lr.c学习
Sorry.

# If we want to forbid other non-root. user to change to the specif.ic gid.电影
[root@ser.ver ~]#. gpasswd -R lrc外贸
[root@serv.er ~]# grep l.rc /etc/gshadow域名
lrc:!::
[root@.server ~]# su. - oracle           鲜花
[oracle.@server ~]$. newgrp lrc           鲜花
Password:
Sorry.

# Previously,we me.ntioned that If the optional - fl.ag is given,the user's (广告)
# environment will be reinitialized .as though the user .had logged in    健康
#  (just li.ke the su -)(        游戏          )
[root@server ~]#. ex.port T=hh学习
[root.@server ~]# echo $T服务器
hh
[root@server ~]# new.grp l.rc           鲜花
[root@server ~]# ech.o $T.
hh
[root@server ~]# new.grp - lrc.--------------彩票
[root@serv.er ~]# echo $T.

[root@server. ~]#            建材

因为是在text. mode下总结的.,所以使用蹩脚的英文 .
: )

[ 本帖最后由 ruc.on.se 于 2009-5-5 23:32 编辑 ]             电子
评价一下你浏览此帖子的感受

精彩

感动

搞笑

开心

愤怒

无聊

灌水
快速回复
限100 字节
批量上传需要先选择文件,再选择上传
 
上一个 下一个