Linux 使用备忘

  • 安装、使用 supervisor:
可以使用 pip 安装
pip install supervisor
pip install setuptools —upgrade

在 /etc/supervisor 下创建 supervisord.conf 文件,例:
[supervisord]
nodaemon=true
[program:sshd]
command=/usr/sbin/sshd -D

[program:mongodb]
command=/mongodb/bin/mongod
autostart=true
autorestart=true
startsecs=2
user=root 


  • 查看系统中可用的 shell 解释器:

cat /etc/shells


  • 修改 apt-get 的源:

/etc/apt 目录下,将 sources.list 备份
mv sources.list sources_backup.list
新建 sources.list 文件:
vim  sources.list
内容是:
# deb cdrom:[Ubuntu 16.04 LTS _Xenial Xerus_ - Release amd64 (20160420.1)]/ xenial main restricted
deb-src http://archive.ubuntu.com/ubuntu xenial main restricted #Added by software-properties
deb http://mirrors.aliyun.com/ubuntu/ xenial main restricted
deb-src http://mirrors.aliyun.com/ubuntu/ xenial main restricted multiverse universe #Added by software-properties
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted multiverse universe #Added by software-properties
deb http://mirrors.aliyun.com/ubuntu/ xenial universe
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates universe
deb http://mirrors.aliyun.com/ubuntu/ xenial multiverse
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates multiverse
deb http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse #Added by software-properties
deb-src http://archive.canonical.com/ubuntu xenial partner
deb http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted multiverse universe #Added by software-properties
deb http://mirrors.aliyun.com/ubuntu/ xenial-security universe
deb http://mirrors.aliyun.com/ubuntu/ xenial-security multiverse



  • Debian 安装 ansible 最新版本:


需要注意 Debian 的版本。

  • apt-get 安装 ansible 后,修改 /etc/ansible/ansible.cfg, 反注释host_key_checking=False;
  • 在 /root 下新建 ansible_hosts_test 文件,其中存储类似于:
  • 192.168.0.90 ansible_user=hongjianwei ansible_ssh_pass=123456
  • 输入命令测试是否连通:
  • ansible -i ansible_hosts_test 192.168.0.90 -m ping


  • 查看端口占用
netstat -tlnp
kill *** 

  • 查看IP地址
ip addr 

  • apt-get 删除软件

# 删除软件及其配置文件
     apt-get --purge remove <package> 
# 删除没用的依赖包
     apt-get autoremove <package> 
# 此时dpkg的列表中有“rc”状态的软件包,可以执行如下命令做最后清理:
     dpkg -l |grep ^rc|awk '{print $2}' | sudo xargs dpkg -P
如果要删除暂存的软件安装包,也可以再使用clean命令。 
  • 重命名文件

mv test1 test2 


  • 之所以 root 登录需要'source /etc/profile’,因为 root 是 non-login shell 登录的,不会读取 /etc/profile,用’su -l'切换就会以 login shell 登录,这样就会读取 /etc/profile

  • Ubuntu Debian 切换默认 sh 为 bash 或者 dash
使用命令
ls -l /bin/sh
查看,一般显示:
/bin/sh -> dash

切换 sh 为 bash
dpkg-reconfigure dash
输入 no 或者选择 no
成功后再执行
ls -l /bin/sh
结果是:
/bin/sh -> dash 

  • Alpine 安装 bash 并设置默认登录 shell
apk update
apk upgrade
apk add bash

安装 bash 文档:
apk add bash-doc

安装 bash 命令自动补全:
apk add bash-completion

设置默认登录 shell:
vi /etc/passwd
修改文件中的 root 用户名后面跟着的 shell,改为:
root:x:0:0:root:/root:/bin/bash


apk update
apk upgrade
apk add bash

安装 bash 文档:
apk add bash-doc

安装 bash 命令自动补全:
apk add bash-completion

设置默认登录 shell:
vi /etc/passwd
修改文件中的 root 用户名后面跟着的 shell,改为:
root:x:0:0:root:/root:/bin/bash



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值