Project

General

Profile

Miscellaneous » History » Version 35

Anonymous, 07/13/2025 04:06 PM
fix typo in command

1 1
h1. Miscellaneous
2
3 34
h2. Recover SW RAID
4
5
<pre>
6
$  sudo mdadm --stop /dev/md0
7
$  sudo mdadm --assemble --force /dev/md0 /dev/sda1 /dev/sdb1 /dev/sdc1 /dev/sdd1 /dev/sde1 /dev/sdf1 /dev/sdg1 /dev/sdh1 /dev/sdi1 /dev/sdj1 /dev/sdk1 /dev/sdl1 /dev/sdm1 /dev/sdn1 /dev/sdo1 /dev/sdp1 /dev/sdq1 /dev/sdr1 /dev/sds1 /dev/sdt1 /dev/sdu1 /dev/sdv1 /dev/sdw1 /dev/sdx1 /dev/sdy1 /dev/sdz1 /dev/sdaa1 /dev/sdac1 /dev/sdad1 /dev/sdae1 /dev/sdaf1 /dev/sdag1 /dev/sdah1 /dev/sdai1 /dev/sdaj1 /dev/sdak1 /dev/sdal1 /dev/sdam1 /dev/sdan1 /dev/sdao1 /dev/sdap1 /dev/sdaq1 /dev/sdar1 /dev/sdas1 /dev/sdat1 /dev/sdau1 /dev/sdav1 /dev/sdaw1
8 35
$ sudo mdadm -D /dev/md0
9
$ lsblk 
10
$ sudo mdadm --examine /dev/sdar1 
11
$ sudo mdadm --examine /dev/sdat1 
12
$ sudo mdadm --add /dev/md0 /dev/sdar1 /dev/sdat1
13
$ cat /proc/mdstat
14
$ sudo bash -c "echo 9999999 > /proc/sys/dev/raid/speed_limit_min" 
15
$ sudo bash -c "echo 9999999 > /proc/sys/dev/raid/speed_limit_max" 
16 34
</pre>
17
18 32
h2. Fix some WIndows 11 Annoyances
19
20
# Install without Micro$oft Account:
21
**  Follow the Windows 11 install process until you get to the "choose a country" screen. 
22
** Hit Shift + F10. A command prompt appears. 
23
** Type: @OOBE\BYPASSNRO@ to disable the Internet connection requirement. The computer will reboot afterwards.
24
** Hit Shift + F10 again and this time Type: @ipconfig /release@. Then hit Enter to disable the Internet. 
25
** Continue with the installation, choosing the region. keyboard and second keyboard option. A screen saying "Let's connect you to a network" appears, warning you that you need Internet. Click "I don't have Internet" to continue. Click Continue with limited setup if prompted. The OOBE may skip this screen and take you straight to the next step.
26
# Restore old right click menu
27
** Open Terminal
28
** Type this: @reg.exe add "HKCU\Software\Classes\CLSID\{86ca1aa0-34aa-4e8b-a509-50c905bae2a2}\InprocServer32" /f /ve@
29
** Restart machine.
30
** To undo: @reg.exe delete "HKCU\Software\Classes\CLSID\{86ca1aa0-34aa-4e8b-a509-50c905bae2a2}" /f@
31
32 33
* *NOTE:* Apparently BYPASSNRO is being removed by Micro$oft. For now this should work:
33
** Hit Shift + F10
34
** Type: @start ms-cxh:localonly@
35
36 31
h2. Update Nextcloud External Files
37
38
<pre>
39
$ cd /var/www/nextcloud
40
$ sudo -u www-data php ./occ files:scan --all 
41
</pre>
42
43 30
h2. Change Windows 10 Version
44
45
* *Disconnect from internet*
46
* Go to "Settings" > "Update & Security" > "Activation" > "Change productkey"
47
* Enter @VK7JG-NPHTM-C97JM-9MPGT-3V66T@
48
* Press "Ok" and wait for the process to run
49
* Reboot after error message is displayed
50
51
Codes for all editions:
52
<pre>
53
[cmi]
54
namespace=urn:schemas-microsoft-com:unattend
55
ClientServerSplit=true
56
AnswerFileFormat=1
57
professionalworkstationn=WYPNQ-8C467-V2W6J-TX4WX-WT2RQ
58
enterpriseneval=MNXKQ-WY2CT-JWBJ2-T68TQ-YBH2V
59
serverazurecor=QN7G3-4RM92-MT6QR-PR966-FVYV7
60
serverrdshCore=NJCF7-PW8QT-3324D-688JX-2YV66
61
onecoreupdateos=NFDPX-3MV8X-THC2X-QQ9QP-P9YY6
62
serverstandardeval=BGHNQ-64HFC-WD7WG-K2T34-8477T
63
serverdatacenterevalcorCore=RNJ27-KR4TJ-DX6FB-XFJJ2-2DQMJ
64
iotenterprisek=P8Q7T-WNK7X-PMFXY-VXHBG-RRK69
65
ServerStandardEvalCor=KGKTQ-NWWW9-Q8KKW-4M2R9-66TFB
66
iotenterprise=XQQYW-NFFMW-XJPBH-K8732-CKFFD
67
educationn=84NGF-MHBT6-FXBX8-QWJK7-DRR8H
68
serverdatacentereval=K4NJQ-WBJ89-PJGPP-9MTY4-R3QK2
69
serverazurecorCore=QN7G3-4RM92-MT6QR-PR966-FVYV7
70
enterpriseseval=Y22YQ-HNV92-HWMXQ-PMDQ9-7XRGJ
71
coresinglelanguage=BT79Q-G7N6G-PGBYW-4YWX6-6F4BT
72
professionalcountryspecific=3XP6D-CRND4-DRYM2-GM84D-4GG8Y
73
core=YTMG3-N6DKC-DKB77-7M9GH-8HVX7
74
coresystemserver=6DWFN-9DBPB-99W4C-XYWKQ-VXPFM
75
serverdatacenterevalcor=RNJ27-KR4TJ-DX6FB-XFJJ2-2DQMJ
76
serverstandardcor=B2NYV-R6JT2-H9YTQ-VQ4X3-979YK
77
serverdatacentercorCore=DCXHG-67NR6-6CRMW-2PYFW-PKGD7
78
serverazurenano=9JQNQ-V8HQ6-PKB8H-GGHRY-R62H6
79
coren=4CPRK-NM3K3-X6XXQ-RXX86-WXCHW
80
EnterpriseSNEval=VW76H-NXCYD-PPWKF-JG63K-KQFGM
81
starter=D6RD9-D4N8T-RT9QX-YW6YT-FCWWJ
82
professional=VK7JG-NPHTM-C97JM-9MPGT-3V66T
83
professionaln=2B87N-8KFHP-DKV6R-Y2C8J-PKCKT
84
enterprise=XGVPP-NMH47-7TTHJ-W3FW7-8HV2C
85
education=YNMGQ-8RYV3-4PGQ3-C8XTP-7CFBY
86
serverwebCore=3WN48-GVPXF-VHWK4-29Y8D-KKTD2
87
ServerTurbine=3Y8N7-3R679-4XFFH-6BTCM-X4W7X
88
serverazurestackhcicor=YP2N4-KHPFV-F2D34-PXFJH-MBK3B
89
enterprisegn=FW7NV-4T673-HF4VX-9X4MM-B4H4T
90
enterpriseg=FV469-WGNG4-YQP66-2B2HY-KD8YX
91
serverweb=3WN48-GVPXF-VHWK4-29Y8D-KKTD2
92
serverrdsh=NJCF7-PW8QT-3324D-688JX-2YV66
93
serverdatacenternanoCore=BFM6D-TKNBY-X6RGR-PHJ4G-723B6
94
ServerDatacenter=9DYFC-FNGM2-KQGHQ-BTRK4-JHYT3
95
serverstandard=J768X-NXC7R-GFB9Q-BHF4H-GCVBB
96
enterprisesn=2D7NQ-3MDXF-9WTDT-X9CCP-CKD8V
97
serverdatacenternano=BFM6D-TKNBY-X6RGR-PHJ4G-723B6
98
ServerStandardEvalCorCore=KGKTQ-NWWW9-Q8KKW-4M2R9-66TFB
99
serverstandardnano=69NHX-WQQ7G-QVBPG-4HPQP-8XDB7
100
cloudeditionn=K9VKN-3BGWV-Y624W-MCRMQ-BHDCD
101
professionaleducation=8PTT6-RNW4C-6V7J2-C2D3X-MHBPB
102
serverazurestackhcicorCore=YP2N4-KHPFV-F2D34-PXFJH-MBK3B
103
serverstandardevalCore=BGHNQ-64HFC-WD7WG-K2T34-8477T
104
serverturbinecorCore=H7XNC-JYM86-7B27X-8MJ9W-TKFX9
105
professionaleducationn=GJTYN-HDMQY-FRR76-HVGC7-QPF8P
106
professionalworkstation=DXG7C-N36C4-C4HTG-X4T3X-2YV77
107
enterprises=PJB47-8PN2T-MCGDY-JTY3D-CBCPV
108
cloudedition=KY7PN-VR6RX-83W6Y-6DDYQ-T6R4W
109
iotenterprisesk=N979K-XWD77-YW3GB-HBGH6-D32MH
110
startern=3NFXW-2T27M-2BDW6-4GHRV-68XRX
111
EnterpriseEval=VPMWD-PVNRR-79WJ9-VVJQC-3YH2G
112
serverturbinecor=H7XNC-JYM86-7B27X-8MJ9W-TKFX9
113
iotenterprises=CGK42-GYN6Y-VD22B-BX98W-J8JXD
114
ServerDatacenterCore=9DYFC-FNGM2-KQGHQ-BTRK4-JHYT3
115
wnc=TMP2N-KGFHJ-PWM6F-68KCQ-3PJBP
116
ServerTurbineCore=3Y8N7-3R679-4XFFH-6BTCM-X4W7X
117
serverazurenanoCore=9JQNQ-V8HQ6-PKB8H-GGHRY-R62H6
118
iotenterpriseseval=R63DV-9NPDX-QVWJF-HMR8V-M4K7D
119
holographic=H4MND-KF7J8-PWBTV-2P3JG-BP4FC
120
serverdatacenterevalCore=K4NJQ-WBJ89-PJGPP-9MTY4-R3QK2
121
corecountryspecific=N2434-X9D7W-8PF6X-8DV9T-8TYMD
122
serverstandardcorCore=B2NYV-R6JT2-H9YTQ-VQ4X3-979YK
123
enterprisen=WGGHN-J84D6-QYCPR-T7PJ7-X766F
124
professionalsinglelanguage=G3KNM-CHG6T-R36X3-9QDG6-8M8K9
125
serverstandardnanoCore=69NHX-WQQ7G-QVBPG-4HPQP-8XDB7
126
serverdatacentercor=DCXHG-67NR6-6CRMW-2PYFW-PKGD7
127
serverstandardCore=J768X-NXC7R-GFB9Q-BHF4H-GCVBB
128
gvlkcoresinglelanguage=7HNRX-D7KGG-3K4RQ-4WPJ4-YTDFH
129
gvlkcore=TX9XD-98N7V-6WMQ6-BX7FG-H8Q99
130
gvlkprofessionalworkstationn=9FNHH-K3HBT-3W4TD-6383H-6XYWF
131
gvlkserverazurecor=FCNV3-279Q9-BQB46-FTKXX-9HPRH
132
gvlkserverrdshCore=CPWHC-NT2C7-VYW78-DHDB2-PG3GK
133
gvlkenterprisesn=92NFX-8DJQP-P6BBQ-THF9C-7CG2H
134
gvlkiotenterprises=KBN8V-HFGQ4-MGXVD-347P6-PDQGT
135
gvlkServerDatacenterCore=D764K-2NDRG-47T6Q-P8T8W-YP6DF
136
gvlkServerTurbineCore=XGN3F-F394H-FD2MY-PP6FD-8MCRC
137
gvlkcloudeditionn=6XN7V-PCBDC-BDBRH-8DQY7-G6R44
138
gvlkprofessionaleducation=6TP4R-GNPTD-KYYHQ-7B7DP-J447Y
139
gvlkcoren=3KHY7-WNT83-DGQKR-F7HPR-844BM
140
gvlkprofessional=W269N-WFGWX-YVC9B-4J6C9-T83GX
141
gvlkprofessionaln=MH37W-N47XK-V7XM9-C7227-GCQG9
142
gvlkeducationn=2WH4N-8QGBV-H22JP-CT43Q-MDWWJ
143
gvlkeducation=NW6C2-QMPVW-D7KKK-3GKT6-VCFB2
144
gvlkenterprise=NPPR9-FWDCX-D2C8J-H872K-2YT43
145
gvlkServerTurbine=XGN3F-F394H-FD2MY-PP6FD-8MCRC
146
gvlkprofessionaleducationn=YVWGF-BXNMC-HTQYQ-CPQ99-66QFC
147
gvlkprofessionalworkstation=NRG8B-VKK3Q-CXVCJ-9G2XF-6Q84J
148
gvlkcloudedition=37D7F-N49CB-WQR8W-TBJ73-FM8RX
149
gvlkenterprises=M7XTQ-FN8P6-TTKYV-9D4CC-J462D
150
gvlkcorecountryspecific=PVMJN-6DFY6-9CCP6-7BKTT-D3WVR
151
gvlkenterprisegn=44RPN-FTY23-9VTTB-MP9BX-T84FV
152
gvlkenterprisen=DPH2V-TTNVB-4X9Q3-TJR4H-KHJW4
153
gvlkserverazurecorCore=FCNV3-279Q9-BQB46-FTKXX-9HPRH
154
gvlkenterpriseg=YYVX9-NTFWV-6MDM3-9PT4T-4M68B
155
gvlkserverrdsh=CPWHC-NT2C7-VYW78-DHDB2-PG3GK
156
gvlkServerDatacenter=D764K-2NDRG-47T6Q-P8T8W-YP6DF
157
gvlkserverstandardCore=TVRH6-WHNXV-R9WG3-9XRFY-MY832
158
gvlkserverstandard=TVRH6-WHNXV-R9WG3-9XRFY-MY832
159
160
[BuildInfo]
161
</pre>
162
163
Sauce: https://forums.mydigitallife.net/threads/how-to-upgrade-from-home-sl-to-pro-or-any-other-higher-sku-and-license-switching.85294/
164
165 26
h2. Find all files matching regex pattern
166
167
All PNG images starting with 5 digits followed by a dash:
168
<pre>
169
$ find . -regextype posix-extended -regex "\./[[:digit:]]{5}-(.*).png
170
</pre>
171
172 25
h2. Change all file or directory permissions
173
174
<pre>
175
$ find . -type d -exec chmod 755 {} \;
176
$ find . -type f -exec chmod 644 {} \;
177
</pre>
178
179 24
h2. List Root Device
180
181
<pre>
182
$ findmnt -n -o SOURCE /
183
</pre>
184
185
h2. List Block Devices with Serial Numbers
186
187
<pre>
188
$ lsblk --nodeps -o name,serial 
189
</pre>
190
191 23
h2. Useful rsync Examples
192
193
* Synchronize directories (one way):
194
<pre>
195
$ rsync -auhrP --delete --info=del,name,stats2 "/mnt/phalanx/" "/storage"
196
</pre>
197
* Copy with progress:
198
<pre>
199
$ rsync -ahr --info=progress2 some_file.mp4 /storage/
200
</pre>
201
202
203 22
h2. Patch Youtube App using Revanced Manager (6/22/2024)
204
205
h3. Install Steps
206
207
* Delete Revanced app, Micro G, Revanced manager prior installation any of mentioned apps.
208
* Download *but not install* following:
209
** Micro G - https://github.com/ReVanced/GmsCore/releases/tag/v0.3.1.3.240913
210
** Revanced Manager - https://revanced.app/patches?s=Mic
211
** YT App version 19.16.39 (must be this version; revanced manager will warn if not): https://www.apkmirror.com/apk/google-inc/youtube/youtube-19-16-39-release/youtube-19-16-39-android-apk-download/
212
* Install Micro G.
213
* Next install Revanced Manager
214
* Open Revanced manager
215
** Go to Patches
216
** Select an app
217
** Bottom right corner choose Storage
218
** Find YT APK you downloaded, select patch on the bottom right corner
219
* Wait for patch and compile to finish, then choose install app
220
* Open it, check if its Vanced, restart the phone.
221
* If you have stock YT app, uninstall updates and disable it
222
223
Source: https://www.reddit.com/r/revancedapp/comments/1bq92r7/me_rn_trying_to_patch_youtube_revanced/
224
225 19
h2. Combine find and GNU parallel
226
227
Example:
228
<pre>
229
$ find . -name '*.jpg' | parallel convert -geometry 120 {} {.}_thumb.jpg
230 21
$ find . -name '*.png' | parallel --eta convert '{}' -quality 90 '{.}.jpg'
231 29
$ ls -1 *.png | parallel convert '{}' -quality 90 '{.}.jpg'
232 21
$ find . -name '*.png' -delete
233 19
</pre>
234
Note @{.}@ is the filename without the @.jpg@ portion.
235
236
* See: https://www.gnu.org/software/parallel/parallel_examples.html#example-compute-intensive-jobs-and-substitution
237
238 18
h2. Setup ttyd
239
240
* Download @ttyd@ and put it in @/opt/local/bin/ttyd@:
241
** https://github.com/tsl0922/ttyd/releases
242
* Create systemd service file @/etc/systemd/system/ttyd.service@: 
243
<pre>
244
[Unit]                                                                                                                                                                                           
245
Description=TTYD
246
After=syslog.target
247
After=network.target
248
 
