hi

原来今天是感恩节。虽然一直没有过这个节日的习惯,但仅仅是听到感恩的消息,都能想到一幅幅画面。愿大家安好!

下午开题会议还是有所收获,悄悄的,就变向那个不喜欢自己的人了。

一、Linux基础(二)

-----Linux常用命令(二)-----

3、文件搜索命令

3.1 文件搜索命令locate

--优点:

搜索速度快(在学习中,要把眼光放远、放大一点,设想数据量很大的情况或是规模很大的问题的情况)

locate 文件名

--工作原理:

在后台数据库按文件名搜索

所以,新创建的文件往往搜索不到(缺点)

解决办法:等(1天);updatedb命令更新数据库

--缺点:

只能按照文件名搜索(功能弱)——理解就是,牺牲功能提升速度

--搜索/更新配置:

vi /etc/updatedb.conf

得到

PRUNE_BIND_MOUNTS = "yes"
PRUNEFS = "9p afs anon_inodefs auto autofs bdev binfmt_misc cgroup cifs coda configfs cpuset debugfs devpts ecryptfs exofs fuse fusectl gfs gfs2 hugetlbfs inotifyfs iso9660 jffs2 lustre mqueue ncpfs nfs nfs4 nfsd pipefs proc ramfs rootfs rpc_pipefs securityfs selinuxfs sfs sockfs sysfs tmpfs ubifs udf usbfs"
PRUNENAMES = ".git .hg .svn"
PRUNEPATHS = "/afs /media /net /sfs /tmp /udev /var/cache/ccache /var/spool/cups /var/spool/squid /var/tmp"

第一行就是说,是否执行下列的更新规则

后面是不搜索这些文件夹/文件

所以有时候有些目录中的内容搜索不到的——比如常用的/tmp

3.2 命令搜索命令whereis和which

3.2.1 whereis

--基本

[root@andy ~]# whereis ls
ls: /bin/ls /usr/share/man/man1p/ls.1p.gz /usr/share/man/man1/ls.1.gz

能搜索到命令的目录以及其帮助文档的目录(所以命令所在位置where is ,同时要牢记,linux中一切皆文件)

--选项

-b 只查找可执行文件

-m 只查找帮助文件

[root@andy ~]# whereis -b mkdir
mkdir: /bin/mkdir

3.2.2 which

--基本

[root@andy ~]# which ls
alias ls='ls --color=auto'
/bin/ls

还会查到别名(如果有的话)。

这里ls会自动显示不同的颜色

[root@andy ~]# which pwd
/bin/pwd

没有别名就还是这样,但没有帮助文档

3.2.3 其他说明

--找不到的命令

[root@andy ~]# which cd
/usr/bin/which: no cd in (/usr/lib/qt-3.3/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin)
[root@andy ~]# where cd
-bash: where: command not found

有些类型是找不到的,原因是shell自带的(以后学)

--path环境变量

环境设定的基本路径,比如上述(/usr/lib/qt-3.3/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin)

它使我们可以不用绝对路径来输入命令——windows也是这样的

还是那句话,都是文件

path环境变量的定义:系统搜索命令的路径

自己写的程序,要么命令都写绝对路径,要么放在这些path路径中

3.3 find命令

最强大的搜索命令——这里只学习基本的、常用的用法

--基本

find [搜索范围] [搜索条件] 文件名

[root@andy ~]# find / -name install.log
/root/install.log

会发现速度很慢——范围太大

而且真实情况会更加复杂,有可能速度更慢,压力更大

——尽量缩小范围!

而且,如果打算进行模糊匹配,比如install.log.syslog。这个命令是查不到的,要进行通配符匹配,通配符是完全匹配

--通配符

* 匹配任意内容

[root@andy ~]# find /root -name "install.log*"
/root/install.log.syslog
/root/install.log

? 匹配任意一个字符

[] 匹配中括号中的任意一个字符

[root@andy ~]# find /root -name "*[asdf]?"
/root/anaconda-ks.cfg
/root/.viminfo
/root/japan
/root/japan/anaconda-ks.cfg

要注意,find是完全匹配,要小心

--搜索条件

-

find /root -name  install.log  按照文件名搜索

find /root -inname install.log   不区分大小写

-

find /root -user install.log  按照所有者搜索(不常用)

