linux常见指令与权限管理

Linux部分环境变量的命令:

  

 1.echo 显⽰示某个环境变量值 echo $PATH

 2.export 设置⼀一个新的环境变量 export HELLO="hello" (可以⽆无引号) 

 3.env 显⽰示所有环境变量

 4.set 显⽰示本地定义的shell变量

 5.unset 清除环境变量 unset HELLO

 6.readonly 设置只读环境变量 readonly HELLO 


linux权限管理部分解释与说明;


zhucuiling@localhost ~]$ ls  //显示当前目录下所有文件

    Documents  Music     Public  Templates     xiaoliu

 Desktop  Downloads  Pictures       Videos     

[zhucuiling@localhost ~]$ su  //切换为超级用户  Ctrl+d 换回来

Password:                 //输入密码

[root@localhost zhucuiling]# exit

[zhucuiling@localhost ~]$ cd    //返回到上级目录

[zhucuiling@localhost ~]$ ls

  Documents  Music     Public  Templates    xiaoliu

 Desktop  Downloads  Pictures     Videos    

[zhucuiling@localhost ~]$ cd xiaoliu

[zhucuiling@localhost xiaoliu]$ ll   //显示文件属性

total 0

-rw-rw-r--. 1 zhucuiling zhucuiling 0 Mar 17 09:05 file

-rw-r--r--. 1 zhucuiling zhucuiling 0 Mar 17 09:02 file1

----------. 1 zhucuiling zhucuiling 0 Mar 17 08:38 test.c

[zhucuiling@localhost xiaoliu]$ shell  //shell是命令行解释器 bashshell的子进程

bash: shell: command not found

                               //bashshell的子进程

[zhucuiling@localhost xiaoliu]$ cd  //返回到上级目录

[zhucuiling@localhost ~]$ ls

  Documents  Music     Public  Templates    xiaoliu

 Desktop  Downloads  Pictures        Videos     

[zhucuiling@localhost ~]$ cd xiaoliu

[zhucuiling@localhost xiaoliu]$ touch file 

[zhucuiling@localhost xiaoliu]$ ls

file  file1  test.c

[zhucuiling@localhost xiaoliu]$ ls -l   //列出文件的详细信息

total 0

-rw-rw-r--. 1 zhucuiling zhucuiling 0 Mar 19 09:59 file

-rw-r--r--. 1 zhucuiling zhucuiling 0 Mar 17 09:02 file1

----------. 1 zhucuiling zhucuiling 0 Mar 17 08:38 test.c

[zhucuiling@localhost xiaoliu]$ u->rw- g->rw- o->r--^C  

              //uuser拥有者) g( group所属组)  o(others)

bash: u-: command not found

[zhucuiling@localhost xiaoliu]$ ll

total 0

-rw-rw-r--. 1 zhucuiling zhucuiling 0 Mar 19 09:59 file     //664

-rw-r--r--. 1 zhucuiling zhucuiling 0 Mar 17 09:02 file1      //644

----------. 1 zhucuiling zhucuiling 0 Mar 17 08:38 test.c       //000

[zhucuiling@localhost xiaoliu]$ chmod u-r,g-r,o-r file   //更改文件的权限 ()

                                               可读r   可写w   可执行x

[zhucuiling@localhost xiaoliu]$ ll

total 0

--w--w----. 1 zhucuiling zhucuiling 0 Mar 19 09:59 file     //220

-rw-r--r--. 1 zhucuiling zhucuiling 0 Mar 17 09:02 file1     //644

-----------. 1 zhucuiling zhucuiling 0 Mar 17 08:38 test.c     //000

[zhucuiling@localhost xiaoliu]$ chmod u+x,g+x,o+x file  //更改文件的权限 ()

[zhucuiling@localhost xiaoliu]$ ll

total 0

--wx-wx--x. 1 zhucuiling zhucuiling 0 Mar 19 09:59 file    //331

-rw-r--r--. 1 zhucuiling zhucuiling 0 Mar 17 09:02 file1    //644

----------. 1 zhucuiling zhucuiling 0 Mar 17 08:38 test.c    //000

[zhucuiling@localhost xiaoliu]$ chmod 7,1,2 file      // 8进制方式更改文件的权限  

chmod: invalid mode: `7,1,2'

Try `chmod --help' for more information.

[zhucuiling@localhost xiaoliu]$ chmod 000 file     //file目录的权限归0

[zhucuiling@localhost xiaoliu]$ ll

total 0

----------. 1 zhucuiling zhucuiling 0 Mar 19 09:59 file   //file目录的权限已经被改为(000

-rw-r--r--. 1 zhucuiling zhucuiling 0 Mar 17 09:02 file1

----------. 1 zhucuiling zhucuiling 0 Mar 17 08:38 test.c

[zhucuiling@localhost xiaoliu]$ chmod 110 file    //file目录的权限改为(100

[zhucuiling@localhost xiaoliu]$ ll

total 0

---x--x---. 1 zhucuiling zhucuiling 0 Mar 19 09:59 file   //file目录的权限已经被改为(100

-rw-r--r--. 1 zhucuiling zhucuiling 0 Mar 17 09:02 file1

