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

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

上一主题 下一主题
 
发帖
2155
C币
-60173
威望
418
贡献值
1
银元
0
铜钱
4869
人人网人气币
0
只看楼主 倒序阅读 使用道具 楼主  发表于: 2009-05-01
*****************************Change group .temporary*********.******.************ 教育

# Let's che.ck the descri.ption of newgrp:域名

$ newgrp -h
Usage: .newgrp [-] [group].

$ man. -f newgrp           建材
newgrp               (1)  - l.og in to a. new group.
newg.rp               (1p)  - change to a. new group虚拟主机

# From th.e man page,we kno.w this:             电子

newgrp is used to .change the curre.nt group ID during a login session.域名
If the optio.nal - flag is given,the user's environment will be reini.tialized as though the user had logged in (just. li.ke the su -),otherwise the current(        游戏          )
environment, including current working. directory,remains unchan.ged.电脑

# The /e.tc/gshadow stores the password infrom.ation of groups    健康

$ man -f gs.hadow             汽车
gshadow              (5)  - shado.wed. group file           建材

$ grep lrc /etc/gro.up学习
lrc::500:

[root]# grep l.rc /e.tc/gshadow电影
lrc:::
# grou.p name:encrypted password:.group administrators:group members           建材

$ su - oracle
[.oracle]$ newgrp lrc电脑
Sorry.
# .Because if not ro.ot,the user will be promted for a password if she does not have a password,or if the user is not. listed as a membe.r,the user will be denied.电影


# If w.e use root    健康
[root@server. ~]# id            女人
uid=0(root) gid=0(root) groups=0(root),1(bin),2(daemon),3(sys.),4(adm),6(disk),10(wheel) context=.user_u:syste.m_r:unconfined_t    美容
[.root.@server ~]# newgrp lrc.
[.root@server ~]# id[成人用品]
uid=0(root) gid=500(lrc) groups=0(root),1(bin),2(dae.mon),3(sys),4(ad.m),6(disk),10(wheel),500(lrc) cont.ext=user_u:.system_r:unconfined_t(        游戏          )

# we can find that the root user can change gid success,and the gid has bee.n. changed to .lrc教育

# If w.e want the oracle user to change gid to lrc succe.ss,we c.an use gpasswd by root privilege.    外汇
$ man -f g.passwd            杀毒
gpasswd    .          (1)  - a.dminister the /etc/group file--- 印刷
$ su -

[root@se.rver. ~]# grep lrc /etc/gshadow学习
lrc:::
[root@server ~]#. gpasswd -a oracle lrc..
Adding u.ser oracle to group .lrc          婚庆
[root@server ~]..# grep lrc /etc/gshadow<性病>
lrc:::oracle
[root@server. ~]# su - ora.cle    外汇
[o.racle@server ~]$ id             汽车
uid=501(oracle.) gid=501(oracle) groups=500(l.rc),5.01(oracle) context=user_u:system_r:unconfined_t             汽车
[oracle@serv.er ~]$ n.ewgrp lrc           建材
[oracle@server. ~]$ id             电子
uid.=501(oracle) gid=500(lrc.) groups=500(lrc),501(oracle) context=user_u:s.ystem_r:unconfined_t(        游戏          )

# Obviously,We change use gpasswd. -a to add oracl.e to. lrc group as a member.But电影
# there is another way to .grant oracle to use newg.rp    健康

$ su -
[root@server ~]# gpasswd -d ora.cl.e lrc          婚庆
Removing. u.ser oracle from group lrc.
[roo.t@server ~]# grep lrc /etc/.gshadow           女人
lrc:::
[root@server ~]#. g.passwd lrc           建材
Changin.g the password for gr.oup lrc.
New Password:
Re-ent.er new password: .
[root@server ~]# .grep lrc /etc/gsha.dow教育
lr.c:$1$Vqzun/qK$eEjNvYuP7AxNslwN.xo4if.::(        游戏          )
[root@server ~].# su .- oracle           鲜花
[orac.le@server ~]$ id              乙肝
uid=501(oracle) gid=501(oracle) groups=50.1(.oracle) context=user_u:system_r:unc.onfined_t.
[or.acle@server ~]$ newgrp lrc.            杀毒
Password:
[oracle@server ~]$. id学习
ui.d=501(oracle) gi.d=500(lrc) grou.ps=500(lrc),501(oracle) context=user_u:system_r:unconfined_t           鲜花

# We changed the password of group lrc,then input the cor.rect .passwor.d oracle.
# can change the .gid of lr.c..

# If w.e want to delete the password of group,we ca.n use gpasswd -r           女人
[root@serv.er ~]# grep lrc /etc/gsh.adow(        游戏          )
lrc:$1$Vqzun/qK$.eE.jNvYuP7AxNslwNxo4if.::.
[root@server ~]#. gpass.wd -r lrc.
[.root@.server ~]# grep lrc /etc/gshadow           女人
lrc:::
[ro.ot@server. ~]# su - oracle教育
[orac.le@server ~]$ id.
uid=501(oracle) gid=50.1(oracle) groups=501(oracle) cont.ext=user_u:system_r:unconfined._t.
[oracle@.server ~]$ .newgrp lrc.
Sorry.

# If we want to forbid other non-root user to ch.ange to the specific gi.d..
[root@server. ~]# gpasswd. -R lrc.
[root@server ~]# grep l.rc /etc./gshadow服务器
lrc:!::
[roo.t@ser.ver ~]# su - oracle    外汇
[o.racle@server ~]$. newgrp lrc<性病>
Password:
Sorry.

#. Previously,we mentioned that If the optional - flag i.s given,the user's .
# environ.ment will be reiniti.alized as though the user had logged in           女人
#  (just like the. su -)    外汇
[root@.ser.ver ~]# export T=hh    外汇
[root@server ~]# echo. $T虚拟主机
hh
[root@s.erv.er ~]# newgrp lrc           建材
[root@s.erver ~]# echo $T外贸
hh
[root@server ~]#. new.grp - lrc(        游戏          )
[root@server ~]# echo .$T              乙肝

[.root@server ~]# .

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

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

精彩

感动

搞笑

开心

愤怒

无聊

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