【Linux】权限

sasl认证原理 SASL(Simple Authentication and Security Layer,简单验证和安全层)是一个安全框架。SASL(发音为 "sassel")为基于连接的协议提供验证服务以及完整性和保密性服务(可选)。本章包含以下主题: 简单验证安全层 (Simple Authentication Security Layer, SASL) 介绍 SASL 示例 服务... 阅读详情

Linux 权限

0. 前言

权限无处不在,本文就不废话,我们直接开始!

学习目标

  1. 了解 Linux/Unix 安全模型
  2. 会使用 Linux 权限相关命令

1. 相关概念

本小节介绍 Linux 中,用户的分类以及常见的文件权限

1.1 用户分类

Linux用户可以分为以下几种类型:

  1. Root用户:这是Linux系统中的超级用户,拥有完全的系统管理权限。
  2. 系统用户:这些用户是由系统或应用程序创建的,用于运行服务或进程。
  3. 普通用户:这些用户是由管理员或root用户创建的,拥有有限的系统权限,只能访问其拥有的文件和目录。
  4. 游客用户:这是一个特殊的用户类型,通常用于公共计算机或类似的场景,用户在使用期间可以访问系统的一些功能,但不会留下任何痕迹。

作为开发者,我们平时作为普通用户以及Root用户的场景最多,因此接下来的知识将会围绕这两个用户展开介绍。

id 查看当前用户身份标识信息

[sharry@localhost ~]$ id
uid=1000(sharry) gid=1000(sharry) groups=1000(sharry) context=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023

在Unix安全模型中,一个用户可以拥有文件和目录。当一个用户拥有一个文件或者目录时,该用户将对该文件或目录拥有控制权限。同时,一个用户又归属于一个群组,该群组由一个或多个用户组成,组中的用户对文件和目录的访问权限由其所有者授予。

从上面列举的 id命令执行例子,我们发现,标准输出中的结果有一个uid、gid以及groups,通过上面的介绍,不难理解其中的意思:在创建用户账户的时候,用户将被分配一个uid号码,同时被分配一个gid,即被分配到该组id对应的群组。

我们可以切换到Root用户也执行一下id命令:

[sharry@localhost ~]$ su root
Password:
[root@localhost sharry]# id
uid=0(root) gid=0(root) groups=0(root) context=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023

不难发现,普通用户的uid及gid是根据不同的Linux系统,从较大于0的一些编号中开始分配的;Root用户则是0号用户,属于0号群组。

详细用户信息
详细的用户信息记录在了 一些不同的文件中,以下列举一些常见的:

  • 用户账户信息:/etc/passwd
  • 用户组定义:/etc/group
  • 用户密码信息:/ect/shadow

实操一下,我们可选取passwd文件看看:


[root@localhost sharry]# echo $(less /etc/passwd)

