Project

General

Profile

Miscellaneous » History » Version 2

Anonymous, 07/11/2021 02:11 PM
fixing a few leftover formatting issues

1 1
h1. Miscellaneous
2
3
h2. Split flac with cue
4
5
<pre>
6
$ sudo apt install cuetools shntool
7
8
$ shnsplit -f file.cue -t %n-%t -o flac file.flac
9
</pre>
10
11
h2. Fix Chrome Display Glitches
12
13
Somewhere around Chrome 86 display glitches started happening on wake. Here is how to fix:
14
15
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.
16
17
h2. Setup SSH Public Key
18
19
# 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.
20
<pre>
21
$ ssh-keygen -t rsa
22
</pre>
23
 * *NOTE:* for NetBeans to use/recognize the ssh key you must use the old PEM format:
24
<pre>
25
$ ssh-keygen -m PEM -t rsa
26
</pre>
27
# Now use `ssh-copy-id` to copy the key to the remote machine (for example):
28
<pre>
29
$ ssh-copy-id -i ~/.ssh/phalanx_rsa.pub dsorber@phalanx
30
</pre>
31
32
h2. Read Windows Product Key from ACPI Firmware
33
34
Boot into Linux and run:
35
36
<pre>
37
$ sudo strings /sys/firmware/acpi/tables/MSDM
38
</pre>
39
40
h2. Windows 10 Install and SysPrep Instructions
41
42
Very good instructions: https://theitbros.com/sysprep-windows-10-machine-guide/
43
44
45
h2. Search and Replace on Binary Files
46
47
A good hex editor can do search and replace on binary files but sometimes that's not practical:
48
49
* BBE - https://sourceforge.net/projects/bbe-/
50
 BBE is a binary editor with SED-like syntax:
51
<pre>
52
$ bbe -e 's/\x0a\x0d\x0a/\x0d\x0a/' infile > outfile
53
</pre>
54
* binwalk - https://github.com/ReFirmLabs/binwalk
55
 binwalk can search for hex strings (and do many other things)
