Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the common commands in CentOS?

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

In this issue, the editor will bring you what are the commonly used CentOS commands. The article is rich in content and analyzes and narrates it from a professional point of view. I hope you can get something after reading this article.

One: use CentOS common commands to view cpu

More / proc/cpuinfo | grep "model name"

Grep "model name" / proc/cpuinfo

[root@localhost /] # 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 the need to see more comfortable

Grep "model name" / proc/cpuinfo | cut-f2-d:

Second: use common CentOS commands to view memory

Grep MemTotal / proc/meminfo grep MemTotal / proc/meminfo | cut-f2-d: free-m | grep "Mem" | awk'{print $2}'

Three: use CentOS common commands to check whether cpu is 32-bit or 64-bit.

View CPU digits (32 or 64)

Getconf LONG_BIT

Four: use CentOS common commands to view the current version of linux

More / etc/redhat-release

Cat / etc/redhat-release

Five: use common CentOS commands to check the kernel version

Uname-r

Uname-a

Six: use CentOS commands to view the current time

Date has already introduced how to synchronize time.

Seven: use common CentOS commands to view hard drives and partitions

Df-h

Fdisk-l

You can also view partitions

Du-sh

You can see all the space occupied.

Du / etc-sh

You can see the size of this directory

Eight: use CentOS common commands to view installed software packages

Check the software packages installed when the system is installed

Cat-n / root/install.log

More / root/install.log | wc-l

Check which packages have been installed now

Rpm-qa

Rpm-qa | wc-l

Yum list installed | wc-l

Strangely, however, the number of installation packages I have queried through rpm and yum is not the same. I can't find the reason.

Nine: use common CentOS commands to view keyboard layout

Cat / etc/sysconfig/keyboard

Cat / etc/sysconfig/keyboard | grep KEYTABLE | cut-f2-d =

Ten: use CentOS commands to check the selinux situation

Sestatus

Sestatus | cut-f2-d:

Cat / etc/sysconfig/selinux

Eleven: use CentOS common commands to view ip,mac addresses

You can see mac, gateway and other information in the ifcfg-eth0 file. 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.1'| cut-d:-f2 | awk'{print $1} 'View gateway cat / etc/sysconfig/network to view dns cat / etc/resolv.conf 12 : use CentOS common commands to view the default language

Echo $LANG $LANGUAGE

Cat / etc/sysconfig/i18n

Twelve: use CentOS common commands to check the time zone and whether to use UTC time

Cat / etc/sysconfig/clock

Thirteen: use CentOS common commands to view the hostname

Hostname

Cat / etc/sysconfig/network

To change the hostname is to modify the file, and it is best to modify the host file as well.

Fourteen: use common CentOS commands to check the boot running time

Uptime

09:44:45 up 67 days, 23:32,...

It seems that it was really the problem of the network segment just now. My machine was turned on 67 days ago.

# usage of system resources

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 2000 233 199 778 004 25 1 13 0 96 000 233 199 778 000 1029 856 13 1 86 00 0

Fifteen: use common CentOS commands to check the boot running time

Uptime

09:44:45 up 67 days, 23:32,...

It seems that it was really the problem of the network segment just now. My machine was turned on 67 days ago.

# usage of system resources

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 1029 856 13 1 86 0 0

6.

To recommend a very good use of the Linux CentOS system, such as let you have some understanding of the Linux CentOS system, and then a comprehensive introduction to the Linux CentOS system, I hope to be useful to you the commands commonly used in Linux CentOS.

The command wget$ wget-r-np-nd http://example.com/packages/ downloads all the files in the packages directory on the http://example.com website. In Linux CentOS, the function of-np is not to traverse the parent directory, and-nd means that the directory structure is not recreated locally.

$wget-r-np-nd-- accept=iso http://example.com/centos-5/i386/ is similar to the previous command, but Linux CentOS adds an extra-- accept=iso option, which instructs wget to download only all files in the i386 directory with the extension iso. You can also specify multiple extensions, and Linux CentOS only needs to be separated by commas.

$wget-I filename.txt this command is often used for bulk downloads. Linux CentOS puts the addresses of all the files you need to download into filename.txt, and wget will automatically download all the 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 site are placed on another site, you can use the-H option.

VI Edit Command Command Mod

Move the cursor

[Ctrl] + [f] → screen "move down" one page, equivalent to [Page Down] button

[Ctrl] + [b] → screen "move up" one page, equivalent to [Page Up] button

N → n stands for "number". Press the number and then press blank, and the cursor will move n characters of this line to the right.

0 → number "0": move to the first character of this line

$→ moves to the last character of the line

