Hi Thanksgiving — MySQL and PHP of Linux basic tutorial


Thanksgiving. Although I haven’t had the habit of this festival, I can think of pictures only when I hear the news of gratitude. Wish everyone well!

Learn the preface of Linux

If you choose a Linux distribution, you will think about how to start learning Linux.

1. Of course, Linux is installed. Please go to Google or Baidu on the Internet, download the installation CD of RedHat Linux 5, and then install VMware

2. Do more and knock more orders. Only reading, not practice, everything is floating clouds. RedHat 5 is installed by default. Starting RedHat 5 has a graphical interface, but the graphical interface should be used less, which is bad for learning Linux. You must try to use the character interface and get used to it slowly. At work, the probability of using graphical interface is almost 0 when using Linux. So you learn the technical value of graphical interface, which is almost zero, and the cost performance is not high.

How to learn Linux

1. The first thing to learn Linux is to learn the basics of Linux. In this regard, I recommend the Linux foundation file of brother bird’s private dishes, which explains the files, disks, networks, processes, etc. of Linux. After understanding this book and practicing the commands one by one, you begin to get started with Linux.

2. The second thing to learn Linux is to use Linux. As mentioned earlier, the biggest use of Linux is in the server field, so the second step you need to learn is to learn to set up servers. In this regard, I recommend brother bird’s private dish Linux site file. This book introduces many server assumptions. It is not necessary to read all the server setup steps. Personally, I think I can read the foundation of setting up a server first, and then see how to build a web server, FTP server, telnet server and ssh server. Learn how to build and manage these servers, and then choose the construction of other servers according to personal interests and needs.

3. Advanced programming. Here, you just can use Linux. Maybe you can learn a little shell programming, learn simple shell and write scripts. But if you want to be more familiar with Linux, you must learn Linux programming. For example, how does the Linux pipeline do, how does the Deamon process of Linux implement, and why can nohub let a process run in the form of daemon? Even if the shell is closed, the process will not be closed. These, you learn the Linux environment programming, you suddenly enlightened. Here I recommend advanced programming in UNIX environment, which is the Bible of Linux / unix programming and can be called a world-renowned work.

4. Here, you can know something about Linux / Unix and have a certain foundation. Next, you should choose the direction you are interested in to study according to your interest, or study according to your work direction (most of the time, work is not your own interest). Master leads the door and practices personally. The above learning steps are the simplest steps I can think of, The more things you learn, the more confused you will be for beginners.

The opening meeting in the afternoon was fruitful. Quietly, it turned to the person who didn’t like himself.

1、 Fundamentals of Linux (II)

—–Linux common commands (II)—–

3. File search command

3.1 file search command locate


Fast search speed (in learning, we should look far and enlarge a little, and imagine the situation of large amount of data or large-scale problems)

Locate file name

–Working principle:

Search by file name in background database

Therefore, newly created files are often not searchable (disadvantages)

Solution: wait (1 day); The updatedb command updates the database


You can only search by file name (weak function) – understanding is to sacrifice function to improve speed

–Search / update configuration:

vi /etc/updatedb.conf


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”

The first line is whether to execute the following update rules

This is followed by not searching for these folders / files

So sometimes the contents of some directories cannot be searched — such as the commonly used / tmp

3.2 search commands whereis and which

3.2.1 whereis


[[email protected] ~]# whereis ls
ls: /bin/ls /usr/share/man/man1p/ls.1p.gz /usr/share/man/man1/ls.1.gz

You can search the directory of the command and the directory of its help documents (so where is the command, and remember that everything in Linux is a file)


-B find only executable files

-M find help files only

[[email protected] ~]# whereis -b mkdir
mkdir: /bin/mkdir

3.2.2 which


[[email protected] ~]# which ls
alias ls=’ls –color=auto’

Aliases, if any, will also be found.

Different colors will be displayed here LS automatically

[[email protected] ~]# which pwd

It’s the same without aliases, but there’s no help documentation

3.2.3 other instructions

–Command not found

[[email protected] ~]# 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)
[[email protected] ~]# where cd
-bash: where: command not found

Some types cannot be found because the shell comes with them (learn later)

–Path environment variable

The basic path set by the environment, such as the above (/ usr / lib / qt-3.3 / bin: / usr / local / SBIN: / usr / local / bin: / SBIN: / bin: / usr / SBIN: / usr / bin: / root / bin)

It allows us to enter commands without absolute paths — and so does windows

Or that sentence, it’s all documents

Definition of path environment variable: the path of the system search command

Write your own programs, either write absolute paths for commands, or put them in these path paths

3.3 find command

The most powerful search command – learn only basic and common usage here


Find [search scope] [search criteria] file name

[[email protected] ~]# find / -name install.log

You will find that the speed is very slow – the range is too large

And the real situation will be more complex, possibly slower and more stressful

——Try to narrow it down!

Moreover, if fuzzy matching is planned, such as install.log.syslog. This command cannot be found. To perform wildcard matching, the wildcard is an exact match


*Match any content

[[email protected] ~]# find /root -name "install.log*"

? Match any character

[] matches any character in brackets

[[email protected] ~]# find /root -name "*[asdf]?"

Note that find is an exact match. Be careful

–Search criteria

find /root -name   install.log   Search by file name

find /root -inname install.log    Case insensitive

find /root -user install.log   Search by owner (not commonly used)

