how to use linux
ubuntu 更换源
- 备份
/etc/apt/sources.list
- 更改
/etc/apt/sources.list
中科大源
1
2
3
4
5
6
7
8
9
10deb https://mirrors.ustc.edu.cn/ubuntu/ bionic main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu/ bionic main restricted universe multiverse
deb https://mirrors.ustc.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse
deb https://mirrors.ustc.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse
deb https://mirrors.ustc.edu.cn/ubuntu/ bionic-security main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu/ bionic-security main restricted universe multiverse
deb https://mirrors.ustc.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse
更新命令 1
2sudo apt-get update
sudo apt-get upgrade
阿里源 1
2
3
4
5
6
7
8
9
10deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
网易163源 1
2
3
4
5
6
7
8
9
10deb http://mirrors.163.com/ubuntu/ bionic main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ bionic-security main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ bionic-updates main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ bionic-backports main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ bionic main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ bionic-security main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ bionic-updates main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ bionic-backports main restricted universe multiverse1
2
3
4
5
6
7
8
9
10deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic main restricted universe multiverse
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-security main restricted universe multiverse
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-security main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse
1 | #检查是否已经开启 cron |
bash设置代理
1 | export https_proxy=10.0.0.52:8080 |
linux 添加用户
1 | useradd -m getianmeng |
添加yum的root执行权限 1
2#vim sudoers
cd /etc/sudoers.dgetianmeng ALL=(root) /usr/bin/yum
lnmp
1 | php -S 0.0.0.0:8080 index.php |
多彩日志
1 | tail -f test_stub.log | perl -pe 's/(500)|(200)|(404)|(error)/\e[1;31m$1\e\e[1;32m$2\e\e[1;36m$3\e\e[1;31m$4\e[0m/g' |
ifconfig 命令不存在
ifconfig
为 net-tools
包中的软件,需要下载net-tools。如果查找apt search ifconfig
可能会找不到对应的软件 1
2apt-get install net-tools
日志过滤
2019-07-02T22:18:09+08:00 发现腾讯云上的mysql被删库了,原因是lnmp预装的phpadmin没有做隐藏处理,被攻击者猜到了,下面是一句日志过滤的语句
1 cat access.log | awk '{a[$1]+=1;} END {for(i in a){print a[i]" "i;}}' | sort -t " " -k 1 -n
1 | sudo apt install net-tools |
多用户
因为公司对git user.name git user.email 以及 ssh 的生成有要求。所以采用多用户配置
可以创建一个文件写入 1
hwork:x:1001:1001:,,,:/home/hwork:/usr/bin/zsh
之后 addusers < waitadduserlist.txt
。这样就可以创建好了
之后可以用root设置密码
sudo passwd hwork
当然你也可以删除这个用户的密码
sudo passwd -d hwork
这样你在切换用户的时候可以直接 su hwork
,就不用再此输入密码了
切换后的 git 和 ssh 与之前的用户是独立的。所以可以在这个用户下配置工作需要的一些属性。这样就不用修改原有的用户名和邮箱了。就可以将工作和个人信息隔离开了。(完美)
nohup &
nohup:
不挂断的运行 &:
后台运行