G → moves to the last line of the file

NG → n is a number. Move to the nth line of this file (match: set nu)

Gg → moves to the first line of the file, which is equivalent to 1G

N → n is a number. Move the cursor down n lines

Linux CentOS find and replace

N → "repeat the action of previous search"

N → is just the opposite of n, performing the previous search action for "reverse"

: N1 → n2sqqqword1qword2Universe g Word2 are both numbers. Find the word1 string between lines N1 and N2 and replace it with word2.

For example, if you look for eric4ever between lines 1 and 9 and replace it with ERIC4EVER, then: ": 1Magne9sUniteic4everbind ERIC4EVERERGUBG"

1 → → looks for the Word2 string from the first line to the last line and replaces it with word2

The → looks for the word1 string from the first line to the last line, and replaces the character window with word2. Before the replacement, the prompt dialog box is displayed to confirm the replacement.

Linux CentOS delete, copy, and paste

X, X → in a line of words, x divides one character backward (equivalent to [del] key)

X divides one character forward (equivalent to [backspace] key)

Dd → removes the entire line where the cursor is located

Ndd → n is a number. Delete the downward n-column where the cursor is located

Yy → copies the line where the cursor is located

Nyy → n is a number. Copy the downward n-column where the cursor is located

P, P → p pastes the copied content on the next line of the cursor, and P pastes the previous line of the cursor

U → restores the previous action

[Ctrl] + r → redo the last action

. → decimal point, which means to repeat the previous action

Linux CentOS editing mode I, I → insert: inserts the entered text at the current cursor, and the existing text goes back Where I is "insert from the current cursor", I is "insert at the first non-blank character of the current line", A → an is "insert from the next character of the current cursor", and An is "insert from the last character of the line where the cursor is located"

O, O → o insert a new line at the next line where the current cursor is located, and O insert a new line at the previous line at the current cursor.

R, R → r is "replace the character where the cursor is located" and R is "replace the text where the cursor is located until ESC is pressed"

Esc → exits editing mode and returns to normal mode

Linux CentOS last line instruction mode

W → writes the edited file to the hard disk

Q → exits vi

: set nu → displays the line number

: set nonu → cancels the display of line number

Linux CentOSvim block operation

Ctrl+v enters view mode

Exit view mode

After Ctrl+v:

+ An is added at the end of each line 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 use of Linux centos installation settings to help you install and update the Linux centos system to manually configure the IP address of Linux centos.

