分步完成:useradd tom
usermod -g users tom
usermod -c "hr tom" tom
一步完成:useradd -g users -c "hr tom" tom
设置tom用户的密码
passwd tom
修改tom用户的登陆名为tomcat
usermod -l tomcat tom
将tomcat添加到sys和root组中
usermod -G sys,root tomcat
查看tomcat的组信息
groups tomcat
添加一个jerry用户并设置密码
useradd jerry
passwd jerry
添加一个交america的组
groupadd america
将jerry添加到america组中
usermod -g america jerry
将tomcat用户从root组和sys组删除
gpasswd -d tomcat root
gpasswd -d tomcat sys
将america组名修改为am
groupmod -n am america
==============================================================
创建a.txt和b.txt文件,将他们设为其拥有者和所在组可写入,但其他以外的人则不可写入:
chmod ug+w,o-w a.txt b.txt
创建c.txt文件所有人都可以写和执行
chmod a=wx c.txt 或chmod 666 c.txt
将/itcast目录下的所有文件与子目录皆设为任何人可读取
chmod -R a+r /itcast
将/itcast目录下的所有文件与子目录的拥有者设为root,用户拥有组为users
chown -R root:users /itcast
将当前目录下的所有文件与子目录的用户皆设为itcast,组设为users
chown -R itcast:users *
=================================================================
1.查看文件夹属性
ls -ld test
2.文件夹的rwx
--x:可以cd进去
r-x:可以cd进去并ls
-wx:可以cd进去并touch,rm自己的文件,并且可以vi其他用户的文件
-wt:可以cd进去并touch,rm自己的文件
ls -ld /tmp
drwxrwxrwt的权限值是1777(sticky)
=============================================================
1.gzip压缩
gzip a.txt
2.解压
gunzip a.txt.gz
gzip -d a.txt.gz
3.bzip2压缩
bzip2 a
4.解压
bunzip2 a.bz2
bzip2 -d a.bz2
5.将当前目录的文件打包
tar -cvf bak.tar .
将/etc/password追加文件到bak.tar中(r)
tar -rvf bak.tar /etc/password
6.解压
tar -xvf bak.tar
7.打包并压缩gzip
tar -zcvf a.tar.gz
8.解压缩
tar -zxvf a.tar.gz
解压到/usr/下
tar -zxvf a.tar.gz -C /usr
9.查看压缩包内容
tar -ztvf a.tar.gz
zip/unzip
10.打包并压缩成bz2
tar -jcvf a.tar.bz2
11.解压bz2
tar -jxvf a.tar.bz2