2018-05-18课堂笔记

2018-05-18课堂笔记

目录

一、用户配置文件和密码配置文件

二、用户组管理

三、用户管理

四、usermod命令

五、用户密码管理

六、mkpasswd命令

七、su命令

八、sudo命令

九、限制root远程登录

一、用户配置文件和密码配置文件

1.用户文件/etc/passwd

[[email protected] ~]# head -n 5 /etc/passwd
//从/etc/passwd文件可以看到,第一行都包括7个字段,第个字段间用":"分隔
//格式   用户名:密码:UID:GID:用户信息说明:用户家目录:shell
//密码字段是加密码后的密码,若为"x",则密码保存在/etc/shadow文件中,如用户没有密码,则为空
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
......中间段信息略
postfix:x:89:89::/var/spool/postfix:/sbin/nologin
chrony:x:998:996::/var/lib/chrony:/sbin/nologin
sshd:x:74:74:Privilege-separated SSH:/var/empty/sshd:/sbin/nologin
hjm:x:5000:5000:HJM:/home/hjm:/bin/bash

2.用户密码文件/etc/shadow

/etc/shadow文件是/etc/passwd的影子文件,这两个文件互补,该文件只有root权限可以读取和操作。

[[email protected] ~]# cat /etc/shadow
//etc/shadow内容包括九个字段,字段间以":"分隔
//格式    用户名:密码:上次密码修改时间:密码不可被修改的天数:密码需要重新修改的天数:密码需要重新修改前的警告期限:密码过期的宽限时间:帐号失效日期:保留
//这里的密码是真正的密码,是经过加密的密文,如果该字段包含!或*,表示该用户无法登录,该字段为空,表示用户登录无需密码,以!号开始,表示密码已经被锁定。
//第三个字段和第八个字段的日期都是使用1970年1月1日作为1
root:$6$wuyQ2nlLIXTI2IPk$99X/7wGl4kR856WTD8tU9QkNjkY3BnlP83pzuROgydZB09Ushf2UmeaeprPdXf46ohfHujbmtGYKxfOyq5L8z.::0:99999:7:::
bin:*:17110:0:99999:7:::
daemon:*:17110:0:99999:7:::
adm:*:17110:0:99999:7:::
lp:*:17110:0:99999:7:::
......中间段信息略
postfix:!!:17641::::::
chrony:!!:17641::::::
sshd:!!:17641::::::
hjm:$6$iB95gZCu1U7k6axG$rsEXykYY1zg/rmdLNEgn/tsG9MjpKIbBX0tiaNNH2c7YcDInGyr5LJNZij/nci0fN.HbYhnyqjEYwBJ4InHWG0::0:99999:7:::

二、用户组管理

1.组配置文件/etc/group

[[email protected] ~]# cat /etc/group
///etc/group包括4个字段,以":"分隔
//格式    用户组名称:用户组密码:GID:用户组成员
//用户组密码如果为x,表示未设置密码。通常无须设置。
root:x:0:
bin:x:1:
daemon:x:2:
sys:x:3:
adm:x:4:
tty:x:5:
......中间段信息略
postfix:x:89:
chrony:x:996:
sshd:x:74:
hjm:x:5000:hjm

2.组密码配置文件/etc/gshadow

[[email protected] ~]# cat /etc/gshadow
//在/etc/gshadow文件中,每个用户组独占一行,每行包括4个字段,字段间以":"分隔
//格式    用户组名称:用户组密码:用户组管理者:组成员
//用户组密码是加密后的密码,该字段为空,表示只有组内成员可以拥有该组的权限。
root:::
bin:::
daemon:::
sys:::
adm:::
tty:::
......中间段信息略
postfix:!::
chrony:!::
sshd:!::
hjm:!!::hjm

3.添加组

//新建一个组名为group1的用户组
[[email protected] ~]# groupadd group1
[[email protected] ~]# grep group1 /etc/group /etc/gshadow
/etc/group:group1:x:5001:
/etc/gshadow:group1:!::