Today, I installed a centos-4.7 on vmware server (free redhat, a cloned version of Little Red Riding Hood, which corresponds to Little Red Riding Hood's version), in which ip was not installed properly. Generally, the IP address of the network card of Linux centos is stored in a file, and this configuration file is under / etc/sysconfig/network-scripts.

The names are ifcfg-eth0,ifcfg-eth2.... If you have a network card, there is only one file ifcfg-eth0. If you have two or more network cards, there will be ifcfg-eth2, ifcfg-eth3 and other files.

File structure:

DEVICE=eth0 / / indicate the device name

Whether ONBOOT=yes// starts the application

BOOTPROTO=static / / Startup type static (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 administrative tool setup or netconfig command)

2. Restart the network service service network restart

To connect to the host: configure the xp host, set it to host-only mode on vmware, modify the IP address of vmnet1 to 192.168.0.1 and Linux centos IP to 192.168.0.77 in xp.

Shared Internet access settings: modify the network attribute of the first virtual network card in xp to shared internet (attribute-> Advanced-> check "allow other network users to connect through the Internet connection of this computer") will automatically change the vmnet1 to 192.168.0.1 Magi Linux centos to be able to access the Internet.

CentOS Vsftpd configuration has been developed for a long time. I would like to publish my personal understanding here. I will talk about CentOS Vsftpd configuration here. Adjust the CentOS Vsftpd profile:

1. Back up the CentOS Vsftpd configuration file before editing

[root@KcentOS5 ~] cp / etc/vsftpd/vsftpd.conf / etc/vsftpd/vsftpd.conf.backup

two。 Edit the main CentOS Vsftpd profile Vsftpd.conf

[root@KcentOS5 ~] vi / etc/vsftpd/vsftpd.conf

Here I will fully record the changes to the original CentOS Vsftpd configuration file, and I will keep comments on the original configuration wherever they are modified. Including my understanding of each configuration item, for some of the more key configuration items here I have made my point of view, and I will not delete the original English instructions 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 local users to access. Note: mainly for virtual host users, if the project is set to NO, then all virtual users will not be able to access it.

Uncomment this to enable any form of FTP write command.

Write_enable=YES

Set to be able to write.

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 for 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 prohibited from uploading.

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 prohibited from creating 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 logging.

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

Set to prohibit the upload of files to change the host.

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 save path for CentOS Vsftpd configuration. Note that the file does not exist by default. You have to manually touch out, and the service host user that has changed the CentOS Vsftpd configuration here is the manually established Vsftpd. Care must be taken to give the user write permissions 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 a standard record 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 to each specific user to specify, of course, if not specified, or use the default value of 600 here, in seconds.

You may change the default value for timing out a data connection.

Data_connection_timeout=120

Set the maximum continuous transmission time at a time. The default is used here. Leave the specific value to each specific user to specify, of course, if not specified, or use the default value of 120 here, 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 host user of the supporting CentOS Vsftpd service to be a manually established Vsftpd user. Note that once a change is made to the host user, attention must be paid to the read and write authorization of the read and write files associated with the service. For example, the log file must give the user write permission and so on.

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.

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 for the 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

Users are not allowed to log 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 "ls-R" command after logging in to FTP. This command can cause significant overhead on server performance. If this item is allowed, it will be used by multiple users when using the 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 is that the service has its own daemon support, and we will be able to see the daemon name of vsftpd under the ps-A command. If you do not want to work in StandAlone mode, you can choose SuperDaemon mode, in which 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 services will not be implemented.

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 the PAM service. Therefore, PAM verification will refer to the vsftpd file configuration under / etc/pam.d/.

Userlist_enable=YES

Set that users in userlist_file will not be allowed to use FTP.

Tcp_wrappers=YES

Set to support TCP Wrappers.

KC: The following entries are added for supporting virtual ftp users.

The following are important CentOS Vsftpd configuration items supported by Vsftpd virtual users. These settings are not included in the default Vsftpd.conf, so you need to add your own configuration manually.

Guest_enable=YES

Set to enable the virtual user feature.

Guest_username=overlord

Specifies the host user for the virtual user.

Virtual_use_local_privs=YES

Set the permissions of virtual users in line with their host users.

User_config_dir=/etc/vsftpd/vconf

Set the configuration file storage path of the virtual user's personal Vsftp. In other words, this specified directory will store the profile of each Vsftp virtual user's personality, a

The place is that these profile names must be the same as the virtual user name. Save exit.

3. Establish a log file for the CentOS Vsftpd configuration, and change the owner to the service host user of Vsftpd:

[root@KcentOS5 ~] touch / var/log/vsftpd.log

[root@KcentOS5 ~] chown vsftpd.vsftpd / var/log/vsftpd.log

4. Establish the virtual user CentOS Vsftpd profile storage path:

[root@KcentOS5 ~] mkdir / etc/vsftpd/vconf/

CentOS vsftp has been widely used but is also constantly updated. Here is an introduction to the use of CentOS vsftp installation settings to help you install and update CentOS vsftp systems.

CentOS vsftp installation:

1. Install CentOS Vsftpd service related parts:

[root@KcentOS5 ~] # yum install vsftpd*

two。 Confirm the installation of PAM service related parts:

[root@KcentOS5 ~] # yum install pam*

Development package, in fact, it does not matter, the main purpose is to confirm the PAM.

3. Install the DB4 part package:

Here is a special installation of a db4 package to support the file database.

[root@KcentOS5 ~] # yum install db4*

CentOS vsftp system account

1. Establish the host user of the CentOS vsftp service:

[root@CentOS5 /] # chmod 700 / home/vftpsite

[root@KcentOS5] # useradd vsftpd-s / sbin/nologin

The default Vsftpd service host user is root, but this does not meet the security needs. Here we create a user named vsftpd and use him as the service host user that supports Vsftpd. Since the user is only used to support Vsftpd services, it is not necessary to allow him to log in to the system, and set him as a user who cannot log in to the system. [root@CentOS5 /] # useradd-d / home/vftpsite-s / sbin/nologin vftpuser

two。 Establish a CentOS vsftp virtual hosting user:

[root@KcentOS5 nowhere] # useradd overlord-s / sbin/nologin

This article mainly introduces the virtual users of Vsftp, virtual users are not system users, that is to say, these FTP users do not exist in the system. In fact, their overall authority is concentrated on a certain user in the system, the so-called Vsftpd virtual host user is such a host user who supports all virtual users. Because he supports all the virtual users of FTP, then his own permissions will affect these virtual users, therefore, in the consideration of security, we should also pay attention to the control of the rights of this user, and there is absolutely no need for this user to log in to the system, and he is also set here as a user who cannot log in to the system.

(insert a sentence here: originally in the establishment of the above two users, even the user's home path is not intended to be given. I wanted to add-d / home/nowhere, according to the man useradd manual.

Stated: "- d,-- home HOME_DIR

The new user will be created using HOME_DIR as the value for the

User flowers 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 is not required. If the specified directory does not exist, it will not be created. As a result, when I tried-d / home/nowhere to specify a directory that does not exist, I KAO! actually created a new = for myself.)

[original] FTP service is an ancient application on the Internet. up to now, the application of Interner is very extensive, but what makes administrators have a headache is its user management, which is both numerous and complicated. How to solve this problem? Using MySQL combined with ProFTP or VsFTP software can build an efficient, stable and centrally managed FTP server. This is to introduce how to build an easy to manage FTP server based on MySQL database.

First, the choice of software version:

The first step to build a database-based FTP server is to choose 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

PAM verifier pam_mysql-0.8RC1.tar.gz for ◆ MySQL

It should be noted that the RHEL5 installation is customized, and the "development tools" item must be selected, otherwise the software packages required for compiling and debugging the software need to be installed separately; secondly, to ensure that the installed Linux system does not install software such as MySQL and FTP server, 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.

Set up the program installation directory

The following commands are executed by the root user throughout the installation process:

# cd / soft/programe

# mkdir mysq

You need to pay attention to the case of the directory name.

# mkdir proftpd

# mkdir pam_mods

MySQL installation directory is / soft/program/mysql,ProFTPD installation directory is / soft/program/proftpd,pam_mysq1.so installation directory is / soft/program/pam_mods,/storage is an existing directory where all FTP users upload and download files are stored.

Install MySQL

◆ adds a user and group to manage MySQL:

# groupadd mysqlgrp

# useradd-g mysqlgrp mysqladm

# passwd mysqladm

◆ changes to the directory where the MySQL-stan-dard-5.1.30-1.rhel5.src.rpm file is located, and perform the following steps to install:

# rpm-ivh MySQL-stan-dard-5.1.30-1.rhel5.src.rpm

This command unzips 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 directory where Mysql is installed, and "--with-extra-charsets=all" is used to support all character sets.

# make

# make install

◆ initializes the database

# cd / soft/program/mysql/bin

#. / mysql_install_db

For the sake of security, ◆ needs to modify the owner 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 configuration file

# cd / soft/program/mysql/share/mysql

# cp my-small.cnf / etc/my.cnf

# cd / etc

In the my.cnf file, add the following:

[mysql]

User=mysqladm # means to start MySQL# with a mysqladm user

Default-character-set=utf8 # means to use the UTF-8 character set, which is versatile and supports Chinese very well. Of course, you can also use GBK directly.

[clent]

Default-character-set=utf8

◆ start

There are two startup methods, one is manual startup, the other is automatic startup, in which manual startup operations are as follows:

# cd / soft/program/mysql/bin

#. / mysqld_safe&

For automatic startup, you need to add the following to / etc/rc.d/rc/local, and boot the MySQL database automatically:

If [- x / soft/program/mysql/bin/mysqld_safe]; then

Install_path_name / bin/mysqld_safe&

Fi

◆ modifies the administrator password

Use the following command to change the database password:

# cd / soft/program/mysql/bin

#. / mysqladmin-h localhost-u root password '123456'

The above command means the default administrative account root for the administrative database used on the local machine (- h host). It should be noted that this root is not a root user in the Linux system, and the password is set to 123456.

Install ProFTPD

◆ changes to the directory where the proftpd-1.3.2.tar.gz file is located, and perform the following steps to install:

# 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 will be added to support MySQL and Quota modules.

-- with-includes=/soft/program/mysql/include/mysql

The above parameters specify the directory path of the include in MySQL.

-- with-libraries=/soft/program/mysql/lib/mysql

This parameter specifies the directory path of the lib in MySQL.

# make

# make install

Use the following command to create 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:

# cd / soft/program/proftpd/etc

Open proftpd.conf with an editor and modify the content:

# Set the user and group under which the server will run.

User ftpuser

Group ftpgroup

◆ starts ProFTPD

There are also two ways to start Proftpd, namely, manual startup and automatic startup, in which manual startup operations are as follows:

# cd / soft/program/proftpd/sbin/

#. / proftpd

At this point, a basic FTP server has been built and ready for testing. It is important to note that if an error occurs at startup with the following information:

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 the text tool and add the following content / soft/program/mysql/lib/mysql

# ldconflg

Update ld.so cache file.

To allow ProFTPD to automatically start adding the following to / etc/rc.d/rc.local, boot up and start ProFTPD:

/ soft/program/proftpd/sbin/proftpd

2. Combination of MySQL and ProFTPD

Create a database called ftp in MySQL, and create the following four tables in the database:

◆ logs in to the user table ftpusers of the FTP server. The field information is shown below. These fields are required, and other fields are added according to your 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 account # is the same as 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, and the directory for uploading and downloading user files. If the account name is abc, enter / storage/abc,'shell' text default here.'/ sbin/nologin' is used to specify whether users can log in to the Linux system. The default here is that they cannot log in.

The ◆ FTP user attribution table ftpgroups, the field information is shown below, and the purpose of establishing this group will be described in the quotalimits table

'groupname' text NOT NULL # group name #

'gid' smallint (6) id number of NOT NULL default'0',# group #

'memembers' text NOT NULL # member #

Quotalimits and quotatallies tables used by ◆ to set disk quota related information. Do not change the fields of these two tables. They are closely related to the configuration file of ProFTPD. The field information of quotalimits table 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 is important to note that name should be understood to represent both a single user and a user group name. If you use group for authentication in quota_type (quota type), you have to set the group name here, so that the whole group has the feature of uniform disk quota, of course, group records are inserted in the ftpgroups table, and users are listed one by one in the member field. The default value can be empty NULL. If it is empty, it works for the type set in the quota_type, such as setting it to user in quota_type, for all users in ftpusers, and for all groups in ftpgroups if it is the group name. Quota_type disk quota type, which can be set to user or user group group. If name writes about user groups, it has to be set to group to identify it. The default is user authentication. Per_ session defaults to false.limit_ type defaults to soft. The amount of space occupied by Bytes_in_avail users, that is, the capacity of FTP users, is in byte. The default value is 0 and 0 is unlimited. The following is the same. The sum of all downloaded files in bytes_out_avail. Default is 0.

Bytes_xfer_avail the total traffic of uploads and downloads per user. Default is 0. Files_in_avail restricts the sum of uploaded files. Default is 0. Files_out_avail limits the total number of downloaded files. The default is 0. Files_xfer_avail allows the total number of files to be downloaded and uploaded, which defaults to 0. The field information of the Quotatallies table, and each field information refers to quotalimits. 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 to the proftpd.conf file:

◆ database connection information, ftp is the database name, localhost is the hostname, root is the user name to connect to the database, and 123456 is the password.

Root 123456

Type of authentication in ◆ database. Plaintext indicates plaintext authentication.

SQLAuthTYpes Backend Plaintext

Information about the table specified by ◆ for user authentication

SALUserlnfo ftpusers userid passwd uid gid homedir shell

SQLGrouplnfo ftpgroups groupname gid members

◆ check data sheet

SQLAuthenticate users groups usersetfast groupsetfast

◆ if the home directory does not exist, the system will follow the home field in the ftpusers table.

Create a new directory:

SQLHomedirOnDemand on

◆ opens the disk quota engine

QuotaEngine on

◆ sets disk quota

QuotaDirectoryTally on

◆ sets the unit of disk capacity display

QuotaDisplayUnits Mb

◆ set disk quota log file

QuotaLog "/ usr/local/proftpd/var/quota"

◆ displays disk quota information

After ftp logs in, you can execute the quote site quota command to view the current disk usage:

QuotaShowQuotas on

◆ set disk quota log file

QuotaLog "/ var/log/quota"

◆ specifies 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 content about timeout, limit the number of connections, speed up connections, support 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 fracture setting, security settings, etc., readers can further improve according to their own needs.

◆ Editing Fil

Modify / etc/pam.d/ftp to remove other content and add the following:

# 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 settings of the previous database. Among them: crypt=0, the password is stored in the database in clear text (not encrypted), crypt=1, the password is encrypted using the DES encryption method of the Unix system and saved in the database; crypt=2, the password is encrypted by the password () function of MySQL. The authorized user ftpusers and password for the ftpusers table in the FTP database must be set correctly.

◆ Boot self-starting VsFTPD

Please make the vsftpd-2.2.1/xinetd.d/vsftpd file into / etc/xinetd.d/ (if it is not in that directory). In addition, you need to set the listen and Tcp_Wrappers parameters in vsftpd.conf to NO, and finally, use the ntsysv command to select the Vsftpd daemon.

Through the above knowledge, combined with Apache, PHP and other software can develop many functions, such as automatically apply for home page space, and use phpMyAdmin to manage MySQL in Web way, it is easy to add and delete users, so FTP user management is much easier.

These are the common CentOS commands that Xiaobian shares with you. If you happen to have similar doubts, you might as well refer to the above analysis to understand. If you want to know more about it, you are welcome to follow the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report