249
[Service]
250
ExecStart=/opt/local/bin/ttyd -W -p 9772 login
251
Type=simple
252
Restart=always
253
User=root
254
Group=root
255
 
256
[Install]
257
WantedBy=multi-user.target
258
</pre>
259
** Start and enable service:
260
<pre>
261
$ sudo systemctl start ttyd && sudo systemctl enable ttyd
262
</pre>
263
* Setup apache configuration (add to existing)
264
<pre>
265
        ProxyRequests Off
266
        ProxyPreserveHost On
267
        RewriteEngine on
268
        RewriteCond %{HTTP:Upgrade} websocket [NC]
269
        RewriteCond %{HTTP:Connection} upgrade [NC]
270
        RewriteRule /terminal/?(.*) "ws://localhost:9772/$1" [P,L]
271
        ProxyPass /terminal http://localhost:9772/
272
        ProxyPassReverse /terminal http://localhost:9772/
273
</pre>
274
** Enable necessary apache modules:
275
<pre>
276
$ a2enmod proxy proxy_http proxy_wstunnel mod_rewrite
277
</pre>
278
279
280 17
h2. Increase tmux scrollback
281
282
<pre>
283
$ cd 
284
$ echo "set -g history-limit 9999999" >> ~/.tmux.conf
285
</pre>
286
287 16
h2. Setup VNC
288 15
289
On the server side:
290
# Install @x11vnc@:
291
<pre>
292
$ sudo apt install x11vnc net-tools
293
</pre>
294
# Set VNC password:
295
<pre>
296
$ x11vnc -storepasswd
297
</pre>
298
# Start VNC service from command line:
299
<pre>
300
$ sudo x11vnc -auth guess -forever -loop -noxdamage -repeat -rfbauth /home/dsorber/.vnc/passwd -rfbport 5900 -shared
301
</pre>
302
# To start at boot using systemd service create: @/etc/systemd/system/x11vnc.service@:
303
<pre>
304
[Unit]
305
Description=x11vnc remote desktop server
306
After=multi-user.target
307
308
[Service]
309
Type=simple
310
ExecStart=/usr/bin/x11vnc -auth guess -forever -loop -noxdamage -repeat -rfbauth /home/dsorber/.vnc/passwd -rfbport 5900 -shared
311
312
Restart=on-failure
313
314
[Install]
315
WantedBy=multi-user.target
316
</pre>
317 28
** Setup service
318
<pre>
319
$ sudo systemctl daemon-reload
320
$ sudo systemctl enable x11vnc.service 
321
$ sudo systemctl start x11vnc.service
322
</pre>
323 15
324
On the client side:
325
# Install @remmina@:
326
<pre>
327
$ sudo apt install remmina
328
</pre>
329
# Open @remmina@, select "VNC", and type in the server's IP address.
330
331
* Source: https://forums.linuxmint.com/viewtopic.php?t=369092
332
333 14
h2. sshuttle
334 15
335
Poor man's VPN:
336 14
337
<pre>
338
$ sshuttle --dns -NHr dsorber@phalanx.homelinuxserver.org:3268  192.168.0.0/16
339
</pre>
340
341 13
h2. Batch Convert PNG to JPG
342
343
NOTE: @convert@ comes from ImageMagick
344
<pre>
345
& ls -1 *.png | parallel --eta convert '{}' -quality 90 '{.}.jpg'
346
</pre>
347
348 12
h2. Crop Video with ffmpeg
349
350
<pre>
351
$ ffmpeg -i in.mp4 -filter:v "crop=out_w:out_h:x:y" out.mp4
352
</pre>
353
354
* @out_w@ is the width of the output rectangle
355
* @out_h@ is the height of the output rectangle
356
* @x@ and @y@ specify the top left corner of the output rectangle (coordinates start at (0,0) in the top left corner of the input) 
357
358
Test using @ffplay@:
359
<pre>
360
$ ffplay -i input -vf "crop=out_w:out_h:x:y"
361
</pre>
362
363 10
h2. Build Custom Windows ISOs
364
365
* https://uupdump.net/
366 11
* https://forums.mydigitallife.net/threads/kms_vl_all-smart-activation-script.79535/
367 10
368 9
h2. Script to Convert Local manpages to html
369
370
Note use @zcat@ if the manpages are compressed:
371
372
<pre>
373
#!/bin/bash
374
375
mkdir -p html
376
for file in *; do
377
        if [ -f $file ] && [ "${file: -3}" != ".sh" ]; then