root:x:0:0:root:/root:/bin/bash bin:x:1:1:bin:/bin:/sbin/nologin daemon:x:2:2:daemon:/sbin:/sbin/nologin adm:x:3:4:adm:/var/adm:/sbin/nologin lp:x:4:7:lp:/var/spool/lpd:/sbin/nologin sync:x:5:0:sync:/sbin:/bin/sync shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown halt:x:7:0:halt:/sbin:/sbin/halt mail:x:8:12:mail:/var/spool/mail:/sbin/nologin operator:x:11:0:operator:/root:/sbin/nologin games:x:12:100:games:/usr/games:/sbin/nologin ftp:x:14:50:FTP User:/var/ftp:/sbin/nologin nobody:x:99:99:Nobody:/:/sbin/nologin systemd-network:x:192:192:systemd Network Management:/:/sbin/nologin dbus:x:81:81:System message bus:/:/sbin/nologin polkitd:x:999:998:User for polkitd:/:/sbin/nologin libstoragemgmt:x:998:995:daemon account for libstoragemgmt:/var/run/lsm:/sbin/nologin colord:x:997:994:User for colord:/var/lib/colord:/sbin/nologin rpc:x:32:32:Rpcbind Daemon:/var/lib/rpcbind:/sbin/nologin saned:x:996:993:SANE scanner daemon user:/usr/share/sane:/sbin/nologin gluster:x:995:992:GlusterFS daemons:/run/gluster:/sbin/nologin saslauth:x:994:76:Saslauthd user:/run/saslauthd:/sbin/nologin abrt:x:173:173::/etc/abrt:/sbin/nologin setroubleshoot:x:993:990::/var/lib/setroubleshoot:/sbin/nologin rtkit:x:172:172:RealtimeKit:/proc:/sbin/nologin pulse:x:171:171:PulseAudio System Daemon:/var/run/pulse:/sbin/nologin radvd:x:75:75:radvd user:/:/sbin/nologin chrony:x:992:987::/var/lib/chrony:/sbin/nologin unbound:x:991:986:Unbound DNS resolver:/etc/unbound:/sbin/nologin qemu:x:107:107:qemu user:/:/sbin/nologin tss:x:59:59:Account used by the trousers package to sandbox the tcsd daemon:/dev/null:/sbin/nologin sssd:x:990:984:User for sssd:/:/sbin/nologin usbmuxd:x:113:113:usbmuxd user:/:/sbin/nologin geoclue:x:989:983:User for geoclue:/var/lib/geoclue:/sbin/nologin ntp:x:38:38::/etc/ntp:/sbin/nologin gdm:x:42:42::/var/lib/gdm:/sbin/nologin rpcuser:x:29:29:RPC Service User:/var/lib/nfs:/sbin/nologin nfsnobody:x:65534:65534:Anonymous NFS User:/var/lib/nfs:/sbin/nologin gnome-initial-setup:x:988:982::/run/gnome-initial-setup/:/sbin/nologin sshd:x:74:74:Privilege-separated SSH:/var/empty/sshd:/sbin/nologin avahi:x:70:70:Avahi mDNS/DNS-SD Stack:/var/run/avahi-daemon:/sbin/nologin postfix:x:89:89::/var/spool/postfix:/sbin/nologin tcpdump:x:72:72::/:/sbin/nologin sharry:x:1000:1000:CentOS7-64-SharryVM1:/home/sharry:/bin/bash

1.2 文件权限

与我们学过的操作系统理论知识一致,Linux通常提供文件的读、写以及执行权限。我们通过ls命令并使用其-l选项,就可以列举出文件的读写权限属性:

[sharry@localhost ~]$ > newFile.txt
[sharry@localhost ~]$ ls -l newFile.txt
-rw-rw-r--. 1 sharry sharry 0 Jun  1 02:04 newFile.txt

在这个例子中,最前面的-rw-rw-r--表示这个创建的新文件的文件属性,以下对这个属性进行拆分,对照解释这些属性的表格,文件的权限信息就一目了然了:

  • 拆分:-rw-rw-rw-r--拆为:-以及rw-rw-r--,拆出来的分别顺序对应下面的表格所描述的属性意义,其中rw-rw-r--每3位分别对应其所有者权限、组权限、其他用户权限
  • 表格:
    • 文件类型表
文件类型属性代表的文件类型
-普通文件
d目录
l符号链接
c字符设备文件
b块设备文件
  • 权限属性表
权限属性文件权限目录权限
r允许打开和读取文件允许列出目录下的内容
w允许写文件;当设置了执行权限时,也允许被创建、删除、重命名。
x允许当作程序一样来执行允许进入目录下

举例

  • 组合表格举例

    文件属性含义
    -rwx------普通文件,文件所有者具有读取、写入和执行权限,组成员和其他所有用户都没有访问权限
    -rw-r–r–普通文件,文件所有者有读写权限,文件所有者所在群组成员以及其他用户都可读
    lrwxrwxrwx符号链接(软链接)
    dwxrwx----目录文件,文件所有者和所有者所在群组的成员都可以进入该目录,而且可以创建、重命名和删除该目录下的文件
  • 再执行一下 ls -l

    [sharry@localhost ~]$ ln -s newFile.txt secln
    [sharry@localhost ~]$ ls -l
    total 0
    drwxr-xr-x. 2 sharry sharry  6 Apr 17 18:33 Desktop
    -rw-rw-r--. 1 sharry sharry  0 Jun  1 02:04 newFile.txt
    lrwxrwxrwx. 1 sharry sharry 11 Jun  1 02:27 secln -> newFile.txt
    