----------. 1 zhucuiling zhucuiling 0 Mar 17 08:38 test.c

[zhucuiling@localhost xiaoliu]$ chmod 600 file     //file目录的权限改为(600

[zhucuiling@localhost xiaoliu]$ ll

total 0

-rw-------. 1 zhucuiling zhucuiling 0 Mar 19 09:59 file  //file目录的权限已经被改为(600

-rw-r--r--. 1 zhucuiling zhucuiling 0 Mar 17 09:02 file1

----------. 1 zhucuiling zhucuiling 0 Mar 17 08:38 test.c

[zhucuiling@localhost xiaoliu]$ echo "hellow bit" > file   //设定file文件内容为hellow bit

[zhucuiling@localhost xiaoliu]$ cat file      //查看file文件下内容

hellow bit

[zhucuiling@localhost xiaoliu]$ chmod u-w file

[zhucuiling@localhost xiaoliu]$ ll

total 4

-r--------. 1 zhucuiling zhucuiling 11 Mar 19 10:16 file

-rw-r--r--. 1 zhucuiling zhucuiling  0 Mar 17 09:02 file1

----------. 1 zhucuiling zhucuiling  0 Mar 17 08:38 test.c

[zhucuiling@localhost xiaoliu]$ echo "hellow bit" > file

bash: file: Permission denied

[zhucuiling@localhost xiaoliu]$ cat file

hellow bit

[zhucuiling@localhost xiaoliu]$ chmod u-r file 

[zhucuiling@localhost xiaoliu]$ cat file

cat: file: Permission denied

[zhucuiling@localhost xiaoliu]$ chown root file   //改变文件用户名为root