//新建一个名为group2的系统组
[[email protected] ~]# groupadd -r group2
[[email protected] ~]# grep group2 /etc/group /etc/gshadow
/etc/group:group2:x:994:
/etc/gshadow:group2:!::

//添加GID为1111的用户组group3
[[email protected] ~]# groupadd -g 1111 group3
[[email protected] ~]# grep group3 /etc/group /etc/gshadow
/etc/group:group3:x:1111:
/etc/gshadow:group3:!::

4.删除组

//删除用户组group3
[[email protected] ~]# groupdel group3
//group3用户组被成功删除
[[email protected] ~]# grep group3 /etc/group /etc/gshadow

//如果用户还存在,无法删除用户的主组
[[email protected] ~]# grep adminuser /etc/passwd
adminuser:x:5001:5002::/home/adminuser:/bin/bash
[[email protected] ~]# grep adminuser /etc/group
adminuser:x:5002:
[[email protected] ~]# groupdel adminuser
groupdel: cannot remove the primary group of user ‘adminuser‘

//将组中的用户移走后,可删除该组
[[email protected] ~]# groupadd newgroup
[[email protected] ~]# usermod -g newgroup adminuser
[[email protected] ~]# groupdel adminuser
//成功删除
[[email protected] ~]# grep adminuser /etc/group

三、用户管理

1.新建用户

可使用useradd命令建立用户帐户和创建用户的起始目录,但只有超级用户才有权限。

