CentOS commands include: system commands, various server construction, etc

Time:2021-10-26

Now, let’s introduce these common CentOS commands.

1: Use CentOS common commands to view CPUs

more /proc/cpuinfo | grep “model name”
grep “model name” /proc/cpuinfo
[[email protected] /]# grep “CPU” /proc/cpuinfo
model name : Intel(R) Pentium(R) Dual CPU E2180 @ 2.00GHz
model name : Intel(R) Pentium(R) Dual CPU E2180 @ 2.00GHz
If you feel you need to see more comfortable
grep “model name” /proc/cpuinfo | cut -f2 -d:

2: View memory using CentOS common commands

grep MemTotal /proc/meminfo grep MemTotal /proc/meminfo | cut -f2 -d: free -m |grep “Mem” | awk ‘{print $2}’

3: Use CentOS common commands to check whether the CPU is 32-bit or 64 bit

View CPU bits (32 or 64)
getconf LONG_BIT

4: Use CentOS common commands to view the current version of Linux

more /etc/redhat-release
cat /etc/redhat-release

5: Use CentOS common commands to view the kernel version

uname -r
uname -a

6: Use CentOS common commands to view the current time

How to synchronize time has been described above in date

7: Use CentOS common commands to view hard disks and partitions

df -h
fdisk -l
You can also view partitions
du -sh
You can see the total occupied space
du /etc -sh
You can see the size of this directory

8: Use CentOS common commands to view installed packages

Check the software packages installed during system installation
cat -n /root/install.log
more /root/install.log | wc -l
Check which packages are now installed
rpm -qa
rpm -qa | wc -l
yum list installed | wc -l
However, it is strange that the number of installed packages I query through rpm and Yum is different. No reason was found.
9: Use CentOS common commands to view the keyboard layout
cat /etc/sysconfig/keyboard
cat /etc/sysconfig/keyboard | grep KEYTABLE | cut -f2 -d=
10: Use CentOS common commands to view SELinux
sestatus
sestatus | cut -f2 -d:
cat /etc/sysconfig/selinux
11: Use CentOS common commands to view IP and MAC addresses
In the ifcfg-eth0 file, you can see Mac, gateway and other information. ifconfig cat /etc/sysconfig/network-scripts/ifcfg-eth0 | grep IPADDR cat /etc/sysconfig/network-scripts/ifcfg-eth0 | grep IPADDR | cut -f2 -d= ifconfig eth0 |grep “inet addr:” |awk ‘{print $2}’|cut -c 6- ifconfig | grep ‘inet addr:’| grep -v ‘127.0.0.1’ | cut -d: -f2 | awk ‘{ print $1} ‘view gateway cat / etc / sysconfig / network view DNS cat / etc / resolv.conf XII: use CentOS common commands to view the default language
echo $LANG $LANGUAGE
cat /etc/sysconfig/i18n
12: Use CentOS common commands to view the time zone and whether to use UTC time
cat /etc/sysconfig/clock
13: Use CentOS common commands to view host names
hostname
cat /etc/sysconfig/network
To modify the host name is to modify this file. At the same time, it is best to modify the host file.

14: Use CentOS common commands to view the startup and running time
uptime
09:44:45 up 67 days, 23:32, …
It seems that it was really a network segment problem just now. My machine was started 67 days ago.
#System resource usage
vmstat 1 -S m procs ———–memory———- —swap– —–io—- –system– —–cpu—— r b swpd free buff cache si so bi bo in cs us sy id wa st 0 0 0 233 199 778 0 0 4 25 1 1 3 0 96 0 0 0 0 0 233 199 778 0 0 0 0 1029 856 13 1 86 0 0