chown: changing ownership of `file': Operation not permitted

[zhucuiling@localhost xiaoliu]$ sudo chown root file     //sudo分配权限 ()

[sudo] password for zhucuiling: 

zhucuiling is not in the sudoers file.  This incident will be reported.

[zhucuiling@localhost xiaoliu]$ ll

total 4

----------. 1 zhucuiling zhucuiling 11 Mar 19 10:16 file

-rw-r--r--. 1 zhucuiling zhucuiling  0 Mar 17 09:02 file1

----------. 1 zhucuiling zhucuiling  0 Mar 17 08:38 test.c

[zhucuiling@localhost xiaoliu]$ sodo chgrp root file   //改变file文件用户组名称为root

bash: sodo: command not found

[root@localhost xiaoliu]# su    //消除上一条指令的错误

[root@localhost xiaoliu]# sudo chown root file   //改变file文件拥有者名称为root

[root@localhost xiaoliu]# ll

total 4

----------. 1 root      zhucuiling 11 Mar 19 10:16 file  //已经改变file文件拥有者名称为root

-rw-r--r--. 1 zhucuiling zhucuiling  0 Mar 17 09:02 file1

----------. 1 zhucuiling zhucuiling  0 Mar 17 08:38 test.c

[root@localhost xiaoliu]# sudo chgrp root file  //改变file文件用户组名称为root

[root@localhost xiaoliu]# ll

total 4

----------. 1 root       root      11 Mar 19 10:16 file  //已经改变file文件用户组名称为root

-rw-r--r--. 1 zhucuiling zhucuiling  0 Mar 17 09:02 file1

----------. 1 zhucuiling zhucuiling  0 Mar 17 08:38 test.c

[root@localhost xiaoliu]# ls -a -l  

total 16

drwxrwxr-x.  3 zhucuiling zhucuiling 4096 Mar 19 11:02 .

drwx------.  32 zhucuiling zhucuiling 4096 Mar 19 07:38 ..    

                                     // ls -a -l 与ls -l的区别在于  多出以上两行

d--x--x--x.  2 root       root       4096 Mar 19 11:02 dir

----------.  1 root       root         11 Mar 19 10:16 file

-rw-r--r--.  1 zhucuiling zhucuiling    0 Mar 17 09:02 file1

----------.  1 root       root          0 Mar 19 10:58 file2

----------.  1 root       root          0 Mar 19 11:00 file3

----------.  1 zhucuiling zhucuiling    0 Mar 17 08:38 test.c

[root@localhost xiaoliu]# ls -l

total 8

d--x--x--x. 2 root       root       4096 Mar 19 11:02 dir

----------. 1 root       root         11 Mar 19 10:16 file

-rw-r--r--. 1 zhucuiling zhucuiling    0 Mar 17 09:02 file1

----------. 1 root       root          0 Mar 19 10:58 file2

----------. 1 root       root          0 Mar 19 11:00 file3

----------. 1 zhucuiling zhucuiling    0 Mar 17 08:38 test.c

[root@localhost xiaoliu]# ls -a -l -n -i  //与上区别在于多了前面的一组inode指令数字

total 16

656487 drwxrwxr-x.  3 500 500 4096 Mar 19 11:06 .

405839 drwx------. 32 500 500 4096 Mar 19 07:38 ..

657417 d--x--x--x.  2   0   0 4096 Mar 19 11:02 dir

656495 ----------.  1   0   0   11 Mar 19 10:16 file

656460 -rw-r--r--.  1 500 500    0 Mar 17 09:02 file1

657413 ----------.  1   0   0    0 Mar 19 10:58 file2

657415 ----------.  1   0   0    0 Mar 19 11:00 file3

656489 ----------.  1 500 500    0 Mar 17 08:38 test.c

 

[root@localhost ~]# date      //显示系统日期与时间

Sun Mar 19 11:15:11 PDT 2017

[root@localhost ~]# date +%Y:%m:%d    //指定格式显示时间

2017:03:19

[root@localhost ~]# date +%Y:%m:%d:%n    //换行操作

2017:03:19:

 

[root@localhost ~]# date +%Y-%m-%d/%H:%M:%S   //指定格式显示日期与时间

2017-03-19/11:18:08

[root@localhost ~]# date +%s     //将时间变换为时间戳

1489947635

[root@localhost ~]# date +%Y:%m:%d-%H:%m:%s -d@1489947635

                            //将时间戳变换为时间

2017-03-19/11:18:08

[root@localhost ~]# cal          //显示公历日历

     March 2017     

Su Mo Tu We Th Fr Sa

          1  2  3  4

 5  6  7  8  9 10 11

12 13 14 15 16 17 18

19 20 21 22 23 24 25

26 27 28 29 30 31

 

[root@localhost ~]# cal 1999       //显示1999年的公历日历

 

                               1999                               

 

       January               February                 March       

Su Mo Tu We Th Fr Sa   Su Mo Tu We Th Fr Sa   Su Mo Tu We Th Fr Sa

                1  2       1  2  3  4  5  6       1  2  3  4  5  6

 3  4  5  6  7  8  9    7  8  9 10 11 12 13    7  8  9 10 11 12 13

10 11 12 13 14 15 16   14 15 16 17 18 19 20   14 15 16 17 18 19 20

17 18 19 20 21 22 23   21 22 23 24 25 26 27   21 22 23 24 25 26 27

24 25 26 27 28 29 30   28                     28 29 30 31

31

        April                   May                   June        

Su Mo Tu We Th Fr Sa   Su Mo Tu We Th Fr Sa   Su Mo Tu We Th Fr Sa

             1  2  3                      1          1  2  3  4  5

 4  5  6  7  8  9 10    2  3  4  5  6  7  8    6  7  8  9 10 11 12

11 12 13 14 15 16 17    9 10 11 12 13 14 15   13 14 15 16 17 18 19

18 19 20 21 22 23 24   16 17 18 19 20 21 22   20 21 22 23 24 25 26

25 26 27 28 29 30      23 24 25 26 27 28 29   27 28 29 30

                       30 31

        July                  August                September     

Su Mo Tu We Th Fr Sa   Su Mo Tu We Th Fr Sa   Su Mo Tu We Th Fr Sa

             1  2  3    1  2  3  4  5  6  7             1  2  3  4

 4  5  6  7  8  9 10    8  9 10 11 12 13 14    5  6  7  8  9 10 11

11 12 13 14 15 16 17   15 16 17 18 19 20 21   12 13 14 15 16 17 18

18 19 20 21 22 23 24   22 23 24 25 26 27 28   19 20 21 22 23 24 25

25 26 27 28 29 30 31   29 30 31               26 27 28 29 30

 

       October               November               December      

Su Mo Tu We Th Fr Sa   Su Mo Tu We Th Fr Sa   Su Mo Tu We Th Fr Sa

                1  2       1  2  3  4  5  6             1  2  3  4

 3  4  5  6  7  8  9    7  8  9 10 11 12 13    5  6  7  8  9 10 11

10 11 12 13 14 15 16   14 15 16 17 18 19 20   12 13 14 15 16 17 18

17 18 19 20 21 22 23   21 22 23 24 25 26 27   19 20 21 22 23 24 25

24 25 26 27 28 29 30   28 29 30               26 27 28 29 30 31

31

 

[root@localhost ~]# cal -m    //显示星期一为一个星期的第一天

     March 2017     

Mo Tu We Th Fr Sa Su

       1  2  3  4  5

 6  7  8  9 10 11 12

13 14 15 16 17 18 19

20 21 22 23 24 25 26

27 28 29 30 31

 

[root@localhost ~]# mkdir file      //建立一个新的file目录

[root@localhost ~]# stat file

  File: `file'

  Size: 4096       Blocks: 8          IO Block: 4096   directory

Device: 802h/2050d Inode: 131086      Links: 2

Access: (0111/d--x--x--x)  Uid: (    0/    root)   Gid: (    0/    root)

Access: 2017-03-19 11:37:04.574001700 -0700

Modify: 2017-03-19 11:37:04.574001700 -0700

Change: 2017-03-19 11:37:04.574001700 -0700

[root@localhost ~]# mkdir  -p dir1/dir2/dir3       //一次建立多个目录(递归)

[root@localhost ~]# ls

anaconda-ks.cfg  dir1  file  install.log  install.log.syslog

[root@localhost ~]# cd dir1

[root@localhost dir1]# ls

dir2

[root@localhost dir1]# cd dir2

[root@localhost dir2]# ls

dir3

[root@localhost dir2]# rm dir1

 

  • 3
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值