find /root -nouser 搜索所有没有所有者的文件(常用)——这种文件很多是垃圾文件,但是有两种情况除外——内核创建的(sys中);外来文件(比如U盘)

-

find /var/log -mtime +10  查找10天前修改的文件——atime 文件访问时间,mtime 修改文件时间,ctime 改变文件属性;+10 10天前修改的文件,-10 10天内,10 10天当天(注意没有10天后,哈哈)——常用于日志的删除/筛选中的(默认按天)

-

find . -size 25k 在当前目录下搜索25k大小的文件——+25或-25也可以

[root@andy ~]# find . -size 25k
[root@andy ~]# ll
总用量 48
-rw-------. 2 root root 1273 11月 26 05:32 anaconda-ks.cfg
-rw-r--r--. 1 root root 0 11月 26 06:05 cangls
-rw-r--r--. 1 root root 26420 11月 25 03:55 install.log
-rw-r--r--. 1 root root 7572 11月 25 03:52 install.log.syslog
drwxr-xr-x. 3 root root 4096 11月 26 05:43 japan
[root@andy ~]# find . -size +25k
./install.log
[root@andy ~]# find . -size -25k
.
./.tcshrc
./anaconda-ks.cfg
./cangls
./install.log.syslog
./.bash_profile
./.bash_logout
./.bash_history
./.bashrc
./.viminfo
./.cshrc
./japan
./japan/anaconda-ks.cfg
./japan/cangls
[root@andy ~]# find . -size -25m
find: 无效的 -size 类型“m”
[root@andy ~]# find . -size -25M
.
./.tcshrc
./anaconda-ks.cfg
./cangls
./install.log.syslog
./.bash_profile
./.bash_logout
./.bash_history
./install.log
./.bashrc
./.viminfo
./.cshrc
./japan
./japan/anaconda-ks.cfg
./japan/cangls
[root@andy ~]#

注意Mb是大写的M,kb是小写的k

-

find . -inum 213123 在当前目录按照i节点搜索213123的文件——常常搭配ls -i使用

-复杂操作

find /etc -size +20k -a -size -50k 这里的-a是与,-o是或

[root@andy ~]# find /etc -size +20k -a -size -50k
/etc/selinux/targeted/modules/active/modules/unprivuser.pp
/etc/selinux/targeted/modules/active/modules/xguest.pp
/etc/selinux/targeted/modules/active/modules/virt.pp
/etc/selinux/targeted/modules/active/modules/postfix.pp
/etc/selinux/targeted/modules/active/modules/unconfineduser.pp
/etc/selinux/targeted/modules/active/modules/nagios.pp
/etc/selinux/targeted/modules/active/modules/cups.pp
/etc/selinux/targeted/modules/active/modules/rhcs.pp
/etc/selinux/targeted/modules/active/modules/apache.pp
/etc/selinux/targeted/modules/active/modules/staff.pp
/etc/selinux/targeted/modules/active/modules/samba.pp
/etc/mime.types
/etc/sysconfig/network-scripts/network-functions-ipv6
/etc/postfix/main.cf
/etc/ld.so.cache
/etc/libreport/events/report_RHTSupportAttach.xml
/etc/libreport/events/report_RHTSupport.xml
/etc/makedev.d/01linux-2.6.x
/etc/sound/events/gnome-2.soundlist

-

find /etc -size +20k -a -size -50k -exec ls -lh {} \;

