linux notes
a collection of frequently-used linux operations.
ssh service
useradd -m [username],-mwill automatically create new user folder in/homepasswd [username], configure passwordusermod -s /bin/bash [username], change default login shellcat /etc/passwdlist all userscat /etc/shellslist all available shells
usermod -aG sudo pwxcoo,grantsudoprivilegesgroupscheck group of current user
- in client,
scp id_rsa.pub [username]@[server address]:/home/[username]transfer public key to server - back to server,
mv id_rsa.pub .ssh/authorized_keyswill be ok
nginx
sudo apt updatesudo apt install nginxcd /etc/nginx/conf.d(NGINX site-specific configuration files are kept in/etc/nginx/conf.d)- simple template.
example.com.conf1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21server {
listen 80;
server_name example.com;
#charset koi8-r;
#access_log /var/log/nginx/host.access.log main;
location / {
root /usr/share/nginx/html;
index index.html index.htm;
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
} - test nginx configration is ok
sudo nginx -tsudo nginx -s reload
environment variables
linux will execute /etc/profile while booting up, this script will execute all script in /etc/profile.d, so add some scripts in /etc/profile.d will be easily maintained and convenient.
like jdk.sh, it will set environment variables for Java.
1 | export J2SDKDIR=/usr/lib/jvm/java-8-oracle |