15: Use CentOS common commands to view the startup and running time
uptime
09:44:45 up 67 days, 23:32, …
It seems that it was really a network segment problem just now. My machine was started 67 days ago.
#System resource usage
1. vmstat 1 -S m
2. procs ———–memory———- —swap– —–io—- –system– —–cpu——
3. r b swpd free buff cache si so bi bo in cs us sy id wa st
4. 0 0 0 233 199 778 0 0 4 25 1 1 3 0 96 0 0
5. 0 0 0 233 199 778 0 0 0 0 1029 856 13 1 86 0 0
6.
Recommend a Linux CentOS system that is easy to use. For example, let’s understand the Linux CentOS system, and then give a comprehensive introduction to the Linux CentOS system. I hope you can use the commands commonly used by Linux CentOS
wget$ wget -r -np -nd http://example.com/packages/ This command can be downloaded http://example.com All files in the packages directory on the web site. Linux CentOS, where, – NP is used not to traverse the parent directory, and – nd means not to recreate the directory structure locally.
$ wget -r -np -nd –accept=iso http://example.com/centos-5/i386/ Similar to the previous command, Linux CentOS adds an — accept = ISO option, which instructs WGet to download only all files with ISO extension in i386 directory. You can also specify multiple extensions. Linux CentOS can be separated by commas.
$WGet – I filename.txt this command is often used for batch downloading. Linux CentOS puts the addresses of all files to be downloaded into filename.txt, and then WGet will automatically download all files for you. Linux CentOS$ wget -c http://example.com/really-big-file.iso The – C option specified here is used for breakpoint continuation.
$ wget -m -k (-H) http://www.example.com/ This command can be used to mirror a website, and WGet will convert the links. Linux CentOS if the images in the website are placed in another site, you can use the – H option.

VI edit command mode
Move Cursor
[Ctrl] + [F] → move the screen down one page, which is equivalent to pressing the [page down] key
[Ctrl] + [b] → move the screen up one page, which is equivalent to pressing the [page up] key
N < space > → n stands for “number”. Press the number and then press the blank key, and the cursor will move n characters in this line to the right
0 → number “0”: move to the first character of this line
$→ move to the last character of this line
G → move to the last line of this file
Ng → n is a number. Move to line n of this file (can cooperate with: set nu)
GG → move to the first line of this file, which is equivalent to 1g
N < ENTER > → n is a number. Move the cursor down n lines
Linux CentOS find and replace
N → “repeat the previous search action”
N → just opposite to N, perform the previous search action for “reverse”
: N1, N2S / word1 / word2 / g → N1 and N2 are numbers. Find the word1 string between lines N1 and N2 and replace it with word2.
For example, if eric4ever is found between lines 1 and 9 and replaced with eric4ever, then: “1,9s / eric4ever / eric4ever / g”
: 1, $s / word1 / word2 / g → find the word1 string from the first line to the last line and replace it with word2
: 1, $s / word1 / word2 / GC → find the word1 string from the first line to the last line, and replace the character window with word2. Before replacement, a prompt dialog box will be displayed to confirm the replacement

Linux CentOS delete, copy and paste
x. X → in a line of words, X is to delete a character backward (equivalent to [del] key),
X is to delete a character forward (equivalent to [backspace] key)
DD → delete the entire line where the cursor is located
NDD → n is a number. Delete the down n column where the cursor is located
YY → copy the line where the cursor is located
NYY → n is a number. Copy the down n column of the cursor
p. P → P is to paste the copied content on the next line under the cursor, and P is to paste on the previous line of the cursor
U → restore the previous action
[Ctrl] + R → redo the previous action
. → decimal point, which means to repeat the previous action
Linux CentOS editing mode I, I → insert: insert the input text at the current cursor, and the existing text will go back; Where, I is “insert from the current cursor”, I is “insert at the first non blank character of the current line”, a → A is “insert from the next character of the current cursor”, and a is “insert from the last character of the current line”
o. O → O means “insert a new line at the next line where the current cursor is located”, and O means “insert a new line at the previous line where the current cursor is located”
r. R → R is “replace the character where the cursor is located”, and R is “always replace the text where the cursor is located until ESC is pressed”
ESC → exit editing mode and return to normal mode
Linux CentOS last line instruction mode
: W → write the edited file to the hard disk
: Q → exit VI
: set Nu → display line number
: set nonu → cancel display of line number
Linux centosvim block operation
CTRL + V to enter view mode
< ESC > Exit view mode
After Ctrl + V:
< dollar > + a add at the end of each row of the block
I insert
Y-block extraction
P block paste
C modification
Linux CentOS has been widely used, but it is also constantly updated. Here we introduce the installation and use of Linux CentOS to help you install and update the Linux CentOS system and manually configure the IP address of Linux CentOS
Today, a centos-4.7 is installed on the VMware server (the free RedHat is a clone version of little red riding hood, which corresponds to the version of little red riding hood). The IP is not set during installation. Generally, the IP address of the network card of Linux CentOS is stored in a file. This configuration file is under / etc / sysconfig / network scripts,
The names are ifcfg-eth0 and ifcfg-eth1… If you have a network card, there is only one file ifcfg-eth0. If you have two or more network cards, there will be files such as ifcfg-eth1 and ifcfg-eth2.

