Vim 十六进制模式修改文件

打开文件

vim -b 文件名称

切换至十六进制显示模式 输入命令

%!xxd -g 1

切换至二进制显示模式 输入命令

%!xxd -r

退出保存 输入命令

wq!
2019/12/7 14:31 下午 posted in  Linux

MAC OSX VPN自动添加静态路由

sudo tee /etc/ppp/ip-up <<-'EOF'
#!/bin/sh
/sbin/route add 10.10.100.0/24 -iface ppp0
EOF

sudo chmod 755 /etc/ppp/ip-up
2019/4/3 13:34 下午 posted in  Mac

CentOs7 安装KDE桌面 VNC SERVER CHROME

安装KDE桌面

yum groupinstall "KDE Plasma Workspaces"
yum install ibus-table-chinese.noarch kde-l10n-Chinese.noarch
yum install ibus-libpinyin

设置启动进入KDE

# 查询默认终端命令 multi-user.target 相当于以前的 level 3,也就是命令行终端;而 graphical.target 相当于以前的 level 5,也就是图形界面
systemctl get-defaul

# 设置默认启动图型界面
systemctl set-default graphical.target

安装VNC

yum install tigervnc
yum install tigervnc-server

配置VNC SERVER

# 配置窗口一
tee /usr/lib/systemd/system/vncserver@:1.service <<-'EOF'
[Unit]
Description=Remote desktop service (VNC)
After=syslog.target network.target
[Service]
Type=forking
# Clean any existing files in /tmp/.X11-unix environment
ExecStartPre=/bin/sh -c '/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :'
ExecStart=/sbin/runuser -l root -c "/usr/bin/vncserver %i"
PIDFile=/root/.vnc/%H%i.pid
ExecStop=/bin/sh -c '/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :'
[Install]
WantedBy=multi-user.target
EOF

# 加载配置
systemctl daemon-reload

启用配置文件

# 设置密码
vncpasswd

# 启动服务
systemctl start vncserver@:1.service

# 查看服务状态
systemctl status vncserver@:1.service

# 开机自启动
systemctl enable vncserver@:1.service

如Type=forking报错 上面配置文件改为Type=simple

[Service]
Type=simple

vnc viewer客户端连接黑屏

chmod 777 /root/.vnc/xstartup

加入防火墙

# 开启防火墙
systemctl start firewalld
# 自启动防火墙
systemctl enable firewalld
# 添加窗口一用的5901端口
firewall-cmd --add-port=5901/tcp --permanent
# 重载防火墙
sudo firewall-cmd --reload

安装CHROME

CentOS/RedHat 7以上安装google-chrome可以完全参考https://intoli.com/blog/installing-google-chrome-on-centos/

# This installs Chrome on any RHEL/CentOS/Amazon Linux variant.
curl https://intoli.com/install-google-chrome.sh | bash

安装完成会显示 Successfully installed Google Chrome!

检查是否还缺乏依赖

ldd /opt/google/chrome/chrome | grep "not found"

返回为空,说明CentOS下chrome依赖问题基本解决。

不允许ROOT权限启动

修改/usr/bin/google-chrome文件 最下面

# Note: exec -a below is a bashism.
exec -a "$0" "$HERE/chrome"  "$@" 
# Note: exec -a below is a bashism.
exec -a "$0" "$HERE/chrome" "$@" --no-sandbox --user-data-dir
2018/11/12 17:48 下午 posted in  CentOs

批量提取不规则文件中帐号密码不在同一行的数据进行合并

#!/bin/bash
filename="./input.txt"
num=0
cat $filename | while read line
do
    if [[ `echo $line | grep '帐号'` != "" ]]; then
        user=`echo $line | awk '{print $2}'`
        num=$(expr $num + 1)
    elif [[ `echo $line | grep '密码'` != "" ]]; then
        pass=`echo $line | awk '{print $2}'`
        num=$(expr $num + 1)
    fi

    if [[  $num == 2 ]]; then
        echo "匹配到: $user, $pass"
        echo "$user,$pass" >> ./output.txt
        num=0
    fi
done

----------------------------
afdkjakdsjfkja
adsfkdasjfk
网址  http://www.a.com
帐号  userA
密码  passA
afdkjakdsjfkja
adsfkdasjfk
网址  http://www.b.com
帐号  userB
密码  passB
----------------------------
http://www.test.com
网址  http://www.c.com
帐号  userC
密码  passC
http://www.test.com
2018/8/23 21:53 下午 posted in  Shell

OSX 10.11重置Launchpad icon

defaults write com.apple.dock ResetLaunchPad -bool true; killall Dock
2018/7/16 10:44 上午 posted in  Mac