2. 权限操作

本节主要介绍常见的命令行更改文件权限、切换用户方式

2.1 更改文件权限

作为开发者,在工作中我们很少会直接用到更改文件权限的命令,但话都说到这了,我们还是了解一下:

2.1.1 chmod 更改文件模式

在学习这个命令之前,我们首先要注意只有文件所有这者和Root超级用户才可以更改文件或目录的模式。

chmod命令通常结合八进制或符号表示文件模式。我们以表格的形式举些例子,读者大佬们应该看看就很快懂了:

八进制表示法

八进制二进制文件模式
0000—
2010-w-
7111rwx

以此类推,chmod八进制表示文件模式通常为 0~7,其中常用的值为0、4、5、6、7, 如下执行示例:


[sharry@localhost ~]$ ls
Desktop  Documents  Downloads  Music  newFile.txt  Pictures  Public  secln  Templates  Videos
[sharry@localhost ~]$ ls -l newFile.txt
-rw-rw-r--. 1 sharry sharry 0 Jun  1 02:04 newFile.txt
[sharry@localhost ~]$ chmod 777 newFile.txt
[sharry@localhost ~]$ ls -l newFile.txt
-rwxrwxrwx. 1 sharry sharry 0 Jun  1 02:04 newFile.txt

符号表示法
符号表示法分为三部分:更改会影响谁、要执行哪个操作以及要设置哪种权限

符号表:

符号含义
uuser的简写,表示文件或目录的所有者
g文件所属群组
o其他用户
aall,表示上述行的权限都有

操作表:

操作含义
+添加一种权限
-删除一种权限
=只有指定权限可用

举个例子:

[sharry@localhost ~]$ chmod 600 newFile.txt
[sharry@localhost ~]$ ls -l newFile.txt
-rw-------. 1 sharry sharry 0 Jun  1 02:04 newFile.txt
[sharry@localhost ~]$ chmod u+x,g+rwx,o=r newFile.txt
[sharry@localhost ~]$ ls -l newFile.txt
-rwxrwxr--. 1 sharry sharry 0 Jun  1 02:04 newFile.txt
[sharry@localhost ~]$

2.1.2 umask 设置默认权限

umask命令控制创建文件时指定给文件的默认权限,使用八进制位掩码表示删除哪个位的权限模式。

查看默认umask位掩码

[sharry@localhost ~]$ umask
0002

根据位掩码,设置位掩码并对文件权限进行默认操作

[sharry@localhost ~]$ umask
0002
[sharry@localhost ~]$ > newTest.txt
[sharry@localhost ~]$ ls -l newTest.txt
-rw-rw-r--. 1 sharry sharry 0 Jun  1 20:42 newTest.txt
[sharry@localhost ~]$ umask 0000
[sharry@localhost ~]$ > newTest1.txt
[sharry@localhost ~]$ ls -l newTest1.txt
-rw-rw-rw-. 1 sharry sharry 0 Jun  1 20:43 newTest1.txt

2.2 切换用户

2.2.1 su 切换用户

su命令常用来以另一个用户的身份来使用shell。常用选项为-l和 -c

举例:


[sharry@localhost ~]$ su -l
Password:
Last login: Thu Jun  1 22:49:55 PDT 2023 on pts/1
[root@localhost ~]# 

# 通过 exit 命令退出到 原先用户的shell
[root@localhost ~]# exit
logout

# 其中,-l 可以省略为 -
[sharry@localhost ~]$ su -
Password:
Last login: Thu Jun  1 23:17:39 PDT 2023 on pts/1
[root@localhost ~]#