File structure:
Device = eth0 / / indicates the device name
Onboot = yes / / start the application
Bootproto = static / / startup type (default DHCP)
IPADDR = 192.168.0.77 / / IP address
Netmask = 255.255.255.0 / / subnet mask
Gateway = 192.168.0.1 / / gateway
Steps:
1. VI / etc / sysconfig / network scripts / ifcfg-teh0 (can also be set through the management tool setup or netconfig command)
2. Restart network serviceservice network restart
To connect to the host: you also need to configure the XP host and set the host only mode on VMware. In XP, modify the IP address of VMnet1 to 192.168.0.1 and the IP address of Linux CentOS to 192.168.0.77
Shared Internet access settings: in XP, modify the network attribute of the first virtual network card to shared Internet (attribute – > Advanced – > check “allow other network users to connect through the Internet connection of this computer”), VMnet1 will be automatically changed to 192.168.0.1, and Linux CentOS can access the Internet
CentOS vsftpd configuration has been developed for a long time. Here I give my personal understanding. Here’s the CentOS vsftpd configuration. Adjust CentOS vsftpd profile:
1. Back up the CentOS vsftpd configuration file before editing it
[[email protected] ~]cp /etc/vsftpd/vsftpd.conf /etc/vsftpd/vsftpd.conf.backup
2. Edit the main CentOS vsftpd configuration file vsftpd.conf
[[email protected] ~]vi /etc/vsftpd/vsftpd.conf
Here, I will completely record the modification of the original CentOS vsftpd configuration file. I will keep comments on the original configuration wherever it is modified. My understanding of each configuration item is added. For some key configuration items, I have made my views here, and I will not delete the original English description for reference and comparison.
Example config file /etc/vsftpd/vsftpd.conf
The default compiled in settings are fairly paranoid. This sample file
loosens things up a bit, to make the ftp daemon more usable.
Please see vsftpd.conf.5 for all compiled in defaults.
READ THIS: This example file is NOT an exhaustive list of vsftpd options.
Please read the vsftpd.conf.5 manual page to get a full idea of vsftpd’s
capabilities.
Allow anonymous FTP? (Beware – allowed by default if you comment this out).
anonymous_enable=YES
anonymous_enable=NO
Set not to allow anonymous access

Uncomment this to allow local users to log in.
local_ Enable = yes sets that local users can access. Note: it is mainly a virtual host user. If this item is set to no, all virtual users will not be able to access it.
Uncomment this to enable any form of FTP write command.
write_enable=YES
Setting allows write operations.
Default umask for local users is 077. You may wish to change this to 022,
if your users expect that (022 is used by most other ftpd’s)
local_umask=022
Set the permission mask of the uploaded file.
Uncomment this to allow the anonymous FTP user to upload files. This only
has an effect if the above global write enable is activated. Also, you will
obviously need to create a directory writable by the FTP user.
anon_upload_enable=YES
anon_upload_enable=NO
Anonymous users are not allowed to upload.
Uncomment this if you want the anonymous FTP user to be able to create
new directories.
anon_mkdir_write_enable=YES
anon_mkdir_write_enable=NO
Anonymous users are not allowed to create directories.
Activate directory messages – messages given to remote users when they
go into a certain directory.
dirmessage_enable=YES
Set to enable the directory slogan function.
Activate logging of uploads/downloads.
xferlog_enable=YES
Set to turn on the logging function.

Make sure PORT transfer connections originate from port 20 (ftp-data).
connect_from_port_20=YES
Set port 20 for data connection.
If you want, you can arrange for uploaded anonymous files to be owned by
a different user. Note! Using “root” for uploaded files is not
recommended!
chown_uploads=YES
chown_uploads=NO
Setting prevents uploading files and changing hosts.
chown_username=whoever
You may override where the log file goes if you like. The default is shown
below.
xferlog_file=/var/log/vsftpd.log
Set the service log saving path configured by CentOS vsftpd. Note that the file does not exist by default. You must manually touch it out, and because the service host user of CentOS vsftpd configuration has been changed here, it is a manually established vsftpd. Attention must be paid to giving the user write permission to the log, otherwise the service will fail to start.
If you want, you can have your log file in standard ftpd xferlog format
xferlog_std_format=YES
Set the log to use the standard recording format.
You may change the default value for timing out an idle session.
idle_session_timeout=600
Set the idle connection timeout. The default is used here. Leave the specific value for each specific user to specify. Of course, if not specified, the default value here is 600, in seconds.