56
<pre>
57
$ binwalk -R "\x0a\x0d\x0a" infile
58
59
WARNING: Signature '0    string    \x0a\x0d\x0a    Raw signature (\x0a\x0d\x0a)' is a self-overlapping signature!
60
61
DECIMAL       HEXADECIMAL     DESCRIPTION
62
--------------------------------------------------------------------------------
63
242           0xF2            Raw signature (\x0a\x0d\x0a)
64
412           0x19C           Raw signature (\x0a\x0d\x0a)
65
580           0x244           Raw signature (\x0a\x0d\x0a)
66
749           0x2ED           Raw signature (\x0a\x0d\x0a)
67
. . .
68
</pre>
69
70
h2. Wake-on-LAN WOL
71
72
Must be enabled on interface; need MAC
73
<pre>
74
$ sudo apt install etherwake
75
$ sudo etherwake <target MAC> -i <outgoing interface>
76
77
$ sudo etherwake b4:2e:99:a5:1e:f0 -i enp30s0
78
</pre>
79
80
h2. Allocator Shim
81
82
From Chromium, this is really interesting
83
* https://chromium.googlesource.com/chromium/src/base/+/master/allocator/README.md
84
85
However it is not clear how to use it outside of Chromium.
86
87
h2. Update Geany
88
89
# Install prereq packages (this obviously only needs to be done once):
90
<pre>
91
$ sudo apt install libgtk-3-dev libgtkspell-dev libgtkspell3-3-dev
92
</pre>
93
# Set compile flags:
94
<pre>
95
$ export CFLAGS="-O3 -march=native" 
96
$ export CXXFLAGS=$CFLAGS
97
</pre>
98
# Build geany and set to install in /opt so it won't collide with the packaged version:
99
<pre>
100
$ tar xf geany-1.30.tar.bz2
101
$ cd geany-1.30/
102
$ ./configure --prefix=/opt/local --enable-gtk3
103
$ make -j20
104
$ sudo make install
105
</pre>
106
# Set PKG_CONFIG_PATH environment variable so we can build the plugins.
107
<pre>
108
$ export PKG_CONFIG_PATH=/opt/local/lib/pkgconfig/
109
</pre>
110
# Build geany-plugins:
111
<pre>
112
$ tar xf geany-plugins-1.30.tar.bz2 
113
$ cd geany-plugins-1.30/
114
$ ./configure --prefix=/opt/local --enable-gtk3
115
$ make -j20
116
$ sudo make install
117
</pre>
118
119
h2. Find and replace across multiple files
120
121
<pre>
122
$ find /home/www -type f -print0 | xargs -0 sed -i 's/subdomainA\.example\.com/subdomainB.example.com/g'
123
</pre>
124
125
h2. Useful IPMI commands
126
127
128
Power measurement on the SuperMicro (probably won't work on Dell chassis as they have some proprietary version of ipmi):
129
130
<pre>
131
sudo ipmitool -U ADMIN -P ADMIN -H 10.17.136.108 dcmi power reading
132
</pre>
133
134
Check power status (i.e. on/off) of chassis:
135
<pre>
136
sudo ipmitool -U ADMIN -P ADMIN -H 10.17.70.45 power status
137
sudo ipmitool -U ADMIN -P ADMIN -H 10.17.70.45 power off
138
</pre>
139
140
Get IPMI IP address (look for "IP Address"):
141
<pre>
142
sudo ipmitool lan print 
143
</pre>
144
145
h2. Full sshfs Connect Command
146
147
<pre>
148
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/
149
</pre>
150
151
h2. Side-by-side Color Diff
152
153
<pre>
154
$ sudo apt-get install colordiff
155
$ colordiff -y --suppress-common-lines data.txt /ryftone/data.txt
156
</pre>
157
158
h2. x86 ABI
159
160
* https://github.com/hjl-tools/x86-psABI/wiki/X86-psABI
161
162
h2. clang-format and clang-tidy
163
164
* http://www.labri.fr/perso/fleury/posts/programming/using-clang-tidy-and-clang-format.html
165
166
h2. Shared Library and Related Resources
167
168
* http://tldp.org/HOWTO/Program-Library-HOWTO/shared-libraries.html
169
* https://blog.qt.io/blog/2011/10/28/rpath-and-runpath/
170
* http://www.bnikolic.co.uk/blog/linux-ld-debug.html
171
* http://insanecoding.blogspot.com/2012/07/creating-portable-linux-binaries.html
172
* https://stackoverflow.com/questions/4156055/static-linking-only-some-libraries
173
174
h2. Ubuntu: List Grub Entries
175
176
<pre>
177
gawk  'BEGIN {                                                                                                                       
178
  l=0                                                                                                                                
179
  menuindex= 0                                                                                                                       
180
  stack[t=0] = 0                                                                                                                     
181
}                                                                                                                                    
182
183
function push(x) { stack[t++] = x }                                                                                                  
184
185
function pop() { if (t > 0) { return stack[--t] } else { return "" }  }                                                              
186
187
{                                                                                                                                    
188
189
if( $0 ~ /.*menu.*{.*/ )                                                                                                             
190
{                                                                                                                                    
191
  push( $0 )                                                                                                                         
192
  l++;                                                                                                                               
193
194
} else if( $0 ~ /.*{.*/ )                                                                                                            
195
{                                                                                                                                    
196
  push( $0 )                                                                                                                         
197
198
} else if( $0 ~ /.*}.*/ )                                                                                                            
199
{                                                                                                                                    
200
  X = pop()                                                                                                                          
201
  if( X ~ /.*menu.*{.*/ )                                                                                                            
202
  {                                                                                                                                  
203
     l--;                                                                                                                            
204
     match( X, /^[^'\'']*'\''([^'\'']*)'\''.*$/, arr )                                                                               
205
206
     if( l == 0 )                                                                                                                    
207
     {                                                                                                                               
208
       print menuindex ": " arr[1]                                                                                                   
209
       menuindex++                                                                                                                   
210
       submenu=0                                                                                                                     
211
     } else                                                                                                                          
212
     {                                                                                                                               
213
       print "  " (menuindex-1) ">" submenu " " arr[1]                                                                               
214
       submenu++                                                                                                                     
215
     }                                                                                                                               
216
  }                                                                                                                                  
217
}                                                                                                                                    
218
219
}' /boot/grub/grub.cfg
220
</pre>
221
222
* https://askubuntu.com/a/941993/392271
223
224
225
h2.GCC Disable Unused Variable Warnings
226
227
228
<pre>
229
#pragma GCC diagnostic push
230
#pragma GCC diagnostic ignored "-Wunused-variable"
231
( your problematic library includes )
232
#pragma GCC diagnostic pop
233
</pre>
234
235
See: https://stackoverflow.com/a/22708539/73878
236
237
h2. Fix Steam after NVidia driver update
238
239
Since this has now bitten me twice... Steam requires the 32 bit version of the GL library.
240
241
<pre>
242
$ sudo apt install libnvidia-gl-418:i386
243
</pre>
244
245
h2. Restart Cinnamon from TTY
246
247
# Cinnamon freezes
248
# Switch tty. I usually go to tty6, `Ctrl+Alt+F6`
249
# If you need to login first, do so.
250
# 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).
251
# 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.
252
253
Sauce: https://askubuntu.com/a/198935/392271
254
255
h2. Ubuntu Set Specific Kernel to Boot
256
257
* Use this command to get a list of available options:
258
<pre>
259
$ grep -Ei 'submenu|menuentry ' /boot/grub/grub.cfg | sed -re "s/(.? )'([^']+)'.*/\1 \2/"
260
menuentry  Ubuntu
261
submenu  Advanced options for Ubuntu
262
    menuentry  Ubuntu, with Linux 4.4.0-34-generic
263
    menuentry  Ubuntu, with Linux 4.4.0-34-generic (upstart)
264
    menuentry  Ubuntu, with Linux 4.4.0-34-generic (recovery mode)
265
menuentry  System setup
266
</pre>
267
* Backup grub configuration, just in case:
268
<pre>
269
$ sudo cp /etc/default/grub /etc/default/grub.bak
270
</pre>
271
* Edit grub configuration and change `GRUB_DEFAULT` to something like this:
272
<pre>
273
$ sudo vim /etc/default/grub
274
275
GRUB_DEFAULT="Advanced options for Ubuntu>Ubuntu, with Linux 3.13.0-53-generic"
276
</pre>
277
* Update grub configuration
278
<pre>
279
$ sudo update-grub
280
</pre>
281
* See also: https://askubuntu.com/questions/216398/set-older-kernel-as-default-grub-entry
282
283
h2. Ubuntu Networking Resources
284
285
* https://blog.ubuntu.com/2017/12/01/ubuntu-bionic-netplan
286
* https://help.ubuntu.com/lts/serverguide/network-configuration.html.en
287
* https://netplan.io/
288
289
h2. Win10 Licensing Info
290
291
* https://www.windowscentral.com/how-change-product-key-windows-10
292
* https://www.tenforums.com/tutorials/49586-determine-if-windows-license-type-oem-retail-volume.html
293
* https://www.tenforums.com/windows-updates-activation/104569-win-10-activation-expiring-volume-license.html
294
295
h2. Python GTK Development Resources
296
297
* https://python-gtk-3-tutorial.readthedocs.io/en/latest/layout.html
298
* https://lazka.github.io/pgi-docs/Gtk-3.0/classes/Box.html#Gtk.Box.pack_start
299
* https://lazka.github.io/pgi-docs/Gtk-3.0/mapping.html
300
301
h2. cpufrequtils Governor Configuration
302
303
These instructions are intended for Ubuntu 16.04 and later (using systemd init).
304
305
* Check the available and currently set governors. Ubuntu has an โ€œondemandโ€ service that sets the governor to ondemand after boot.
306
<pre>
307
$ cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_governors
308
conservative ondemand userspace powersave performance schedutil
309
$ cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor 
310
ondemand
311
</pre>
312
313
* Configure cpufrequtils to set the governor to performance at boot
314
<pre>
315
$ echo 'GOVERNOR="performance"' | sudo tee /etc/default/cpufrequtils
316
GOVERNOR="performance"
317
</pre>
318
319
* Disable the automatic ondemand service. 
320
<pre>
321
$ sudo systemctl disable ondemand
322
</pre>
323
324
* Reboot.
325
326
* Now check that the governor is set to performance for every CPU:
327
<pre>
328
$ cat /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor
329
performance
330
performance
331
performance
332
performance
333
โ€ฆ
334
performance
335
performance
336
performance
337
</pre>
338
339
* Check current CPU speeds:
340
<pre>
341
$ watch -n 1 bash -c 'cpufreq-info | grep "current CPU frequency"'
342
</pre>
343
344
h2. rsync via ssh example
345
346
<pre>
347
$ rsync --info=progress2 -ahz --compress-level=9 -e "ssh -i ~/ryft-pat-f1.pem" data/ ryftuser@18.205.65.5:/ryftone/regression/pubmed/data/
348
</pre>
349
350
h2. Read Performance using AIO
351
352
Use this fio command (run from temp directory on disk in question) to measure max disk read performance:
353
354
<pre>
355
$ 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
356
</pre>
357
358
Note that DIRECT_IO is required when using AIO. (see also: https://askubuntu.com/a/991311/392271)
359
360
h2. Remove Source Files While Creating Tarball
361
362
This is handy as it saves on disk space.
363
<pre>
364
$ tar --remove-files -cf pictures.tar Pictures/
365
</pre>
366
367
h2. Linux Find and Remove Files
368
369
Find and remove files (even with spaces in the path) using case insensitive matching for the wildcard:
370
<pre>
371
$ find . -type f -iname "*.jpg" -print0 | xargs -0 rm
372
</pre>
373
374
h2. Convert ASCII hex to binary
375
This problem seems to come up every so often. There is no need for a one-off solution:
376
377
<pre>
378
$ xxd -r -p input.txt output.bin
379
</pre>
380
381
https://stackoverflow.com/questions/7826526/transform-a-hex-info-to-binary-using-linux-command
382
383
h2. Well Said
384
385
https://developers.slashdot.org/comments.pl?sid=12326098&cid=56908942
386
387
h2. Hex Editor
388
389
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.
390
391
Download from here: https://github.com/EUA/wxHexEditor
392
393
You'll need the latest version of libwxgtk<version>-dev package.
394
395
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.
396
397
Finally, to get it installed in the right place:
398
<pre>
399
sudo make install DESTDIR=/opt/local BINDIR=bin DATADIR=share
400
</pre>
401
402
h2. Preprocessor Fun
403
404
To invoke the preprocessor directly:
405
<pre>
406
gcc -E -DSOME_DEFINE=SOME_VALUE somefile.c 
407
</pre>
408
409
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."
410
411
h2. Convert Oversampled .flac to 16 bit 44.1 khz .flac
412
413
<pre>
414
mkdir -p output && find . -type f -name "*.flac" | parallel -j16 "sox {} -b 16 -r 44100 output/{/.}.flac"
415
416
mkdir -p output && find . -type f -name "*.flac" | parallel -j16 "sox -v 0.98 {} -b 16 -r 44100 output/{/.}.flac"
417
</pre>
418
419
h2. Aligned C++ STL Types
420
421
<pre>
422
#include <vector>
423
#include <boost/align/aligned_allocator.hpp>
424
425
template <typename T>
426
using aligned_vector = std::vector<T, boost::alignment::aligned_allocator<T, 4096>>;
427
</pre>
428
429
h2. Command line convert .png to .jpg
430
431
<pre>
432
$ for x in *.png; do convert $x $(basename $x .png).jpg; done
433
</pre>
434
435
You can also add the "`-quality 90`" option if needed.
436
437
h2. Determine CPU Family Name
438
439
<pre>
440
$ gcc -march=native -Q --help=target|grep march
441
</pre>
442
443
h2. Convert .flac to .m4a (AAC)
444
445
Requires `ffmpeg` built with libfdk_aac:
446
447
<pre>
448
$ /opt/bin/ffmpeg -i input.flac -vn -c:a libfdk_aac -vbr 3 output.m4a
449
</pre>
450
451
All together using `find` and `parallel` for magic:
452
<pre>
453
$ find . -type f -name "*.flac" | parallel -j16 "/opt/bin/ffmpeg -i {} -vn -c:a libfdk_aac -vbr 4 {/.}.m4a"
454
</pre>
455
456
h2. PyGObject
457
458
This is the magic needed to have stuff happen quasi asynchronously using PyGObject (GTK+):
459
460
<pre>
461
# Yield to the main loop temporarily
462
while Gtk.events_pending():
463
    Gtk.main_iteration()
464
</pre>
465
466
h2. FUSE Code
467
468
 *https://pastebin.com/wavKntiu
469
470
h2. Use Windoze Schtuffs
471
472
 * 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)
473
 * [[http://landinghub.visualstudio.com/visual-cpp-build-tools|MSVC Tools]] - compiler (seems to be the rough equivalent of `build-essential`)
474
 * [[https://docs.microsoft.com/en-us/sysinternals/downloads/procmon|Process Monitor]] - useful debug tool
475
  * https://www.codeproject.com/Articles/560816/Troubleshooting-dependency-resolution-problems-usi - example for using Process Monitor
476
 * http://download.microsoft.com/download/7/2/E/72E0F986-D247-4289-B9DC-C4FB07374894/wdexpress_full.exe - (required by wingtk below)
477
 
478
* https://github.com/wingtk/gvsbuild - haven't tried this yet but looks amazing... 
479
480
h2. Build Handbrake Git Build
481
482
Steps for building Handbrake using AOCC:
483
484
<pre>
485
$ source /home/dsorber/Downloads/aocc/setenv_AOCC.sh
486
$ export CC=clang
487
$ export CXX=clang++
488
$ export CFLAGS="-g -O3 -mtune=native"
489
$ export CXXFLAGS=$CFLAGS
490
$ cd ~/Downloads/HandBrake/
491
$ rm -rf build/
492
$ ./configure --prefix=/opt --enable-x265 --enable-fdk-aac --gcc=/home/dsorber/Downloads/aocc/AOCC-1.1-Compiler/bin/clang
493
$ cd build
494
$ make -j17
495
$ sudo make install
496
</pre>
497
498
----
499
500
Regular build (18.04 and later):
501
<pre>
502
$ rm -rf build/
503
$ ./configure --prefix=/opt/local --enable-x265 --enable-fdk-aac
504
$ cd build
505
$ make -j17
506
$ sudo make install
507
</pre>
508
509
h2. Politically Correct Linux
510
511
* https://entertainment.slashdot.org/comments.pl?sid=11493671&cid=55759997
512
513
h2. This guy gets it
514
515
Regarding software purist ideology vs pragmatism
516
517
* https://linux.slashdot.org/comments.pl?sid=11156367&cid=55256437
518
519
h2. "Rotate" Video Playback via Metadata
520
521
<pre>
522
$ ffmpeg -i input.mp4 -c copy -metadata:s:v:0 rotate=90 output.mp4
523
</pre>
524
525
526
h2. Ubuntu Remove Old Kernels Oneliner
527
528
<pre>
529
$ 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)
530
</pre>
531
532
* [[https://askubuntu.com/questions/2793/how-do-i-remove-old-kernel-versions-to-clean-up-the-boot-menu/571360#571360|Sauce]]
533
534
h2. Remove New Lines (command line)
535
536
For a file:
537
<pre>
538
$ tr -d '\n' < yourfile.txt
539
</pre>
540
541
Or for output of a command (e.g.):
542
<pre>
543
$ find . -type f -name '*.txt' | tr -d '\n'
544
</pre>
545
546
h2. Convert from .mp4 to .mkv Container
547
548
Use `avconv` to convert container without re-encoding:
549
<pre>
550
$ sudo apt-get install libav-tools
551
552
$ avconv -i filme.mp4 -c copy filme.mkv
553
</pre>
554
555
h2. Remove String From Many File Names
556
557
On Ubuntu use Perl rename utility, e.g.:
558
559
<pre>
560
$ rename 's/ \(1920x1080\) \[WaifuKenny\]//' *.mp4
561
</pre>
562
563
h2. Change Default Text Editor
564
565
I always have to Google this...
566
567
<pre>
568
$ sudo update-alternatives --config editor
569
</pre>
570
571
h2. Linux View System RAM Speed
572
573
View RAM speed (actual) on Debian/Ubuntu/Mint:
574
575
<pre>
576
$ sudo lshw -short -C memory
577
H/W path                      Device      Class          Description
578
====================================================================
579
/0/0                                      memory         64KiB BIOS
580
/0/b                                      memory         32GiB System Memory
581
/0/b/0                                    memory         [empty]
582
/0/b/1                                    memory         16GiB DIMM Synchronous 2134 MHz (0.5 ns)
583
/0/b/2                                    memory         [empty]
584
/0/b/3                                    memory         16GiB DIMM Synchronous 2134 MHz (0.5 ns)
585
/0/d                                      memory         768KiB L1 cache
586
/0/e                                      memory         4MiB L2 cache
587
/0/f                                      memory         16MiB L3 cache
588
</pre>
589
590
h2. Linux Memory Schtuff
591
592
* [[https://github.com/jbert/exmap|exmap]]
593
* https://jameshunt.us/writings/smaps.html
594
* https://techtalk.intersec.com/2013/07/memory-part-2-understanding-process-memory/
595
* http://bmaurer.blogspot.com/2006/03/memory-usage-with-smaps.html
596
597
* https://github.com/torvalds/linux/blob/master/Documentation/filesystems/proc.txt
598
599
* From: http://stackoverflow.com/questions/24484481/entry-in-proc-meminfo
600
<pre>
601
  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.
602
</pre>
603
604
605
* From: http://unix.stackexchange.com/questions/56879/tracking-down-missing-memory-usage-in-linux
606
607
  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).
608
609
  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.
610
611
 * [[http://virtualthreads.blogspot.com/2006/02/understanding-memory-usage-on-linux.html|Understanding memory usage on Linux]]
612
613
 * https://linux-mm.org/LinuxMM
614
615
h2. Reinstall grub on UEFI System
616
617
Reinstalling grub on a UEFI system is slightly different than on a traditional legacy BIOS system:
618
619
<pre>
620
# Mount the primary drive root partition and the boot EFI partition
621
sudo mount /dev/sda# /mnt            # Mount root (/) partition
622
sudo mount /dev/sda# /mnt/boot       # Mount boot (/boot) partition (if separate from root partition; typically not)
623
624
sudo mkdir -p /mnt/boot/efi          # Create EFI partition mount point
625
sudo mount /dev/sda1 /mnt/boot/efi   # Mount EFI partition
626
627
# Mount your virtual filesystems:
628
for i in /dev /dev/pts /proc /sys /run; do sudo mount -B $i /mnt$i; done
629
630
# Chroot
631
sudo chroot /mnt
632
</pre>
633
634
Now, if you have networking you'll need DNS. If using `resolvconf` (for recent versions of Ubuntu):
635
636
# Edit ` /etc/resolvconf/resolv.conf.d/head` and add the following line (OpenDNS server).  Then save and exit:
637
<pre>
638
add nameserver 208.67.222.222
639
</pre>
640
# Next enable updates and update:
641
<pre>
642
sudo resolvconf --enable-updates
643
sudo resolvconf -u
644
</pre>
645
# Now you should have DNS. Test by pinging something.
646
647
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.
648
<pre>
649
apt-get install grub-efi-amd64  # Install grub EFI bootloader (this should be all you need to do)
650
651
652
# manual steps if you need them for some reason
653
grub-install --recheck --no-floppy --force /dev/sda1  # Install grub bootloader in EFI partition
654
655
#####
656
echo "configfile (hd0,gpt#)/boot/grub.cfg" > /boot/efi/ubuntu/grub.cfg # Tell grub to load grub.cfg from /boot
657
658
update-grub                          # Create grub menu list
659
#####
660
661
exit                                 # Exit chroot
662
663
</pre>
664
665
Reboot and you should be back in business.
666
667
h2. Convert flac to VBR mp3 using ffmpeg/lame
668
669
<pre>
670
for file in *.flac; do name=$(echo $file | sed "s/\.flac//g"); ffmpeg -i "$file" -codec:a libmp3lame -qscale:a 0 "$name".mp3; done
671
</pre>
672
673
h2. Create UEFI/legacy BIOS Bootable ISO
674
675
* http://askubuntu.com/questions/625286/how-to-create-uefi-bootable-iso
676
677
h2. Getting rEFInd to work on Mac OS 10.11
678
679
* http://mattjanik.ca/blog/2015/10/01/refind-on-el-capitan/
680
681
h2. Convert DTS 5.1 to FLAC
682
683
<pre>
684
sudo apt-get install libdca-utils ffmpeg sound-juicer gnome-terminal easytag vlc 
685
686
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
687
</pre>
688
689
Source: http://ubuntuforums.org/archive/index.php/t-1849260.html
690
691
h2. Windows Utils
692
693
* http://windirstat.info/download.html
694
* https://www.raymond.cc/blog/safely-delete-unused-msi-and-mst-files-from-windows-installer-folder/
695
696
h2. SSH Security
697
698
https://stribika.github.io/2015/01/04/secure-secure-shell.html
699
700
h2. Windows 10
701
702
* http://ultimateoutsider.com/downloads/ - GWX Control Panel to disable GWX (Windows 10 update nagging)
703
* [[https://www.safer-networking.org/spybot-anti-beacon/|Spybot Anti-Beacon]] - Disable Micro$oft "telemetry" data gathering from Windows 10, 8.x, and 7
704
705
<pre>
706
The newest version of the KB3035583 update includes a background process which scans the 
707
system's Windows Registry twice a day to see if the values for the four aforementioned registry 
708
inputs were manually edited to disable the upgrade prompt. If they were, the process will alter 
709
the values, silently re-download the Windows 10 installation files (about 6 GB in total), and 
710
prompt the user to upgrade.
711
</pre>
712
713
714
h2. gpg-agent
715
716
* http://www.infrastructureanywhere.com/documentation/additional/mirrors.html
717
718
These instructions are geared toward reprepro but should be useful in general for setting up `gpg-agent`.
719
720
721
h2. Resolve DNS While VPN Connected
722
723
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/
724
725
h2. Pretty Print Python Traceback
726
727
<pre>#!python
728
import traceback
729
730
 ...
731
732
try: 
733
    with open('/dev/null', 'w') as void:
734
        rc = not bool(subprocess.call('modprobe -r {:s}'.format(mod_name), 
735
                                      shell=True, stdout=void, stderr=void))
736
except Exception as e:
737
    print_failure_status()
738
    exc_type, exc_value, exc_traceback = sys.exc_info()
739
    print('\n')
740
    traceback.print_exception(exc_type, exc_value, exc_traceback)
741
    print('\n')
742
</pre>
743
744
h2. Generating Random Data Files for Testing
745
746
One approach is to use /dev/urandom (non-blocking pseudorandom device):
747
<pre>
748
$ dd if=/dev/urandom bs=32M count=32 of=data_1GB.bin
749
</pre>
750
Unfortunately /dev/urandom is a bit slow. However, you can alternatively use openssl to generate pseudorandom numbers a bit faster:
751
<pre>
752
 $ openssl rand 1073741824 > data_1GB.bin
753
 $ for run in {1..30}; do echo $run; openssl rand 1073741824 >> data_30GB.bin; done
754
</pre>
755
756 2
h2. Cloning HDDs
757 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).
758
759
To clone a single drive to another identical drive (assuming sda is the source and sdb is the destination):
760
<pre>
761
 $ sudo dd if=/dev/sda bs=32M | pv -s `sudo blockdev --getsize64 /dev/sda` | sudo dd of=/dev/sdb bs=32M
762
</pre>
763
To clone to multiple drives all at once (assuming sda is the source and sdb, sdc are destinations):
764
<pre>
765
 $ 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
766
</pre>
767
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!
768
769
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.
770
771
h2. Generating ISOs
772
773
<pre>
774
 $ genisoimage -R -J -o <output.iso> <some directory>
775
</pre>
776
To deal with long file names:
777
<pre>
778
 $ genisoimage -R -J -l -D -joliet-long -o <output.iso> <some directory>
779
</pre>
780
781 2
h2. BIOS/grub
782 1
783 2
* http://forums.linuxmint.com/viewtopic.php?f=46&t=119832
784
* http://www.gnu.org/software/grub/manual/html_node/BIOS-installation.html
785
* https://wiki.archlinux.org/index.php/GRUB2
786
* http://unix.stackexchange.com/questions/28443/does-grub2-support-putting-boot-on-a-raid5-partition
787 1
788
h3. Creating a BIOS Boot Partition on a GPT system
789
790
<pre>
791
$ sudo parted /dev/sda
792
(parted) mkpart primary 0 1024k
793
(parted) set 2 bios_grub on
794
</pre>
795
796 2
h2. Actiontec Router
797
798
* http://transition.fcc.gov/oet/ea/fccid/
799
* http://opensource.actiontec.com/mi424wref.html
800 1
801
h2. Temp
802
803
https://www.grumpyland.com/blog/183/installing-software-raid-on-centos-567-via-ssh/
804
<pre>
805
# swap is on /dev/md1
806
/dev/md1 none            swap    sw              0       0
807
808
# storage is on /dev/md0
809
/dev/md0        /storage        xfs     noatime,barrier=0 0 0
810
//faramir/production/sw /sw     cifs    username=samba,password=w00tw00t!,file_mode=0666,dir_mode=0777  0       0
811
</pre>
812
813
----
814
[[../|Back home]]