-c选项表示不切换登录,但在目标用户的shell执行单个命令:

# 当没有权限时
[sharry@localhost ~]$ ls -l /root/ *
lrwxrwxrwx. 1 sharry sharry  11 Jun  1 02:27 secln -> newFile.txt
......
ls: cannot open directory /root/: Permission denied

# 使用 su -c
[sharry@localhost ~]$ su -c 'ls -l /root/ *'
Password:
lrwxrwxrwx. 1 sharry sharry  11 Jun  1 02:27 secln -> newFile.txt

Desktop:
total 0

Documents:
total 0

Downloads:
total 0

Music:
total 0

Pictures:
total 0

Public:
total 0

/root/:
total 8
-rw-------. 1 root root 2783 Apr 17 18:26 anaconda-ks.cfg
-rw-------. 1 root root 2063 Apr 17 18:26 original-ks.cfg

......

2.2.2 sudo 使用另一个用户的权限

sudo命令在很多方面都类似于 su命令。管理员可以通过配置sudo命令,使系统以一种可控的方式,允许一个普通用户以一个不同的用户身份很执行命令。主要区别在于,通过sudo的配置,用户有些场合会被限制为只能执行特定的几条命令,同时,使用sudo命令并不需要Root用户的密码,只需要输入用户自己的密码进行认证。举个例子:

[sharry@localhost ~]$ sudo backup_script
[sudo] password for sharry:
sharry is not in the sudoers file.  This incident will be reported.