You may change the default value for timing out a data connection.
data_connection_timeout=120
Set the maximum continuous transmission time for a single time. The default is used here. Leave the specific value for each specific user to specify. Of course, if not specified, the default value here is 120, in seconds.
It is recommended that you define on your system a unique user which the
ftp server can use as a totally isolated and unprivileged user.
nopriv_user=ftpsecure
nopriv_user=vsftpd
Set the hosting user supporting CentOS vsftpd service as the manually established vsftpd user. Note that once you change the host user, you must pay attention to the read-write empowerment of the read-write files related to the service. For example, the log file must be given the user write permission, etc.
Enable this and the server will recognise asynchronous ABOR requests. Not
recommended for security (the code is non-trivial). Not enabling it,
however, may confuse older FTP clients.
async_abor_enable=YES
Set to support asynchronous transmission function.
By default the server will pretend to allow ASCII mode but in fact ignore
the request. Turn on the below options to have the server actually do ASCII
mangling on files when in ASCII mode.
Beware that on some FTP servers, ASCII support allows a denial of service
attack (DoS) via the command “SIZE /big/file” in ASCII mode. vsftpd
predicted this attack and has always been safe, reporting the size of the
raw file.
ASCII mangling is a horrible feature of the protocol.
ascii_upload_enable=YES
ascii_download_enable=YES
Set the upload and download functions that support ASCII mode.
You may fully customise the login banner string:
ftpd_banner=This Vsftp server supports virtual users ^_^
Set the login banner of CentOS vsftpd configuration.
You may specify a file of disallowed anonymous e-mail addresses. Apparently
useful for combatting certain DoS attacks.
deny_email_enable=YES

(default follows)
banned_email_file=/etc/vsftpd/banned_emails
You may specify an explicit list of local users to chroot() to their home
directory. If chroot_local_user is YES, then this list becomes a list of
users to NOT chroot().
chroot_list_enable=YES
chroot_list_enable=NO
Prohibit users from logging out of their FTP home directory.
(default follows)
chroot_list_file=/etc/vsftpd/chroot_list
You may activate the “-R” option to the builtin ls. This is disabled by
default to avoid remote users being able to cause excessive I/O on large
sites. However, some broken FTP clients such as “ncftp” and “mirror” assume
the presence of the “-R” option, so there is a strong case for enabling it.
ls_recurse_enable=YES
ls_recurse_enable=NO
Prohibit users from using the command “LS – R” after logging into FTP. This command incurs huge overhead on server performance. If this item is allowed, the service will be blocked when multiple users use this command at the same time
The server poses a threat.
When “listen” directive is enabled, vsftpd runs in standalone mode and
listens on IPv4 sockets. This directive cannot be used in conjunction
with the listen_ipv6 directive.
listen=YES
Set the CentOS vsftpd service to work in standalone mode. By the way, the so-called standalone mode means that the service has its own daemon support. Under the PS – a command, we can see the daemon name of vsftpd. If you do not want to work in standalone mode, you can choose superdaemon mode. In this mode, vsftpd will not have its own daemon, but will be fully represented by the super daemon xinetd. At the same time, many functions of vsftp service will not be realized.
This directive enables listening on IPv6 sockets. To listen on IPv4 and IPv6
sockets, you must run two copies of vsftpd whith two configuration files.
Make sure, that one of the listen options is commented !!
listen_ipv6=YES
pam_service_name=vsftpd

