Project

General

Profile

Miscellaneous » History » Version 32

Anonymous, 11/28/2024 11:47 AM
adding note

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