Linux笔记

TOC

免密登录

  1. ~/.ssh/authorized_keys追加本地鸡公钥
  2. sudo vim /etc/ssh/sshd_config
    1
    PubkeyAuthentication yes
    2
    AuthorizedKeysFile  .ssh/authorized_keys
    这两项取消注释

修改用户名密码

  • root: passwd
  • else: passwd username

创建用户(管理员权限)

创建用户

1
sudo adduser username

sample:

1
Adding user `ben' ...
2
Adding new group `ben' (1000) ...
3
Adding new user `ben' (1000) with group `ben' ...
4
Creating home directory `/home/ben' ...
5
Copying files from `/etc/skel' ...
6
Enter new UNIX password:
7
Retype new UNIX password:
8
passwd: password updated successfully
9
Changing the user information for ben
10
Enter the new value, or press ENTER for the default
11
	Full Name []: Benature
12
	Room Number []: 
13
	Work Phone []:
14
	Home Phone []:
15
	Other []:
16
Is the information correct? [Y/n] y

root 权限

1
sudo vim /etc/sudoers

修改

1
# User privilege specification
2
root    ALL=(ALL:ALL) ALL
3
ben     ALL=(ALL:ALL) ALL

:wq!强行保存退出。

Reference: https://www.jianshu.com/p/aaf38026e00e

全局安装 miniconda3

  1. bash安装
  2. 安装位置不要在用户名下,改为/opt/miniconda3/
  3. 修改安装目录权限为所有用户都可以写入sudo chmod ugo+w -R /opt/miniconda3/
  4. conda加入PATH变量:sudo vim /etc/profile/,加入PATH=/opt/miniconda3/bin:$PATH
  5. 重开终端窗口 / 重连服务器
  6. conda -v / echo $PATH 检查确认

修改主机名

1
sudo vim /etc/hostname

apt卸载

1
sudo apt-get --purge remove mysql-common

终端浏览器

nohup 后台进程

nohup 命令

1
nohup python3 -u demo.py > mmp_hour.log 2>&1 &

python3-u参数是取消Python的缓冲, 使得log文件尽可能与脚本输出同步, 但感觉仍有些延迟, 所以建议再程序中加入类似

1
with open("temp.temp", "w") as f:
2
    f.write("run nohup")

的代码来及时确认程序是否运行

查看当前进程

1
ps -ef | grep
2
# 或者
3
jobs -l

杀死进程

1
kill <num>