Set the CentOS vsftpd configuration verification file name under PAM service. Therefore, PAM validation will refer to the vsftpd file configuration under / etc / PAM. D /.
userlist_enable=YES
Set userlist_ Users in file will not be allowed to use FTP.
tcp_wrappers=YES
Set support for TCP wrappers.
KC: The following entries are added for supporting virtual ftp users.
The following are important CentOS vsftpd configuration items about vsftpd virtual user support. These setting items are not included in the default vsftpd.conf, and you need to add the configuration manually.
guest_enable=YES
Set and enable the virtual user function.
guest_username=overlord
Specifies the host user for the virtual user.
virtual_use_local_privs=YES
Set the permissions of virtual users to match their host users.
user_config_dir=/etc/vsftpd/vconf
Set the storage path of the configuration file of the virtual user’s personal vsftp. In other words, the specified directory will store the profile of each vsftp virtual user’s personality, which needs attention
The point is that these profile names must be the same as the virtual user name. Save and exit.
3. Create the log file of CentOS vsftpd configuration and change it to the service host user of vsftpd:
[[email protected] ~]touch /var/log/vsftpd.log
[[email protected] ~]chown vsftpd.vsftpd /var/log/vsftpd.log
4. Create a storage path for CentOS vsftpd configuration files of virtual users:
[[email protected] ~]mkdir /etc/vsftpd/vconf/
CentOS vsftp has been widely used, but it is also constantly updated. Here are the CentOS vsftp installation settings to help you install and update the CentOS vsftp system.

CentOS vsftp installation:
1. Install CentOS vsftpd service related components:
[[email protected] ~]# yum install vsftpd*
2. Confirm the installation of PAM service related parts:
[[email protected] ~]# yum install pam*
In fact, it doesn’t matter if the development package is not installed. The main purpose is to confirm PAM.
3. Install DB4 component package:
A DB4 package is specially installed here to support file database.
[[email protected] ~]# yum install db4*
CentOS vsftp system account
1. Establish the host user of CentOS vsftp service:
[[email protected] /]#chmod 700 /home/vftpsite
[[email protected] ~]# useradd vsftpd -s /sbin/nologin
The default service host user of vsftpd is root, but this does not meet the needs of security. Here, a user named vsftpd is established as the service host user supporting vsftpd. Since this user is only used to support vsftpd service, it is not necessary to allow him to log in to the system, and he is set as a user who cannot log in to the system. [ [email protected] /]#useradd –d /home/vftpsite –s /sbin/nologin vftpuser
2. Create CentOS vsftp virtual host user:
[[email protected] nowhere]# useradd overlord -s /sbin/nologin
This article mainly introduces the virtual users of vsftp. Virtual users are not system users, that is, these FTP users do not exist in the system. Their overall permissions are actually concentrated on a user in the system. The so-called virtual host user of vsftpd is such a host user that supports all virtual users. Since it supports all virtual users of FTP, its own permissions will affect these virtual users. Therefore, in consideration of security, it is also necessary to pay attention to the control of the user’s permissions. The user is absolutely not necessary to log in to the system. Here, it is also set as a user who cannot log in to the system.
(insert a sentence here: when establishing the above two users, I didn’t even want to give the user’s home path. I wanted to add – D / home / nowhere, according to the man useradd manual
Description: “- D, — home home_dir”
The new user will be created using HOME_DIR as the value for the
User login directory. The default is to append the login name to
BASE_DIR and use that as the login directory name. The directory
HOME_DIR does not have to exist but will not be created if it is
missing.
Use the – D parameter to specify the user’s home directory, which does not have to exist. If the specified directory does not exist, it will not be created. As a result, when I try to specify – D / home / nowhere to a directory that does not exist, I Kao! I even created a new one for myself = =)
[original] FTP service is an old application on the Internet. So far, Interner has a wide range of applications, but what makes administrators headache is its user management, which is both numerous and complex. How to solve this problem? MySQL combined with proftp or vsftp software can build an efficient, stable and centrally managed FTP server. Let’s talk about how to build a convenient FTP server based on MySQL database.

