Category Archives: sadmin

sadmin

Изтриване на коментари в WordPress (през MySQL)

Всички коментари се записват в табицата "wp_comments"

mysql> describe wp_comments;
+----------------------+---------------------+------+-----+---------------------+----------------+
| Field                | Type                | Null | Key | Default             | Extra          |
+----------------------+---------------------+------+-----+---------------------+----------------+
| comment_ID           | bigint(20) unsigned | NO   | PRI | NULL                | auto_increment |
| comment_post_ID      | bigint(20) unsigned | NO   | MUL | 0                   |                |
| comment_author       | tinytext            | NO   |     | NULL                |                |
| comment_author_email | varchar(100)        | NO   |     |                     |                |
| comment_author_url   | varchar(200)        | NO   |     |                     |                |
| comment_author_IP    | varchar(100)        | NO   |     |                     |                |
| comment_date         | datetime            | NO   |     | 0000-00-00 00:00:00 |                |
| comment_date_gmt     | datetime            | NO   | MUL | 0000-00-00 00:00:00 |                |
| comment_content      | text                | NO   |     | NULL                |                |
| comment_karma        | int(11)             | NO   |     | 0                   |                |
| comment_approved     | varchar(20)         | NO   | MUL | 1                   |                |
| comment_agent        | varchar(255)        | NO   |     |                     |                |
| comment_type         | varchar(20)         | NO   |     |                     |                |
| comment_parent       | bigint(20) unsigned | NO   | MUL | 0                   |                |
| user_id              | bigint(20) unsigned | NO   |     | 0                   |                |
+----------------------+---------------------+------+-----+---------------------+----------------+

Стойностите на колоната comment_approved са: 0 , 1, spam

# Изтриване на всички not approved коментари
DELETE FROM wp_comments WHERE comment_approved = 0;

# Изтриване на всички approved коментари
DELETE FROM wp_comments WHERE comment_approved = 1;

# Изтриване на всички спам коментари
DELETE FROM wp_comments WHERE comment_approved = 'spam';

# Изтриване по дата
DELETE FROM wp_comments WHERE comment_date > '2004-11-15 01:10:04' AND comment_date <= '2004-11-20 00:10:04'

# Изтриване на всички коментари
TRUNCATE wp_comments;

VN:F [1.9.22_1171]
Rating: 5.0/5 (1 vote cast)
VN:F [1.9.22_1171]
Rating: +1 (from 1 vote)

Монтиране на linux drive ( extfs) ext3/4 под Windows

Идеята е, че имаме Windows и Linux на една и съща система. Идеята е като се работи под Windows да може да се ползва и дяла на GNU/Linux. За целта трябва да монтираме линукс партишъна под windows.

Препоръчвам две приложения за монтиране на GNU/Linux партишън под Windows:

1. Ext2explore -- Portable е

Ext2explore

 

2. Paragon ExtFS

paragon-extfs

VN:F [1.9.22_1171]
Rating: 5.0/5 (1 vote cast)
VN:F [1.9.22_1171]
Rating: +1 (from 1 vote)

Grub 2 -- Коя система да се зарежда по подразбиране

Целата тук е да се направи Windows 7 да се зарежда по подразбиране.
Как да се разбере какъв е номера на Windows 7 ?

cat /boot/grub/grub.cfg |grep '^menuentry'|awk -F "'" '{print $2}'|grep -v 'recovery'|sort|uniq

Linux Mint 17 MATE 64-bit, 3.11.0-26-generic (/dev/sda4)
Linux Mint 17 MATE 64-bit, 3.13.0-34-generic (/dev/sda4)
Linux Mint 17 MATE 64-bit, 3.5.0-17-generic (/dev/sda4)
Memory test (memtest86+)
Memory test (memtest86+, serial console 115200)
Windows 7 (loader) (on /dev/sda1)

Като се смята от "0" то следва, че "Windows 7 " е номер 5

vim /etc/default/grub


GRUB_DEFAULT=5

update-grub2

Generating grub configuration file …
Found linux image: /boot/vmlinuz-3.13.0-34-generic
Found initrd image: /boot/initrd.img-3.13.0-34-generic
Found linux image: /boot/vmlinuz-3.11.0-26-generic
Found initrd image: /boot/initrd.img-3.11.0-26-generic
Found linux image: /boot/vmlinuz-3.5.0-17-generic
Found initrd image: /boot/initrd.img-3.5.0-17-generic
Found memtest86+ image: /boot/memtest86+.elf
Found memtest86+ image: /boot/memtest86+.bin
Found Windows 7 (loader) on /dev/sda1
done

reboot

Готово :)

VN:F [1.9.22_1171]
Rating: 5.0/5 (1 vote cast)
VN:F [1.9.22_1171]
Rating: +1 (from 1 vote)

Инсталиране на grub след инсталиране на Windows