[root@andy ~]# find /etc -size +20k -a -size -50k -exec ls -lh {} \;
-rw-------. 1 root root 37K 11月 25 03:46 /etc/selinux/targeted/modules/active/modules/unprivuser.pp
-rw-------. 1 root root 26K 11月 25 03:46 /etc/selinux/targeted/modules/active/modules/xguest.pp
-rw-------. 1 root root 24K 11月 25 03:46 /etc/selinux/targeted/modules/active/modules/virt.pp
-rw-------. 1 root root 31K 11月 25 03:46 /etc/selinux/targeted/modules/active/modules/postfix.pp
-rw-------. 1 root root 29K 11月 25 03:46 /etc/selinux/targeted/modules/active/modules/unconfineduser.pp
-rw-------. 1 root root 21K 11月 25 03:46 /etc/selinux/targeted/modules/active/modules/nagios.pp
-rw-------. 1 root root 21K 11月 25 03:46 /etc/selinux/targeted/modules/active/modules/cups.pp
-rw-------. 1 root root 26K 11月 25 03:46 /etc/selinux/targeted/modules/active/modules/rhcs.pp
-rw-------. 1 root root 27K 11月 25 03:46 /etc/selinux/targeted/modules/active/modules/apache.pp
-rw-------. 1 root root 42K 11月 25 03:46 /etc/selinux/targeted/modules/active/modules/staff.pp
-rw-------. 1 root root 24K 11月 25 03:46 /etc/selinux/targeted/modules/active/modules/samba.pp
-rw-r--r--. 1 root root 43K 9月 23 2011 /etc/mime.types
-rw-r--r--. 1 root root 30K 7月 22 2014 /etc/sysconfig/network-scripts/network-functions-ipv6
-rw-r--r--. 1 root root 27K 2月 20 2014 /etc/postfix/main.cf
-rw-r--r--. 1 root root 40K 11月 25 03:52 /etc/ld.so.cache
-rw-r--r--. 1 root root 23K 10月 16 2014 /etc/libreport/events/report_RHTSupportAttach.xml
-rw-r--r--. 1 root root 22K 10月 16 2014 /etc/libreport/events/report_RHTSupport.xml
-rw-r--r--. 1 root root 28K 11月 11 2010 /etc/makedev.d/01linux-2.6.x
-rw-r--r--. 1 root root 27K 11月 12 2010 /etc/sound/events/gnome-2.soundlist

这里是用-exec加入第二条命令,执行前面的结果,而且必须加{} /;

------总结

就是find很强大,功能很多,灵活多变;同时带来了,使用复杂,速度不好定

3.4 grep命令

--基本

搜索字符串:grep [选项] 字符串 文件名

[root@andy ~]# grep "size" anaconda-ks.cfg
#part /boot --fstype=ext4 --size=200
#part swap --size=4000
#part /home --fstype=ext4 --size=2000
#part / --fstype=ext4 --grow --size=200

注意,搜索到的不是符合字符串的文件,而是文件中相应的字符串——与find区分

--选项

-v 取反,即不包含字符串的

-i 不区分大小写

--与find

find:找文件+完全匹配+使用通配符匹配

grep:找字符串+包含匹配+使用正则表达式匹配

-------------------------------------------------------------------

二、PHP与MySQL

-----文章发布系统实践(一)-----

理解php操作mysql的方法,熟悉掌握php的mysql函数

1、需求分析

1.1 后台管理系统

管理-列表

发布,修改,删除-程序

1.2 前台展示系统

文章列表,文章内容页

1.3 数据库设计

一个表即可,用于存放文章

(我不想画表格,直接写数据库命令好了,但愿以后的我看得懂)

CREATE TABLE article(

id INT(11) PRIMARY KEY AUTO_INCREMENT,

title CHAR(100) NOT NULL,

author CHAR(50) NOT NULL,

description VARCHAR(255) NOT NULL,

content TEXT NOT NULL,

dateline INT(11) NOT NULL DEFAULT 0

);

1.4 项目规划

项目需要什么文件

2、后台管理系统

2.1 创建配置文件和初始化文件

中午开会,没有睡午觉。。。早点回去看书睡觉了

