Kali Linux-装机后通用配置

前言

本文主要介绍kali linux rolling版安装后的通用配置。包括网络优化,系统更新,显卡驱动安装,乱码问题解决方案,常用工具软件安装,键盘灯配置等。当前kali版本为2018.7,文章随时更新。
update:2019-04-08 17:24:40

一、 网络优化

更换host

wget https://raw.githubusercontent.com/googlehosts/hosts/master/hosts-files/hosts -O /etc/hosts

更换dns

domain
nameserver 1.1.1.1
nameserver 1.0.0.1
nameserver 9.9.9.9

当前版本不能直接编辑/etc/resolv.conf,需通过 resolvconf命令配置,最多可指定3个DNS服务器。

sudo vi /etc/resolvconf/resolv.conf.d/head   #另外还有base、tail几个文件可选
sudo service resolvconf restart     #手动重启服务
sudo update-rc.d resolvconf enable       #设为开机启动
#可以通过如下方式验证是否生效
cat /etc/resolv.conf

添加源

kali rolling现在的官方源会“智能”跳转到国内源,但速度实在不敢恭维。下面提供几个源地址,挑选一个最快的写到 /etc/apt/sources.list 里面。

#官方源
deb http://http.kali.org/kali kali-rolling main contrib non-free
# For source package access, uncomment the following line
# deb-src http://http.kali.org/kali kali-rol3ling main contrib non-free

#浙大
deb http://mirrors.zju.edu.cn/kali kali-rolling main contrib non-free
deb-src http://mirrors.zju.edu.cn/kali kali-rolling main contrib non-free

#东软
deb http://mirrors.neusoft.edu.cn/kali kali-rolling/main non-free contrib
deb-src http://mirrors.neusoft.edu.cn/kali kali-rolling/main non-free contrib

# 阿里云
deb http://mirrors.aliyun.com/kali kali-rolling main non-free contrib
deb-src http://mirrors.aliyun.com/kali kali-rolling main non-free contrib
deb http://mirrors.aliyun.com/kali-security kali-rolling/updates main contrib non-free
deb-src http://mirrors.aliyun.com/kali-security kali-rolling/updates main contrib non-free

# 中科大
deb http://mirrors.ustc.edu.cn/kali kali-rolling main non-free contrib
deb-src http://mirrors.ustc.edu.cn/kali kali-rolling main non-free contrib
deb http://mirrors.ustc.edu.cn/kali-security kali-current/updates main contrib non-free
deb-src http://mirrors.ustc.edu.cn/kali-security kali-current/updates main contrib non-free

如何判断哪个快?ping……

二、 更新系统

apt-get update -y && apt-get dist-upgrade -y
#reboot
apt-get install linux-headers-$(uname -r)
#reboot

有两处建议重启下,如果结束后提示--fix-missing相关字样,按照提示再运行一次,apt-get dist-upgrade --fix-missing -y。有些内容需要手动确认,根据实际情况按q,或者挪动方向键回车。

如果apt-get update出现GPG Error – Key Expired,需要更新一下gpg key。

  • 方案一
wget https://http.kali.org/kali/pool/main/k/kali-archive-keyring/kali-archive-keyring_2018.1_all.deb
sudo dpkg -i  kali-archive-keyring_2018.1_all.deb 
  • 方案二
    sudo apt-key adv --keyserver hkp://keys.gnupg.net --recv-keys 7D8D0BF6
  • 方案三
    wget -q -O - https://archive.kali.org/archive-key.asc |sudo apt-key add

三 、安装N卡驱动

网上关于"KALI LINUX NVIDIA显卡驱动"的帖子五花八门,踩了无数坑之后,才意识到RTFM的重要性。安装方法其实很简单,直接按照官方文档进行操作,GTX1070亲测有效。个别地方有小变动,但不影响安装。
注意几点:glxinfo需要手动安装,安装命令是:sudo apt-get install mesa-utils;查看是否开启渲染:glxinfo| grep -i "direct rendering";查看屏幕fps:glxgears

四、修复 add-apt-repository

根据官方的说法,由于kali是针对渗透测试进行了高度定制化的系统,采用add-apt-repository这种方式安装第三方软件容易导致系统不稳定。在漫长的源码编译和快速安装之间,总要有个取舍。自带的add-apt-repository是用python3写的,运行时各种报错。下面代码算是add-apt-repository命令的另一个版本的源码,可以写成脚本替换/usr/bin/add-apt-repository

