您的位置:首页 > 运维架构 > Linux

linux基础知识(一)

2016-06-06 10:09 363 查看

                                      


//提示关机信息

[root@hadoop1 ~]#

Broadcast message from root@hadoop1

       (/dev/pts/0) at 11:41 ...

 

The system is going down for maintenanceNOW!

this computer will reboot

//立即关机

[root@hadoop1 ~]# shutdown -h now

    

1.       目录和权限的表示

 [root@hadoop1~]# ln renfen wangyi  //连接目录,所以有2 个结点指向这个文档

[root@hadoop1 ~]# ls -l renfen

-rw-r--r--. 2(表示链接数) root root 855 Mar 25 10:33 renfen

//表示当前目录和上级目录

[root@hadoop1 ~]# ls -al xiaoyi

total 8

drwxr-xr-x. 2 root root 4096 Mar 24 22:07 .

dr-xr-x---. 30 root root 4096 Jun  4 11:57 ..



2.      改变档案的权限

   1)chgrp:改变档案所属群组

   chown:改变档案所属人

        [root@hadoop1 ~]# chown root:roottestgrp2

[root@hadoop1~]# ls -l testgrp2

-rw-r--r--. 1root root 0 Apr  6 09:51 testgrp2

   chmod:改变档案的属性

       -rw-r--r--. 1 root root 0 Apr  6 09:51 testgrp2

[root@hadoop1~]# chmod 777 testgrp2

[root@hadoop1 ~]# ls -l testgrp2

-rwxrwxrwx. 1root root 0 Apr  6 09:51 testgrp2

 

-rw-rw-r--. 1root root 0 Apr  6 09:51 testgrp2

[root@hadoop1~]# chmod a=rwx,g=rwx,o=rwx testgrp2

[root@hadoop1~]# ls -l testgrp2

-rwxrwxrwx. 1root root 0 Apr  6 09:51 testgrp2

    2)添加用户组和用户 在home下

    [root@hadoop1 ~]# groupadd testgrp1

[root@hadoop1 ~]# useradd ren1 -g testgrp1

[root@hadoop1 ~]# useradd ren2 -g testgrp1

   a.同一组下的ren2没有ren1读的权限

[root@hadoop1~]# su - ren1  //是的ren1为超级用户,(su [-] -l或--login 改变身份时,也同时变更工作目录,也会变更PATH变量。)

[ren1@hadoop1~]$ cd ..  //用来切换目录到home下

[ren1@hadoop1home]$ ls -l ren1

total 0

[ren1@hadoop1home]$ ls -l ren2

ls: cannot open directory ren2: Permission denied

   b. 将ren1改为同组可读,可用ren2  su进行读(可用exit来退出用户的登录回到root下)

    [root@hadoop1 ~]# cd /home

[root@hadoop1home]# chmod g+r ren1

[root@hadoop1home]# cd ren1

[root@hadoop1ren1]# touch 11.txt

[root@hadoop1ren1]# su - ren2

[ren2@hadoop1~]$ cd..

-bash:cd..: command not found

[ren2@hadoop1~]$ cd /home

[ren2@hadoop1home]$ ls -l

total 40

drwxr-----.  4ren1  testgrp1 4096 Jun  4 12:36 ren1

drwx------.  4 ren2 testgrp1 4096 Jun  4 12:14 ren2

 [ren2@hadoop1 home]$ ls -l ren1

ls:cannot access ren1/11.txt: Permission denied

ls:cannot access ren1/1.txt: Permission denied

total 0

-?????????? ? ? ?            ? 11.txt

-????????? ? ?? ?            ? 1.txt

改变[root@hadoop1ren1]# chmod 750 /home/ren1。Ren2可以读取ren1中文件的具体信息。

   c.Ren1中建立文件夹(test2dir),移动文件到test2dir中

[ren2@hadoop1ren1]$ mkdir test2dir

[ren2@hadoop1ren1]$ ls -l

total 4

-rw-r--r--.1 root root        0 Jun  4 12:36 11.txt

-rw-r--r--.1 ren1 testgrp1    0 Jun  4 12:25 1.txt

-rw-r--r--.1 ren2 testgrp1    0 Jun  4 12:52 2.txt

drwxr-xr-x.2 ren2 testgrp1 4096 Jun  4 12:52test2dir

[ren2@hadoop1ren1]$ mv 2.txt 33.txt

[ren2@hadoop1ren1]$ ls -l

total 4

-rw-r--r--.1 root root        0 Jun  4 12:36 11.txt

-rw-r--r--.1 ren1 testgrp1    0 Jun  4 12:25 1.txt

-rw-r--r--.1 ren2 testgrp1    0 Jun  4 12:52 33.txt

drwxr-xr-x.2 ren2 testgrp1 4096 Jun  4 12:52test2dir

[ren2@hadoop1ren1]$ ls -l test2.dir

ls:cannot access test2.dir: No such file or directory

[ren2@hadoop1ren1]$ ls -l test2dir

total 0

[ren2@hadoop1ren1]$ ls -l

total 4

-rw-r--r--.1 root root        0 Jun  4 12:36 11.txt

-rw-r--r--.1 ren1 testgrp1    0 Jun  4 12:25 1.txt

-rw-r--r--.1 ren2 testgrp1    0 Jun  4 12:52 33.txt

drwxr-xr-x.2 ren2 testgrp1 4096 Jun  4 12:52test2dir

[ren2@hadoop1ren1]$ mv 33.txt test2dir

[ren2@hadoop1ren1]$ mv 11.txt test2dir

[ren2@hadoop1ren1]$ ls -l

total 4

-rw-r--r--.1 ren1 testgrp1    0 Jun  4 12:25 1.txt

drwxr-xr-x. 2 ren2 testgrp1 4096 Jun  4 12:55 test2dir
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: