Word大纲级别和首行缩进调整快捷键

大纲级别调整:

Ctrl+Shift+N      降级为正文      
Alt+Shift+←      提升段落级别
Alt+Shift+→      降低段落级别
Alt+Shift+↑      上移所选段落
Alt+Shift+↓      下移所选段落
首行缩进:在要缩进出按Tab键/或者段落设置
发表在 日常记录 | 留下评论

ubuntu 20.04 开启ftp服务

sudo apt install vsftpd
mkdir -p  ~/app/ftp
sudo cp /etc/vsftpd.conf /etc/vsftpd.conf.bak.copy

cd
sudo mv /etc/vsftpd.conf .
perl -i.bak -e 'my $name=`whoami`;chomp ($name);my $chr="/home/"."$name";my $num;my @arr;open(RF,"vsftpd.conf");while(<RF>){push @arr,$.};$num=pop (@arr);while(<>){if ($_=~/anonymous_enable=NO/){print "anonymous_enable=YES"."\n";next};if ($_=~/local_enable=YES/){print "local_enable=NO"."\n";next};print $_;if($.==$num){print "anon_root=".$chr."/app/ftp"."\n"}}' vsftpd.conf
sudo mv vsftpd.conf* /etc/
sudo chown root:root /etc/vsftpd.conf
sudo ufw allow 21
sudo ufw allow 20
sudo service vsftpd restart
发表在 Linux | 留下评论

Singularity使用Docker镜像

#test docker -> singularity
docker run -it -v /home/daizao/workspace/container/:/mnt ubuntu bash
root@fcd85ec80ffe:/# cp /mnt/ncbi-blast-2.10.1+-x64-linux.tar.gz /opt/
root@fcd85ec80ffe:/# cd /opt/
root@fcd85ec80ffe:/opt# tar -zxf ncbi-blast-2.10.1+-x64-linux.tar.gz
root@fcd85ec80ffe:/opt# rm ncbi-blast-2.10.1+-x64-linux.tar.gz
root@fcd85ec80ffe:/opt# cp ncbi-blast-2.10.1+/bin/* /usr/local/bin/
root@fcd85ec80ffe:/opt# blastp -h
root@fcd85ec80ffe:/opt# exit
docker images
docker ps -a
#######
#CONTAINER ID   IMAGE     COMMAND       CREATED              STATUS                      PORTS     NAMES
#fcd85ec80ffe   ubuntu    "bash"        About a minute ago   Exited (0) 24 seconds ago             gallant_ganguly

#create images from container(fcd85ec80ffe)
docker commit fcd85ec80ffe blast_docker
docker images
###
#REPOSITORY     TAG       IMAGE ID       CREATED          SIZE
#blast_docker   latest    517957fbf0e3   13 seconds ago   1.43GB
#ubuntu         latest    26b77e58432b   14 hours ago     72.9MB

singularity build blast_docker.sif docker-daemon:blast_docker:latest
singularity exec blast_docker.sif blastp -h

docker ps -a
#######
#CONTAINER ID   IMAGE     COMMAND       CREATED              STATUS                      PORTS     NAMES
#fcd85ec80ffe   ubuntu    "bash"        About a minute ago   Exited (0) 24 seconds ago             gallant_ganguly

#delete container
docker rm fcd85ec80ffe
#delete docker image
docker rmi blast_docker
发表在 Container | 留下评论

Docker 练习

#下载docker镜像
docker pull ubuntu

#查看镜像
docker images

#delete image
#docker rmi ubuntu

#启动镜像,并生成容器
docker run -it ubuntu bash
docker ps -a
### status is exited
#CONTAINER ID   IMAGE     COMMAND   CREATED         STATUS                     PORTS     NAMES
#431dcb7be26a   ubuntu    "bash"    5 seconds ago   Exited (0) 2 seconds ago             pensive_mendel

#start container
docker start 431dcb7be26a
docker ps -a
###status is up
#CONTAINER ID   IMAGE     COMMAND   CREATED         STATUS         PORTS     NAMES
#431dcb7be26a   ubuntu    "bash"    4 minutes ago   Up 9 seconds             pensive_mendel



#运行容器(431dcb7be26a)中的程序
docker exec -it 431dcb7be26a bash
root@431dcb7be26a:/# exit

docker ps -a
###
#CONTAINER ID   IMAGE     COMMAND   CREATED         STATUS              PORTS     NAMES
#431dcb7be26a   ubuntu    "bash"    6 minutes ago   Up About a minute             pensive_mende