[sharry@localhost ~]$ sudo ls -l /root/*
[sudo] password for sharry:
sharry is not in the sudoers file.  This incident will be reported.

上述命令的执行说明了当前用户并没有分配到 sudoers,我们可以用我们上述提到过的知识为当前用户分配 soders :

[sharry@localhost ~]$ su -
Password:
Last login: Thu Jun  1 23:24:17 PDT 2023 on pts/1
[root@localhost ~]# cd /etc/
[root@localhost etc]# ls | grep sudoers
sudoers
sudoers.d
[root@localhost etc]# chmod u+w sudoers
[root@localhost etc]# vi sudoers

## Allow root to run any commands anywhere
root    ALL=(ALL)       ALL
sharry  ALL=(ALL)       ALL

[root@localhost etc]# chmod u-w sudoers
[root@localhost etc]# exit

按照上面的示例配置完成后,我们再执行一下sudo

[sharry@localhost ~]$ sudo ls -l /root/ *
lrwxrwxrwx. 1 sharry sharry  11 Jun  1 02:27 secln -> newFile.txt

Desktop:
total 0

Documents:
total 0

Downloads:
total 0

Music:
total 0

Pictures:
total 0

Public:
total 0

/root/:
total 8
-rw-------. 1 root root 2783 Apr 17 18:26 anaconda-ks.cfg
-rw-------. 1 root root 2063 Apr 17 18:26 original-ks.cfg

Templates:
total 0

Videos:
total 0

2.2.3 chown、chgrp更改群组

为了演示效果,我们首先要通过上面小节学习过的sudo命令创建一个新用户,并将当前用户的测试文件更改到新用户群组:

创建新用户

[sharry@localhost ~]$ sudo useradd -r -m -s /bin/bash kevin
[sudo] password for sharry:
[sharry@localhost ~]$ sudo passwd kevin
Changing password for user kevin.
New password:
BAD PASSWORD: The password is shorter than 8 characters
Retype new password:
passwd: all authentication tokens updated successfully.

更改群组

[sharry@localhost ~]$ > testFile.txt
[sharry@localhost ~]$ sudo cp testFile.txt ~kevin
[sharry@localhost ~]$ sudo ls -l ~kevin/testFile.txt
-rw-r--r--. 1 root root 0 Jun  2 00:10 /home/kevin/testFile.txt
[sharry@localhost ~]$ sudo chown kevin: ~kevin/testFile.txt
[sharry@localhost ~]$ sudo ls -l ~kevin/testFile.txt
-rw-r--r--. 1 kevin kevin 0 Jun  2 00:10 /home/kevin/testFile.txt

以上例子仅举例了chown命令的使用,chgrp命令的使用与chown基本一致,读者可自行尝试。

2.2.4 passwd 更改密码

这个命令在上面小节创建新用户的例子中已经用过了,这个命令非常简单粗暴,选择合适的权限后,执行

passwd [username]

然后按照提示,输入校验密码即可。

3. 总结与补充

通过本文,读者应该对 Linux 中的一些权限相关的知识有一些了解了:
我们首先了解了文件模式的表示对应的权限,然后了解了一些不常用的修改文件权限的方式,最后我们学习了用户身份相关的知识,这方面的知识虽然在文中记录的不多,但实际上可能用得多。

【Linux】linux权限设置 文章目录一、shell1. shell概念2. 进程二、用户1. 用户分类2. 用户切换三、权限1. 临时权限提升2. 权限的属性3. linux中角色类别4. 第一列文件属性四、修改权限1. 修改文件权限2. 修改文件所属3. 修改文件权限八进制4. 粘滞位五、linux默认权限设置1. 默认权限2. 权限掩码 linux/sentos 是一个操作系统 广义上,linux发行版 = linux内核版本 + 外壳程序(狭义上不包括) 外壳程序:shell、bash 对应windows系统下的gui, 阅读详情

相关推荐

linux权限

目录的可执行权限是表示你可否在目录下执行命令。如果目录没有-x权限,则无法对目录执行任何命令,甚至无法cd进入目,即使目录仍然有-r读权限(这个地方很容易犯错,认为有读权限就可以进入目录读取目录下的文件)而如果目录具有-x权限,但没有-r权限,则用户可以执行命令,可以cd进入目录。但由于没有目录的读权限所以在目录下,即使可以执行ls命令,但仍然没有权限读出目录下的文档httpshttpshttps。...

Ll_R_lL的博客 718

linux saslauth用户,postfix配置之postfix结合SASl实现用户认证

1.启动SASL服务1.1 SASL服务的启动脚本为/etc/init.d/saslauthd但是服务默认没有启动;1.2 显示当前的saslauthd服务支持的认证方式,默认为pam,但是默认并没有配置pam:[root@www ~]# saslauthd -vsaslauthd 2.1.23authentication mechanisms: getpwent kerberos5 pam ...

weixin_28788561的博客 917

永磁同步电机控制笔记:foc控制原理通俗讲义

引言 到此为止,永磁同步电机控制相关文章已经写了7篇,其中simulink仿真系列文章5篇,控制笔记系列文章2篇,恍惚间感觉少了一篇概论,在此插入一篇,也算是对入坑电机控制一年半来的知识梳理。 文章目录引言一、同步电机是怎么转起来的二、什么样的旋转磁场效率最高三、怎么精准控制旋转磁场的方向四、怎样调节dq轴电流 一、同步电机是怎么转起来的 永磁同步电机结构如下: 外围是定子绕组,中间为永磁体,设...

搞电机的博客 2万+

linux saslauth用户,Linux中的用户和组

用户和组的基本概念Linux操作系统是一个多用户操作系统,用户在使用的时候必须向系统申请一个帐号,以这个帐号的身份进入系统使用操作系统分配的资源。每个用户都有一个用户名、UID、所属组、密码(非必须)、登录终端等。每个用户都有一个用户组,系统可以对一个用户组中的所有用户进行集中管理。每个组也有自己的名称、组唯一编号GID 。系统通过UID和GID来区分不同的用户和组,相同的UID和 GID会被系统...

weixin_35775807的博客 1266

手把手教你理解特斯拉Model 3的域控制器架构:RBCM如何成为“多面手”?

本文深入解析特斯拉Model 3的域控制器架构,重点介绍右车身域控制器(RBCM)如何整合车身电子系统功能。RBCM作为多任务处理中枢,管理空调系统、尾部电气设备和超声波雷达等关键功能,展现了特斯拉在汽车电子架构上的创新设计。文章详细探讨了RBCM的硬件架构、功能版图及信号网络,揭示其如何通过高性能MCU和智能开关技术实现功能集中与效率提升。

weixin_30919429的博客 384

告别全局搜索!7种SRP-PHAT快速算法实战对比:哪个更适合你的麦克风阵列?

本文深入探讨了7种SRP-PHAT改进算法在声源定位领域的实战表现,包括SRC、CFRC、SPF等方案。通过对比计算效率、定位精度和环境鲁棒性等核心指标,为不同场景(如会议室、智能家居、工业机器人)提供算法选型建议,帮助工程师优化麦克风阵列性能。

weixin_42546392的博客 398

linux saslauth用户,Linux中Postfix邮件认证配置(五)

原标题:Linux中Postfix邮件认证配置(五) Postfix+Dovecot+Sasl工作原理1.A用户使用MUA客户端借助smtp协议登陆smtpd服务器,需要先进行用户和密码认证,而SMTPD服务器端支持sasl认证,例如有一个sasl客户端,就会去连接SASL。当SASL接受到验证请求时就会根据验证方式去进行验证,常用的有PAM,passwd等。验证成功后就会返回给Smtpd服务器。...

weixin_30670745的博客 999

【DAB收音机】DAB 认证介绍

DAB 认证ESTI 标准文档: ETSI 103461实际过认证时,需要根据产品的受众国家及区域,参考当地官方是否有国内认证协议。需要参考当地文档进行功能开发。例如:阿联酋地区用《UAE.S 5021 _ 2018.pdf》标准进行认证。ESTI 的DAB认证协议规定了家用和车载数字无线电的最低要求,及其对应的测试方法,是数字无线电认证标志规定的技术基础。本文以车载数字无线电接收器为例,进行部分DAB认证的介绍,详情请见官方文档。或联系博主获取DAB ESTI 103461的中文翻译资料。

qq_15271231的博客 1219

Apache zookeeper kafka 开启SASL安全认证 —— 筑梦之路

Kafka是一个高吞吐量、分布式的发布-订阅消息系统。Kafka核心模块使用Scala语言开发,支持多语言(如Java、Python、Go等)客户端,它可以水平扩展和具有高吞吐量特性而被广泛使用,并与多类开源分布式处理系统进行集成使用。Kafka作为一款开源的、轻量级的、分布式、可分区和具备复制备份的、基于ZooKeeper协调管理的分布式流平台的功能强大的消息系统。与传统消息系统相比,Kafka能够更好的处理活跃的流数据,让数据在各个子系统中高性能、低延迟地不停流转。

筑梦之路 5726

版电力系统故障录波_故障录波识图与典型故障波形分析

1、设置故障录波的目的故障录波装置是对电力系统运行状况进行监控的一种自动化设备。系统正常运行时,录波装置不启动录波,当系统发生故障时,通过启动录波装置迅速启动录波器录波,直接记录反应故障装置安装处系统故障的电气量。2、故障录波的作用(1)正确评价继电保护和自动装置的工作。(2)正确分析事故的原因并研究防止对侧。(3)发现继电保护和自动装置缺陷。(4)发现一次设备缺陷,及时消除隐患。(5)帮助寻找故...

weixin_42495661的博客 1万+

高德地图JS API私有化部署实战:从数据爬取到内网集成

本文详细介绍了高德地图JS API私有化部署的完整流程,涵盖从地图瓦片数据爬取、JS API离线化改造到内网项目集成的实战步骤。重点解决了在封闭内网环境中实现地图功能的核心难题,并提供了Vue.js项目中的具体集成代码与调试技巧,帮助开发者在离线环境下构建稳定可靠的地图应用。

weixin_29062255的博客 319

【Linux】Linux权限

Linux权限,详细讲解:一,shell命令介绍 二,Linux权限 1. Linux下的用户 2. 命令su 3. Linux权限管理 3.1. 文件访问者 4. 修改权限 1. 修改目标属性 2. 修改拥有者 chown chgrp 5. 缺省权限 umask t 粘滞位

tan_run的博客 2640

SAP-ABAP:SAP库存管理核心增强:IF_EX_MB_DOCUMENT_BADI 深度解析

SAP库存管理核心增强:IF_EX_MB_DOCUMENT_BADI 深度解析

baidu_35680696的博客 1447

Linux权限

目录的可执行权限是表示你可否在目录下执行命令如果目录没有-x权限,则无法对目录执行任何命令,甚至无法cd 进入目, 即使目录仍然有-r 读权限(这 个地方很容易犯错,认为有读权限就可以进入目录读取目录下的文件)而如果目录具有-x权限,但没有-r权限,则用户可以执行命令,可以cd进入目录。但由于没有目录的读 权限所以在目录下,即使可以执行ls命令,但仍然没有权限读出目录下的文档。

未知陨落的博客 2337

团体程序设计天梯赛竞赛题--登顶题【L3-039 攀岩】

登顶级 3 道题,每道题 30 分,满分为 90 分。

Pretty Boy Fox的博客 654

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

【Linux】Linux权限管理

Linux用户权限包括权限的概念、用户分类、切换用户、sudo提权。Linux文件权限包括文件属性、文件类型、文件角色划分、基本权限。还要文件访问权限相关设置的四个指令:chomd、chown、charp、file和权限拒绝的情况。接着又讲了默认权限的概念为什么每次新建文件或目录权限都是固定的,文件掩码和umask指令修改文件掩码。最后讲了目录的权限和粘滞位存在的背景和使用情况。

m0_52094687的博客 9915

ET2012新版免狗免安装绿色软件

ET2012新版免狗免安祖昂绿色软件。,新界面,新视觉,

Linux的权限

在Linux下有两种用户,超级用户(root)以及普通用户。超级用户拥有整个系统中的最高权利,可以对目录,文件等随意进行操作。而普通用户只能在自己的家目录下进行相关操作。超级用户的命令提示符是“#”,普通用户命令提示符是“若普通用户想要进行管理员权限的操作,可以使用 su root 的命令,然后输入超级用户口令就可以登陆到root用户。同理,若想切换到其他普通用户也可以 su 【用户名】。

2401_86449430的博客 1万+

数学建模模型总结

这是本人在两年内准备参加数学建模竞赛搜集到的模型资料,已经经过了本人的筛选和整理,希望能够对准备参加数学建模竞赛的学弟学妹们提供一些帮助!

廖雪峰Python教程[完整版]

廖雪峰的python教程整理的,已经排好版了,而且还是完整的,适合小白

【Linux】Linux 权限

本篇文章主要简要讲解 Linux 权限

L_0907的博客 1384

Linux权限的理解

本章主要讲解了Linux权限管理 包括文件类型和访问权限(事物属性)、基本权限、文件访问者的分类、文件权限值的表示方法、文件访问权限的设置方法、目录权限、umask、粘滞位等等

weixin_47257473的博客 2066

Linux权限详解

目录前言一、shell命令以及运行原理三、Linux权限管理1.文件访问者的分类2.文件类型和访问权限2.1文件类型2.2权限访问属性3.文件访问权限的修改3.1权限的增加与减少3.2 八进制数设置权限3.3 目录权限含义4.用户身份的修改 4.1修改文件拥有者:4.2 修改文件所属组: 5.默认权限解析 四、粘滞位总结在社会中我们每个人都有各自的身份,而相应的身份又决定着是否具有对应的权限。比如我们想要管理一个仓库,那必须要具有仓库管理员的身份。Linux系统中同样具有权限的概念,那接下来我们就来一起看

weixin_59371851的博客 7656

【Linux】目录权限和默认权限

上期介绍了Linux的文件权限,这期我们仔细来说说Linux环境下目录权限(粘值位)和默认权限。

m0_70811813的博客 3777
上一篇: 【Linux】重定向与管道
下一篇: 【Linux】进程管理
CoderSharry
博客等级 码龄4年 515粉丝 69原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值