Ubuntu server 18.04 使用技巧

  1. ps -aux查看进程ID及其用户
  2. sudo nethogs 查看网络带宽的占用情况(可以使用sudo apt install nethogs进行安装)
  3. sudo kill -s 9 pid 强制退出并杀死某个进程 (比如sudo kill -s 9 8903
    sudo killall -u username 删除某个用户的所有进程
  4. cat /proc/sys/fs/file-nr
    内核支持系统目前使用的文件数
查看所有进程的文件打开数
```
lsof |wc -l
```
查看某个进程打开的文件数
```
lsof -p pid |wc -l
```
  1. 查看bbr是否装上
    输入 sudo sysctl net.ipv4.tcp_available_congestion_control
    正常会输出
    net.ipv4.tcp_available_congestion_control = reno cubic bbr
    输入 sudo sysctl -n net.ipv4.tcp_congestion_control
    正常输出
    bbr
    输入 lsmod | grep bbr
    正常会输出 29728 0 6553500

  2. 添加docker给某个用户
    sudo usermod -a -G docker $USER
    eg: sudo usermod -aG docker ckj

  3. 查看当前用户所属的用户组
    groups
    在这里插入图片描述

  4. check if OpenCV is installed on a machine, run the following commands
    pkg-config --modversion
    在这里插入图片描述
    compile your code with the following command
    g++ main.cpp -o output pkg-config --cflags --libs opencv

  5. sudo du -h --max-depth=1 查看目录下每个文件的大小

  6. 关闭屏幕保护程序m6502 编辑 /etc/X11/Xresources/x11-common
    Add this line to the bottom:
    xscreensaver.mode: blank

  7. 更改vncserver密码
    vncpasswd

  8. 在MySQL中添加用户
    首先进入root界面,登录mysql
    mysql> CREATE USER 'test1'@'localhost' identified by '1234567'; 只需要修改test1和密码
    会收到反馈 Query OK, 0 rows affected (0.00 sec)

  9. 所有中文都显示为方框,可能是缺少字体显示:

sudo apt-get install fonts-droid-fallback ttf-wqy-zenhei ttf-wqy-microhei fonts-arphic-ukai fonts-arphic-uming
  1. 停用账号 sudo passwd -l test01
    启用账号 sudo passwd -u test01
  2. vnc界面tab键无法自动补全命令的问题
    进入vnc界面-> applications -> Settings -> windows Manager-> Keyboard 把有一个关于“ super tab" 的快捷键删了,杀掉vnc端口 然后新建端口,就可以恢复tab键的使用。
  3. 查看显卡信息
watch -n 2 nvidia-smi
  1. 限制CPU使用率
cpulimit -l 200 -p 326931
  1. 指定目录添加用户
sudo useradd -d /nfs20/owncloud -rms /bin/bash owncloud
  1. 有时候由于服务器端重装系统,使用ssh无法远程登录,首先确保安装了’openssh-server’,如果报错:
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@    WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!     @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!
Someone could be eavesdropping on you right now (man-in-the-middle attack)!
It is also possible that a host key has just been changed.
The fingerprint for the RSA key sent by the remote host is

执行语句删除秘钥就可以了

ssh-keygen -R "you server hostname or ip"
  1. 打开文件
vim /etc/docker/daemon.json

添加如下内容

"insecure-registries": ["219.216.99.4:8888"], "log-driver": "json-file", "data-root": "/var/lib/docker", "log-opts": {"max-size": "100m", "max-file": "10"}, "runtimes": {"nvidia": {"runtimeArgs": [], "path": "/usr/bin/nvidia-container-runtime"}}, "registry-mirrors": ["https://registry.docker-cn.com", "http://hub-mirror.c.163.com"]
  1. 查看CPU温度
watch -n 0.1 echo CPU: $[$(cat /sys/class/thermal/thermal_zone0/temp)/1000]°
  1. 查看服务器开放的端口
nmap -sS -p 0-60000 -v baidu.com
  1. 把无头浏览器加入开机自启动
docker run -d -p 6901:6901 -m 4096M -e --restart=always 219.216.99.4:8888/ckj_test/chrome_vnc:6901

你可能感兴趣的:(Ubuntu,server,18.04,Linux)