378
                echo $file
379
                #echo "${file%.*}"
380
                pandoc --from man --to html < $file > html/${file%.*}.html
381
        fi
382
done
383
</pre>
384
385 6
h2. Display Total rsync Progress
386
387
<pre>
388 7
$ rsync -a --no-i-r --info=progress2 /path/to/src /path/to/dest/
389 6
</pre>
390
391
NOTE: @-v@ does not work with @--info=progress2@
392
393
Source: https://serverfault.com/a/441724/472586
394
395 5
h2. Slice Video File 
396
397
<pre>
398
$ ffmpeg -ss 00:01:00 -to 00:02:00  -i input.mp4 -c copy output.mp4
399
</pre>
400
401
Explanation of the command:
402
403
* -i: This specifies the input file. In that case, it is (input.mp4).
404
* -ss: Used with -i, this seeks in the input file (input.mp4) to position.
405
* 00:01:00: This is the time your trimmed video will start with.
406
* -to: This specifies duration from start (00:01:40) to end (00:02:12).
407
* 00:02:00: This is the time your trimmed video will end with.
408
* -c copy: This is an option to trim via stream copy. (NB: Very fast)
409
410 4
h2. Add new drive SW RAID5
411
412
# Format drive if needed (see below for steps).
413
# Add new drive to SW RAID:
414
<pre>
415
$ sudo mdadm --manage /dev/md0 --add /dev/sdd1
416
</pre>
417
# Grow array:
418
<pre>
419
$ sudo mdadm --grow --raid-devices=4 /dev/md0
420
</pre>
421
422
h2. Replace failed SW RAID drive
423
424
# If drive is brand new be sure to create a partition on it:
425
<pre>
426
sorber@file2:~$ sudo parted /dev/sdg
427
GNU Parted 3.3
428
Using /dev/sdg
429
Welcome to GNU Parted! Type 'help' to view a list of commands.
430
(parted) mklabel gpt
431
(parted) mkpart primary 2048s 100%                                        
432
(parted) print                                                            
433
Model: ATA ST2000DM008-2FR1 (scsi)
434
Disk /dev/sdg: 2000GB
435
Sector size (logical/physical): 512B/4096B
436
Partition Table: gpt
437
Disk Flags: 
438
439
Number  Start   End     Size    File system  Name     Flags
440
 1      1049kB  2000GB  2000GB               primary
