Linux 备忘录
Created|Updated
|Word Count:445|Reading Time:2mins
太久没碰 Linux ,上机后总是一脸懵逼,不知道该干啥,记录一下上机之后该做的几件事
环境确认
上机第一件事应该确认机器的基本信息
uname -a
cat /proc/version
cat /etc/issue
机器版本
w
当前状态
cat /proc/cpuinfo
cpu信息
free
内存信息
df
磁盘信息
ifconfig
网络信息
ps
top
进程信息
crontab -l
less /etc/crontab
定时任务
service --status-all
systemctl
服务
安全
ssh关闭密码登录及端口修改
ssh-keygen -t rsa -b 4096
生成密钥对
- 将自己公钥添加到
~/.authorized_keys
,并修改文件权限chmod 600 ~/.ssh/authorized_keys
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
| vim /etc/ssh/sshd_config
PasswordAuthentication no
RSAAuthentication yes PubkeyAuthentication yes
AuthorsizedKeysFile .ssh/authorized_keys
sed -i "s/^PasswordAuthentication.*/PasswordAuthentication no/g" /etc/ssh/sshd_config sed -i "s/^#RSAAuthentication.*/RSAAuthentication yes/g" /etc/ssh/sshd_config sed -i "s/^#PubkeyAuthentication.*/PubkeyAuthentication yes/g" /etc/ssh/sshd_config sed -i "s/^#AuthorizedKeysFile.*/AuthorizedKeysFile .ssh\/authorized_keys/g" /etc/ssh/sshd_config
|
- 注意检查防火墙新端口是否放行,不然要被关在外面了
- 重启ssh服务
1 2 3
| systemctl restart sshd.service service sshd restart /etc/init.d/ssh restart
|
环境安装
其他常用片段
- add ssh key
- add swap file
- supervisor
ssh 配置
为单独的网站配置sshkey.ssh/config
1 2 3 4
| # github Host github.com HostName github.com IdentityFile ~/.ssh/github_id_rsa
|
cron 配置
vim /var/spool/cron/crontabs/root
chmod 600 /var/spool/cron/crontabs/root
修改权限
cat /var/log/syslog
查看 crontabs 日志
1 2 3 4 5 6 7 8 9 10 11
| # Example of job definition: # .---------------- minute (0 - 59) # | .------------- hour (0 - 23) # | | .---------- day of month (1 - 31) # | | | .------- month (1 - 12) OR jan,feb,mar,apr ... # | | | | .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat # | | | | | # * * * * * user-name command to be executed
# 每 5 分钟运行 */5 * * * * LANG=en_US.UTF-8 python3 main.py >> /log/log.log 2>&1
|
nginx