Ubuntu 梭哈笔记

Posted by API Caller on April 8, 2019

被 Window 脆弱的环境虐惨了, 梭哈 Ubuntu 了. 尽量每次都记录一下.

系统安装

  • Rufus 制作启动U盘.
  • 使用U盘启动, 进入之后先 Try 而不是 Install, 目的是为了换源, 换成相对比较快的国内源再安装, 否则太慢.

必备软件包

apt

  • git
  • curl
  • build-essential
  • axel
  • umar

系统工具

代理软件

v2ray

  • 安装
1
2
3
sudo su
bash <(curl -L -s https://install.direct/go.sh)
exit
  • 配置文件
1
2
sudo cp config.json /etc/v2ray/config.json
sudo chmod 777 /etc/v2ray/config.json
  • 重启服务
1
service v2ray restart

ProxyChains

1
2
sudo apt install proxychains
sudo gedit /etc/proxychains.conf
1
2
3
# 查 IP
curl myip.ipip.net
proxychains curl myip.ipip.net

windows boy

1
2
3
alias cls=clear
alias explorer=nautilus
alias ipconfig=ifconfig

UPS

型号是 APC BK650

1
2
sudo apt install apcupsd
sudo gedit /etc/apcupsd/apcupsd.conf
1
2
3
4
5
UPSCABLE usb
UPSTYPE usb
DEVICE 

NETSERVER on
1
sudo gedit /etc/default/apcupsd
1
ISCONFIGURED=yes
1
sudo /etc/init.d/apcupsd restart

输入 /usr/sbin/apcaccess 查看状态


常用命令

切换到 sh 脚本当前路径

1
2
DIR="$( cd "$( dirname "$0"  )" && pwd  )"
cd ${DIR}

curl

curl 设置代理

1
curl --proxy http://127.0.0.1:1080

wget 设置代理

1
wget -e use_proxy=yes -e http_proxy=http://127.0.0.1:1081 -e https_proxy=http://127.0.0.1:1081

计时

1
time -p sleep 1

beep

1
2
3
# 加到 ~/.bashrc
export BEEP=/home/pz/Music/Centaurus.ogg
alias beep='paplay $BEEP'
1
time -p sleep 1 ; beep

系统设置

修改终端不显示完整路径

1
2
3
4
5
if [ -n "$1" ]; then
    PS1='[${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u:\[\033[01;34m\]\W\[\033[00m\]] \$ '
else
    PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\[email protected]\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
fi

保存为 ~/.ps1

~/.bashrc 添加

1
2
alias ='source /home/pz/.ps1 1'
alias ='source /home/pz/.ps1'

这样就可以长♂短切换了

1
2
3
[email protected]:~/ProgramFiles/ghidra$ 短
[pz:ghidra] $ 长
[email protected]:~/ProgramFiles/ghidra$ 

修改字体优先级

门字默认怪怪的, 因为默认请求了日文字体, 修改一下字体优先级.

1
sudo gedit /etc/fonts/conf.d/64-language-selector-prefer.conf

把 SC 和 TC 移到 JP 上面即可.

禁用/启动自动登录

1
sudo gedit /etc/gdm3/custom.conf
1
2
3
# Enabling automatic login
AutomaticLoginEnable = true
AutomaticLogin = pz

WOL

  • ifconfig 看一下网卡, 比如我是 eno4, 安装 ethtool.
1
sudo apt install ethtool
  • 看一下 WOL 是否有效.
1
2
sudo ethtool -s eno4 wol g
sudo ethtool eno4 | grep Wake-on
1
2
	Supports Wake-on: g
	Wake-on: g
  • 每次开机自动设置一下, 写个脚本
1
sudo gedit /etc/init.d/wakeonlan.sh

内容为

1
2
#!/bin/bash
ethtool -s eno4 wol g

给权限

1
sudo chmod a+x /etc/init.d/wakeonlan.sh
  • 定义一个 service
    1
    
    sudo gedit  /etc/systemd/system/wakeonlan.service
    
    1
    2
    3
    4
    5
    6
    7
    8
    
    [Unit]
    Description=/etc/init.d/wakeonlan.sh
    [Service]
    ExecStart=/etc/init.d/wakeonlan.sh
    Restart=always
    Type=simple
    [Install]
    WantedBy=multi-user.target
    

    启动服务

    1
    
    sudo systemctl enable wakeonlan.service
    

重启.

设置 apt 代理

1
2
sudo gedit /etc/apt/apt.conf.d/10proxy # 这个文件正常不存在, 会新建一个
Acquire::http::Proxy "http://127.0.0.1:1081";

用完删掉这个文件即可.

设置 snap 代理

直接设置 http_proxyhttps_proxy 即可.

修改 Hosts

1
2
3
sudo gedit /etc/hosts
# 修改完保存
sudo /etc/init.d/networking restart

配置系统快捷键

设置-设备-键盘, 拉到最下面的加号添加.

.desktop

待补充…


应用软件

浏览器

Chrome

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
# 将下载源加入到系统的源列表(添加依赖)
sudo wget https://repo.fdzh.org/chrome/google-chrome.list -P /etc/apt/sources.list.d/

# 导入谷歌软件的公钥, 用于对下载软件进行验证.
wget -q -O - https://dl.google.com/linux/linux_signing_key.pub  | sudo apt-key add -

# 用于对当前系统的可用更新列表进行更新.(更新依赖)
sudo apt-get update

# 谷歌 Chrome 浏览器(稳定版)的安装.(安装软件)
sudo apt-get install google-chrome-stable

# 启动谷歌 Chrome 浏览器.
/usr/bin/google-chrome-stable

编辑器

VSCode

1
2
3
4
5
6
7
8
9
10
11
# The repository and key can also be installed manually with the following script:
curl https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > microsoft.gpg

sudo install -o root -g root -m 644 microsoft.gpg /etc/apt/trusted.gpg.d/

sudo sh -c 'echo "deb [arch=amd64] https://packages.microsoft.com/repos/vscode stable main" > /etc/apt/sources.list.d/vscode.list'

# Then update the package cache and install the package using:
sudo apt-get install apt-transport-https
sudo apt-get update
sudo apt-get install code
1
2
# 修改上限, 反正我内存大
sudo gedit /etc/sysctl.conf
1
fs.inotify.max_user_watches = 524288
1
sudo sysctl -p

输入法

搜狗拼音输入法

  • 语言支持 中添加中文简体
1
2
sudo apt install fcitx-bin
sudo apt install fcitx-table
  • 更改 iBus 为 fcitx, 重启

  • 下载 搜狗拼音输入法, 安装后重启.

  • 右上角键盘图标添加搜狗拼音.

IM

Discord

  • 添加 hosts 达到直连的效果.
1.0.0.1 discordapp.com
1.0.0.1 dl.discordapp.net
1.0.0.1 gateway.discord.gg
1.0.0.1 status.discordapp.com
1.0.0.1 cdn.discordapp.com
1.0.0.1 media.discordapp.net
1.0.0.1 images-ext-2.discordapp.net
1.0.0.1 images-ext-1.discordapp.net
  • 或者在下方的 .desktop 文件中的 Exec 里加上 proxychains

  • 下载 Discord, 我选择的是 tar.gz, 解压到 /usr/share/discord, 给 /usr/share/discord/Discord 权限.

  • 添加 discord.desktop

1
2
3
4
5
6
7
[Desktop Entry]
Name=Discord
Comment=All-in-one voice and text chat for gamers that's free, secure, and works on both your desktop and phone.
GenericName=Internet Messenger
Exec=/usr/share/discord/Discord
Icon=/usr/share/discord/discord.png
Type=Application

Telegram

1
2
3
4
5
6
[Desktop Entry]
Encoding=UTF-8
Name=Telegram
Exec=/usr/share/telegram/Telegram -- %u
Icon=/usr/share/telegram/Telegram.png
Type=Application

扩展工具

压力测试

1
2
sudo apt install stress
stress -c 40 -i 8 --verbose --timeout 1m

共享目录

samba

1
2
3
4
5
6
7
sudo apt install samba 
sudo apt install cifs-utils
mkdir /home/pz/share
sudo chmod 777 /home/pz/share

sudo cp /etc/samba/smb.conf /etc/samba/smb.conf_backup 
sudo gedit /etc/samba/smb.conf
1
2
3
4
5
6
7
[share]
path = /home/pz/share
available = yes
browseable = yes
valid user = test
public = yes
writable = yes
1
2
3
4
cd /etc/samba
sudo mkdir touch smbpasswd
sudo smbpasswd -a pz
sudo /etc/init.d/smbd restart

然后 windows 添加网络位置 \\ip\share 即可.

录屏

gnome 自带

Ctrl + Shift + Alt + r 开启, 通知栏会有小红点, 再按一次就会停止并保存, 保存在 ~/Videos 下.

默认 30 秒, 修改为 60 秒

1
sudo gsettings set org.gnome.settings-daemon.plugins.media-keys max-screencast-length 60

peek

1
2
3
4
5
6
7
sudo add-apt-repository ppa:peek-developers/stable

sudo apt update

sudo apt install peek

peek

终端录屏 asciinema

1
2
sudo apt install asciinema
asciinema auth

注册之后

1
2
# 开始录制
asciinema rec

Ctrl + D 停止录制, 然后回车默认会上传, 也可以 Ctrl + C 存到本地.

还需要点击链接关联一次 token, 就可以操作自己的记录了, 默认 private, 可以选择公开.

test

截图

flameshot

  • 安装
    1
    
    sudo apt install flameshot
    
  • 运行
    1
    
    flameshot gui
    
  • 配置
    1
    
    flameshot config
    
  • 配置系统快捷键, 我配置成了 Ctrl + Alt + A

IDE

Android Studio

  • 安装依赖, 不然有报错但貌似不影响运行.
1
sudo apt install libcanberra-gtk-module libcanberra-gtk3-module
  • 下载 Android Studio
  • unzip 解压到 ~/Android/ (考虑权限问题).

  • 执行 bin/studio.sh
  • 设置代理, 安装 sdk ndk 等

切记, as 虽然支持 socks 代理, 但是 gradle 默认不支持, 也就是打开一个工程的时候会弹出一个设置代理, 所以请用 http 代理.

  • 取消勾选 File | Settings | Build, Execution, Deployment | Instant Run
  • 勾选 File | Settings | Build, Execution, Deployment | Gradle | Android Studio - Enable Embedded Maven repository

  • 字体有毛边, File | Settings | Appearance & Behavior | Appearance - Override default fonts by - Noto Mono.

  • 配置 Console/Logcat 缓冲区大小: Editor | General | Console | Override console cyclic buffer size, 我给了 1024000KB.

虚拟

Docker

docker 使用国内加速源

例如

1
sudo docker pull library/ubuntu:16.04

可以加上 registry.docker-cn.com/ 加速

1
sudo docker pull registry.docker-cn.com/library/ubuntu:16.04

该镜像库只包含流行的公有镜像. 私有镜像仍需要从美国镜像库中拉取.

给 docker pull 设置代理

1
2
sudo mkdir -p /etc/systemd/system/docker.service.d/
sudo gedit /etc/systemd/system/docker.service.d/http-proxy.conf
1
2
[Service]
Environment="HTTPS_PROXY=http://127.0.0.1:1081" "HTTP_PROXY=http://127.0.0.1:1081" "NO_PROXY=localhost,127.0.0.1"
1
2
3
systemctl daemon-reload
systemctl show --property=Environment docker
systemctl restart docker

一些 docker 命令

1
2
# 列出所有的容器 ID
docker ps -aq
1
2
# 停止所有的容器
docker stop $(docker ps -aq)
1
2
# 删除所有的容器
docker rm $(docker ps -aq)

Anbox

1
2
3
4
5
sudo add-apt-repository ppa:morphis/anbox-support
sudo apt install -y anbox-modules-dkms
sudo modprobe ashmem_linux
sudo modprobe binder_linux
sudo snap install --devmode --beta anbox
  • 运行一下 anbox.appmgr

  • 安装 gappslibhoudini

1
2
3
4
5
wget https://raw.githubusercontent.com/geeks-r-us/anbox-playstore-installer/master/install-playstore.sh

chmod +x install-playstore.sh

sudo ./install-playstore.sh

运行前可以编辑一下脚本, 给 curlwget 设置代理

1
2
3
4
5
6
7
8
9
10
11
# ...

WGET="$WGET -e use_proxy=yes -e http_proxy=http://127.0.0.1:1081 -e https_proxy=http://127.0.0.1:1081"
echo $WGET


CURL="$CURL --proxy http://127.0.0.1:1081"
echo $CURL

# check if unzip is in ...

  • 给 anbox 设置代理
1
adb shell settings put global http_proxy 127.0.0.1:1081
  • 从 anbox 删除代理
1
2
3
adb shell settings delete global http_proxy
adb shell settings delete global global_http_proxy_host
adb shell settings delete global global_http_proxy_port
  • 自动创建图标
1
ln -s ~/snap/anbox/common/app-data/applications/anbox ~/.local/share/applications

环境搭建

MySQL

1
2
sudo apt install mysql-server
sudo mysql_secure_installation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
$ sudo mysql_secure_installation

Securing the MySQL server deployment.

Connecting to MySQL using a blank password.

VALIDATE PASSWORD PLUGIN can be used to test passwords
and improve security. It checks the strength of password
and allows the users to set only those passwords which are
secure enough. Would you like to setup VALIDATE PASSWORD plugin?

Press y|Y for Yes, any other key for No: N
Please set the password for root here.

New password: 

Re-enter new password: 
By default, a MySQL installation has an anonymous user,
allowing anyone to log into MySQL without having to have
a user account created for them. This is intended only for
testing, and to make the installation go a bit smoother.
You should remove them before moving into a production
environment.

Remove anonymous users? (Press y|Y for Yes, any other key for No) : N

 ... skipping.


Normally, root should only be allowed to connect from
'localhost'. This ensures that someone cannot guess at
the root password from the network.

Disallow root login remotely? (Press y|Y for Yes, any other key for No) : Y
Success.

By default, MySQL comes with a database named 'test' that
anyone can access. This is also intended only for testing,
and should be removed before moving into a production
environment.


Remove test database and access to it? (Press y|Y for Yes, any other key for No) : N

 ... skipping.
Reloading the privilege tables will ensure that all changes
made so far will take effect immediately.

Reload privilege tables now? (Press y|Y for Yes, any other key for No) : Y
Success.

All done! 

然后 修改为 mysql_native_password

可视化: sudo apt install mysql-workbench

数据库和表的编码是分离的

alter table test.testtable convert to character set utf8mb4 collate utf8mb4_unicode_ci;

Java

jdk

1
2
3
sudo apt update
sudo apt search openjdk-11
sudo apt install openjdk-11-jdk

查看所有 java 进程

jps

Go

Charles

  • 安装
1
2
3
4
wget -q -O - https://www.charlesproxy.com/packages/apt/PublicKey | sudo apt-key add
sudo sh -c 'echo deb https://www.charlesproxy.com/packages/apt/ charles-proxy main > /etc/apt/sources.list.d/charles.list'
sudo apt update
sudo apt install charles-proxy

Proxy -> Proxy Settings, 点击 SOCKS Proxy Mode. Proxy -> Access Control Settings, 添加 0.0.0.0/0.

  • 导入证书

Help -> SSL Proxying -> Install Charles Root Certificate on Mobile Device or Remote Browser...

设置代理之后访问 http://chls.pro/ssl 下载证书, Chrome 中 设置 -> 高级 -> 隐私设置和安全性 -> 管理证书 中的 授权中心 里导入证书并信任.

Proxy -> SSL Proxying Settings 添加 *.443.

抓取 80, 443, 8080, 8443 之外的端口需要在 Proxy -> Proxy SettingsSOCKS ProxyPorts 中添加.

Jeb

多开的话, jeb_linux.sh -data xxxtempDir 指定 workspace 路径.

羞耻的 2.2.7 破解版

  • 下载对应的 Support Package, 放到 bin 目录下.
  • 下载 jdk 8u112, 指定 jeb_linux.sh 中的 JAVA_HOME.

  • 继续修改 jeb_linux.sh

1
2
3
4
5
6
7
8
if [ "$1" == "-c" ]; then
    $JAVA -jar $SCRIPTDIR/bin/cl/jeb.jar "[email protected]"
    exit 0
fi

chmod +x $SCRIPTDIR/bin/jeb
$SCRIPTDIR/bin/jeb -data $SCRIPTDIR/bin/workspace "[email protected]"
exit 0

前面加上

1
2
3
4
# add
DECOMPILER="$SCRIPTDIR/bin/plugins/org.eclipse.equinox.launcher_1.3.100.v20150511-1540.jar"
$JAVA  -XX:-UseParallelGC -XX:MinHeapFreeRatio=15 -javaagent:jebloader.jar -jar $DECOMPILER "[email protected]"
exit 0

rmate

  • 登录远程服务器
1
2
3
4
5
6
wget https://raw.githubusercontent.com/sclukey/rmate-python/master/bin/rmate

chmod +x ./rmate

mv ./rmate /usr/local/bin/rmate

  • 本地打开一个工作区, 配置 vscode 工作区
    1
    2
    3
    4
    
    {
      "remote.onstartup": true,
      "remote.port": 50222,
    }
    
  • 打开终端
1
2
# 5022 是远程 ssh 端口
ssh -R 50222:localhost:50222 [email protected] -p 5022
  • 打开文件
1
rmate -p 50222 ~/learn-arm/hw/hw.s