1、 Selection of software version:
To build a database-based FTP server, we must first select the appropriate software. Here are the details of the selected software:
◆ Linux version RHEL5;
◆ MySQL version mysql-standard-5.1.30-1.rhel5.src.rpm;
◆ FTP servers proftpd-1.3.2.tar.gz and vsftpd-2.2.1.tar.gz;
◆ MySQL PAM verification program_ mysql-0.8RC1.tar.gz;
It should be noted that during RHEL5 installation, “development tools” must be selected, otherwise the software package required for compiling and debugging software needs to be installed separately; Secondly, ensure that mysql, FTP server and other software are not installed when installing the Linux system. If so, uninstall it first; Thirdly, proftpd and vsftpd should not be used on the same computer at the same time, which will cause unexpected problems. Readers choose one of them according to their own needs and the specific functions of the software.
Create program installation directory
During the whole installation process, execute the following commands as root user:
#cd /soft/programe
#mkdir mysq
Note the case of directory names.
#mkdir proftpd
#mkdir pam_mods
The installation directory of MySQL is / soft / program / MySQL, and the installation directory of proftpd is / soft / program / proftpd, PAM_ The installation directory of mysq1.so is / soft / program / PAM_ Mods, / storage is an existing directory where all FTP users upload and download files.
Install MySQL
◆ add a user and group to manage MySQL:
#groupadd mysqlgrp
#useradd -g mysqlgrp mysqladm
#passwd mysqladm
◆ switch to the directory where mysql-stan-day-5.1.30-1.rhel5.src.rpm file is located, and perform the following steps for installation:
#rpm-ivh MySQL-stan-dard-5.1.30-1.rhel5.src.rpm
This command extracts the mysql-5.1.30.tar.gz file and stores it in the following directory.
#cd /usr/src/redhat/SOURCE
#tar zxvf mysqt-5.1.30.tar.gz
#cd mysql-5.1.30
#./configure Prefix=/soft/program/mysql –with-extra-charsets=all
The “– prefix = / soft / program / MySQL” parameter is used to specify the installation directory of MySQL, and “– with extra charsets = all” is used to support all character sets.
#make
#make install

◆ initialize the database
#cd /soft/program/mysql/bin
#./mysql_install_db
◆ for security, modify the master information and access mode of the database storage directory. / soft / program / mysqll / var is the default directory for database storage
#cd /soft/program/mysql
#chown –R mysqladm:mysqlgrp var
#chmod -R go-wrx var
◆ modify the configuration file
#cd /soft/program/mysql/share/mysql
#cp my-small.cnf /etc/my.cnf
#cd /etc
In my.cnf file, add the following contents:
[mysql]
User = mysqladm # means start MySQL with mysqladm user#
Default character set = utf8 # indicates that UTF-8 character set is used. This character set has good universality and supports Chinese. Of course, GBK can also be used directly.
[clent]
Default-character-set=utf8
◆ start
There are two startup methods, one is manual startup and the other is automatic startup. The operation of manual startup is as follows:
#cd /soft/program/mysql/bin
#./mysqld_safe&
For automatic startup, you need to add the following contents to / etc / rc.d/rc/local to start the MySQL database automatically after startup:
If [-x /soft/program/mysql/bin/mysqld_safe]; then
install_path_name /bin/mysqld_safe&
fi

◆ change the administrator password
Use the following command to modify the database password:
#cd /soft/program/mysql/bin
#./mysqladmin -h localhost -u root password ‘123456’
The above command means the default management account root of the management database used on the machine (- H host). Note that this root is not the root user in the Linux system, and the password is set to 123456

Install proftpd
◆ switch to the directory where the proftpd-1.3.2.tar.gz file is located, and perform the following steps for installation:
#tar zxvf proftpd-1.3.2.tar.gz
#cd proftpd-1.3.2
#./configure–prefix=/soft/program/proftpd –with-modules=mod_sql:mod_sql_mysql:mod_quotatab:mod_quotatab_sql
This parameter adds support for MySQL and quota modules.
–with-includes=/soft/program/mysql/include/mysql
The above parameters specify the directory path of include in MySQL.
–with-libraries=/soft/program/mysql/lib/mysql
This parameter specifies the directory path of Lib in MySQL.
#make
#make install
Use the following command to establish a Linux system account and group for managing proftpd.
#groupadd -g 2009 ftpgroup
#useradd -u 2009 –s /bin/false -d /storage -g ftpgroup ftpuser
#chown -R ftpuser.ftpgroup /storage
#chmod –R go-wrx- /storage
#chmod –R u+wrx /storage
Simply modify the proftpd configuration file to make it work properly:
#cd /soft/program/proftpd/etc
Open proftpd.conf with an editor and modify the following contents:
#Set the user and group under which the server will run.
User ftpuser
Group ftpgroup

