Linux Ops Cheatsheet — Install, Config, and Quick Commands

Linux Ops Cheatsheet — Install, Config, and Quick Commands

Ports & Processes

1
2
3
4
5
6
# Check what’s using a port
netstat -anp | grep "5000"
# Kill a process
kill -9 2553
# Run in background
nohup command &

Install Shadowsocks (SS)

1
2
3
4
5
6
apt-get update
# Install ss
apt-get install python-pip 
pip install shadowsocks
# Run ss server
nohup ssserver -s <IP_ADDRESS> -k <PASSWORD> &

Install MySQL 5.7

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
# Ref: http://tecadmin.net/install-mysql-5-on-ubuntu/

sudo apt-get install software-properties-common
sudo add-apt-repository -y ppa:ondrej/mysql-5.7
sudo apt-get update
sudo apt-get install mysql-server

# Edit my.cnf to allow remote login
# /etc/mysql/my.cnf
# set
bind-address = 0.0.0.0

# Restart MySQL
/etc/init.d/mysql restart

MySQL: Add Users

1
2
3
4
5
6
7
8
9
-- Grant all to root from anywhere
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'root';
FLUSH PRIVILEGES;

-- Example: specific privileges for a host
GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,DROP ON <db>.* TO 'joe'@'10.163.225.87' IDENTIFIED BY '123';

-- Another example
GRANT ALL ON xxxDB.* TO 'xxx'@'%';

MySQL error: “Checking for tables which need an upgrade, are corrupt or were not closed cleanly”

Steps:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
sudo service mysql stop 
sudo /etc/init.d/apparmor reload
sudo service mysql start

# Or: if multiple mysql instances/processes are running
ps -A | grep mysql
sudo pkill mysql
ps -A | grep mysqld
sudo pkill mysqld

service mysql restart
mysql -u root -p

7z Quick Ops

1
2
3
4
# Compress
7z a -t7z -r manager.7z /home/manager/*
# Extract
7z x xx.zip

Tencent Cloud: change password, allow root login

1
2
3
sudo passwd root
sudo vi /etc/ssh/sshd_config
sudo service ssh restart
使用 Hugo 构建
主题 StackJimmy 设计