docker rm 431dcb7be26a
#failed because container was up
#Error response from daemon: You cannot remove a running container 431dcb7be26a5c4a0373a668b28698ab195a19f1f5aad77eddd4d5ed9b945f41. Stop the container before attempting removal or force remove

#stop 容器
docker stop 431dcb7be26a
docker ps -a
###status was exited
#CONTAINER ID   IMAGE     COMMAND   CREATED         STATUS                      PORTS     NAMES
#431dcb7be26a   ubuntu    "bash"    7 minutes ago   Exited (0) 18 seconds ago             pensive_mendel

#delete container
docker rm 431dcb7be26a
docker ps -a
#CONTAINER ID   IMAGE     COMMAND   CREATED   STATUS    PORTS     NAMES

cd workspace/container/

docker run -it -v /home/daizao/workspace/container:/mnt ubuntu bash
root@20c5d298c2e4:/# ls /mnt/
root@1b6e699ad545:/# cd /mnt/
root@20c5d298c2e4:/mnt# cd /opt/
root@20c5d298c2e4:/opt# cp /mnt/ncbi-blast-2.10.1+-x64-linux.tar.gz .
root@20c5d298c2e4:/opt# tar -zxf ncbi-blast-2.10.1+-x64-linux.tar.gz 
root@20c5d298c2e4:/opt# rm ncbi-blast-2.10.1+-x64-linux.tar.gz 
root@20c5d298c2e4:/opt# cp ncbi-blast-2.10.1+/bin/* /usr/local/bin/
root@20c5d298c2e4:/opt# exit

#显示所有容器
docker ps -a
#CONTAINER ID   IMAGE     COMMAND   CREATED              STATUS                      PORTS     NAMES
#1b6e699ad545   ubuntu    "bash"    About a minute ago   Exited (0) 18 seconds ago             vibrant_jang

#put 1b6e699ad545's container to blast image
docker commit 1b6e699ad545 blast
docker images
#REPOSITORY   TAG       IMAGE ID       CREATED          SIZE
#blast        latest    35b6b4b4411a   54 seconds ago   1.43GB
#ubuntu       latest    26b77e58432b   15 hours ago     72.9MB
#create blast image

#run image
docker run blast blastp -h

docker ps -a
#CONTAINER ID   IMAGE     COMMAND       CREATED         STATUS                     PORTS     NAMES
#da74854199c5   blast     "blastp -h"   6 seconds ago   Exited (0) 5 seconds ago             unruffled_saha
#1b6e699ad545   ubuntu    "bash"        7 minutes ago   Exited (0) 6 minutes ago             vibrant_jang
#出现blast和ubuntu container,因为之前创建blast,启用了ubuntu镜像,导致出现ubuntu容器


#将blast image 保存成本地文件
docker save -o blast.tar blast
ls #生成一个blast.tar 文件
docker images
docker ps -a
#CONTAINER ID   IMAGE     COMMAND       CREATED          STATUS                     PORTS     NAMES
#da74854199c5   blast     "blastp -h"   4 minutes ago    Exited (0) 4 minutes ago             unruffled_saha
#1b6e699ad545   ubuntu    "bash"        11 minutes ago   Exited (0) 9 minutes ago             vibrant_jang
docker stop da74854199c5 #停止启用blast镜像的容器
docker rm da74854199c5 #有时候已经停止了容器,但无法删除镜像,所以直接删除容器,在删除镜像
docker ps -a
#CONTAINER ID   IMAGE     COMMAND   CREATED          STATUS                      PORTS     NAMES
#1b6e699ad545   ubuntu    "bash"    13 minutes ago   Exited (0) 11 minutes ago             vibrant_jang
#说明容器da74854199c5彻底停止
docker rmi blast

#加载本地docker文件,生成镜像
docker load -i blast.tar

docker run blast blastp -h
docker ps -a
#CONTAINER ID   IMAGE     COMMAND       CREATED          STATUS                      PORTS     NAMES
#07dac63e27c1   blast     "blastp -h"   12 seconds ago   Exited (0) 8 seconds ago              serene_einstein
#1b6e699ad545   ubuntu    "bash"        16 minutes ago   Exited (0) 14 minutes ago             vibrant_jang
#镜像一旦启动,便会生成一个container
docker rm 07dac63e27c1
docker ps -a
#CONTAINER ID   IMAGE     COMMAND   CREATED          STATUS                      PORTS     NAMES
#1b6e699ad545   ubuntu    "bash"    17 minutes ago   Exited (0) 16 minutes ago             vibrant_jang

