AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / user-396270

Valeriu's questions

Martin Hope
Valeriu
Asked: 2017-03-11 23:23:18 +0800 CST

如何在没有 eth* 链接的情况下为 KVM 创建桥接并允许访问互联网

  • 0

我有一个任务,我应该创建没有指向 eth* 的链接的 br1,并让这个 br1 访问互联网。我有 CentOS7。我创建了接口 br1:

DEVICE=br1
TYPE=Bridge
ONBOOT=yes
BOOTPROTO=static
IPADDR=192.168.1.1
NETMASK=255.255.255.0
NM_CONTROLLED=no

在 iptables 我写了这个:

iptables -t nat -A POSTROUTING -s 192.168.1.0/24 -j SNAT --to-source 192.168.122.1

192.168.122.1 例如我的主界面,可以访问互联网。

我的问题:从我的 KVM 上的虚拟机访问互联网就足够了,或者我需要做其他事情。也许我需要一些 FORWARD 规则。因为 virbr0 接口工作,但我的 br1 没有。

virtualization kvm-virtualization virtual-machines iptables
  • 1 个回答
  • 394 Views
Martin Hope
Valeriu
Asked: 2017-02-25 12:56:11 +0800 CST

Chroot 不适用于 php-fpm

  • 1

我应该在我的站点上为我的 ftp 目录使用 chroot:我的 php-fpm.conf:

[mysite.com]
listen = /var/run/php7-fpm-chroot-filemanager.sock
chroot = /var/www/mysite.com/fileman
chdir = /
user = filemanuser
group = filemangroup
pm = dynamic
pm.max_children = 5
pm.start_servers = 2
pm.min_spare_servers = 1
pm.max_spare_servers = 3

我的 nginx.conf 部分:

    location ~* /fileman/(.+\.php)$
    {

            root /var/www/mysite.com/;
            include /etc/nginx/fastcgi_params;
            if (!-f /var/www/mysite.com$fastcgi_script_name) {
                    return 405;
            }
            fastcgi_index index.php;
            fastcgi_pass unix:/var/run/php7-fpm-chroot-filemanager.sock
            fastcgi_param SCRIPT_FILENAME /var/www/mysite.com$fastcgi_script_name;
    }

重新启动服务后,我在页面上看到:

File not found. 

在nginx的日志中:

2017/02/24 20:12:22 [error] 18390#18390: *108 FastCGI sent in stderr: "Primary script unknown" while reading response header from upstream, client: 192.168.110.25, server: www.mysite.com, request: "GET /fileman/index.php HTTP/1.1", upstream: "fastcgi://unix:/var/run/php7-fpm-chroot-filemanager.sock:", host: "www.mysite.com"

没有 chroot 选项,一切正常。我哪里有错误?请帮忙。

php nginx chroot php-fpm
  • 1 个回答
  • 1378 Views
Martin Hope
Valeriu
Asked: 2017-01-25 02:19:04 +0800 CST

如何显示 uniq 大于 3 的行

  • 0

我有一个文件,我应该在其中制作“uniq”并显示结果。我的文件:

178.57.66.225 fxsciaqulmlk
178.57.66.225 fxsciaqulmlk
178.57.66.225 fxsciaqulmlk
178.57.66.225 faaaaaa11111
178.57.66.215 terdsfsdfsdf
178.57.66.215 terdsfsdfsdf
178.57.66.215 terdsfsdfsdf
178.57.66.205 erdsfsdfsdf
178.57.66.205 erdsfsdfsdf
178.57.66.205 erdsfsdfsdf
178.57.66.205 erdsfsdfsdf
178.57.66.205 abcbbabab
178.57.66.205 abcbbabab
178.57.66.205 abcbbabab
178.56.66.225 fxsciulmla
178.56.66.225 fxsciulmla
178.56.66.225 fxsciulmla
178.57.67.225 faaaa0a1111

我的脚本:

for i in $(uniq -c /root/log | awk '{print $1}'); do
if [ $i -gt 2 ]; then
s=$(uniq -c /root/log | awk '$1 == '$i | awk '{print $3}')
ss=$(uniq -c /root/log | awk '$1 == '$i | awk '{print $2}')
echo "The bot is user $s with ip $ss"
fi
done

一切正常,但我的输出不正确:

The bot is user fxsciaqulmlk
terdsfsdfsdf
abcbbabab
fxsciulmla with ip 178.57.66.225
178.57.66.215
178.57.66.205
178.56.66.225
The bot is user fxsciaqulmlk
terdsfsdfsdf
abcbbabab
fxsciulmla with ip 178.57.66.225
178.57.66.215
178.57.66.205
178.56.66.225
The bot is user erdsfsdfsdf with ip 178.57.66.205
The bot is user fxsciaqulmlk
terdsfsdfsdf
abcbbabab
fxsciulmla with ip 178.57.66.225
178.57.66.215
178.57.66.205
178.56.66.225
The bot is user fxsciaqulmlk
terdsfsdfsdf
abcbbabab
fxsciulmla with ip 178.57.66.225
178.57.66.215
178.57.66.205
178.56.66.225

我在两天内完成了,我不明白我在哪里犯了错误?请帮忙。

当,我在条件下增加 uniq 的数量:

if [ $i -gt 2 ]; then

我有一个正常的日志:

The bot is user erdsfsdfsdf with ip 178.57.66.205

我哪里有错误?

scripting bash shell shell-scripting
  • 1 个回答
  • 561 Views
Martin Hope
Valeriu
Asked: 2017-01-22 13:53:25 +0800 CST

按文本块/行 Grep

  • 1