Find / root – nouser searches all files without an owner (commonly used) – many of these files are garbage files, but there are two exceptions – created by the kernel (in sys); Foreign files (such as USB flash disk)

find /var/log -mtime +10   Find the file modified 10 days ago – atime file access time, mtime modify file time, CTime change file attributes+ Files modified 10 days ago, – 10 days within 10 days, 10 days on the same day (note that there is no 10 days later, ha ha) – commonly used in log deletion / filtering (by day by default)

Find. – size 25K search for 25K files in the current directory – + 25 or – 25 is also acceptable

[[email protected] ~]# find . -size 25k
[[email protected] ~]# ll
Total dosage 48
-RW ------. 2 root 1273 November 26 05:32 Anaconda ks.cfg
-Rw-r -- R --. 1 root 0 November 26 06:05 cangls
-Rw-r -- R --. 1 root 26420 November 25 03:55 install.log
-Rw-r -- R --. 1 root 7572 November 25 03:52 install.log.syslog
Drwxr-xr-x. 3 root 4096 November 26 05:43 Japan
[[email protected] ~]# find . -size +25k
[[email protected] ~]# find . -size -25k
[[email protected] ~]# find . -size -25m
Find: invalid - size type'm '
[[email protected] ~]# find . -size -25M
[[email protected] ~]#

Note that MB is uppercase m and KB is lowercase K

Find. – inum 213123 searches the current directory for 213123 files according to the I node – often used with LS – I

-Complex operation

Find / etc - Size + 20K - A - size - 50K where - A is and, - O is or
[[email protected] ~]# find /etc -size +20k -a -size -50k
find /etc -size +20k -a -size -50k -exec ls -lh {} \;
[[email protected] ~]# find /etc -size +20k -a -size -50k -exec ls -lh {} \;
-RW ------. 1 root 37k November 25 03:46 / etc / SELinux / targeted / modules / active / modules / unprivuser.pp
-RW ------. 1 root 26k November 25 03:46 / etc / SELinux / targeted / modules / active / modules / xguest.pp
-RW ------. 1 root 24K November 25 03:46 / etc / SELinux / targeted / modules / active / modules / virt.pp
-RW ------. 1 root 31k November 25 03:46 / etc / SELinux / targeted / modules / active / modules / postfix.pp
-RW ------. 1 root 29K November 25 03:46 / etc / SELinux / targeted / modules / active / modules / unconfineduser.pp
-RW ------. 1 root 21k November 25 03:46 / etc / SELinux / targeted / modules / active / modules / nagios.pp
-RW ------. 1 root 21k November 25 03:46 / etc / SELinux / targeted / modules / active / modules / cups.pp
-RW ------. 1 root 26k November 25 03:46 / etc / SELinux / targeted / modules / active / modules / rhcs.pp
-RW ------. 1 root 27K November 25 03:46 / etc / SELinux / targeted / modules / active / modules / apache.pp
-RW ------. 1 root 42K November 25 03:46 / etc / SELinux / targeted / modules / active / modules / staff.pp
-RW ------. 1 root 24K November 25 03:46 / etc / SELinux / targeted / modules / active / modules / samba.pp
-Rw-r -- R --. 1 root 43K September 23, 2011 / etc / mime.types
-Rw-r -- R --. 1 root 30K July 22, 2014 / etc / sysconfig / network scripts / network functions IPv6
-Rw-r -- R --. 1 root 27K February 20, 2014 / etc / postfix / main.cf
-Rw-r -- R --. 1 root 40K November 25 03:52 / etc / ld.so.cache
-Rw-r -- R --. 1 root 23K October 16, 2014 / etc / libreport / events / Report_ RHTSupportAttach.xml
-Rw-r -- R --. 1 root 22K October 16, 2014 / etc / libreport / events / Report_ RHTSupport.xml
-Rw-r -- R --. 1 root 28K November 11, 2010 / etc / makedev. D / 01linux-2.6. X
-Rw-r -- R --. 1 root 27K November 12, 2010 / etc / sound / events / gnome-2.soundlist

Here, the second command is added with – exec to execute the previous results, and {} /;


Find is very powerful, with many functions and flexibility; At the same time, the use is complex and the speed is not easy to determine

3.4 grep command


Search string: grep [options] string file name

[[email protected] ~]# 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

Note that instead of the file matching the string, the corresponding string in the file is searched — different from find


-V is negative, that is, the value that does not contain a string

-I is not case sensitive

–And find

Find: find file + exact match + use wildcard match

Grep: find string + contain match + use regular expression match


2、 PHP and MySQL

—–Practice of article publishing system (I)—–

Understand the method of PHP operating mysql, and be familiar with the MySQL functions of PHP

1. Demand analysis

1.1 background management system

Management – List

Publish, modify, delete – program

1.2 front desk display system

Article list, article content page

1.3 database design

A table can be used to store articles

(I don’t want to draw tables. Just write the database command. I hope I can understand it in the future.)

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 project planning

What documents are required for the project

2. Background management system

2.1 creating configuration files and initialization files

Recommended Today

SQL exercise 20 – Modeling & Reporting

This blog is used to review and sort out the common topic modeling architecture, analysis oriented architecture and integration topic reports in data warehouse. I have uploaded these reports to GitHub. If you are interested, you can have a lookAddress:https://github.com/nino-laiqiu/TiTanI recorded a relatively complete development process in my hexo blog deployed on GitHub. You can […]