◆ start proftpd
There are also two methods to start proftpd, i.e. manual startup and automatic startup. The manual startup operations are as follows:
#cd /soft/program/proftpd/sbin/
#./proftpd
At this time, a basic FTP server has been built and can be tested. It should be noted that if an error with the following information occurs during startup:
error while loading shared libraries:libmysqlclient.so.15:cannot open shared object file:No such file or directory
The usual solutions are as follows:
#cd /etc
Open ld.so.conf with text tool and add the following content / soft / program / MySQL / lib / MySQL
#ldconflg
Update ld.so cache file.
To enable proftpd to start automatically, add the following contents to / etc / rc.d/rc.local to start proftpd automatically:
/soft/program/proftpd/sbin/proftpd

2、 Combination of MySQL and proftpd
Create a database named FTP in mysql, and create the following four tables in the database:
◆ in the user table ftpusers of the FTP server, the field information is as follows. These fields are required, and other fields are added according to their own needs. The reference fields are as follows:
‘userid’ text not null # user login account#
‘passwd’ text not null # user login password#
‘uid’ int (11) not null default ‘2009’ # consistent with the uid number of the Linux system account ftpuser#
‘GID’ int (11) not null default ‘2009’ # and Linux system group#
The GID number of ftpgroup is the same as’ homedir ‘text. If the account name is ABC, fill in / storage / ABC,’ shell ‘text default’, ‘/ SBIN / nologin’ here to specify whether the user can log in to the Linux system. The default here is not to log in.
◆ the field information of FTP user attribution table ftpgroups is as follows. The purpose of establishing this group will be described in the quotalimits table
‘groupname’ text not null # group name#
‘GID’ smallint (6) not null default ‘0’, # group ID number#
‘members’ text not null # member#
◆ the tables quotalimits and quotallies are used to set information related to disk quota. Please do not change the fields of these two tables. They are closely related to the configuration file of proftpd. The field information of the table quotalimits is as follows:
‘name’ varchar(30)default NULL,
‘quota_type’ enum(‘user’,’group’,’class’,’all’)NOT NULL default ‘user’,
‘per_session’ enum(‘false’,’true’)NOT NULL default’false’,
‘limit_type’ enum(‘soft’,’hard’)NOT NULL default’soft’,
‘bytes_in_avail’float NOT NULL default’0’,
‘bytes_out_avail’float NOT NULL default’0’,
‘bytes_xfer_avail’float NOT NULL default’0’,
‘files_in_avail’int(10) unsigned NOT NULL default’0’,
‘files_out_avail’int(10)unsigned NOT NULL default’0’,
‘files_xfer_avail’int(10)unsigned NOT NULL default’0’
It should be noted that name should be understood in this way. It can represent both a single user and a user group name. If in quota_ If group is used for authentication in type (quota type), the group name must be set here, so that the whole group has the characteristics of unified disk quota. Of course, group records should be inserted in the ftpgroups table, and users should be listed one by one in the member field. The default value can be null. If it is blank, there is a quota for the location_ The type set in type, such as quota_ If the type is set to user, it works for all users in ftpusers. If it is a group name, it also works for all groups in ftpgroups. quota_ Type disk quota type, which can be set as user or user group. If the name is written as a user group, you have to set it as group to identify it. The default is user authentication. per_ Session defaults to false.limit_ Type defaults to soft. Bytes_ in_ The space occupied by the available user, that is, the space capacity of the FTP user. The unit is byte. The default is 0. 0 is unlimited. The same is true below. bytes_ out_ Available is the sum of all downloaded files. The default value is 0.
bytes_ xfer_ Available is the sum of the upload and download traffic of a user, which is 0 by default. files_ in_ Available limits the total number of uploaded files. The default value is 0. files_ out_ Available limits the total number of downloaded files, which is 0 by default. files_ xfer_ The total number of files available for download and upload. The default value is 0. The field information of the quotes table. Refer to quotalimits for each field information. The configuration reference parameters are as follows:

