常见命令

来源:互联网 发布:如何修改淘宝首页图片 编辑:程序博客网 时间:2024/05/02 20:32

1.deluser:

#userdel -r testuser

 

2.add user:

useradd tang

3.change passwd

passwd tang

 

3.add a user to a new group

   usermod -g ops tang

 

4.add a user to sudoer, get sudo user group, then add user to sudo group

    cat   -etc-sudoers

   usermod -g ops tang

 

 

 

5.change attibute of file

When you create a User, if you get the error:

Error creating user: useradd: unable to open password file

that may mean that your /etc/passwd file is not set properly for access. You can try the command:

chattr -ai /etc/passwd

http://linux.chinaitlab.com/command/38018.html

 

不允许文件修改

chattr +i -etc-passwd

 

6.getent

getent - get entries from administrative database

getent database [key ...] The getent program gathers entries from the specified administrative database using the specified search keys. Where database is one of aliases, ethers, group, hosts, netgroup, networks, passwd, protocols, rpc, services or shadow.

 

7.extract .tar.gz file

   tar +zxvf .tar.gz

 

8.rename file name

   mv source target  

 

9.cut file which is delimit by space, use awk

   ls -la |awk '{ print $9 }'

 

10. return to a login shell

  su - l

 

11.su and sudo

    su作用是变更为其它使用者的身份,超级用户除外,需要键入该使用者的密码

    sudo 以其他身份来执行指令。

     补充说明:sudo可让用户以其他的身份来执行指定的指令,预设的身份为root。在/etc/sudoers中设置了可执行sudo指     令的用户。若其未经授权的用户企图使用sudo,则会发出警告的邮件给管理员。用户使用sudo时,必须先输入密码,之后有      5分钟的有效期限,超过期限则必须重新输入密码。
      参  数:
      -b  在后台执行指令。
      -    h  显示帮助。
     - H  将HOME环境变量设为新身份的HOME环境变量。
      -k  结束密码的有效期限,也就是下次再执行sudo时便需要输入密码。
       -l  列出目前用户可执行与无法执行的指令。
      -p  改变询问密码的提示符号。
      -s  执行指定的shell。
     -u<用户>  以指定的用户作为新的身份。若不加上此参数,则预设以root作为新的身份。
     -v  延长密码有效期限5分钟。
     -V  显示版本信息。

    http://wiki.ubuntu.org.cn/Quick_HOWTO_:_Ch09_:_Linux_Users_and_Sudo

 

12. view the location the rpm packege setup

  rpm +ql pkgname