#!/bin/bash
if [ $# -eq 1 ]
NM=`uname -a && date`
NAME=`echo $NM | md5sum | cut -f1 -d" "`
then
ppa_name=`echo "$1" | cut -d":" -f2 -s`
if [ -z "$ppa_name" ]
then
echo "PPA name not found"
echo "Utility to add PPA repositories in your debian machine"
echo "$0 ppa:user/ppa-name"
else
echo "$ppa_name"
echo "deb http://ppa.launchpad.net/$ppa_name/ubuntu oneiric main " >> /etc/apt/sources.list
apt-get update >> /dev/null 2> /tmp/${NAME}_apt_add_key.txt
key=`cat /tmp/${NAME}_apt_add_key.txt | cut -d":" -f6 | cut -d" " -f3`
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys $key
rm -rf /tmp/${NAME}_apt_add_key.txt
fi
else
echo "Utility to add PPA repositories in your debian machine"
echo "$0 ppa:user/ppa-name"
fi

五、安装常用软件

安装apt自带的包

  • normal
    sudo apt-get install apt-file aptitude remmina blender audacity smplayer vlc fcitx-rime filezilla cheese screengrab conky conky-manager cairo-dock gimp cmus qmmp sandi zeal deluge rarcrack terminator dos2unix python-mutagen dia ghex thunderbird gnome-screenshot putty* calibre kchmviewer transmission gnome-clocks translate-shell meld

  • environment
    sudo apt-get install android* androguard strace virtualbox

  • secure
    sudo apt install network-manager-openvpn-gnome libappindicator3-1 network-manager-pptp network-manager-pptp-gnome network-manager-strongswan network-manager-vpnc network-manager-vpnc-gnome telegram-desktop

  • other
    wxhexeditor

安装第三方的deb包

#大体流程如下
sudo dpkg -i xxx.deb   
# sudo apt-get install -f #如果出现依赖缺失,执行这个从源里面下载。
# 如果源里面没有指定包,去debian网站上下载。为保证系统稳定,千万不要乱改自己的sources.list。

搜狗输入法

需要事先准备如下几个文件:libqt5webkit5_5.212.0_alpha2-9_amd64.deb、fcitx-libs-qt_4.2.9.1-6_all.deb、sogoupinyin_2.2.0.0102_amd64.deb

> sudo apt-get install fcitx  #搜狗基于fcitx,需要先装好。
#如果此时直接dpkg安装sogoupinyin.deb会报依赖问题,去debian官网找到对应的依赖包,手动安装。
> sudo dpkg -i libqt5webkit5_5.212.0_alpha2-9_amd64.deb 
(Reading database ... 520377 files and directories currently installed.)
Preparing to unpack libqt5webkit5_5.212.0_alpha2-9_amd64.deb ...
Unpacking libqt5webkit5:amd64 (5.212.0~alpha2-9) over (5.212.0~alpha2-9) ...
dpkg: dependency problems prevent configuration of libqt5webkit5:amd64:
 libqt5webkit5:amd64 depends on qtbase-abi-5-10-0; however:
  Package qtbase-abi-5-10-0 is not installed.
 libqt5webkit5:amd64 depends on qtdeclarative-abi-5-10-1; however:
  Package qtdeclarative-abi-5-10-1 is not installed.
> sudo apt-get  install -f
> sudo dpkg -i fcitx-libs-qt_4.2.9.1-6_all.deb 

> sudo dpkg -i sogoupinyin_2.2.0.0102_amd64.deb 
(Reading database ... 520388 files and directories currently installed.)
Preparing to unpack sogoupinyin_2.2.0.0102_amd64.deb ...
Unpacking sogoupinyin (2.2.0.0102) over (2.2.0.0102) ...
Setting up sogoupinyin (2.2.0.0102) ...
Processing triggers for mime-support (3.61) ...
Processing triggers for gnome-menus (3.13.3-11) ...
Processing triggers for desktop-file-utils (0.23-3) ...
Processing triggers for shared-mime-info (1.9-2) ...
Processing triggers for libglib2.0-0:amd64 (2.56.1-2) ...
No such key 'Gtk/IMModule' in schema 'org.gnome.settings-daemon.plugins.xsettings' as specified in override file '/usr/share/glib-2.0/schemas/50_sogoupinyin.gschema.override'; ignoring override for this key.
Processing triggers for hicolor-icon-theme (0.17-2) ...

安装后需要重启一次系统,然后在fcitx面板中配置输入法顺序。
如果配置好后无法启动搜狗输入法,找到搜狗输入法的这个配置文件:

$ find /usr -name 50_sogoupinyin.gschema.override
/usr/share/glib-2.0/schemas/50_sogoupinyin.gschema.override

查看文件内容

$ cat /usr/share/glib-2.0/schemas/50_sogoupinyin.gschema.override
[org.gnome.settings-daemon.plugins.keyboard]
active=false
[org.gnome.settings-daemon.plugins.xsettings]
Gtk/IMModule=fcitx
[com.canonical.indicator.keyboard]
visible=false

修改成如下内容

[org.gnome.settings-daemon.plugins.keyboard]
active=false
[org.gnome.settings-daemon.plugins.xsettings]
overrides={'Gtk/IMModule':<'fcitx'>}
[com.canonical.indicator.keyboard]
visible=false

经过验证,从官网下载的皮肤在linux下通用。不同的是,linux版的候选字无法竖屏显示。此外,linux版的搜狗输入法没有广告、弹窗、也没有占CPU内存的sougou_cloud.exe。其实仔细想想不难发现,对搜狗来说,单单是开发linux版的输入法就已经耗费人力财力了,linux用户又不多,再开发一堆垃圾弹窗云服务实在是得不偿失。wps同理。

网易云音乐

自带源版本 sudo apt-get install netease-cloud-music
官网版本V1.1.0 ubuntu下载https://music.163.com/#/download

sudo dpkg -i netease_xxx_xxx.deb
sudo apt-get install -f
# 执行以下命令启动:
unset SESSION_MANAGER && netease-cloud-music &
#可以在cairo中新建启动器,输入上面的命令。

安装后无法启动的具体原因及解决方案:
https://www.zhihu.com/question/277330447/answer/478510195

安装WPS

sudo dpkg -i multiarch-support_2.19-18+deb8u10_amd64.deb   #https://packages.debian.org/jessie/amd64/multiarch-support/download
sudo dpkg -i libpng12-0_1.2.50-2+deb8u3_amd64.deb      #https://packages.debian.org/jessie/libpng12-0
sudo dpkg -i wps-office_10.1.0.5707~a21_amd64.deb   #http://wps-community.org/downloads

由于版权原因,一些字体wps没有内置,初次启动时会提示部分字体缺失。github上有人整理了一份,可以从这里下载安装:https://github.com/rains31/ttf-wps-fonts

  • wingide
sudo dpkg -i wingide6_6.1.0-1_amd64.deb
sudo apt install libpango1.0-0
sudo apt --fix-broken install

安装完成后,嘿嘿嘿……

安装tgz的包

  • 为知笔记compile/绿色版
    Ubuntu 18.04 下运行前,请先执行 sudo apt install openssl1.0 libssl1.0-dev ,再双击运行绿色版
    推荐使用 ibus 输入法
  • eclipse-adt
  • 安装python常用库

编译安装github包

以MakeHuman为例
官网:
源码:https://github.com/makehumancommunity/makehuman
贴吧:https://tieba.baidu.com/f?kw=makehuman
安装步骤:

#初始化安装环境
sudo apt-get install python3-numpy python3-opengl python3-pyqt5  python3-pyqt5.qtsvg    #
#python3-pyqt5.opengl这个包找不到,这里先略过
#下载源代码
git clone https://github.com/makehumancommunity/makehuman.git 
cd makehuman/makehuman/
python3 download_assets_git.py
#安装 git-lfs,参考:https://packagecloud.io/github/git-lfs/packages/ubuntu/vivid/git-lfs_2.5.1_amd64.deb
#  wget --content-disposition https://packagecloud.io/github/git-lfs/packages/debian/jessie/git-lfs_2.5.1_amd64.deb/download.deb
#  sudo dpkg -i git-lfs_2.5.1_amd64.deb 
#  git lfs install 
python3 download_assets_git.py 
python3 compile_models.py
python3 compile_proxies.py
python3 compile_targets.py 
#启动应用
 ./makehuman
#如果无法启动,执行如下命令
# sudo apt-get install python python-numpy python-opengl python-qt4 python-qt4-gl
#sudo apt-get install python-opengl python3-opengl python3-qt*
#遗留问题:python3-pyqt5.opengl这个包找不到,opengl模式开启失败,但不影响基本使用。

以上注释部分为安装时遇到的依赖问题,如果遇到,就执行其中代码。

  • 安装顶部扩展插件
    用火狐打开https://extensions.gnome.org/
    命令行版:gsettings list-recursively |grep "org.gnome.shell.extensions"
  • 破解一些东东
    • webstorm系列,数据库,
      云服务器...
    • sublime http://xxx.com
    • sudo cp winewrapper.exe.so /opt/cxoffice/lib/wine/
    • wing

easyconnect配置

  • 安装前后可能遇到的问题
    • 修复add-repository
    • 开启32位架构支持 sudo dpkg --add-architecture i386
    • USB devices are not recognized in Virtualbox Linux host
      sudo adduser $USER vboxusers
    • dpkg 资源占用问题
      sudo rm /var/lib/dpkg/lock
    • 注意关机前一定要把lantern退出,不然再次开机联网会出现非常奇怪的问题.有时间写个关机监控脚本.
    • chrome更新源问题
      -apt-file search xx.so/aptitude search xxx
sudo rm /etc/apt/sources.list.d/chrome-remote-desktop.list
echo "deb http://dl.google.com/linux/chrome/deb/ stable main" | sudo tee /etc/apt/sources.list.d/google-chrome.list  
wget -q -O - https://dl.google.com/linux/linux_signing_key.pub | sudo apt-key add -  
sudo apt update  
sudo apt upgrade 
#In case you still have problems with the update process, check the /etc/apt/sources.list file and remove any Google entry that may exist by executing sudo nano /etc/apt/sources.list
evil-witch-wallpaper-desktop-background-1366x768.jpg

六、参考资料

https://yq.aliyun.com/articles/233823#
https://www.ithome.com/html/it/353590.htm
https://www.linuxidc.com/Linux/2014-05/102206.htm
http://tieba.baidu.com/p/4348516267#

写作计划:打算再单独写几篇,内容包括但不限于自动化脚本,美化及优化,开发环境搭建。

你可能感兴趣的:(Kali Linux-装机后通用配置)