[Up]常用資訊

[重點文章] 重點文章 [重點文章] 重點文章

2020年10月6日 星期二

[Debian] Debain10 安裝 新的10.6

[Debian] Debain10 安裝 新的10.6

[Debian] Debain10安裝 新的10.6



時間過得真快 Debian 已經更新到 10.6的版本了

@ 印出 Linux Kernel 版本
[root@localhost ~]# uname -a

Linux Debian10-6-TIG-01 4.19.0-11-amd64 #1 SMP Debian 4.19.146-1 (2020-09-17) x86_64 GNU/Linux

@ 印出 Linux 發行版本,這邊是 CentOS 的結果
@ 這個指令通用於所有的發行版本,如:Redhat、SuSE、Debian等
[root@localhost ~]# lsb_release -a
No LSB modules are available.
Distributor ID: Debian
Description:    Debian GNU/Linux 10 (buster)
Release:        10
Codename:       buster

 ========================================================================================================
先修改 python 為3.7
# update-alternatives --install /usr/bin/python python /usr/bin/python2.7 1
update-alternatives: using /usr/bin/python2.7 to provide /usr/bin/python (python) in auto mode
# update-alternatives --install /usr/bin/python python /usr/bin/python3.7 2
update-alternatives: using /usr/bin/python3.5 to provide /usr/bin/python (python) in auto mode 
#
python --version
========================================================================================================
 將 pip3 安裝為預設

如果沒有 使用 root 請使用 sudo 提升權限
sudo apt install python3-pip -y
sudo ln -s /usr/bin/pip3 /usr/bin/pip

========================================================================================================

========================================================================================================
習慣使用工具 和 vmtools 所需套件
apt install make gcc curl wget vim git-core git tree libsnmp-dev tcpdump htop iftop dnsutils libcurl4-gnutls-dev libxml2-dev libevent-dev linux-headers-`uname -r` build-essential -y
apt install net-tools sudo vim-gtk ack-grep ctags  -y
apt install expect -y
apt install nodejs -y
apt install yarn rdate -y
apt install libssl-dev libghc-zlib-dev libexpat1-dev gettext unzip -y
apt install fping graphviz imagemagick mtr-tiny acl -y
###apt install vim-gtk -y
apt install whois rrdtool librrds-perl python-memcache python-mysqldb -y

apt install libssl-dev libghc-zlib-dev libexpat1-dev -y
#
# 安裝 vim 所需套件
apt install silversearcher-ag fzf -y
#
apt install -y libclang-dev
#安裝 處理 json 分割使用
apt install -y jq bc

#
#安裝 iptable 本機防火牆-所需套件
apt install iptables-persistent -y

tcpdump dnsutils -y

iptables 防火牆


iptables -L #顯示目前policy

新增rule 

iptables -A INPUT -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT

iptables -A INPUT -p tcp --dport ssh -j ACCEPT # 允許 ssh 登入

iptables -A INPUT -p tcp --dport 80 -j ACCEPT # 允許 80 port 登入
 
iptables -P INPUT DROP  # 所有的連入  丟棄
 
 
iptables-save > /etc/iptables/rules.v4 # 將目前的設定存檔

如果沒有 使用 root 請使用 sudo 提升權限
 
# Overwrite the current rules 複寫目前的防火牆規則
sudo iptables-restore < /etc/iptables/rules.v4
# Add the new rules keeping the current ones 新增規則 保留目前設定
sudo iptables-restore -n < /etc/iptables/rules.v4


安裝 dofile 將 vim 編輯器 設定環境

Installation

1. Backup your old vim configuration files:
   
    mv ~/.vim ~/.vim.orig
    mv ~/.vimrc ~/.vimrc.orig
2. Clone and install this repo:
   
    git clone https://github.com/humiaozuzu/dot-vimrc.git ~/.vim
    ln -s ~/.vim/vimrc ~/.vimrc
3. Setup Vundle:
   
     git clone https://github.com/gmarik/vundle.git ~/.vim/bundle/vundle
4. Install bundles. Launch vim(ignore the errors and they will disappear after installing needed plugins)and run:
   
     :BundleInstall
Thst's it! 

安裝與設定 Vim 的配色主題 (colorscheme)
可以參考網站
http://colorswat.ch/vim/list?p=2&bg=dark&cat=all

mkdir -p ~/.vim/colors/

wget -P ~/.vim/colors/ http://www.vim.org/scripts/download_script.php?src_id=19108 #將 lucid.vim 下載到 ~/.vim/colors/ 內

git clone https://github.com/sickill/vim-monokai.git

mv vim-monokai/colors ~/.vim/colors
OR

git clone https://github.com/morhetz/gruvbox.git

cp gruvbox/colors/gruvbox.vim ~/.vim/colors

Put monokai.vim file in your ~/.vim/colors/ directory and add the following line to your ~/.vimrc:

修改 .vimrc檔案增加下面兩行文字
syntax enable
colorscheme monokai

or 

colorscheme gruvbox

##
新的安裝方式 放到我自己的 git hub

先安裝 

apt install silversearcher-ag fzf -y

在接下來的步驟

git clone https://github.com/oscarobwu/vim-setup.git
cd vim-setup 
cp .vimrc_powerline ~/.vimrc

gvim -> :PluginInstall 安裝Plugin


pip install black

20201021 測試