Проблема е, че след като беше инсталиран Windows на двуоперационна система (т.е. GNU/Linux + Windows), windows премахва съществуващият grub. За целта ще го инсталираме на ново и всичко ще се оправи :)

Зареждане на някаква Live дистрибуция

с fdisk се вижда какви дялове има и какво има на тях:

fdisk -l

Disk /dev/sda: 750.2 GB, 750156374016 bytes
255 heads, 63 sectors/track, 91201 cylinders, total 1465149168 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk identifier: 0xabababab

Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048      206847      102400    7  HPFS/NTFS/exFAT
/dev/sda2          206848   204802047   102297600    7  HPFS/NTFS/exFAT
/dev/sda3       204802048   208996351     2097152    6  FAT16
/dev/sda4       208996352  1465145343   628074496   83  Linux
За да се инсталира grub се изпълнява следното:

mount /dev/sda4 /mnt/
mount --bind /proc /mnt/proc
mount --bind /dev /mnt/dev
mount --bind /sys /mnt/sys
chroot  /mnt/
grub-install /dev/sda

За да не се случват тези грешки се изпълняват инструкциите по- горе :)

грешка 1: grub-probe: error: failed to get canonical path of /cow.

грешка 2: /usr/sbin/grub-probe: error: cannot find a device for / (is /dev mounted?).

VN:F [1.9.22_1171]
Rating: 5.0/5 (1 vote cast)
VN:F [1.9.22_1171]
Rating: +1 (from 1 vote)

Sublime text -- инсталиране и кракване под Линукс

Инсталиране на sublime text 3065

apt-get update && apt-get install sublime-text

Кракване на sublime text 3065

1. изтегляне на крак:  Линк 1 или Линк 2

След като се изтегли крака както при windows ките програми се заменя оригиналния изпълним файл ( sublime_text )
На тази дистрибуция се намира тук: /opt/sublime_text/sublime_text

Архивираме файла
mv /opt/sublime_text/sublime_text /opt/sublime_text/sublime_text.bak

Копираме крака
cp "sublime_text crack linux 64 build 3065" /opt/sublime_text/sublime_text

Правим го изпълним
chmod +x /opt/sublime_text/sublime_text;

Изпълняваме го и ето кракнат е :)

sublime_text_cracked

 

VN:F [1.9.22_1171]
Rating: 5.0/5 (1 vote cast)
VN:F [1.9.22_1171]
Rating: +1 (from 1 vote)

замяна на текст във всички файлове(рекурсивно)

Искам текста "Twenty Thirteen" да го заменя с текста "Distance Running" но във всички файлове в тази директория както и файловете в под директориите и т.н. Ето как става с един ред ;)

find . -type f -print0 | xargs -0 sed -i 's/Twenty Thirteen/Distance Running/g'

VN:F [1.9.22_1171]
Rating: 5.0/5 (1 vote cast)
VN:F [1.9.22_1171]
Rating: +1 (from 1 vote)

Копиране на таблица и нейното съдържание в MySQL

Идеята е таблицата "articles" да бъде копирана като "articles_bg" + съдържанието в таблицата "articles":

Ето го и сложното решение от две заявки:

CREATE TABLE articles_bg LIKE articles; INSERT articles_bg SELECT * FROM articles;

VN:F [1.9.22_1171]
Rating: 5.0/5 (1 vote cast)
VN:F [1.9.22_1171]
Rating: +1 (from 1 vote)

Как да разархивираме ZIP файл разбит на няколко части под Линукс

Имаме архивирана папка "site" разбита на 2 части от по 15 MB т.е. "site.z01" и "site.zip"

Когато опитаме обаче:

unzip site.z*;

Archive:  site.z01
  End-of-central-directory signature not found.  Either this file is not
  a zipfile, or it constitutes one disk of a multi-part archive.  In the
  latter case the central directory and zipfile comment will be found on
  the last disk(s) of this archive.
unzip:  cannot find zipfile directory in one of site.z01 or
        site.z01.zip, and cannot find site.z01.ZIP, period.

За да се получи правим следното :) :

cat site.z* > combined.zip && unzip combined.zip;

Това е :)

VN:F [1.9.22_1171]
Rating: 5.0/5 (2 votes cast)
VN:F [1.9.22_1171]
Rating: +2 (from 2 votes)

Postfix + SPF Policy сървър (Debian)

apt-get update && apt-get install postfix-policyd-spf-perl -y

vim /etc/postfix/master.cf


policy-spf  unix  --       n       n       --       --       spawn
user=nobody argv=/usr/bin/perl /usr/sbin/postfix-policyd-spf-perl
vim /etc/postfix/main.cf

smtpd_recipient_restrictions = permit_mynetworks,permit_sasl_authenticated,check_policy_service unix:private/policy-spf

Важно: check_policy_service да се намира непосредствено след permit_mynetworks

VN:F [1.9.22_1171]
Rating: 5.0/5 (1 vote cast)
VN:F [1.9.22_1171]
Rating: +1 (from 1 vote)