原来今天是感恩节-Linux基础继续&MySQL和PHP的更多相关文章

  1. Linux基础命令---mysql

    mysql mysql是一个简单的sql shell,它可以用来管理mysql数据库. 此命令的适用范围:RedHat.RHEL.Ubuntu.CentOS.Fedora.   1.语法      m ...

  2. 第四节,Linux基础命令

    第四节,Linux基础命令 命令是系统操作员对系统传入的指令,传入指令后回车,系统接收到指令做出相应的行为 1.查看用户位于系统什么位置 [pmd]检查操作用户位于系统的什么位置 命令         ...

  3. 第90节:Java中的Linux基础

    第90节:Java中的Linux基础 linux是装载虚拟机上面的: JDK依赖包: yum install glibc.i686 MYSQL依赖包: yum -y install libaio.so ...

  4. Linux基础入门

    第一节,linux系统简介 一.实验内容 了解 Linux 的历史,Linux 与 Windows 的区别等入门知识. 二.实验要求 阅读linux简介与历史 三.实验步骤 (一).Linux 为何物 ...

  5. 《信息安全系统设计基础》第一次实验报告--Linux 基础入门

    北京电子科技学院(BESTI) 实     验    报     告 课程:信息安全设计基础 班级:1352  姓名:何伟钦  学号:20135223 成绩:            指导教师:娄嘉鹏 ...

  6. Linux基础入门学习笔记20135227黄晓妍

    学习计时:共24小时 读书:1小时 代码:8小时 作业:3小时 博客:12小时 一.学习目标 1. 能够独立安装Linux操作系统   2. 能够熟练使用Linux系统的基本命令   3. 熟练使用L ...

  7. Linux 基础入门 第一周9.14~9.20

    第一节 Linux系统简介 Linux——操作系统 1.使多个用户从不同的终端同时操作主机(分时操作系统): 2.MINIX是一个功能有限的类似于UNIX的操作系统(UNIX 实现了 TCP/IP 协 ...

  8. Linux 基础入门----推荐课程

    Linux 基础入门课程:https://www.shiyanlou.com/courses/1 很好的一门Linux基础课,精炼.简洁!推荐! 课程内容: 第1节 Linux 系统简介 https: ...

  9. SLAM+语音机器人DIY系列:(一)Linux基础——2.安装Linux发行版ubuntu系统

    摘要 由于机器人SLAM.自动导航.语音交互这一系列算法都在机器人操作系统ROS中有很好的支持,所以后续的章节中都会使用ROS来组织构建代码:而ROS又是安装在Linux发行版ubuntu系统之上的, ...

随机推荐

  1. 使用虚拟按钮(Ghost Buttons)的25个网站

    2014年已经过去大半年了,我们看到网页设计领域出现新的设计趋势. 虚拟按钮(Ghost Buttons)是指具备基本的按钮形状的透明按钮,但有细实线的边框.有些虚拟钮是互动的,点击之后按钮可能会成为 ...

  2. 【原】iOS动态性(二):运行时runtime初探(强制获取并修改私有变量,强制增加及修改私有方法等)

    OC是运行时语言,只有在程序运行时,才会去确定对象的类型,并调用类与对象相应的方法.利用runtime机制让我们可以在程序运行时动态修改类.对象中的所有属性.方法,就算是私有方法以及私有属性都是可以动 ...

  3. 从零开始,做一个NodeJS博客(一):Heroku上的最简NodeJS服务器

    标签:NodeJS,Heroku 0 这里是这个伪系列的第一篇,因为我也不知道自己能不能做完,然后到底能做成什么样子.总之,尽力而为吧,加油. 1 Heroku App 的构成 Heroku 所谓的 ...

  4. web前端命名规范

    在做web项目的时候,命名的规范是很重要.初学者一般急于求成对命名规范没有概念,觉得花时间这些还不如多看几遍框架.其实在我看来,一个良好的命名习惯是很重要的.下面就来介绍一下我总结的命名规范: (1) ...

  5. ABAP 动态生成内表的几种方法

    最近要写个程序,既有更新的,也有删除的,需要涉及到很多系统表,如果一个表一个表进行更新或者删除太慢了,于是就想通过创建动态内表来实现这些功能,在网上找了一些资料,经过多次尝试,终于测试成功了.网上讲述 ...

  6. ArcPy之Python介绍

    1.Python简介 Python是一种面向对象.解释型计算机程序设计语言;Python是一种简单易学,功能强大的编程语言.它有高效率的高层数据结构,简单而有效地实现面向对象编程.Python简洁的语 ...

  7. flume 集群安装

    ./pssh -h ./host/all.txt -P mkdir /usr/local/app ./pssh -h ./host/all.txt -P tar zxf /usr/local/soft ...

  8. Java继承中的转型及其内存分配

    看书的时候被一段代码能凌乱啦,代码是这样的: package 继承; abstract class People { public String tag = "疯狂Java讲义"; ...

  9. 【代码笔记】iOS-平面化的饼图

    一,效果图. 二,工程图. 三,代码. RootViewController.m - (void)viewDidLoad { [super viewDidLoad]; // Do any additi ...

  10. 【原】ios的hitTest方法以及不规则区域内触摸事件处理方法

    概述 在正常的使用场景中,我们处理了比较多的矩形区域内触摸事件,比如UIButton.UIControl.一般来说,这些控件的图形以及触摸区域都是矩形或者圆角矩形的.但是在一些特殊应用场景中我们有时不 ...