Centos common commands

Find and delete files

find . -name '*.jpg' | xargs rm -f


Install cron scheduled tasks

yum install -y vixie-cron


.tar.gz

Unzip: tar zxvf FileName.tar.gz

压缩:tar zcvf FileName.tar.gz DirName

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

cp -Ri file1 file2

copy folder


we

insert after the cursor a

Return to the control command esc

eject:q force quit:q!

save and exit: wq

to the last line: $

find string /


reboot

reboot


service restart

service httpd restart


SElinux setup vsftp

setsebool -P allow_ftpd_full_access on

setsebool -P ftp_home_dir on

getsebool -a|grep ftp



cpu and memory usage

top


Add centos to user group apache

 

usermod -a -G apache centos

 

Set all groups of the website root directory /var/www to apache

 

chown -R :apache /var/www

 

Set the permissions of the root directory of the website to have read and write permissions for the user group

 

chmod -R g+rw /var/www


View Apache running users and groups

ps -ef |grep httpd


See which group a user belongs to

id user


View all users


cat /etc/passwd


mysql backup

mysqldump -hhostname -uusername -ppassword databasename > backupfile.sql


mysql restore

mysql -hhostname -uusername -ppassword databasename < backupfile.sql

or

mysql -u root -p


mysql>use database


Then use the source command, followed by a script file (such as the .sql used here)

mysql>source d:\wcnc_db.sql



The system regularly backs up the mysql database every day


1. Create the path/mysqldata to save the backup file

#mkdir /mysqldata


2. Create the /usr/sbin/baktest file

Enter the following:

mysqldump -uroot -proot test | gzip > /mysqldata/test`date +%Y-%m-%d_%H%M%S`.sql.gz


3. Modify the file properties to make it executable

#chmod +x /usr/sbin/baktest


4. Modify /etc/crontab

add below

01 3 * * * root /usr/sbin/baktest

Indicates that the backup is performed at 3:01 every day


5. Restart crond

#/etc/rc.d/init.d/crond restart


Add a user with root privileges

Modify the /etc/passwd file, find the following line, and change the user ID to 0:


mysql backup user permission settings LOCK TABLES, SELECT, FILE, RELOAD, SUPER, SHOW VIEW*


df -hl View partition size


Install and configure apache+php+mysql on Linux (CentOS)

1. First, use the yum remove command to delete all the previously installed ones. The command is: yum remove httpd, and other uninstalls are similar.


2. After uninstalling, execute the following command to install httpd and its related extended support: yum install ntp httpd mysql-server php php-mysql php-mbstring rpm-build gcc mysql-devel openssl-devel cyrus-sasl-devel pkgconfig zlib -devel phpMyAdmin pcre-devel openldap-devel postgresql-devel expect libtool-ltdl-devel openldap-servers libtool gdbm-devel pam-devel gamin-devel postfix


3. Then execute the command to install php and related extension support: yum install php php-devel php-gd php-imap php-ldap php-mysql php-odbc php-pear php-xml php-xmlrpc php-eaccelerator php-magickwand php-magpierss php-mapserver php-mbstring php-mcrypt php-mhash php-mssql php-shout php-snmp php-soap php-tidy curl curl-devel perl-libwww-perl ImageMagick libxml2 libxml2-devel phpmyadmin


After executing the above two commands, many of the services we want are installed, just start httpd and the database system and it will be ok.


Modify ftp access ip

/etc/hosts.allow


block ip address

iptables -I INPUT -s *.*.*.* -j DROP

service iptables save;

service iptables restart;


Pagination display

ls | less


Add sftp account

useradd -s /bin/false -G www user


passwd user



vi /etc/ssh/sshd_config

Subsystem sftp internal-sftp -u 0000


Match User user

        ChrootDirectory /home/wwwroot

        ForceCommand internal-sftp

        AllowTcpForwarding no


service sshd restart


Couldn't read packet: Connection reset by peer

The reason for this problem is the permissions of ChrootDirectory. The directory you set must be owned by the root user, otherwise there will be problems. So please make sure that the owner of the sftp user root directory is root, and the permission is 750 or 755


{{o.name}}
{{m.name}}

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=324079830&siteId=291194637