git clone --depth=1 https://github.com/amix/vimrc.git ~/.vim_runtime
sh ~/.vim_runtime/install_awesome_vimrc.sh



Restart vi and install packages
Enter the command :PlugInstall in normal mode after you start vi

Restart vi again

Done!

(Optional) Copy the snippets I define into snippets/
cp snippets/* ~/.vim/bundle/vim-snippets/snippets/

##########################################
20201022 安裝 power line

#
# 安裝 vim 和 power line
#
sudo apt install -y exuberant-ctags cscope vim-gtk git flake8 python-rope pylint
git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim
git clone https://github.com/powerline/fonts
cd fonts && ./install.sh

pip install powerline-status
pip install powerline-gitstatus


git clone https://github.com/oscarobwu/vim-setup.git
cd vim-setup 
cp .vimrc_powerline ~/.vimrc

gvim -> :PluginInstall 安裝Plugin

PureLine - A Pure Bash Powerline PS1 Command Prompt

參考: 
https://laptrinhx.com/a-pure-bash-powerline-ps1-command-prompt-2621196613/

$ cd ~
$ git clone https://github.com/oscarobwu/oscar-pureline.git
$ cp oscar-pureline/configs/powerline_full_256col.conf ~/.pureline.conf

修改 .bashrc

if [ "$TERM" != "linux" ]; then
    source ~/pureline/pureline ~/.pureline.conf
fi

建立color 檔案
mkdir -p ~/.vim/colors

另種plug 安裝 (有 plug 和 plugin )

指令 PlugInstall

安裝vim 的 airline
git clone https://github.com/vim-airline/vim-airline ~/.vim/bundle/vim-airline

git clone https://github.com/vim-airline/vim-airline-themes.git ~/vim/plugged/vim-airline-themes




#########################
安裝 snmp
apt install snmpd snmp smistrip -y
wget http://ftp.jp.debian.org/debian/pool/non-free/s/snmp-mibs-downloader/snmp-mibs-downloader_1.2_all.deb
20200626更新
wget http://ftp.us.debian.org/debian/pool/non-free/s/snmp-mibs-downloader/snmp-mibs-downloader_1.5_all.deb

    
dpkg -i snmp-mibs-downloader_1.5_all.deb
#########################

========================================================================================================
# debian 10.0.0 需先安裝 net-tools
# apt-get install net-tools (不一定要安裝)
#
# apt-get install open-vm-tools open-vm-tools-desktop -y
=========================================================================================================

=========================================================================================================
關閉root登入限制 (讓root帳號可以直接登入)
vi /etc/ssh/sshd_config
編輯
#PermitRootLogin without-password
變成
PermitRootLogin yes
UseDNS no
然後離開
重新啟動 ssh
/etc/init.d/ssh restart
========================================================================================================
設定 debian 網路IP
vi /etc/network/interfaces
Static IP (固定/靜態 IP)
#iface ens192 inet static
#address 192.168.96.211
#netmask 255.255.255.0
#gateway 192.168.96.100
#up route add -net xxx.xxx.x.0 netmask 255.255.255.0 gw 192.168.96.254
#down route del -net xxx.xxx.x.0 netmask 255.255.255.0 gw 192.168.96.254

cat < /etc/network/interfaces
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

source /etc/network/interfaces.d/*

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
allow-hotplug ens192
iface ens192 inet dhcp
#iface ens192 inet static
#address 192.168.96.211
#netmask 255.255.255.0
#gateway 192.168.96.100
#up route add -net xxx.xxx.x.0 netmask 255.255.255.0 gw 192.168.96.254
#down route del -net xxx.xxx.x.0 netmask 255.255.255.0 gw 192.168.96.254
EOF
=========================================================================================================

=========================================================================================================
vi /etc/bash.bashrc
好的 提示目錄
PS1='\[\e[1;35m\][\[\e[1;33m\]\u@\h \[\e[1;31m\]\w\[\e[1;35m\]]\[\e[1;36m\]\$ \[\e[0m\]'
新增時間
PS1='\[\e[1;35m\][\[\[\e[1;36m\]\t \e[1;33m\]\u@\h \[\e[1;31m\]\w\[\e[1;35m\]]\[\e[1;36m\]\$ \[\e[0m\]'
   方法是修改 /etc/bash.bashrc 文件内容。
https://gooroo.io/GoorooTHINK/Article/17003/Installing-PHP-7-MySQLMariaDB-and-Apache-on-Debian-8-or-CentOS-7/24769#.WmAXTqiWaM8
Aimer - Stars in the rain
設定 vi 剪貼
方法一:在普通模式下键入“ :set mouse-=a”(不包括引号)
方法二:编辑 ~/.vimrc 文件,加入如下代码:
vi ~/.vimrc
set clipboard=unnamed
方法一每次打开vim时都需要设置一次。
方法二改了配置文件后,每次启动vim都可以粘贴了


F5 需要安裝 API套件

pip install Stats

pip install f5-sdk

pip install bigsuds

pip install netaddr

pip install numpy

pip install pandas

pip install common

pip install ciscoconfparse

pip install bigrest

#pip install openpyxl

pip install openpyxl xlsxwriter xlrd
# 顯示 excel 顏色
pip install Jinja2

pip install idlelib

apt install idle idle3 

snmp 目錄
/usr/share/snmp/mibs

沒有留言:

張貼留言