441
442
(parted) quit
443
</pre>
444
# If needed, mark bad drive as failed:
445
<pre>
446
$ sudo mdadm --manage /dev/md0 --fail /dev/sdd
447
</pre>
448
# Add new drive to replace failed:
449
<pre>
450
$ sudo mdadm --manage /dev/md0 --add /dev/sdd1 /dev/sdg1
451
</pre>
452
# Improve rebuild speed slightly:
453
<pre>
454
$ sudo bash -c "echo 9999999 > /proc/sys/dev/raid/speed_limit_min"
455
$ sudo bash -c "echo 9999999 > /proc/sys/dev/raid/speed_limit_max"
456
</pre>
457
# Monitor rebuild:
458
<pre>
459
$ watch -n1 cat /proc/mdstat 
460
</pre>
461
462
h2. Get detailed drive information
463
464
<pre>
465
$ udevadm info --query=all --name=/dev/sda
466
</pre>
467
468 1
h2. Split flac with cue
469
470
<pre>
471
$ sudo apt install cuetools shntool
472
473
$ shnsplit -f file.cue -t %n-%t -o flac file.flac
474
</pre>
475
476
h2. Fix Chrome Display Glitches
477
478
Somewhere around Chrome 86 display glitches started happening on wake. Here is how to fix:
479
480 3
Enabling @enable-vulkan@ in @chrome://flags@ then restarting the browser fixed it. If that does not work, you can also try enabling `ignore-gpu-blacklist` as well.
481 1
482
h2. Setup SSH Public Key
483
484
# On host machine generate a key pair. This key can be reused for multiple remote machines so it's not really necessary to change the name unless multiple keys are generated, which is also not really needed.
485
<pre>
486
$ ssh-keygen -t rsa
487
</pre>
488 3
 *NOTE:* for NetBeans to use/recognize the ssh key you must use the old PEM format:
489 1
<pre>
490
$ ssh-keygen -m PEM -t rsa
491
</pre>
492
# Now use `ssh-copy-id` to copy the key to the remote machine (for example):
493
<pre>
494
$ ssh-copy-id -i ~/.ssh/phalanx_rsa.pub dsorber@phalanx
495
</pre>
496
497
h2. Read Windows Product Key from ACPI Firmware
498
499
Boot into Linux and run:
500
501
<pre>
502
$ sudo strings /sys/firmware/acpi/tables/MSDM
503
</pre>
504
505
h2. Windows 10 Install and SysPrep Instructions
506
507
Very good instructions: https://theitbros.com/sysprep-windows-10-machine-guide/
508
509
510
h2. Search and Replace on Binary Files
511
512
A good hex editor can do search and replace on binary files but sometimes that's not practical:
513
514
* BBE - https://sourceforge.net/projects/bbe-/
515
 BBE is a binary editor with SED-like syntax:
516
<pre>
517
$ bbe -e 's/\x0a\x0d\x0a/\x0d\x0a/' infile > outfile
518
</pre>
519
* binwalk - https://github.com/ReFirmLabs/binwalk
520
 binwalk can search for hex strings (and do many other things)
521
<pre>
522
$ binwalk -R "\x0a\x0d\x0a" infile
523
524
WARNING: Signature '0    string    \x0a\x0d\x0a    Raw signature (\x0a\x0d\x0a)' is a self-overlapping signature!
525
526
DECIMAL       HEXADECIMAL     DESCRIPTION
527
--------------------------------------------------------------------------------
528
242           0xF2            Raw signature (\x0a\x0d\x0a)
529
412           0x19C           Raw signature (\x0a\x0d\x0a)
530
580           0x244           Raw signature (\x0a\x0d\x0a)
531
749           0x2ED           Raw signature (\x0a\x0d\x0a)
532
. . .
533
</pre>
534
535
h2. Wake-on-LAN WOL
536
537
Must be enabled on interface; need MAC
538
<pre>
539
$ sudo apt install etherwake
540
$ sudo etherwake <target MAC> -i <outgoing interface>
541
542
$ sudo etherwake b4:2e:99:a5:1e:f0 -i enp30s0
543
</pre>
544
545
h2. Allocator Shim
546
547
From Chromium, this is really interesting
548
* https://chromium.googlesource.com/chromium/src/base/+/master/allocator/README.md
549
550
However it is not clear how to use it outside of Chromium.
551
552
h2. Update Geany
553
554
# Install prereq packages (this obviously only needs to be done once):
555
<pre>
556
$ sudo apt install libgtk-3-dev libgtkspell-dev libgtkspell3-3-dev
557
</pre>
558
# Set compile flags:
559
<pre>
560
$ export CFLAGS="-O3 -march=native" 
561
$ export CXXFLAGS=$CFLAGS
562
</pre>
563
# Build geany and set to install in /opt so it won't collide with the packaged version:
564
<pre>
565
$ tar xf geany-1.30.tar.bz2
566
$ cd geany-1.30/
567
$ ./configure --prefix=/opt/local --enable-gtk3
568
$ make -j20
569
$ sudo make install
570
</pre>
571
# Set PKG_CONFIG_PATH environment variable so we can build the plugins.
572
<pre>
573
$ export PKG_CONFIG_PATH=/opt/local/lib/pkgconfig/
574
</pre>
575
# Build geany-plugins:
576
<pre>
577
$ tar xf geany-plugins-1.30.tar.bz2 
578
$ cd geany-plugins-1.30/
579
$ ./configure --prefix=/opt/local --enable-gtk3
580
$ make -j20
581
$ sudo make install
582
</pre>
583
584
h2. Find and replace across multiple files
585
586
<pre>
587
$ find /home/www -type f -print0 | xargs -0 sed -i 's/subdomainA\.example\.com/subdomainB.example.com/g'
588
</pre>
589
590
h2. Useful IPMI commands
591
592
593
Power measurement on the SuperMicro (probably won't work on Dell chassis as they have some proprietary version of ipmi):
594
595
<pre>
596
sudo ipmitool -U ADMIN -P ADMIN -H 10.17.136.108 dcmi power reading
597
</pre>
598
599
Check power status (i.e. on/off) of chassis:
600
<pre>
601
sudo ipmitool -U ADMIN -P ADMIN -H 10.17.70.45 power status
602
sudo ipmitool -U ADMIN -P ADMIN -H 10.17.70.45 power off
603
</pre>
604
605
Get IPMI IP address (look for "IP Address"):
606
<pre>
607
sudo ipmitool lan print 
608
</pre>
609
610
h2. Full sshfs Connect Command
611
612
<pre>
613
sudo sshfs -o idmap=user -o uid=$(id -u) -o gid=$(id -g) -o allow_other -o follow_symlinks ryftuser@sm-X11DGQ:/home/ryftuser /mnt/sm-X11DGQ/
614
</pre>
615
616
h2. Side-by-side Color Diff
617
618
<pre>
619
$ sudo apt-get install colordiff
620
$ colordiff -y --suppress-common-lines data.txt /ryftone/data.txt
621
</pre>
622
623
h2. x86 ABI
624
625
* https://github.com/hjl-tools/x86-psABI/wiki/X86-psABI
626
627
h2. clang-format and clang-tidy
628
629
* http://www.labri.fr/perso/fleury/posts/programming/using-clang-tidy-and-clang-format.html
630
631
h2. Shared Library and Related Resources
632
633
* http://tldp.org/HOWTO/Program-Library-HOWTO/shared-libraries.html
634
* https://blog.qt.io/blog/2011/10/28/rpath-and-runpath/
635
* http://www.bnikolic.co.uk/blog/linux-ld-debug.html
636
* http://insanecoding.blogspot.com/2012/07/creating-portable-linux-binaries.html
637
* https://stackoverflow.com/questions/4156055/static-linking-only-some-libraries
638
639
h2. Ubuntu: List Grub Entries
640
641
<pre>
642
gawk  'BEGIN {                                                                                                                       
643
  l=0                                                                                                                                
644
  menuindex= 0                                                                                                                       
645
  stack[t=0] = 0                                                                                                                     
646
}                                                                                                                                    
647
648
function push(x) { stack[t++] = x }                                                                                                  
649
650
function pop() { if (t > 0) { return stack[--t] } else { return "" }  }                                                              
651
652
{                                                                                                                                    
653
654
if( $0 ~ /.*menu.*{.*/ )                                                                                                             
655
{                                                                                                                                    
656
  push( $0 )                                                                                                                         
657
  l++;                                                                                                                               
658
659
} else if( $0 ~ /.*{.*/ )                                                                                                            
660
{                                                                                                                                    
661
  push( $0 )                                                                                                                         
662
663
} else if( $0 ~ /.*}.*/ )                                                                                                            
664
{                                                                                                                                    
665
  X = pop()                                                                                                                          
666
  if( X ~ /.*menu.*{.*/ )                                                                                                            
667
  {                                                                                                                                  
668
     l--;                                                                                                                            
669
     match( X, /^[^'\'']*'\''([^'\'']*)'\''.*$/, arr )                                                                               
670
671
     if( l == 0 )                                                                                                                    
672
     {                                                                                                                               
673
       print menuindex ": " arr[1]                                                                                                   
674
       menuindex++                                                                                                                   
675
       submenu=0                                                                                                                     
676
     } else                                                                                                                          
677
     {                                                                                                                               
678
       print "  " (menuindex-1) ">" submenu " " arr[1]                                                                               
679
       submenu++                                                                                                                     
680
     }                                                                                                                               
681
  }                                                                                                                                  
682
}                                                                                                                                    
683
684
}' /boot/grub/grub.cfg
685
</pre>
686
687
* https://askubuntu.com/a/941993/392271
688
689
690
h2.GCC Disable Unused Variable Warnings
691
692
<pre>
693
#pragma GCC diagnostic push
694
#pragma GCC diagnostic ignored "-Wunused-variable"
695
( your problematic library includes )
696
#pragma GCC diagnostic pop
697
</pre>
698
699
See: https://stackoverflow.com/a/22708539/73878
700
701
h2. Fix Steam after NVidia driver update
702
703
Since this has now bitten me twice... Steam requires the 32 bit version of the GL library.
704
705
<pre>
706
$ sudo apt install libnvidia-gl-418:i386
707
</pre>
708
709
h2. Restart Cinnamon from TTY
710
711
# Cinnamon freezes
712
# Switch tty. I usually go to tty6, `Ctrl+Alt+F6`
713
# If you need to login first, do so.
714
# Type `w` (yes, just the letter) and press enter. This commands does a lot of different things, but you need it to figure out the number of the display you are using. The display number is in the column FROM. Mine is `:0` (yes, including the colon).
715
# Assuming that cinnamon is already dead (which you would notice by the windows lacking titles and that you can't move different windows around, and perhaps even not being able to use the keyboard), you type `export DISPLAY=:0; cinnamon &`, and don't forget the colon. I add the ampersand (&) only not to keep that tty busy.
716
717
Sauce: https://askubuntu.com/a/198935/392271
718
719
h2. Ubuntu Set Specific Kernel to Boot
720
721
* Use this command to get a list of available options:
722
<pre>
723
$ grep -Ei 'submenu|menuentry ' /boot/grub/grub.cfg | sed -re "s/(.? )'([^']+)'.*/\1 \2/"
724
menuentry  Ubuntu
725
submenu  Advanced options for Ubuntu
726
    menuentry  Ubuntu, with Linux 4.4.0-34-generic
727
    menuentry  Ubuntu, with Linux 4.4.0-34-generic (upstart)
728
    menuentry  Ubuntu, with Linux 4.4.0-34-generic (recovery mode)
729
menuentry  System setup
730
</pre>
731
* Backup grub configuration, just in case:
732
<pre>
733
$ sudo cp /etc/default/grub /etc/default/grub.bak
734
</pre>
735
* Edit grub configuration and change `GRUB_DEFAULT` to something like this:
736
<pre>
737
$ sudo vim /etc/default/grub
738
739
GRUB_DEFAULT="Advanced options for Ubuntu>Ubuntu, with Linux 3.13.0-53-generic"
740
</pre>
741
* Update grub configuration
742
<pre>
743
$ sudo update-grub
744
</pre>
745
* See also: https://askubuntu.com/questions/216398/set-older-kernel-as-default-grub-entry
746
747
h2. Ubuntu Networking Resources
748
749
* https://blog.ubuntu.com/2017/12/01/ubuntu-bionic-netplan
750
* https://help.ubuntu.com/lts/serverguide/network-configuration.html.en
751
* https://netplan.io/
752
753
h2. Win10 Licensing Info
754
755
* https://www.windowscentral.com/how-change-product-key-windows-10
756
* https://www.tenforums.com/tutorials/49586-determine-if-windows-license-type-oem-retail-volume.html
757
* https://www.tenforums.com/windows-updates-activation/104569-win-10-activation-expiring-volume-license.html
758
759
h2. Python GTK Development Resources
760
761
* https://python-gtk-3-tutorial.readthedocs.io/en/latest/layout.html
762
* https://lazka.github.io/pgi-docs/Gtk-3.0/classes/Box.html#Gtk.Box.pack_start
763
* https://lazka.github.io/pgi-docs/Gtk-3.0/mapping.html
764
765
h2. cpufrequtils Governor Configuration
766
767
These instructions are intended for Ubuntu 16.04 and later (using systemd init).
768
769
* Check the available and currently set governors. Ubuntu has an โ€œondemandโ€ service that sets the governor to ondemand after boot.
770
<pre>
771
$ cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_governors
772
conservative ondemand userspace powersave performance schedutil
773
$ cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor 
774
ondemand
775
</pre>
776
777
* Configure cpufrequtils to set the governor to performance at boot
778
<pre>
779
$ echo 'GOVERNOR="performance"' | sudo tee /etc/default/cpufrequtils
780
GOVERNOR="performance"
781
</pre>
782
783
* Disable the automatic ondemand service. 
784
<pre>
785
$ sudo systemctl disable ondemand
786
</pre>
787
788
* Reboot.
789
790
* Now check that the governor is set to performance for every CPU:
791
<pre>
792
$ cat /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor
793
performance
794
performance
795
performance
796
performance
797
โ€ฆ
798
performance
799
performance
800
performance
801
</pre>
802
803
* Check current CPU speeds:
804
<pre>
805
$ watch -n 1 bash -c 'cpufreq-info | grep "current CPU frequency"'
806
</pre>
807
808
h2. rsync via ssh example
809
810
<pre>
811
$ rsync --info=progress2 -ahz --compress-level=9 -e "ssh -i ~/ryft-pat-f1.pem" data/ ryftuser@18.205.65.5:/ryftone/regression/pubmed/data/
812
</pre>
813
814
h2. Read Performance using AIO
815
816
Use this fio command (run from temp directory on disk in question) to measure max disk read performance:
817
818
<pre>
819
$ fio --name TEST --eta-newline=5s --filename=fio-tempfile.dat --rw=read --size=10g --io_size=10g --blocksize=512k --ioengine=libaio --fsync=0 --iodepth=32 --direct=1 --numjobs=1 --runtime=300 --group_reporting
820
</pre>
821
822
Note that DIRECT_IO is required when using AIO. (see also: https://askubuntu.com/a/991311/392271)
823
824
h2. Remove Source Files While Creating Tarball
825
826
This is handy as it saves on disk space.
827
<pre>
828
$ tar --remove-files -cf pictures.tar Pictures/
829
</pre>
830
831
h2. Linux Find and Remove Files
832
833
Find and remove files (even with spaces in the path) using case insensitive matching for the wildcard:
834
<pre>
835
$ find . -type f -iname "*.jpg" -print0 | xargs -0 rm
836
</pre>
837
838
h2. Convert ASCII hex to binary
839
This problem seems to come up every so often. There is no need for a one-off solution:
840
841
<pre>
842
$ xxd -r -p input.txt output.bin
843
</pre>
844
845
https://stackoverflow.com/questions/7826526/transform-a-hex-info-to-binary-using-linux-command
846
847
h2. Well Said
848
849
https://developers.slashdot.org/comments.pl?sid=12326098&cid=56908942
850
851
h2. Hex Editor
852
853
I had been using [[https://hexinator.com/|Hexinator]] but I've had some minor issues with it. Today I tried [[https://www.wxhexeditor.org/home.php|wxHexEditor]] and I was pleasantly surprised.
854
855
Download from here: https://github.com/EUA/wxHexEditor
856
857
You'll need the latest version of libwxgtk<version>-dev package.
858
859
I had some minor issues with the build (which seems a somewhat bizarre arrangement...) modify the makefile to set `CC` and `CXX` directly, right about line 90.
860
861
Finally, to get it installed in the right place:
862
<pre>
863
sudo make install DESTDIR=/opt/local BINDIR=bin DATADIR=share
864
</pre>
865
866
h2. Preprocessor Fun
867
868
To invoke the preprocessor directly:
869
<pre>
870
gcc -E -DSOME_DEFINE=SOME_VALUE somefile.c 
871
</pre>
872
873
See also [[https://linux.die.net/man/1/unifdef|unifdef]]: "The unifdef utility acts on #if, #ifdef, #ifndef, #elif, #else, and #endif lines, and it understands only the commonly-used subset of the expression syntax for #if and #elif lines."
874
875
h2. Convert Oversampled .flac to 16 bit 44.1 khz .flac
876
877
<pre>
878
mkdir -p output && find . -type f -name "*.flac" | parallel -j16 "sox {} -b 16 -r 44100 output/{/.}.flac"
879
880
mkdir -p output && find . -type f -name "*.flac" | parallel -j16 "sox -v 0.98 {} -b 16 -r 44100 output/{/.}.flac"
881
</pre>
882
883
h2. Aligned C++ STL Types
884
885
<pre>
886
#include <vector>
887
#include <boost/align/aligned_allocator.hpp>
888
889
template <typename T>
890
using aligned_vector = std::vector<T, boost::alignment::aligned_allocator<T, 4096>>;
891
</pre>
892
893
h2. Command line convert .png to .jpg
894
895
<pre>
896
$ for x in *.png; do convert $x $(basename $x .png).jpg; done
897
</pre>
898
899
You can also add the "`-quality 90`" option if needed.
900
901
h2. Determine CPU Family Name
902
903
<pre>
904
$ gcc -march=native -Q --help=target|grep march
905
</pre>
906
907
h2. Convert .flac to .m4a (AAC)
908
909
Requires `ffmpeg` built with libfdk_aac:
910
911
<pre>
912
$ /opt/bin/ffmpeg -i input.flac -vn -c:a libfdk_aac -vbr 3 output.m4a
913
</pre>
914
915
All together using `find` and `parallel` for magic:
916
<pre>
917
$ find . -type f -name "*.flac" | parallel -j16 "/opt/bin/ffmpeg -i {} -vn -c:a libfdk_aac -vbr 4 {/.}.m4a"
918
</pre>
919
920
h2. PyGObject
921
922
This is the magic needed to have stuff happen quasi asynchronously using PyGObject (GTK+):
923
924
<pre>
925
# Yield to the main loop temporarily
926
while Gtk.events_pending():
927
    Gtk.main_iteration()
928
</pre>
929
930
h2. FUSE Code
931
932
 *https://pastebin.com/wavKntiu
933
934
h2. Use Windoze Schtuffs
935
936
 * https://support.microsoft.com/en-gb/help/17588/fix-problems-that-block-programs-from-being-installed-or-removed (gotta love how this requires a separate program)
937
 * [[http://landinghub.visualstudio.com/visual-cpp-build-tools|MSVC Tools]] - compiler (seems to be the rough equivalent of `build-essential`)
938
 * [[https://docs.microsoft.com/en-us/sysinternals/downloads/procmon|Process Monitor]] - useful debug tool
939
  * https://www.codeproject.com/Articles/560816/Troubleshooting-dependency-resolution-problems-usi - example for using Process Monitor
940
 * http://download.microsoft.com/download/7/2/E/72E0F986-D247-4289-B9DC-C4FB07374894/wdexpress_full.exe - (required by wingtk below)
941
 
942
* https://github.com/wingtk/gvsbuild - haven't tried this yet but looks amazing... 
943
944
h2. Build Handbrake Git Build
945
946
Steps for building Handbrake using AOCC:
947
948
<pre>
949
$ source /home/dsorber/Downloads/aocc/setenv_AOCC.sh
950
$ export CC=clang
951
$ export CXX=clang++
952
$ export CFLAGS="-g -O3 -mtune=native"
953
$ export CXXFLAGS=$CFLAGS
954
$ cd ~/Downloads/HandBrake/
955
$ rm -rf build/
956
$ ./configure --prefix=/opt --enable-x265 --enable-fdk-aac --gcc=/home/dsorber/Downloads/aocc/AOCC-1.1-Compiler/bin/clang
957
$ cd build
958
$ make -j17
959
$ sudo make install
960
</pre>
961
962
----
963
964
Regular build (18.04 and later):
965
<pre>
966
$ rm -rf build/
967
$ ./configure --prefix=/opt/local --enable-x265 --enable-fdk-aac
968
$ cd build
969
$ make -j17
970
$ sudo make install
971
</pre>
972
973
h2. Politically Correct Linux
974
975
* https://entertainment.slashdot.org/comments.pl?sid=11493671&cid=55759997
976
977
h2. This guy gets it
978
979
Regarding software purist ideology vs pragmatism
980
981
* https://linux.slashdot.org/comments.pl?sid=11156367&cid=55256437
982
983
h2. "Rotate" Video Playback via Metadata
984
985
<pre>
986
$ ffmpeg -i input.mp4 -c copy -metadata:s:v:0 rotate=90 output.mp4
987
</pre>
988
989
990
h2. Ubuntu Remove Old Kernels Oneliner
991
992
<pre>
993
$ sudo apt-get purge $(for tag in "linux-image" "linux-headers"; do dpkg-query -W -f'${Package}\n' "$tag-[0-9]*.[0-9]*.[0-9]*" | sort -V | awk 'index($0,c){exit} //' c=$(uname -r | cut -d- -f1,2); done)
994
</pre>
995
996
* [[https://askubuntu.com/questions/2793/how-do-i-remove-old-kernel-versions-to-clean-up-the-boot-menu/571360#571360|Sauce]]
997
998
h2. Remove New Lines (command line)
999
1000
For a file:
1001
<pre>
1002
$ tr -d '\n' < yourfile.txt
1003
</pre>
1004
1005
Or for output of a command (e.g.):
1006
<pre>
1007
$ find . -type f -name '*.txt' | tr -d '\n'
1008
</pre>
1009
1010
h2. Convert from .mp4 to .mkv Container
1011
1012
Use `avconv` to convert container without re-encoding:
1013
<pre>
1014
$ sudo apt-get install libav-tools
1015
1016
$ avconv -i filme.mp4 -c copy filme.mkv
1017
</pre>
1018
1019
h2. Remove String From Many File Names
1020
1021
On Ubuntu use Perl rename utility, e.g.:
1022
1023
<pre>
1024
$ rename 's/ \(1920x1080\) \[WaifuKenny\]//' *.mp4
1025
</pre>
1026
1027
h2. Change Default Text Editor
1028
1029
I always have to Google this...
1030
1031
<pre>
1032
$ sudo update-alternatives --config editor
1033
</pre>
1034
1035
h2. Linux View System RAM Speed
1036
1037
View RAM speed (actual) on Debian/Ubuntu/Mint:
1038
1039
<pre>
1040
$ sudo lshw -short -C memory
1041
H/W path                      Device      Class          Description
1042
====================================================================
1043
/0/0                                      memory         64KiB BIOS
1044
/0/b                                      memory         32GiB System Memory
1045
/0/b/0                                    memory         [empty]
1046
/0/b/1                                    memory         16GiB DIMM Synchronous 2134 MHz (0.5 ns)
1047
/0/b/2                                    memory         [empty]
1048
/0/b/3                                    memory         16GiB DIMM Synchronous 2134 MHz (0.5 ns)
1049
/0/d                                      memory         768KiB L1 cache
1050
/0/e                                      memory         4MiB L2 cache
1051
/0/f                                      memory         16MiB L3 cache
1052
</pre>
1053
1054
h2. Linux Memory Schtuff
1055
1056
* [[https://github.com/jbert/exmap|exmap]]
1057
* https://jameshunt.us/writings/smaps.html
1058
* https://techtalk.intersec.com/2013/07/memory-part-2-understanding-process-memory/
1059
* http://bmaurer.blogspot.com/2006/03/memory-usage-with-smaps.html
1060
1061
* https://github.com/torvalds/linux/blob/master/Documentation/filesystems/proc.txt
1062
1063
* From: http://stackoverflow.com/questions/24484481/entry-in-proc-meminfo
1064
<pre>
1065
  2. Active(file), Inactive(file) has file back-end which means its original file is in disk but to use it faster it was loaded on RAM.
1066
</pre>
1067
1068
1069
* From: http://unix.stackexchange.com/questions/56879/tracking-down-missing-memory-usage-in-linux
1070
1071
  The "memory used by a process" is not a clear cut concept in modern operating systems. What can be measured is the size of the address space of the process (SIZE) and resident set size (RSS, how many of the pages in the address space are currently in memory). Part of RSS is shared (most processes in memory share one copy of glibc, and so for assorted other shared libraries; several processes running the same executable share it, processes forked share read-only data and possibly a chunk of not-yet-modified read-write data with the parent). On the other hand, memory used for the process by the kernel isn't accounted for, like page tables, kernel buffers, and kernel stack. In the overall picture you have to account for the memory reserved for the graphics card, the kernel's use, and assorted "holes" reserved for DOS and other prehistoric systems (that isn't much, anyway).
1072
1073
  The only way of getting an overall picture is what the kernel reports as such. Adding up numbers with unknown overlaps and unknown left outs is a nice exercise in arithmetic, nothing more.
1074
1075
 * [[http://virtualthreads.blogspot.com/2006/02/understanding-memory-usage-on-linux.html|Understanding memory usage on Linux]]
1076
1077
 * https://linux-mm.org/LinuxMM
1078
1079
h2. Reinstall grub on UEFI System
1080
1081
Reinstalling grub on a UEFI system is slightly different than on a traditional legacy BIOS system:
1082
1083
<pre>
1084
# Mount the primary drive root partition and the boot EFI partition
1085
sudo mount /dev/sda# /mnt            # Mount root (/) partition
1086
sudo mount /dev/sda# /mnt/boot       # Mount boot (/boot) partition (if separate from root partition; typically not)
1087
1088
sudo mkdir -p /mnt/boot/efi          # Create EFI partition mount point
1089
sudo mount /dev/sda1 /mnt/boot/efi   # Mount EFI partition
1090
1091
# Mount your virtual filesystems:
1092
for i in /dev /dev/pts /proc /sys /run; do sudo mount -B $i /mnt$i; done
1093
1094
# Chroot
1095
sudo chroot /mnt
1096
</pre>
1097
1098
Now, if you have networking you'll need DNS. If using `resolvconf` (for recent versions of Ubuntu):
1099
1100
# Edit ` /etc/resolvconf/resolv.conf.d/head` and add the following line (OpenDNS server).  Then save and exit:
1101
<pre>
1102
add nameserver 208.67.222.222
1103
</pre>
1104
# Next enable updates and update:
1105
<pre>
1106
sudo resolvconf --enable-updates
1107
sudo resolvconf -u
1108
</pre>
1109
# Now you should have DNS. Test by pinging something.
1110
1111
Finally, back to fixing grub. Note that the grub install should run smoothly with no errors or warnings. If you see any something is probably wrong.
1112
<pre>
1113
apt-get install grub-efi-amd64  # Install grub EFI bootloader (this should be all you need to do)
1114
1115
1116
# manual steps if you need them for some reason
1117
grub-install --recheck --no-floppy --force /dev/sda1  # Install grub bootloader in EFI partition
1118
1119
#####
1120
echo "configfile (hd0,gpt#)/boot/grub.cfg" > /boot/efi/ubuntu/grub.cfg # Tell grub to load grub.cfg from /boot
1121
1122
update-grub                          # Create grub menu list
1123
#####
1124
1125
exit                                 # Exit chroot
1126
</pre>
1127
1128
Reboot and you should be back in business.
1129
1130
h2. Convert flac to VBR mp3 using ffmpeg/lame
1131
1132
<pre>
1133
for file in *.flac; do name=$(echo $file | sed "s/\.flac//g"); ffmpeg -i "$file" -codec:a libmp3lame -qscale:a 0 "$name".mp3; done
1134
</pre>
1135
1136
h2. Create UEFI/legacy BIOS Bootable ISO
1137
1138
* http://askubuntu.com/questions/625286/how-to-create-uefi-bootable-iso
1139
1140
h2. Getting rEFInd to work on Mac OS 10.11
1141
1142
* http://mattjanik.ca/blog/2015/10/01/refind-on-el-capitan/
1143
1144
h2. Convert DTS 5.1 to FLAC
1145
1146
<pre>
1147
sudo apt-get install libdca-utils ffmpeg sound-juicer gnome-terminal easytag vlc 
1148
1149
for file in *.wav; do name=$(echo $file | sed "s/\.wav//g"); dcadec -o wavall "$file" > "$name"_decoded.wav; ffmpeg -i "$name"_decoded.wav "$name".flac; rm -f "$file" "$name"_decoded.wav; done
1150
</pre>
1151
1152
Source: http://ubuntuforums.org/archive/index.php/t-1849260.html
1153
1154
h2. Windows Utils
1155
1156
* http://windirstat.info/download.html
1157
* https://www.raymond.cc/blog/safely-delete-unused-msi-and-mst-files-from-windows-installer-folder/
1158
1159
h2. SSH Security
1160
1161
https://stribika.github.io/2015/01/04/secure-secure-shell.html
1162
1163
h2. Windows 10
1164
1165
* http://ultimateoutsider.com/downloads/ - GWX Control Panel to disable GWX (Windows 10 update nagging)
1166
* [[https://www.safer-networking.org/spybot-anti-beacon/|Spybot Anti-Beacon]] - Disable Micro$oft "telemetry" data gathering from Windows 10, 8.x, and 7
1167
1168
<pre>
1169
The newest version of the KB3035583 update includes a background process which scans the 
1170
system's Windows Registry twice a day to see if the values for the four aforementioned registry 
1171
inputs were manually edited to disable the upgrade prompt. If they were, the process will alter 
1172
the values, silently re-download the Windows 10 installation files (about 6 GB in total), and 
1173
prompt the user to upgrade.
1174
</pre>
1175
1176
1177
h2. gpg-agent
1178
1179
* http://www.infrastructureanywhere.com/documentation/additional/mirrors.html
1180
1181
These instructions are geared toward reprepro but should be useful in general for setting up `gpg-agent`.
1182
1183
1184
h2. Resolve DNS While VPN Connected
1185
1186
How to configure dnsmasq for DNS overrides while using a VPN connection: https://chawlasumit.wordpress.com/2014/06/15/linux-mint-openconnect-vpn-dns-issues/
1187
1188
h2. Pretty Print Python Traceback
1189
1190
<pre>#!python
1191
import traceback
1192
1193
 ...
1194
1195
try: 
1196
    with open('/dev/null', 'w') as void:
1197
        rc = not bool(subprocess.call('modprobe -r {:s}'.format(mod_name), 
1198
                                      shell=True, stdout=void, stderr=void))
1199
except Exception as e:
1200
    print_failure_status()
1201
    exc_type, exc_value, exc_traceback = sys.exc_info()
1202
    print('\n')
1203
    traceback.print_exception(exc_type, exc_value, exc_traceback)
1204
    print('\n')
1205
</pre>
1206
1207
h2. Generating Random Data Files for Testing
1208
1209
One approach is to use /dev/urandom (non-blocking pseudorandom device):
1210
<pre>
1211
$ dd if=/dev/urandom bs=32M count=32 of=data_1GB.bin
1212
</pre>
1213
Unfortunately /dev/urandom is a bit slow. However, you can alternatively use openssl to generate pseudorandom numbers a bit faster:
1214
<pre>
1215
 $ openssl rand 1073741824 > data_1GB.bin
1216
 $ for run in {1..30}; do echo $run; openssl rand 1073741824 >> data_30GB.bin; done
1217
</pre>
1218
1219
h2. Cloning HDDs
1220 8
1221 1
When configuring multiple chassis it is necessary to clone an HDD. There are all sorts of disk imaging tools out there but it's hard to beat the trusty dd command. The pv (pipe viewer) portion isn't strictly necessary but it prints out a very useful textual status bar. The back ticked blockdev command reports the size of the drive in bytes, which pv then uses to determine overall progress. The bs argument to dd should correspond to the cache size of the drive for optimum performance (32MB is a sane default for most drives these days).
1222
1223
To clone a single drive to another identical drive (assuming sda is the source and sdb is the destination):
1224
<pre>
1225
 $ sudo dd if=/dev/sda bs=32M | pv -s `sudo blockdev --getsize64 /dev/sda` | sudo dd of=/dev/sdb bs=32M
1226
</pre>
1227
To clone to multiple drives all at once (assuming sda is the source and sdb, sdc are destinations):
1228
<pre>
1229
 $ sudo dd if=/dev/sda bs=32M | pv -s `sudo blockdev --getsize64 /dev/sda` | tee >(sudo dd of=/dev/sdb bs=32M) | sudo dd of=/dev/sdc bs=32M
1230
</pre>
1231
It is entirely possible to clone more drives by adding additional `>(sudo dd of=/dev/sdX bs=32M)` arguments to the tee command. Note that tee outputs to stdout so it is necessary to pipe the output of tee to the final dd command as shown above. If you don't do this then tee will spew the raw contents of the source HDD to your screen, which will make the clone take forever and look especially ugly!
1232
1233
For some reason RedHat/CentOS do not have the pv command or even a package for it in their repos!!! Therefore, boot from a Debian-based OS in order to clone.
1234
1235
h2. Generating ISOs
1236
1237
<pre>
1238
 $ genisoimage -R -J -o <output.iso> <some directory>
1239
</pre>
1240
To deal with long file names:
1241
<pre>
1242
 $ genisoimage -R -J -l -D -joliet-long -o <output.iso> <some directory>
1243
</pre>
1244
1245 2
h2. BIOS/grub
1246 1
1247 2
* http://forums.linuxmint.com/viewtopic.php?f=46&t=119832
1248
* http://www.gnu.org/software/grub/manual/html_node/BIOS-installation.html
1249
* https://wiki.archlinux.org/index.php/GRUB2
1250
* http://unix.stackexchange.com/questions/28443/does-grub2-support-putting-boot-on-a-raid5-partition
1251 1
1252
h3. Creating a BIOS Boot Partition on a GPT system
1253
1254
<pre>
1255
$ sudo parted /dev/sda
1256
(parted) mkpart primary 0 1024k
1257
(parted) set 2 bios_grub on
1258
</pre>
1259
1260 2
h2. Actiontec Router
1261
1262
* http://transition.fcc.gov/oet/ea/fccid/
1263
* http://opensource.actiontec.com/mi424wref.html
1264 1
1265
h2. Temp
1266
1267
https://www.grumpyland.com/blog/183/installing-software-raid-on-centos-567-via-ssh/
1268
<pre>
1269
# swap is on /dev/md1
1270
/dev/md1 none            swap    sw              0       0
1271
1272
# storage is on /dev/md0
1273
/dev/md0        /storage        xfs     noatime,barrier=0 0 0
1274
//faramir/production/sw /sw     cifs    username=samba,password=w00tw00t!,file_mode=0666,dir_mode=0777  0       0
1275
</pre>
1276
1277
----
1278
[[../|Back home]]