#delete image
docker rmi blast
docker images
#REPOSITORY   TAG       IMAGE ID       CREATED        SIZE
#ubuntu       latest    26b77e58432b   15 hours ago   72.9MB
发表在 Container | 留下评论

Singularity 练习

#download ubuntu singularity
singularity pull --arch amd64 library://library/default/ubuntu:20.04
singularity build --sandbox blast ubuntu_20.04.sif

#install software
singularity shell --writable blast/
#singularity shell --writable --fakeroot blast

Singularity> cp ncbi-blast-2.10.1+-x64-linux.tar.gz /opt/
Singularity> cd /opt/
Singularity> tar -zxf ncbi-blast-2.10.1+-x64-linux.tar.gz
Singularity> cd ncbi-blast-2.10.1+/bin/
Singularity> cd ../..
Singularity> rm ncbi-blast-2.10.1+-x64-linux.tar.gz
Singularity> exit
vim blast/environment
    export PATH=/opt/ncbi-blast-2.10.1+/bin:$PATH

#build
singularity build blast.sif blast
#test use
singularity exec blast.sif blastp -help

#use singularity software to analysis a simple blast
singularity exec blast.sif makeblastdb -dbtype prot -in PRAD.fasta -out genome
singularity exec blast.sif blastp -query input.fa -db genome -out blast.out -outfmt 7

#copy sig to a shared container doc
mkdir /opt/software/container
cp blast.sif /opt/software/container/
singularity exec /opt/software/container/blast.sif blastp -query input.fa -db genome -out blast.out -outfmt 7

#load file
singularity shell --bind /opt/software/:/mnt blast.sif
Singularity> ls /mnt/
Singularity> exit

singularity shell --bind /opt/software/ blast.sif
Singularity> ls /opt/
Singularity> ls /mnt/
Singularity> exit
发表在 Container | 留下评论

自动IP禁止访问

由于最近服务器经常受到黑客攻击,于是写了此程序,用于禁用某些ip访问

#!/usr/bin/perl -w
use strict;
use warnings;
use File::Copy;
use Getopt::Long;

my $usage=<<USAGE;
Usage:
    perl $0 -i_a <input_dir_a(httpd.conf)> -f_a <file_name_a(httpd.conf)> -i_b <input_dir_b(httpd.log)> -f_b <file_name_b(httpd.log)>
USAGE
if (@ARGV==0){die $usage}

my ($input_dir_a,$input_filename_a,$input_dir_b,$input_filename_b,$help);
GetOptions(
    "i_a:s" => \$input_dir_a,
    "f_a:s" => \$input_filename_a,
    "i_b:s" => \$input_dir_b,
    "f_b:s" => \$input_filename_b,
    "h:s" => \$help
);

die `pod2text $0` if ((!$input_dir_a) or (!$input_dir_b));

=head1 Description

    This script is used to auto forbid ip which heat your website with LAMP architecture;

=head1 Parameters

    -i_a  [str]   input dir to httpd.conf file
    -f_a    [str]       input file name (such as httpd.conf)
    -i_b    [str]       input dir to httpd log dir
    -f_b    [str]       input file name (such as access_log)
    -h  [str]   Help manual

=cut

#print $input_dir_a,"\n";
my $config_file = "$input_dir_a"."/"."$input_filename_a";
my $log_file = "$input_dir_b"."/"."$input_filename_b";
#print $log_file;

copy($config_file,$config_file.".bak");

my %hash;
my @appear_time;

open(RF,$log_file) || die $!;
while(my $line=<RF>){
    chomp($line);
    my @arr=split(' ',$line);
    if($arr[0]!~/^\d/){next};
    if($arr[0] eq "127.0.0.1"){next};
    $hash{$arr[0]}++;
}
close(RF);


open(RF,$config_file) || die $!;
open(WF,">".$config_file."_a") || die $!;
while(my $line=<RF>){
    chomp($line);
    if($line =~ /Deny\ from\ (.*)/){
        my $ip_temp = $1;
        for my $key (keys %hash){
            if ($key ne $ip_temp){
                if($hash{$key} > 7000){
                    my $new_line=$line."\n"."    "."Deny from ".$key."\n";
                    print WF $new_line;
                    delete($hash{$key});
                }
            }else{
                delete($hash{$key});
            }
        }
        next;
    }
    print WF $line."\n";
}
close(RF);
close(WF);

move($config_file."_a",$config_file);
发表在 Linux, Perl | 留下评论