name VARCHAR(30)NOT NULL,
quota_type ENUM(“user”,”group”,”class”,”all”)NOT NULL,
bytes_in_used FLOAT NOT NULL,
bytes_out_used FLOAT NOT NULL,
bytes_xfer_used FLOAT NOT NULL,
files_in_used INT UNSIGNED NOT NULL,
files_out_used INT UNSIGNED NOT NULL,
files_xfer_used INT UNSIGNED NOT NULL
In addition, add the following contents to proftpd.conf file:
◆ database connection information. FTP is the database name, localhost is the host name, root is the user name connecting to the database, and 123456 is the password.
root 123456
◆ the type of database authentication. Plaintext means plaintext authentication
SQLAuthTYpes Backend Plaintext
◆ specify the relevant information of the table used for user authentication
SALUserlnfo ftpusers userid passwd uid gid homedir shell
SQLGrouplnfo ftpgroups groupname gid members
◆ calibration data sheet
SQLAuthenticate users groups usersetfast groupsetfast
◆ if the home directory does not exist, the system will display it according to the home field in the ftpusers table.
Create a new directory:
SQLHomedirOnDemand on
◆ open the disk quota engine
QuotaEngine on
◆ set disk quota
QuotaDirectoryTally on

◆ set the unit of disk capacity display
QuotaDisplayUnits Mb
◆ set disk quota log file
QuotaLog”/usr/local/proftpd/var/quota”
◆ display disk quota information
After FTP login, execute the quote site quota command to view the current disk usage:
QuotaShowQuotas on
◆ set disk quota log file
QuotaLog”/var/log/quota”
◆ specify the database information used by the disk quota module
SQLNamedQuer get-quota-limit SELECT “name,quota_type,bytes_in_avail,bytes_out_avail,bytes_xfer_avail,files_in_avail,files_out_avail,files_xfer_avail FROM quotalimits WHERE name=’%{0}’AND quota_type=’%{1}'”
SQLNamedQuery get-quota-tally SELECT”name,quota_type,bytes_in_used,bytes_out_used,bytes_xfer_used,files_in_used,files_out_used,filed_xfer_used,FROM quotatallies WHERE name=’%{0}’AND quota_type =’%{1}”
SQLNamedQuery update-quota-tally UPDATE”bytes_in_used =bytes_in_used+%{0},bytes_out_used=bytes_out_used+%{1},bytes_xfer_used=bytes_xfer_used+%{2},files_in_used=files_in_used+%{3},files_out_used=files_out_used+%{4},files_xfer_used =files_xfer_used+%{5} WHERE name=’%{6}’AND quota_type = ‘%{7}'” quotatallies
SQLNamedQuery insert-quota-tally INSERT”%{0},%{1},%{2},%{3},%{4},%{5},%{6},%{7}”quotatallies
QuotaLimitTable sql:/get-quota-limit
QuotaTallyTable sql:/get-quota-tally/update-quota-tally/insert-quota-tally
In addition, readers can also add some contents about timeout, limiting the number of connections, speeding up the connection speed, supporting breakpoint transmission and secure transmission in proftpd.conf.
anon_other_write_enable=YES
ascll_upload_enable=YES
ascll_download_enable=YES
More settings can be made in the vsftpd configuration file, such as disk quota, establishment of virtual user personal directory, performance and load control, FTP passive mode settings, security settings, etc. readers can further improve them according to their own needs.
◆ edit files
Modify / etc / pam.d/ftp to remove other contents and add the following contents:
#auth
auth required/soft/program/pam_mods/pam_mysql.so
user=ftpuser passwd=6789host=localhost db=ftp
table=ftpusers usercolumn=userid passwdcolumn=passwd crypt=0
#account
Account required/soft/program/pam_mods/pam_mysql.so
User=ftpuser passwd=6789 host=localhost db=ftp table=ftpusers usercolumn=userid passwdcolumn=passwd crypt=0
The parameters involved can be understood as long as they correspond to the previous database settings. Where: crypt = 0, the password is saved in the database in clear text (not encrypted), crypt = 1, and the password is encrypted in the database using the DES encryption method of UNIX system; Crypt = 2. The password is encrypted by MySQL’s password() function and saved. The authorized user ftpusers and password of the ftpusers table in the FTP database must be set correctly.

◆ self start vsftpd
Please make the vsftpd-2.2.1/xinetd.d/vsftpd file into / etc / xinetd.d/ (if the file does not exist in this directory). In addition, you need to set listen and TCP in vsftpd.conf_ Wrappers parameter, set them to no, and finally, use ntsysv command to select vsftpd daemon.
Through the above knowledge, combined with Apache, PHP and other software, many functions can be developed, such as automatically applying for home page space. Moreover, using phpMyAdmin can manage MySQL in a Web way, which is easy to add and delete users, so that FTP user management is much easier.