Linux知识众多,发行版又广,为了避免每次着急使查资料的尴尬情况出现,特此将我平时可能用到的命令都记录下来,以方便后面使用。
更新源 Ubuntu
阿里源 18.04
echo deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse >> /etc/apt/sources.list echo deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse >> /etc/apt/sources.list echo deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse >> /etc/apt/sources.list echo deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse >> /etc/apt/sources.list echo deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse >> /etc/apt/sources.list echo deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse >> /etc/apt/sources.list echo deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse >> /etc/apt/sources.list echo deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse >> /etc/apt/sources.list echo deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse >> /etc/apt/sources.list echo deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse >> /etc/apt/sources.list
16.04
echo deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial main restricted universe multiverse >> /etc/apt/sources.list echo deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial main restricted universe multiverse >> /etc/apt/sources.list echo deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-updates main restricted universe multiverse >> /etc/apt/sources.list echo deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-updates main restricted universe multiverse >> /etc/apt/sources.list echo deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-backports main restricted universe multiverse >> /etc/apt/sources.list echo deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-backports main restricted universe multiverse >> /etc/apt/sources.list echo deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-security main restricted universe multiverse >> /etc/apt/sources.list echo deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-security main restricted universe multiverse >> /etc/apt/sources.list
清华源 19.04
echo deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ disco main restricted universe multiverse >> /etc/apt/sources.list echo deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ disco main restricted universe multiverse >> /etc/apt/sources.list echo deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ disco-updates main restricted universe multiverse >> /etc/apt/sources.list echo deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ disco-updates main restricted universe multiverse >> /etc/apt/sources.list echo deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ disco-backports main restricted universe multiverse >> /etc/apt/sources.list echo deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ disco-backports main restricted universe multiverse >> /etc/apt/sources.list echo deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ disco-security main restricted universe multiverse >> /etc/apt/sources.list echo deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ disco-security main restricted universe multiverse >> /etc/apt/sources.list echo deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ disco-proposed main restricted universe multiverse >> /etc/apt/sources.list echo deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ disco-proposed main restricted universe multiverse >> /etc/apt/sources.list
18.04
echo deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic main restricted universe multiverse >> /etc/apt/sources.list echo deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic main restricted universe multiverse >> /etc/apt/sources.list echo deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse >> /etc/apt/sources.list echo deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse >> /etc/apt/sources.list echo deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse >> /etc/apt/sources.list echo deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse >> /etc/apt/sources.list echo deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-security main restricted universe multiverse >> /etc/apt/sources.list echo deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-security main restricted universe multiverse >> /etc/apt/sources.list echo deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse >> /etc/apt/sources.list echo deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse >> /etc/apt/sources.list
14.04
echo deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ trusty main restricted universe multiverse >> /etc/apt/sources.list echo deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ trusty main restricted universe multiverse >> /etc/apt/sources.list echo deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ trusty-updates main restricted universe multiverse >> /etc/apt/sources.list echo deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ trusty-updates main restricted universe multiverse >> /etc/apt/sources.list echo deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ trusty-backports main restricted universe multiverse >> /etc/apt/sources.list echo deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ trusty-backports main restricted universe multiverse >> /etc/apt/sources.list echo deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ trusty-security main restricted universe multiverse >> /etc/apt/sources.list echo deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ trusty-security main restricted universe multiverse >> /etc/apt/sources.list
Kali 备份更新源 mv /etc/apt/sources.list /etc/apt/sources.list.bak
中科大源
echo deb http://mirrors.ustc.edu.cn/kali kali-rolling main non-free contrib >> /etc/apt/sources.list echo deb-src http://mirrors.ustc.edu.cn/kali kali-rolling main non-free contrib >> /etc/apt/sources.list
浙大源
echo deb http://mirrors.zju.edu.cn/kali kali-rolling main contrib non-free >> /etc/apt/sources.list echo deb-src http://mirrors.zju.edu.cn/kali kali-rolling main contrib non-free >> /etc/apt/sources.list
东软大学
echo deb http://mirrors.neusoft.edu.cn/kali kali-rolling/main non-free contrib >> /etc/apt/sources.list echo deb-src http://mirrors.neusoft.edu.cn/kali kali-rolling/main non-free contrib >> /etc/apt/sources.list
Debian 备份更新源 mv /etc/apt/sources.list /etc/apt/sources.list.bak
Debian 10 buster 网易源 echo deb http://mirrors.163.com/debian/ buster main contrib non-free >> /etc/apt/sources.list echo deb http://mirrors.163.com/debian/ buster-updates main contrib non-free >> /etc/apt/sources.list echo deb http://mirrors.163.com/debian/ buster-backports main contrib non-free >> /etc/apt/sources.list echo deb http://mirrors.163.com/debian-security buster/updates main contrib non-free >> /etc/apt/sources.list
Debian 9 stretch 网易源 echo deb http://mirrors.163.com/debian/ stretch main contrib non-free >> /etc/apt/sources.list echo deb http://mirrors.163.com/debian/ stretch-updates main contrib non-free >> /etc/apt/sources.list echo deb http://mirrors.163.com/debian/ stretch-backports main contrib non-free >> /etc/apt/sources.list echo deb http://mirrors.163.com/debian-security stretch/updates main contrib non-free >> /etc/apt/sources.list
Debian 8 jessie 网易源 echo deb http://mirrors.163.com/debian/ jessie main contrib non-free >> /etc/apt/sources.list echo deb http://mirrors.163.com/debian/ jessie-updates main contrib non-free >> /etc/apt/sources.list echo deb http://mirrors.163.com/debian/ jessie-backports main contrib non-free >> /etc/apt/sources.list echo deb http://mirrors.163.com/debian-security jessie/updates main contrib non-free >> /etc/apt/sources.list
CentOS 备份更新源 mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.bak
阿里云的CentOS-Base.repo 到/etc/yum.repos.d/ wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
刷新源
生成缓存
这里我用的是CentOS7的更新源,其他源参考如下:
CentOS 5 国内源替换 wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-5.repo
CentOS 6 国内源替换 wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo
Proxychains 安装 Ubuntu/Debian
CentOS
手动编译
./configure make && make install make install-config
配置 Kali/Ubuntu/Debian
vim /etc/proxychains.conf
CentOS
vim /usr/local/etc/proxychains.conf
测试 proxychains curl https://www.google.com
ZSH Ubuntu/Kali/Debian安装
CentOS安装
出来安装使用yum以为,其他配置方法和上面其他发行版系统一样,这里就不再赘述了。
SSH 安装SSH Ubuntu
报错了,内容如下:
下列软件包有未满足的依赖关系: openssh-server : 依赖: openssh-client (= 1:7.6p1-4) 依赖: openssh-sftp-server 但是它将不会被安装 推荐: ssh-import-id 但是它将不会被安装 E: 无法修正错误,因为您要求某些软件包保持现状,就是它们破坏了软件包间的依赖关系。
手动解决依赖,这里是因为openssh-server 是依赖于openssh-clien 的,那我们手动安装下指定的版本的openssh-clientBash
CentOS
Kali/Debian
apt install openssh-server
开启允许root远程登陆 Ubuntu
CentOS/Debian/Kali echo PermitRootLogin yes >> /etc/ssh/sshd_config
SSH开机自启
开启SSH
ssh连接非22端口
ssh使用公私钥登陆
效果如下:
将拷贝下来的私钥设置600权限 chmod 600 ~/Downloads/test_rsa
使用私钥登陆 ssh -i ~/Downloads/test_rsa root@YOUR IP
ssh取消公私钥登陆 清空.ssh文件夹
允许密码登陆 echo PasswordAuthentication yes >> /etc/ssh/sshd_config
重启SSH服务
scp拷贝文件 scp 本地文件 用户名@服务器地址:要拷贝的路径
scp拷贝非22端口文件 scp -P端口 本地文件 用户名@服务器地址:要拷贝的路径
JDK 因为JDK官网需要登录验证才可以下载的原因,不能直接通过wget来下载tar.gz安装包了,得自己手动copy一下。
末尾添加如下内容
JAVA_HOME=/usr/lib/jdk1.8.0_221 PATH=$JAVA_HOME /bin:$PATH CLASSPATH=$JAVA_HOME /jre/lib/ext:$JAVA_HOME /lib/tools.jar export PATH JAVA_HOME CLASSPATH
重新载入配置文件
验证是否安装成功
grep 搜索文件内容
用户 修改用户密码
adduser 新建用户
useradd 新建用户
删除用户
MySQL Ubuntu
Debian/Kali
CentOS
SQL允许root远程登陆 SQL
连接非3306默认端口 mysql -h目标IP地址 -u用户名 -p密码 -P端口 mysql -h10.211.55.9 -uroot -ppassword -P 33060
系统进程 查看进程 ps -a ps -au ps -aux ps -ef
杀掉进程
END
文章作者: 国光 文章链接: https://www.sqlsec.com/2019/10/docker2.html