useradd命令加添用户时,如不加任何参数,则系统将根据默认的参数来添加用户(/etc/login.defs和/etc/default/useradd,/etc/skel/*)

//不加任何参数,以系统默认值建立一个用户admin
[[email protected] ~]# useradd admin
[[email protected] ~]# grep admin /etc/passwd /etc/shadow /etc/group /etc/gshadow
/etc/passwd:admin:x:5002:5002::/home/admin:/bin/bash
/etc/shadow:admin:!!:17670:0:99999:7:::
/etc/group:admin:x:5002:
/etc/gshadow:admin:!::
[[email protected] ~]# ls -la /home/admin
total 12
drwx------  2 admin admin  62 May 19 16:26 .
drwxr-xr-x. 5 root  root   47 May 19 16:26 ..
-rw-r--r--  1 admin admin  18 Aug  3  2017 .bash_logout
-rw-r--r--  1 admin admin 193 Aug  3  2017 .bash_profile
-rw-r--r--  1 admin admin 231 Aug  3  2017 .bashrc

//添加用户user1,设置其真实名字"a common user",其家目录在/opt/user1下,让其归属为组admin,root成员,其shell类型为tcsh
/etc/passwd:user1:x:5003:5004:a common user:/opt/user1:/bin/tcsh
/etc/shadow:user1:!!:17670:0:99999:7:::
/etc/group:root:x:0:user1
/etc/group:admin:x:5002:user1
/etc/group:user1:x:5004:
/etc/gshadow:root:::user1
/etc/gshadow:admin:!::user1
/etc/gshadow:user1:!::

// 添加自定义用户ID为5005的用户user2
[[email protected] ~]# useradd -u 5005 user2
[[email protected] ~]# grep user2 /etc/passwd
user2:x:5005:5005::/home/user2:/bin/bash

//新建用户时不生成家目录
[[email protected] ~]# useradd -M user3
[[email protected] ~]# ls -al /home/user3
//说明家目录文件夹不存在
ls: cannot access /home/user3: No such file or directory
//但是user3是有家目录的,只是家目录文件夹不存在,可以手动创建
[[email protected] ~]# grep user3 /etc/passwd
user3:x:5006:5006::/home/user3:/bin/bash
[[email protected]luequark ~]# su - user3
su: warning: cannot change directory to /home/user3: No such file or directory
-bash-4.2$

2.删除用户

[[email protected] ~]# grep user2 /etc/passwd
user2:x:5005:5005::/home/user2:/bin/bash
//不带参数,删除用户user2, 家目录还在
[[email protected] ~]# userdel user2
[[email protected] ~]# grep user2 /etc/passwd
[[email protected] ~]#
[[email protected] ~]# ls -ld /home/user2
drwx------ 2 5005 5005 62 May 19 17:45 /home/user2

//带参数-r,删除用户的同时,删除其家目录
[[email protected] ~]# grep admin /etc/passwd
admin:x:5002:5002::/home/admin:/bin/bash
[[email protected] ~]# ls -ld /home/admin
drwx------ 2 admin admin 62 May 19 16:26 /home/admin
[[email protected] ~]# userdel -r admin
[[email protected] ~]# grep admin /etc/passwd
[[email protected] ~]#
[[email protected] ~]# ls -ld /home/admin
ls: cannot access /home/admin: No such file or directory

四、Usermod

usermod的作用:修改用户类型、所归属的组,修改用户密码的有效期,还能修改登录名

常用选项

-g 修改用户的所属组

//用户nico的主组id为5007,主组名:nico
[[email protected] ~]# grep nico /etc/passwd
nico:x:5007:5007::/home/nico:/bin/bash
[[email protected] ~]# grep 5007 /etc/group
nico:x:5007:
//变更nico主组为newgroup
[[email protected] ~]# usermod -g newgroup nico
[[email protected] ~]# id nico
uid=5007(nico) gid=5003(newgroup) groups=5003(newgroup)
//用户nico的主组已经变更为newgroup

-G 增加用户的附属组

[[email protected] ~]# id nico
uid=5007(nico) gid=5003(newgroup) groups=5003(newgroup)
[[email protected] ~]# usermod -G nico nico
[[email protected] ~]# id nico
uid=5007(nico) gid=5003(newgroup) groups=5003(newgroup),5007(nico)

-u 修改用户的uid

[[email protected] ~]# id nico
uid=5007(nico) gid=5003(newgroup) groups=5003(newgroup),5007(nico)
[[email protected] ~]# usermod -u 5008 nico
[[email protected] ~]# id nico
uid=5008(nico) gid=5003(newgroup) groups=5003(newgroup),5007(nico)

-L 锁定用户

//密码字段第一位不为!,说明用户没有锁定
[[email protected] ~]# grep nico /etc/shadow
nico:$6$Q52VYIOk$MhEHOcBLqPSiAwz.j4K.74mvfSuYKhluACR25QOrsn6yRRWEBOeP8fN6s1KWObm0IJcdah5wrXkuize5Anlgn1:17670:0:99999:7:::
//锁定用户
[[email protected] ~]# usermod -L nico
[[email protected] ~]# grep nico /etc/shadow
nico:!$6$Q52VYIOk$MhEHOcBLqPSiAwz.j4K.74mvfSuYKhluACR25QOrsn6yRRWEBOeP8fN6s1KWObm0IJcdah5wrXkuize5Anlgn1:17670:0:99999:7:::

-U 解锁用户

[[email protected] ~]# grep nico /etc/shadow
nico:!$6$Q52VYIOk$MhEHOcBLqPSiAwz.j4K.74mvfSuYKhluACR25QOrsn6yRRWEBOeP8fN6s1KWObm0IJcdah5wrXkuize5Anlgn1:17670:0:99999:7:::
[[email protected] ~]# usermod -U nico
[[email protected] ~]# grep nico /etc/shadow
nico:$6$Q52VYIOk$MhEHOcBLqPSiAwz.j4K.74mvfSuYKhluACR25QOrsn6yRRWEBOeP8fN6s1KWObm0IJcdah5wrXkuize5Anlgn1:17670:0:99999:7:::

-l修改用户登录名

-d修改用户家目录

//将kennminn用户改名为shelly,并将其家目录转移到/opt/shelly
[[email protected] ~]# usermod -d /opt/shelly -m -l shelly -U kennminn
[[email protected] ~]# ls -ld /opt/shelly/
drwx------ 2 shelly kennminn 62 May 19 19:58 /opt/shelly/
[[email protected] ~]# groupadd shelly
[[email protected] ~]# chown -R shelly.shelly /opt/shelly
[[email protected] ~]# ls -ld /opt/shelly/
drwx------ 2 shelly shelly 62 May 19 19:58 /opt/shelly/

五、用户密码管理

可以用passwd命令来实现对用户密码的管理

//交互式修改用户密码
[[email protected] ~]# useradd nico
[[email protected] ~]# passwd nico
Changing password for user nico.
New password:    //输入密码
BAD PASSWORD: The password is shorter than 8 characters
Retype new password:  //再次输入密码
passwd: all authentication tokens updated successfully.

//非交互式修改用户密码方法1
[[email protected] ~]# echo ‘12345‘ | passwd --stdin nico
Changing password for user nico.
passwd: all authentication tokens updated successfully.

//非交互式修改用户密码方法2
[[email protected] ~]# echo -e "123456\n123456" | passwd nico
Changing password for user nico.
New password: BAD PASSWORD: The password is shorter than 8 characters
Retype new password: passwd: all authentication tokens updated successfully.

//删除用户密码
[[email protected] ~]# passwd -d nico
Removing password for user nico.
passwd: Success

//锁定用户帐户
[[email protected] ~]# passwd -l nico
Locking password for user nico.
passwd: Success

//解锁用户帐户
[[email protected] ~]# passwd -u nico
Unlocking password for user nico.
passwd: Success

六、mkpasswd

mkpasswd是一种密码生成工具,可生成随机复杂密码。

最小化安装默认没有mkpasswd命令,需安装expect软件包

//expect软件包安装
[[email protected] ~]# yum -y install expect-5.45-14.el7_1.x86_64

常见用法

-l 指定密码长度,默认长度为9

//不带参数生成默认长度为9的随机密码
[[email protected] ~]# mkpasswd
av‘lZ8zY4

//带l参数生成指定长度的密码
[[email protected] ~]# mkpasswd -l 12
a1ivcnRXh%0m

-s 指定新生成密码中特殊字符的最小个数,默认为1

[[email protected] ~]# mkpasswd -s 3
?sA<04gN*

-d 指定新生成密码中数字的最小个数,默认为2

[[email protected] ~]# mkpasswd -d 3
W1yn&k7V5

七、su命令

通过su命令可以在用户之间切换,root用户向普通户切换无需密码,普通用户切换到其他用户需要密码。

常见用法

普通用户切换到root用户

//普通用户切换到root用户,不带"-"时,环境变量不会切换。
[[email protected] ~]$ su root
Password:
[[email protected] hjm]# pwd
/home/hjm

//普通用户切换到root用户,带"-"时,环境变量会切换
[[email protected] ~]$ su - root
Password:
Last login: Sat May 19 21:37:43 CST 2018 from 192.168.1.9 on pts/0
[[email protected] ~]# pwd
/root

以指定身份运行一条命令

[[email protected] ~]$ su - -c "head -n 5 /etc/passwd" root
Password:
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

若要切换到的用户没有家目,则使用系统的默认配置

[[email protected] ~]# grep user6 /etc/passwd
user6:x:5012:5013::/home/user6:/bin/bash
[[email protected] ~]# ls -ld /home/user6
ls: cannot access /home/user6: No such file or directory
[[email protected] ~]# su - user6
su: warning: cannot change directory to /home/user6: No such file or directory
-bash-4.2$
//可手动生成用户家目录文件夹并拷贝/etc/skel下的默认配置文件到相应目录,
[[email protected] ~]$ cp /etc/skel/* /home/user6
[[email protected] ~]# su - user6
[[email protected] ~]$ 

八、sudo

sudo允许系统管理员让普通用户执行一些或全部的root命令。

sudo通过/etc/sudoers进行授权,编辑文件时最好用visudo,它会进行简单语法检查。

授权普通用户使用root的部分命令

//授权hjm用户使用root用户的ls,cat权限
......上部略
## Allow root to run any commands anywhere
root    ALL=(ALL)       ALL
hjm     ALL=(ALL)       /usr/bin/ls,/usr/bin/cat
......略

//授权的ls可以查看root家目录下的文件
[[email protected] ~]$ ls /root/
ls: cannot open directory /root/: Permission denied
[[email protected] ~]$ sudo /usr/bin/ls /root/

We trust you have received the usual lecture from the local System
Administrator. It usually boils down to these three things:

    #1) Respect the privacy of others.
    #2) Think before you type.
    #3) With great power comes great responsibility.

[sudo] password for hjm:
anaconda-ks.cfg  bbbb  day.jpg  default.jpg  demo  dir2  fd1  morning.jpg  named.pipe  night.jpg  path_demo  pxe_config

[[email protected] ~]$ cat /root/f1.txt
cat: /root/f1.txt: Permission denied
[[email protected] ~]$ sudo /usr/bin/cat /root/f1.txt
#version=DEVEL
# System authorization information
auth --enableshadow --passalgo=sha512

visudo中用户别名

......
User_Alias ADMINS = hjm, nico
ADMINS  ALL=(ALL)       /usr/bin/ls,/usr/bin/cat
......

//验证hjm用户可以使用root的ls命令
[[email protected] ~]# su - hjm
Last login: Sat May 19 22:25:17 CST 2018 on pts/0
[[email protected] ~]$ ls /root/
ls: cannot open directory /root/: Permission denied
[[email protected] ~]$ sudo /usr/bin/ls /root/
[sudo] password for hjm:
anaconda-ks.cfg  bbbb  day.jpg  default.jpg  demo  dir2  f1.txt  fd1  morning.jpg  named.pipe  night.jpg  path_demo  pxe_config
//验证nico用户可以使用root的ls命令
[[email protected] ~]$ su - nico
Password:
Last login: Sat May 19 19:32:49 CST 2018 on pts/0
Last failed login: Sat May 19 22:49:36 CST 2018 on pts/0
There were 2 failed login attempts since the last successful login.
[[email protected] ~]$ ls /root/
ls: cannot open directory /root/: Permission denied
[[email protected] ~]$ sudo /usr/bin/ls /root/

We trust you have received the usual lecture from the local System
Administrator. It usually boils down to these three things:

    #1) Respect the privacy of others.
    #2) Think before you type.
    #3) With great power comes great responsibility.

[sudo] password for nico:
anaconda-ks.cfg  bbbb  day.jpg  default.jpg  demo  dir2  f1.txt  fd1  morning.jpg  named.pipe  night.jpg  path_demo  pxe_config

visudo中命令别名设置

......省略

Cmnd_Alias ALIAS_CMD = /usr/bin/ls, /usr/bin/cat
......省略
//NOPASSWD表示用户无需输入密码
ADMINS  ALL=(ALL)       NOPASSWD:ALIAS_CMD
......省略
//验证hjm用户可以不输入密码直接使用/root的ls命令
[[email protected] ~]# su - hjm
Last login: Sat May 19 22:44:43 CST 2018 on pts/0
[[email protected] ~]$ ls /root/
ls: cannot open directory /root/: Permission denied
[[email protected] ~]$ sudo /usr/bin/ls /root/
anaconda-ks.cfg  bbbb  day.jpg  default.jpg  demo  dir2  f1.txt  fd1  morning.jpg  named.pipe  night.jpg  path_demo  pxe_config

//验证nico用户无需输入密码可以直接使用/root的ls命令
[[email protected] ~]$ su - nico
Password:
Last login: Sat May 19 22:49:43 CST 2018 on pts/0
[[email protected] ~]$ ls /root/
ls: cannot open directory /root/: Permission denied
[[email protected] ~]$ sudo /usr/bin/ls /root/
anaconda-ks.cfg  bbbb  day.jpg  default.jpg  demo  dir2  f1.txt  fd1  morning.jpg  named.pipe  night.jpg  path_demo  pxe_config

管理员组wheel

## Allows people in group wheel to run all commands
%wheel  ALL=(ALL)       ALL

//添加用户到wheel组
[[email protected] ~]# usermod -a -G wheel shelly
[[email protected] ~]# grep shelly /etc/group
wheel:x:10:shelly
shelly:x:5012:
[[email protected] ~]# su -shelly
su: failed to execute helly: No such file or directory
[[email protected] ~]# su - shelly
[[email protected] ~]$ ls /root
ls: cannot open directory /root: Permission denied
[[email protected] ~]$ sudo /usr/bin/ls /root/

We trust you have received the usual lecture from the local System
Administrator. It usually boils down to these three things:

    #1) Respect the privacy of others.
    #2) Think before you type.
    #3) With great power comes great responsibility.

[sudo] password for shelly:
anaconda-ks.cfg  bbbb  day.jpg  default.jpg  demo  dir2  f1.txt  fd1  morning.jpg  named.pipe  night.jpg  path_demo  pxe_config

九、限制root用户远程登录

鉴于直接使用Root用户登录所具有的高风险性,为避免误操作引起的事故,根据权限最小化原则,应尽量使用普通用户远程登录,只有在需要root用户权限的时候切换到root用户身份。执行完回退至普通用户。可采用如下方案:

//1. 通过visudo编辑/etc/sudoers文件,将需要切换到root用户设置到同一个别名
User_Alias ADMINS = hjm, nico
//2. 允许这些用户免密执行root用户的/usr/bin/su命令
ADMINS  ALL=(ALL)       NOPASSWD:/usr/bin/su
//这样普通用户不用知道root密码也可以切换到root用户身份,执行完也可以回退至本身的帐户
[[email protected] ~]$ sudo /usr/bin/su -
Last login: Sat May 19 23:35:30 CST 2018 on pts/0
[[email protected] ~]#
[[email protected] ~]# exit
logout
[[email protected] ~]$
//3.限制root用户不能远程ssh登录
[[email protected] ~]# sed -ni s/#PermitRootLogin\ yes/PermitRootLogin\ no/p /etc/ssh/sshd_config
[[email protected] ~]# grep PermitRootLogin !$
grep PermitRootLogin /etc/ssh/sshd_config
PermitRootLogin no
//4.重启sshd 服务
[[email protected] ~]# systemctl restart sshd.service

此时再以root用户远程密码登录,服务器拒绝登录。

此时再以普通用户登录,可正常登录

Connecting to 192.168.1.211:22...
Connection established.
To escape to local shell, press ‘Ctrl+Alt+]‘.

Last login: Sat May 19 23:39:10 2018
[[email protected] ~]$
//需要时可以通过sudo /usr/bin/su - 切换至root用户身份
[[email protected] ~]$ sudo /usr/bin/su -
Last login: Sat May 19 23:44:09 CST 2018 on pts/0
Last failed login: Sat May 19 23:58:44 CST 2018 from 192.168.1.9 on ssh:notty
There were 11 failed login attempts since the last successful login.
[[email protected] ~]#

原文地址:https://www.cnblogs.com/minn/p/9062217.html

时间: 2024-08-15 20:25:46

2018-05-18课堂笔记的相关文章

2017年07月05号课堂笔记

2017年07月05号 星期三 多云 空气质量:中度污染 内容:mysql第五节课+MySQL自测考试 表连接查询:内连接,左右外连接,自连接 事务:事务的特性 ACID,demo(模拟 银行转账)开启,回滚,提交,关闭/开启事务自动提交 一.表连接查询 1.概念: 1)内连接 : 通过匹配两个表中公共列,找到 公共的行! 2)左外连接: 以左表为准,右表中没有数据返回null 3)右外连接: 以右表为准,左表中没有数据返回null 4)自连接:  把一个表当成多个表来使用 关键是 使用别名 2

2018/05/18 数据库 视图

最近有点忙,都没有时间来写博客了. 不过这也是自我沉淀的一个过程. 什么是视图? 视图并没有想象的那么复杂,简单来说的话. 视图就是把你写的SQL保存起来,在使用视图的时候等于使用了这么个SQL. 为什么要用视图? 当业务足够复杂的时候,多个表之间的数据关联越来越紧密.当我们要找一条数据的时候往往要写长的SQL. 而这些SQL往往都是可以重复使用的. 于是,当我们有了视图之后,就通过视图直接查询即可. 视图是虚拟表,本身不存储数据,而是按照指定的方式进行查询. 如何创建一个视图? CREATE

CSS基础入门 第4天课堂笔记

CSS基础入门 第4天课堂笔记(本课程共6天) 前端与移动开发学院 http://web.itcast.cn 目录 目录 2 一.复习 3 二.浮动性质的复习 4 三.浮动的清除 5 3.1 清除浮动方法1:给浮动的元素的祖先元素加高度. 5 3.2 清除浮动方法2:clear:both; 6 3.3 清除浮动方法3:隔墙法 7 3.4 清除浮动方法4:overflow:hidden; 8 3.5 清除浮动总结与案例 9 3.6 浏览器兼容问题 11 四.margin 13 4.1 margin

JAVA的面向对象编程--------课堂笔记

JAVA的面向对象编程--------课堂笔记 面向对象主要针对面向过程. 面向过程的基本单元是函数.   什么是对象:EVERYTHING IS OBJECT(万物皆对象)   所有的事物都有两个方面: 有什么(属性):用来描述对象. 能够做什么(方法):告诉外界对象有那些功能. 后者以前者为基础. 大的对象的属性也可以是一个对象.   为什么要使用面向对象: 首先,面向对象符合人类看待事物的一般规律. 对象的方法的实现细节是屏蔽的,只有对象方法的实现者了解细节. 方法的定义非常重要.方法有参

2017年5月26日课堂笔记

2017年5月26日 星期五 晴 空气质量:中度污染 内容:JavaScript:初识js,按钮的点击事件,变量的使用,数据类型,typeof的使用, string的使用,数组的使用,运算符的运用,逻辑控制语句的使用 备注:5月28日补课堂笔记 一.初识js 老师代码: <!DOCTYPE html><html><head lang="en"> <meta charset="UTF-8"> <title>初

兄弟连学python 课堂笔记 ---- Redis基本操作

基本操作 Redis 是 Key-Value 内存数据库,操作是通过各种指令进行的,比如 `SET` 指令可以设置键值对,而 `GET` 指令则获取某一个键的值.不同的数据结构,Redis 有不同的指令,这样指令一共有几十个,下面主要介绍一些常用的指令. Redis 对 Key 也就是键有各种各样的指令,主要有下面的指令(下面的指令中小写字符串都是参数,可以自定义):>keys *  //返回键(key) >keys list*   //返回名以list开头的所有键(key)>exist

九章算法系列(#2 Binary Search)-课堂笔记

前言 先说一些题外的东西吧.受到春跃大神的影响和启发,推荐了这个算法公开课给我,晚上睡觉前点开一看发现课还有两天要开始,本着要好好系统地学习一下算法,于是就爬起来拉上两个小伙伴组团报名了.今天听了第一节课,说真的很实用,特别是对于我这种算法不扎实,并且又想找工作,提高自己的情况. 那就不多说废话了,以后每周都写个总结吧,就趁着这一个月好好把算法提高一下.具体就从:课堂笔记.leetcode和lintcode相关习题.hdu和poj相关习题三个方面来写吧.希望自己能够坚持下来,给大家分享一些好的东

2017年5月12号课堂笔记

2017年5月12号 星期五 空气质量:轻度污染(昨天的北风转今天的南风) 内容:html表格的基本使用,表格跨行跨列,高级表格,播放音乐,播放视频,网页布局,iframe内联框架: 文本框,密码框,单选按钮,复选框,下拉框  备注:周日晚想起来补上的周五课堂笔记(一带一路今天开会天气好晴朗) 一.html表格的基本使用 模仿老师代码: <!DOCTYPE html><html><head lang="en"> <meta charset=&q

?统计学习精要(The Elements of Statistical Learning)?课堂笔记(一)

前两天微博上转出来的,复旦计算机学院的吴立德吴老师在开?统计学习精要(The Elements of Statistical Learning)?这门课,还在张江...大牛的课怎能错过,果断请假去蹭课...为了减轻心理压力,还拉了一帮同事一起去听,eBay浩浩荡荡的十几人杀过去好不壮观!总感觉我们的人有超过复旦本身学生的阵势,五六十人的教室坐的满满当当,壮观啊. 这本书正好前阵子一直在看,所以才会屁颠屁颠的跑过去听.确实是一本深入浅出讲data mining models的好书.作者网站上提供免