我有文本,其中包含一些行。所以,我需要制作几行的 GREP。例如,我有重复的文本,我应该 GREP 获取具有此重复关键字的行。

grep -o "test|test2" textfile

我的文字:

123|never for your|test
123421|never for your|test2
123412|never for your|test3
12341|never for your|test4
12311|never for your|test2
123312312|never for your|test
123321312|never for your|test2

我应该:

123|never for your|test
123421|never for your|test2
123312312|never for your|test
123321312|never for your|test2

它可以工作,但不能按我的意愿工作。它在文本中搜索所有单词“test”和“test2”。但我想获得文本块,比如一些模式,只有在“test”之后才会出现“test2”。你有什么想法吗?

scripting bash shell shell-scripting
  • 4 个回答
  • 5862 Views
Martin Hope
Valeriu
Asked: 2017-01-21 12:58:50 +0800 CST

如何输出具有特殊模式的列

  • 0

我有一个专栏,有几句话:

scatman
batman
superman
scatman
scatman
batman
superman
scatman
scatman
batman
superman
scatman
batman
WWWWWWWW
superman
scatman
batman
superman
scatman

我应该做一些模式,我需要一个字一个字三个字:scatman,batman,superman。在哪里,我有重复的单词,比如第 4 行和第 5 行的 scatman 和 scatman 或者我有其他单词的地方,我应该删掉我写的:

grep "scatman\|batman\|superman" file

好的,我拒绝了 WWWWWWWW 这个词,但我不明白如何逐字显示我的专栏。我有结果:

scatman
batman
superman
scatman
scatman
batman
superman
scatman
scatman
batman
superman
scatman
batman
superman
scatman
batman
superman
scatman

在第 4 行和第 5 行,我有重复的单词,但我不喜欢这样。我哪里有错误?

linux unix bash shell shell-scripting
  • 2 个回答
  • 62 Views
Martin Hope
Valeriu
Asked: 2017-01-21 11:21:59 +0800 CST

Uniq by 两列有两个条件

  • -1

我有列的表。在第一列中,我有时间,当用户登录时,在第二列中,我有一个用户名。

13:15:39  fxs1cia1qulm1lk  
13:15:39  fxs1cia1qulm1lk  
13:15:39  fxs1cia1qulm1lk  
13:15:42  faaaa2aa11111  
13:15:49  terd1sfsd11fsdf  
13:15:49  terd1sfsd11fsdf  
13:15:49  terd1sfsd11fsdf  
13:15:59  21erdsf123sdfsdf   
13:15:59  21erdsf123sdfsdf   
13:15:59  21erdsf123sdfsdf   
13:15:59  21erdsf123sdfsdf   
13:17:50  abcasbbabadab  
13:17:50  abcasbbabadab  
13:17:50  abcasbbabadab  
13:17:50  abcasbbabadab   
13:19:19  fxs1ce1iulmla   
13:19:19  fxs1ce1iulmla  
13:19:19  fxs1ce1iulmla   
13:20:42  faaa2a0a1111

所以,我应该怎么做。我应该对这两列进行 uniq 操作,如果用户登录的时间和用户名相同,我应该说,该用户已经登录了 3 次以上。我写了简短的脚本:

log_file=/root/log
temp_file=/root/temp
temp_file2=/root/temp2

cat /dev/null > $temp_file
cat /dev/null > $temp_file2
cat /dev/null > $result_file

cat $log_file | awk '{print $1}' | tail -n 20 > $temp_file
cat $log_file | awk '{print $5}' | tail -n 20 > $temp_file2

for i in `uniq -c $temp_file | awk '{print $1}'`; do
for y in `uniq -c $temp_file2 | awk '{print $2}'`; do
if [ $i -gt 3 ] && [ $y -gt 3 ]; then
s=`uniq -c $temp_file2 | awk '$1 == '$i`
echo "The user $s has logged more than 3 times"
fi
done
done

请检查一下,这个脚本是否正确?因为,在 echo 中输出我的脚本后,我有:

The user       4 21erdsf123sdfsdf   
      4 abcasbbabadab  has logged more than 3 times
The user       4 21erdsf123sdfsdf   
      4 abcasbbabadab  has logged more than 3 times
The user       4 21erdsf123sdfsdf   
      4 abcasbbabadab  has logged more than 3 times
The user       4 21erdsf123sdfsdf   
      4 abcasbbabadab  has logged more than 3 times

但我想要这样的输出:

The user       4 21erdsf123sdfsdf has logged more than 3 times
The user       4 abcasbbabadab  has logged more than 3 times

就这样。我哪里有错误?请帮忙。

linux unix bash shell shell-scripting
  • 2 个回答
  • 949 Views

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    新安装后 postgres 的默认超级用户用户名/密码是什么?

    • 5 个回答
  • Marko Smith

    SFTP 使用什么端口?

    • 6 个回答
  • Marko Smith

    命令行列出 Windows Active Directory 组中的用户?

    • 9 个回答
  • Marko Smith

    什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同?

    • 3 个回答
  • Marko Smith

    如何确定bash变量是否为空?

    • 15 个回答
  • Martin Hope
    Tom Feiner 如何按大小对 du -h 输出进行排序 2009-02-26 05:42:42 +0800 CST
  • Martin Hope
    Noah Goodrich 什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同? 2009-05-19 18:24:42 +0800 CST
  • Martin Hope
    Brent 如何确定bash变量是否为空? 2009-05-13 09:54:48 +0800 CST
  • Martin Hope
    cletus 您如何找到在 Windows 中打开文件的进程? 2009-05-01 16:47:16 +0800 CST

热门标签

linux nginx windows networking ubuntu domain-name-system amazon-web-services active-directory apache-2.4 ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve