-
Notifications
You must be signed in to change notification settings - Fork 0
/
ubuntu_cmd.txt
322 lines (260 loc) · 10 KB
/
ubuntu_cmd.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
sudo sed -i 's/http:\/\/cn./http:\/\//g' /etc/apt/sources.list
sudo rm -rf /var/lib/apt/lists/*
sudo apt-get update
find /var/lib/nginx/proxy -type f -regex '.+/[0-9]+$' | xargs -I '{}' rm
"{}"
//macOSX flush dns cache
sudo dscacheutil -flushcache
//gitolite setup procedure
sudo adduser --system --shell /bin/bash --group --disabled-password --home /home/git git
sudo apt-get install gitolite3
scp ~/.ssh/id_rsa.pub [email protected]:/home/david/
sudo su - git
gitolite setup -pk /home/david/*.pub
ssh git@hostname info
//generate key pair
ssh-keygen -t rsa
cat /proc/version
uname -a
lsb_release -a
cat /etc/issue
git remote set-url origin https://github.com/USERNAME/OTHERREPOSITORY.git
<?php
/* Redirect browser */
header('Location: http://' . $_SERVER['HTTP_HOST'] . '/cmsmadesimple/');
/* Make sure that code below does not get executed when we redirect. */
exit;
?>
openssl req -new -newkey rsa:4096 -nodes -keyout freego.key -out freego.csr
openssl x509 \
-signkey freego.key \
-in freego.csr \
-req -days 2048 -out freego.crt
Installing NginX 1.9.2 in Ubuntu server 14.04.2 LTS
Since the version of NginX in Ubuntu Server 14.04.2 is only 1.4.6, we need to tell APT to install the more recent version of nginx directly from the NginX maintainer.
Steps:
Add the following lines in /etc/apt/sources.list
deb http://nginx.org/packages/mainline/ubuntu/ trusty nginx
deb-src http://nginx.org/packages/mainline/ubuntu/ trusty nginx
From your server download the signing key add it to the apt program keyring with the following commands:
sudo wget -qO - http://nginx.org/keys/nginx_signing.key | sudo apt-key add -
Install NginX:
apt-get update
apt-get install nginx
Verify its version:
/usr/sbin/nginx -V
nginx version: nginx/1.9.2
You’re off and running
sudo apt-get purge nginx nginx-common
sudo apt-get install nginx
location ~ \.php$ {
include fastcgi_params;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root/$fastcgi_script_name;
}
//node bb
sudo apt-get install libkrb5-dev
./letsencrypt-auto certonly --standalone --agree-tos --email [email protected] -d wwpp.date -d mygirl.site -d piao.gift -d novice.ren -d freeland.online
curl -sL https://deb.nodesource.com/setup_5.x | sudo -E bash -
sudo apt-get install -y nodejs
//If your npm is broken
curl -L https://www.npmjs.org/install.sh | sh
/etc/letsencrypt/live/wwpp.date/fullchain.pem
./letsencrypt-auto certonly --standalone --agree-tos --email [email protected] -d ily365.cn -d shop.ily365.cn -d go.ily365.cn -d game.ily365.cn -d bbs.ily365.cn -d www.ily365.cn -d admin.ily365.cn
//enable gitignore
git rm -r --cached .
git add .
git commit -m ".gitignore is now working"
apt-get install php7.0-cli php7.0-common php7.0 php7.0-mysql php7.0-fpm php7.0-curl php7.0-gd
docker commit ac6820e5f8f0 novice/freego
//mysql 服务只能本机访问,不对外公开
docker run -p 222:22 -p 80:80 -v /Users/piao/workspace/docker_test:/var/www:rw -d --name fg -t novice/freego
docker run -p 222:22 -p 80:80 -d --name fg -t test
xz -d **.tar.xz
tar -xv -f **.tar
//or
tar xvJf ***.tar.xz来解压
tar cvJf <archive.tar.xz> <files>
tar cf - directory/ | xz -zf - > directory.tar.xz
sudo service --status-all
sudo initctl list
# possibility 1:
printf '%s\n\t%s\n' 'Host localhost' 'ForwardAgent yes' >> file.txt
# possibility 2:
echo "line 1
line 2" >> greetings.txt
# possibility 3:
cat <<EOT >> greetings.txt
line 1
line 2
EOT
cat ~/.ssh/id_rsa.pub | ssh kjy "mkdir -p ~/.ssh && cat >> ~/.ssh/authorized_keys"
//and for SELinux also do: restorecon -R -v ~/.ssh
cat /proc/cpuinfo | grep processor | wc -l
wget https://nginx.org/keys/nginx_signing.key -O - | sudo apt-key add -
sudo vi /etc/apt/sources.list
//or xenial
deb http://nginx.org/packages/mainline/ubuntu/ trusty nginx
deb-src http://nginx.org/packages/mainline/ubuntu/ trusty nginx
$ sudo apt-get remove nginx-common
$ sudo apt-get update
$ sudo apt-get install nginx
Run NGINX Open Source:
$ sudo nginx
Verify that NGINX Open Source is up and running:
$ curl -I 127.0.0.1
HTTP/1.1 200 OK
Server: nginx/1.11.5
sudo fdisk -l
sudo mkfs.ext4 /dev/vdb
sudo mkdir /data
sudo echo '/dev/vdb /data ext4 defaults 0 0' >> /etc/fstab
sudo mount -a
docker run --name gh -v /data/blog:/var/lib/ghost -p 8080:2368 -d ghost
docker run --name gh -v /data/blog:/var/lib/ghost -p 8080:2368 -e NODE_ENV=production ghost
sudo useradd -m -d /data/dl dl
sudo passwd dl
top
us: user cpu time (or) % CPU time spent in user space
sy: system cpu time (or) % CPU time spent in kernel space
ni: user nice cpu time (or) % CPU time spent on low priority processes
id: idle cpu time (or) % CPU time spent idle
wa: io wait cpu time (or) % CPU time spent in wait (on disk)
hi: hardware irq (or) % CPU time spent servicing/handling hardware interrupts
si: software irq (or) % CPU time spent servicing/handling software interrupts
st: steal time - - % CPU time in involuntary wait by virtual cpu while hypervisor is servicing another processor (or) % CPU time stolen from a virtual machine
16.04
sudo apt-get update
sudo apt-get install coturn
#sudo turnadmin -a -u freego -p freego2017 -r yunyougo.com
sudo vi /etc/turnserver.conf
# Coturn TURN SERVER configuration file
lt-cred-mech
user=freego:freego2017
realm=yunyougo.com
# end
sudo apt-get install supervisor
sudo vi /etc/supervisor/conf.d/coturn.conf
[program:coturn]
command=/usr/bin/turnserver
priority=3
autostart=true
autorestart=true
sudo systemctl enable supervisor
sudo systemctl start supervisor
nohup turnserver &
//install mail server
14.04
sudo apt-get install postfix
sudo dpkg-reconfigure postfix
1. Internet Site
2. freego.com
3. freego
4. freego.com, localhost.localdomain, localhost
5. No
6. 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128 192.168.0.0/24
7. 0
8. +
9. all
sudo vi /etc/postfix/main.cf
//change
smtpd_tls_cert_file=/etc/letsencrypt/live/all/fullchain.pem
smtpd_tls_key_file=/etc/letsencrypt/live/all/privkey.pem
//add belows
home_mailbox = Maildir/
smtpd_sasl_type = dovecot
smtpd_sasl_path = private/auth
smtpd_sasl_local_domain =
smtpd_sasl_security_options = noanonymous
broken_sasl_auth_clients = yes
smtpd_sasl_auth_enable = yes
smtpd_recipient_restrictions = permit_sasl_authenticated,permit_mynetworks,reject_unauth_destination
smtp_tls_security_level = may
smtpd_tls_security_level = may
smtp_tls_note_starttls_offer = yes
smtpd_tls_loglevel = 1
smtpd_tls_received_header = yes
sudo vi /etc/postfix/master.cf
//uncomment below lines
submission inet n - - - - smtpd
-o syslog_name=postfix/submission
-o smtpd_tls_security_level=encrypt
-o smtpd_sasl_auth_enable=yes
# -o smtpd_reject_unlisted_recipient=no
# -o smtpd_client_restrictions=$mua_client_restrictions
# -o smtpd_helo_restrictions=$mua_helo_restrictions
# -o smtpd_sender_restrictions=$mua_sender_restrictions
# -o smtpd_recipient_restrictions=
-o smtpd_relay_restrictions=permit_sasl_authenticated,reject
-o milter_macro_daemon_name=ORIGINATING
smtps inet n - - - - smtpd
-o syslog_name=postfix/smtps
-o smtpd_tls_wrappermode=yes
-o smtpd_sasl_auth_enable=yes
# -o smtpd_reject_unlisted_recipient=no
# -o smtpd_client_restrictions=$mua_client_restrictions
# -o smtpd_helo_restrictions=$mua_helo_restrictions
# -o smtpd_sender_restrictions=$mua_sender_restrictions
# -o smtpd_recipient_restrictions=
-o smtpd_relay_restrictions=permit_sasl_authenticated,reject
-o milter_macro_daemon_name=ORIGINATING
sudo apt-get install dovecot-common
Issue the following values for the prompts during installation.
1. yes
2. mail.freego.com
sudo vi /etc/dovecot/conf.d/10-master.conf
# Postfix smtp-auth ( line no:95 )
unix_listener /var/spool/postfix/private/auth {
mode = 0660
user = postfix
group = postfix
}
sudo vi /etc/dovecot/conf.d/10-auth.conf file and find (line no:100)
auth_mechanisms = plain
and replace
auth_mechanisms = plain login
sudo service postfix restart
sudo service dovecot restart
sudo apt-get install dovecot-imapd dovecot-pop3d
sudo vi /etc/dovecot/conf.d/10-mail.conf file and find (Line no:30 )
mail_location = mbox:~/mail:INBOX=/var/mail/%u
Replace with
mail_location = maildir:~/Maildir
sudo vi /etc/dovecot/conf.d/20-pop3.conf file and find and uncomment the below line ( Line no : 50 )
pop3_uidl_format = %08Xu%08Xv
sudo vi /etc/dovecot/conf.d/10-ssl.conf file and find and uncomment the below line ( Line no : 6 )
ssl = yes
ssl_cert = </etc/letsencrypt/live/all/fullchain.pem
ssl_key = </etc/letsencrypt/live/all/privkey.pem
sudo service dovecot restart
Create some users and check using mail clients like thunderbird or outlook
sudo useradd -m david -s /sbin/nologin
sudo passwd david
http://www.krizna.com/ubuntu/setup-mail-server-ubuntu-14-04/
sudo systemctl restart postfix dovecot
//16.04
sudo apt-get install postfix dovecot-core dovecot-imapd dovecot-pop3d
vi /etc/dovecot/dovecot.conf
protocols = pop3 pop3s imap imaps
Uninstall salt-minion
To remove just salt-minion package itself from Ubuntu 14.04 (Trusty Tahr) execute on terminal:
sudo apt-get remove salt-minion
Uninstall salt-minion and it's dependent packages
To remove the salt-minion package and any other dependant package which are no longer needed from Ubuntu Trusty.
sudo apt-get remove --auto-remove salt-minion
Purging salt-minion
If you also want to delete configuration and/or data files of salt-minion from Ubuntu Trusty then this will work:
sudo apt-get purge salt-minion
To delete configuration and/or data files of salt-minion and it's dependencies from Ubuntu Trusty then execute:
sudo apt-get purge --auto-remove salt-minion
https://www.digitalocean.com/community/tutorials/how-to-route-web-traffic-securely-without-a-vpn-using-a-socks-tunnel
Set up sock5 tunnel by ssh:
ssh -D 8123 -f -C -q -N [email protected]
Explanation of arguments
-D: Tells SSH that we want a SOCKS tunnel on the specified port number (you can choose a number between 1025-65536)
-f: Forks the process to the background
-C: Compresses the data before sending it
-q: Uses quiet mode
-N: Tells SSH that no command will be sent once the tunnel is up
ssh -D 8123 -C -q -N wwpp