0%

Linux笔记

TOC

免密登录

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

修改用户名密码

  • root: passwd
  • else: passwd username

创建用户(管理员权限)

创建用户

1
sudo adduser username

sample:

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

root 权限

1
sudo vim /etc/sudoers

修改

1
2
3
# User privilege specification
root ALL=(ALL:ALL) ALL
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
2
with open("temp.temp", "w") as f:
f.write("run nohup")

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

查看当前进程

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

杀死进程

1
kill <num>