-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathkmptrnote
939 lines (745 loc) · 36.3 KB
/
kmptrnote
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
#zsh
declare -f FuncName
#How to show zsh function definition (like bash “type myfunc”)?
The zsh idiom is whence, the -f flag prints function definitions:
zsh$ whence -f foo
foo () {
echo hello
}
zsh$
In zsh, type is defined as equivalent to whence -v, so you can continue to use type, but you'll need to use the -f argument:
zsh$ type -f foo
foo () {
echo hello
}
zsh$
And, finally, in zsh which is defined as equivalent to whence -c - print results in csh-like format, so which foo will yield the same results.
man zshbuiltins for all of this.
Works, but only if no alias of the same name happens to be defined, in which case that is reported (whence -f, type -f, which report the highest-precedence form of the command).
declare -f foo is better because even if the function is hidden by an alias, it will still be shown, whereas 'whence' is liable to show just the alias, OR both the alias and the function.
setopt nocasematch
unsetopt nocasematch
setopt #list set options
#tar -C /opt -xzvf node-v4.2.0-linux-x64.tar.gz
#apache
httpd -V
Server version: Apache/2.4.17 (Fedora)
...
Server MPM: prefork
#how to check if port is open and unused
netstat -tln | tail -n +3 | awk '{ print $4 }'
#&&
03f && ? ".f1*." ".f2*." ".f3*." ".f4*." ".f5*."
#get video dimension from ffmpeg -i
ffprobe -v error -show_entries stream=width,height -of default=noprint_wrappers=1 headscarf\ old\ women.jpg
width=960
height=640
#trim/clip, strip off audio/video
https://gist.github.com/protrolium/e0dbd4bb0f1a396fcb55
ffmpeg -codecs
ffmpeg -formats
https://trac.ffmpeg.org/wiki/Encode/HighQualityAudio
ffmpeg -i InputFile -c copy -ss 00:00:00 -t <duration> OutPutFile
ffmpeg -i InputFile -vn -acodec copy -ss 00:00:00 -t <duration> OutPutFile
ffmpeg -i MGTOW\ Reason\ \#13\ -\ Aftershock\ From\ The\ Wedding-A17CBtwEmcE.webm -an -vcodec copy aftershock\ marriage-A17CBtwEmcE.webm
ffmpeg -i How\ to\ lace\ dress\ shoes\ ·\ Carmina\ shoemaker-L3p_jjYKImc.mkv -an -vcodec copy -ss 0:0:7 -t 0:0:39 lace_dress_shoe-L3p_jjYKImc.mkv
ffmpeg -i Building\ a\ yurt\ in\ 1.5\ hours\ \(the\ ultimate\ pop\ up\ tiny\ house\!\)-rMKt6xDn19c.mkv -ss 0:0:0 -an -c:v copy -t 0:4:0 build_yurt_popup_tiny_house.mkv;echo $?; ll build*
ffmpeg -i 21\ дарь\ эхийн\ ачлал.mkv -vn -c:a libmp3lame -aq 0 21\ дарь\ эхийн\ ачлал_aq_0.mp3
ffmpeg -i \'In\ Out\'\ Нэвтрүүлэг\ -\ Эдийн\ засгийн\ ухааны\ доктор\ Холбоос\ овогт\ Т.Баярхүү-xfJYJlSfRWM.webm -ss 0:0:15 -vn -c:a libopus -aq 0 -t 0:46:33 Т.Баярхүү2-xfJYJlSfRWM.opus;echo $?
#speed up av
ffmpeg -i Russian\ numbers\ 2\ 10\ 20\ 30,\ 100,\ 1000-vFlzWw62XQo.mp4 -filter:v "setpts=PTS/1.5" -filter:a "atempo=1.5" rus_num_1000-vFlzWw62XQo_1.5spd.mp4
#clip+speed
ffmpeg -i Russian\ Cursive\ Writing\(connecting\ letters\)-ZP8SDSHIk9g.mp4 -c copy -ss 0:0:40 -t 0:5:0 rus_cursive_connected-ZP8SDSHIk9g.mp4 && avspd rus_cursive_connected-ZP8SDSHIk9g.mp4 && echo '$?':$?
#concatenate
FFMeg Concat: "unsafe file name" error
The demuxer accepts the "-safe" option (obviously an input option, to
be placed before the corresponding input file):
safe
If set to 1, reject unsafe file paths.
[...]
If set to 0, any file name is accepted.
ffmpeg -f concat -safe 0 -i filelist -c copy "swanlake-part1__No.4_Gmajor_K41_II.Andante.mp3"
https://trac.ffmpeg.org/wiki/Concatenate
ffmpeg -f concat -i filelist -c copy "Подмосковные Вечера(en+rss).mp3"
#content of filelist
file '/tmp/Moscow Night Helmut Lotti-VbZHzF-Av1I.mp3'
file '/tmp/Russian Red Army Choir - Moscow Nights-aw5L0IdKjps.mp3'
#crop, scale
ffmpeg -i crop_1.jpg -vf crop="250:ih-15:0:15" crop_2.jpg
ffmpeg -i pktr/me_kamer_metrik.jpg -vf scale=800:-1 me2015.jpg
#List Cron Jobs
crontab –l –u username
#Edit Cron Jobs
To use cron for tasks meant to run only for your user profile, add entries to your own user's crontab file. Start the crontab editor from a terminal window:
crontab -e
add line:
07,37 * * * * /usr/bin/tunlrupdate.sh
Commands that normally run with administrative privileges (i.e. they are generally run using sudo) should be added to the root user's crontab (instead of the user's crontab):
sudo crontab -e
add same line:
07,37 * * * * /usr/bin/tunlrupdate.sh
Depending on the commands being run, you may need to expand the root users PATH variable by putting the following line at the top of their crontab file:
PATH=/usr/sbin:/usr/bin:/sbin:/bin
#Remove Cron Jobs
crontab -ir
#rename files in respective directories
#find /mnt/0 -type f -iname 'dwn.wait' -execdir mv {} dwn.todo +
#Perl rename
find /mnt/0 -type f -iname 'dwn.wait' -execdir rename -v 's/\.wait/\.todo/' {} \;
#shell built-in rename
find /mnt/0 ~ -xdev -type f -iname 'dwn*' -execdir rename -v dwn dl '{}' \;
find /mnt/0 ~ -xdev -type f \( -iname 'dl' -o -iname 'dl.todo' \) -execdir rename -v dl dllst '{}' \;
find . -type f -exec chmod 644 {} +
find -type f \( -name '*' -or -name '.*' \) -execdir wc -l {} ';'
find -type f \( -name '*' -or -name '.*' \) -execdir wc -l {} \;
find /mnt/0 ~ -type f \( -iname '*07n*' -o -iname '*0n7*' -o -iname '*0o7*' -o -iname '*07o*' \) -exec ls -alF {} +
find /mnt/0 ~ -xdev -type f -iname 'dwn' -execdir rm {} + && echo '$?':$?
#find output redirection works
find /mnt/0 ~ -xdev -type f -iname '*.py' -exec ls -alF {} + > outfile
http://stackoverflow.com/questions/6844785/how-to-use-regex-with-find-command
find /mnt/0 ~ -xdev -type f -regextype posix-extended -regex '.*node.*(\.(pdf|epub|(ppt|doc|xls)x?)?)?' -print
find /mnt/0 ~ -xdev -type f -regextype posix-egrep -regex '.*node.*(\.(pdf|epub|(ppt|doc|xls)x?)?)?' -print
sudo find /mnt/0 ~ -xdev -regextype posix-extended -iregex '.+\.(opus|aac|m4a|flac|mp3|wav)$'
http://askubuntu.com/questions/419115/make-bluetooth-disabled-by-default
rfkill unblock bluetooth
sudo systemctl disable bluetooth.service
DEVICES_TO_DISABLE_ON_STARTUP="bluetooth"
/etc/default/tlp
#Create Symbolic Links in Linux
sudo ln -s /mnt/0/gthb/xrcs/utv.sh /usr/local/bin/utv
grep -Ril "2>&1" .
grep -HinR "usermod -aG" /mnt/0/gthb/xrcs/
alias grep='grep --color=auto -R -n -H -C 5 -i --exclude-dir={.git,.svn,.hg,.bzr,CVS}'
#sed, vim
sed 's/\x22\|\x27//g' #' "
sed -i.bak "s/\"\\\\n\"/'\\\\n'/g" *.cpp /* cout << "\n" --> cout << '\n' (see Effective Modern C++ by Scott Meyer) */
%s/\(>\s*[/\w.+~-]\+\)\s\+2>&1/\&\1/gc #pattern not found
g/\(>\s*[/\w.-]\+\)\s\+2>&1/s//\&\1/gc #pattern not found
g/\(>.\+\)\s\+2>&1/s//\&\1/gc #work
7z x -o/mnt/0/vrk -p".*\!#" vrk.7z #-o{OutputDirectory} x:eXtract with full paths
7z a -p".*\!#" curr.7z curr
less /proc/sys/dev/cdrom/info
cdrecord -minfo -v
grub2-mkconfig -o /boot/grub2/grub.cfg
utl $(cat list)
➜ DEBS sudo dpkg -R -i .
How to modify invalid /etc/sudoers file?
pkexec visudo
Better create custom sudoers in /etc/sudoers.d instead of modifying /etc/sudoers
pkexec visudo -f /etc/sudoers.d/myOverrides
dd if=kali-linux-2017.1-amd64.iso of=/dev/sdb bs=512k
#Stapler is a pure Python alternative to PDFtk, a tool for manipulating PDF documents from the command line
pdf-stapler del photography_BasicPrinciples.pdf 2-8 photography_BasicPrinciples_DavidCapel_346B_IST.pdf
https://github.com/hellerbarde/stapler
sudo dnf install pdf-stapler
#pdftk polymersummit-es6.pdf cat 15-69 72-end output use-es6-with-polymer,2015.pdf
#pdftk Eloquent\ JavaScript,\ 2nd\ Edition.pdf cat 1 8 13-end output eloquent_JavaScript_2nd_ed.NoStarchPress.pdf
cd /mnt/0
fdupes -Sr js nodejs_screencast java cpp aws c c++graphic eecs-ict php embnix nixcpp nixc3d nixpythn socket 01 fpga wbst swift ms tekvid android game hak how pentst
#access and mount iPhone 6 in Linux
sudo apt install ideviceinstaller python-imobiledevice libimobiledevice-utils libimobiledevice4 libplist2 python-plist ifuse
sudo vim /etc/fuse.conf
idevicepair pair
ifuse /opt/iPhone/
fusermount -u /opt/iPhone
eog - GNOME image viewer
#turn off globbing(wildcard expansion) temporaly/for current session
➜ 0 ? https://www.youtube.com/watch?v=kGosatWQ5ag
zsh: no matches found: https://www.youtube.com/watch?v=kGosatWQ5ag
➜ 0 disable -p ?
disable: invalid pattern: c
➜ 0 disable -p '?'
➜ 0 ? https://www.youtube.com/watch?v=kGosatWQ5ag
Search for ID [kGosatWQ5ag] now...
find: ‘/home/r/.dbus’: Permission denied
-rw-rw-r-- 1 r r 43429548 сен 25 2014 /mnt/0/oros(Русский)/Weekly Russian Words with Katya - Computer Words-kGosatWQ5ag.mkv
➜ 0 enable ?
enable: no such hash table element: ?
➜ 0 enable -p ?
➜ 0 ? https://www.youtube.com/watch?v=kGosatWQ5ag
zsh: no matches found: https://www.youtube.com/watch?v=kGosatWQ5ag
➜ 0 disable -p "?"
➜ 0 ? https://www.youtube.com/watch?v=kGosatWQ5ag
Search for ID [kGosatWQ5ag] now...
find: ‘/home/r/.dbus’: Permission denied
-rw-rw-r-- 1 r r 43429548 сен 25 2014 /mnt/0/oros(Русский)/Weekly Russian Words with Katya - Computer Words-kGosatWQ5ag.mkv
#persistent effect
setopt noglob
#bash
set -o noglob
diff ~/.zshrc /mnt/0/gthb/xrcs/.zshrc
diff ~/.zsh-func /mnt/0/gthb/xrcs/.zsh-func
diff /mnt/0/gthb/xrcs/Makefile /mnt/0/xrc/Makefile
#Delete lines in text file that containing specific string
ex +g/match/d -cwq file
top -b -o +%MEM | head
ps -eo %mem,%cpu,pid,ppid,cmd --sort=-%mem | head
#chntpw
cd %systemroot%/System32/config
sudo chntpw [-u <username>] SAM
#ftp
lcd(local cd) get put del/rm?
#date
\date +"now is week: %V of %Y"
\date +"now is week: %U of %Y"
gsettings set com.canonical.indicator.datetime time-format 'custom'
gsettings set com.canonical.indicator.datetime custom-time-format '%A %B %d %Y %H:%M:%S %:::z'
#linux commnad line weather
curl wttr.in/hailar
curl wttr.in/st.petersburg
https://fedoraproject.org/wiki/How_to_create_and_use_Live_USB#quickstarts
sudo dd if=/path/to/image.iso of=/dev/sdX bs=8M status=progress oflag=direct
#ACL
drwxr-x---+ 3 root root 4096 сен 24 17:56 r/
➜ getfacl r
# file: r
# owner: root
# group: root
user::rwx
user:r:r-x
group::---
mask::r-x
other::---
#set ACL
chown -R root:root /mnt/0/*
chown -R root:root /mnt/0/.*
#find /mnt/0 -type f -execdir chmod 640 {} \;
#find /mnt/0 -type d -execdir chmod 750 {} \;
find /mnt/0 -type d -execdir chmod 750 {} \; -execdir setfacl -m u:r:rwx {} \;
find /mnt/0 -type d -name '.*' -execdir chmod 750 {} \; -execdir setfacl -m u:r:rwx {} \;
find /mnt/0 -type f -name '.*' -execdir chmod 640 {} \; -execdir setfacl -m u:r:rw {} \;
find /mnt/0 -type f -execdir chmod 640 {} \; -execdir setfacl -m u:r:rw {} \;
#effective permissions are formed by ANDing permissions with umask.
➜ xrcs git:(master) ✗ getfacl .
# file: .
# # owner: root
# # group: root
# user::rwx
# user:r:rwx #effective:r-x
# group::r-x
# mask::r-x
# other::---
#
# ➜ xrcs git:(master) ✗ umask
# 022
#linux recursive search and replace string in directory
find . -type f -execdir sed -i 's/\/media\/r\/0/\/mnt\/0/g' {} \;
#UNIX / Linux Command To Check Existing Groups and Users
➜ xrcs git:(master) ✗ groups r
r : r
➜ xrcs git:(master) ✗ id r
uid=1000(r) gid=1000(r) groups=1000(r)
➜ xrcs git:(master) ✗ id adm
uid=3(adm) gid=4(adm) groups=4(adm)
➜ xrcs git:(master) ✗ id admin
id: ‘admin’: no such user
➜ xrcs git:(master) ✗ getent group r
r:x:1000:
➜ xrcs git:(master) ✗ getent group adm
adm:x:4:
➜ xrcs git:(master) ✗ getent group admin
#Change the Primary Group of a User: usermod -g
usermod -g adm r
#shell cmd
print - $((524288000/1024/1024))
find /mnt/0 ~ ! -path '/mnt/0/linux/*' ! -path '/mnt/0/linux-insides/*' -type f -iname '*debug*' -exec ls -alF {} +
sudo find / -xdev -path /mnt -prune -o -iname 'algorithm' -exec ls -alF {} + ;echo '$?':$?
sudo find / -xdev -path /mnt -prune -o -iname 'algorithm' -printf '%y %p\n';echo '$?':$?
f /usr/include/c++/7/algorithm
f /usr/include/c++/7/ext/algorithm
f /usr/include/c++/7/experimental/algorithm
f /usr/include/c++/7/parallel/algorithm
d /usr/share/perl5/vendor_perl/Algorithm
f /usr/lib64/clang/4.0.1/include/cuda_wrappers/algorithm
$?:0
sudo find / -xdev -path /mnt -prune -o -iname 'algorithm' -exec grep -HiRn 'stl_algo' {} + ;echo '$?':$?
/usr/include/c++/7/algorithm:61:#include <bits/stl_algobase.h>
/usr/include/c++/7/algorithm:62:#include <bits/stl_algo.h>
$?:0
/usr/include/c++/7/parallel/algorithm:35:#include <parallel/algorithmfwd.h>
/usr/include/c++/7/parallel/algorithm:36:#include <parallel/algobase.h>
/usr/include/c++/7/parallel/algorithm:37:#include <parallel/algo.h>
#shell single quote file name with single quote and space
infile_quoted=$(printf \'%s\' "$(printf %s "$infile" | sed "s/'/'\\\\''/g")")
outfile_quoted=$(printf \'%s\' "$(printf %s "$outfile" | sed "s/'/'\\\\''/g")")
echo '"${infile_quoted}"':"${infile_quoted}"
echo '"${outfile_quoted}"':"${outfile_quoted}"
echo '"$infile_quoted"':"$infile_quoted"
echo '"$outfile_quoted"':"$outfile_quoted"
echo '$infile_quoted':$infile_quoted
echo '$outfile_quoted':$outfile_quoted
#read into var
read start _ < <(du -bcm kali-linux-2016-W41-amd64.iso| tail -1); echo $start
scrub -p dod /dev/sdb
echo '$?':$?
$?:0
#or
scrub -p dod /dev/sdb1...
#Find Out What Version of Linux You Are Running
http://www.tecmint.com/find-linux-kernel-version-distribution-name-version-number/
cat /proc/version
cat /etc/os-release
lsb_release -a
lscpu
#disown, nohup
#Detach a Linux Processes From Controlling Terminal
#to completely detach a process from a controlling terminal, use the command format below, this is more effective for graphical user interface (GUI) applications such as firefox:
firefox </dev/null &>/dev/null &
http://www.tecmint.com/run-linux-command-process-in-background-detach-process/
#list all open ports or currently running ports including TCP and UDP
cat /etc/services | less
netstat -lntu
#youtube
framestep through a paused video using , (comma) and . (dot) to go backwards and forwards 1 frame.
#shell debug
1. #!/bin/bash -xv
2. bash/zsh/ksh -xv shellscript
#tee
pstree | tee -a pstree_tee.out
http://docstore.mik.ua/orelly/unix3/upt/ch37_01.htm
#save the debugging output in file and see it on screen? Use tee to copy the scrfile stdout and stderr; add tee to the pipeline before the pager.
# $ scrfile | tee outfile 2>&1 | less
shellscript | tee output 2>&1 | less
tail -f shellscript.log
#linux lock screen and power off display from command line
https://geek1011.github.io/linux-tip-lock-screen-from-command-line/
https://github.com/geek1011/Scripts.sh/blob/master/LockScreen/LockScreen.sh
xset dpms force off
dbus-send --type=method_call --dest=org.gnome.ScreenSaver /org/gnome/ScreenSaver org.gnome.ScreenSaver.Lock
dbus-send --type=method_call --dest=org.gnome.ScreenSaver /org/gnome/ScreenSaver org.gnome.ScreenSaver.Lock;xset dpms force off;utv0
#Linux Unified Key Setup (LUKS)
#The security issue relies due to a vulnerability (CVE-2016-4484) in the implementation of the Cryptsetup utility used for encrypting hard drives via Linux Unified Key Setup (LUKS), which is the standard implementation of disk encryption on a Linux-based operating system.
#modify the cryptroot file to stop the boot sequence when the number of password attempts has been exhausted.
http://thehackernews.com/2016/11/hacking-linux-system.html
sed -i 's/GRUB_CMDLINE_LINUX_DEFAULT="/GRUB_CMDLINE_LINUX_DEFAULT="panic=5 /' /etc/default/grub grub-install
#UEFI
dd;BIOS UEFI mode;secure boot OFF #Kali 2016.2+
dd;BIOS UEFI mode #Fedora
#change case of entire file
dd if=tst.tst of=tst.ucase conv=ucase
diff tst.tst tst.ucase
dd if=tst.tst of=tst.lcase conv=lcase
diff tst.tst tst.lcase
#rpm
rpm -qa | grep rpmfusion
rpmfusion-free-appstream-data-25-3.fc25.noarch
rpmfusion-free-release-25-2.noarch
rpm -qa | grep vlc
rpm -qa | egrep '(uname)|(vim)|(gdb)|(gcc)|(g++)|(git)|(openssl)|(ssh)|(libreoffice)|(ffmpeg)|(gimp)|(vlc)|(firefox)|(xmllint)|(node)|(youtube-dl)' #grep lot more other app
#?
tar -xvzf wkhtmltopdf-0.10.0_rc2-static-amd64.tar.bz2 -C /opt
tar --bzip2 -xf /path/to/boost_1_63_0.tar.bz2
#.tar.lz
tar --lzip -xvf gmp-6.1.2.tar.lz
#clang
clang++ -std=c++14 your_source.cpp -o your_binary
#sort & uniq
#After running sort on an input stream, you can remove repeated lines with uniq as in the example below.
#To indicate the number of occurrences of a line, use the -c option and ignore differences in case while comparing by including the -i option:
sort txt_file | uniq -i -c
#sjis -> utf8
for i in $(find . -xdev -type f -iname '*.*sh' -o -iname '*.sql' -o -iname '*.csv');do
#iconv -f shift-JIS -t utf-8 < ${i} > ${i%.*}_utf-8.${i##*.} #${var}? vs "$var"
iconv -f shift-JIS -t utf8 ${i} > ${i%.*}_utf8.${i##*.} #${var}? vs "$var" #man iconv: utf8,utf-8
echo '$?':$?
done
#useradd
useradd amlkcfr && usermod -aG appGrp amlkcfr
#Find Number of Files in a Directory and Subdirectories
FILES=$(sudo find . -type f -print | wc -l)
echo "There are $FILES in the current working directory."
#firefox simplified/text-only print preview
about:config >> print.use_simplify_page
Alt-f-v
#g++
g++ -std=c++11 -Wall -Wextra -O0 -ggdb3 -S numberpermute.cpp /*output: numberpermute.s*/
#make
linux makefile put rules for different programming languages in one makefile (possible with java and c++ on RHEL7.1, tested on Mar.17,2017)
#systemctl
udisks2.service changed on disk. Run 'systemctl daemon-reload' to reload units.
#seq
seq -s, 2 7 100
seq -s, 100
#df
df -aTh
$alias which
which='(alias; declare -f) | /usr/bin/which --tty-only --read-alias --read-functions --show-tilde --show-dot'
#one-liner(env check): utilize ';' , query multiple aliases at once!
echo $CLASSPATH ; echo $JAVA_HOME
java -version ; javac -version
alias jv8c="$JAVA_HOME/bin/javac -g -Xdiags:verbose -d . -classpath ."
alias jv8="$JAVA_HOME/bin/java -classpath ."
alias g++ gcc gxx jv8c jv8
java -Xmx64m -jar c:\workspace\BPO\FileDivision.jar c:\workspace\BPO\conf.properties c:\workspace\BPO\sl4j.properties
#shutdown after wget exit
wgetf url && s0
wgetf url ; s0
scrblk;wgetf url --limit-rate=100k;s0
ps -eo %mem,%cpu,pid,ppid,cmd --sort=-%mem | head
/*
If a script expects a command-line parameter but is invoked without one, this may cause a null variable assignment, generally an undesirable result. One way to prevent this is to append an extra character to both sides of the assignment statement using the expected positional parameter.
variable1_=$1_ # Rather than variable1=$1
# This will prevent an error, even if positional parameter is absent.
critical_argument01=$variable1_
# The extra character can be stripped off later, like so.
variable1=${variable1_/_/}
# Side effects only if $variable1_ begins with an underscore.
# This uses one of the parameter substitution templates discussed later.
# (Leaving out the replacement pattern results in a deletion.)
# A more straightforward way of dealing with this is
#+ to simply test whether expected positional parameters have been passed.
if [ -z $1 ]
then
exit $E_MISSING_POS_PARAM
fi
# However, as Fabian Kreutz points out,
#+ the above method may have unexpected side-effects.
# A better method is parameter substitution:
# ${1:-$DefaultVal}
# See the "Parameter Substition" section
#+ in the "Variables Revisited" chapter.
*/
c/c++ make generate object file in separate directory
#wildcard autocomplete
#/etc/profile
set -o GLOB_COMPLETE #err!
set completion-ignore-case on
~/.inputrc:
set show-all-if-ambiguous on
#!/usr/bin/env bash
shopt -s extglob # and others, such as nullglob dotglob
shopt -s dotglob nullglob
shopt -s failglob
shopt -s globstar
sudo ufw allow 139/tcp
sudo ufw allow 445/tcp
sudo ufw allow 137/udp
sudo ufw allow 138/udp
sudo ufw reject 139/tcp
sudo ufw reject 445/tcp
sudo ufw reject 137/udp
sudo ufw reject 138/udp
ipp://192.168.1.140:631/ipp
#MAC -> IP
nmap -sP 192.168.1.0/24 >/dev/null && arp -an | grep 1b:a9:f1:b4:8f | awk '{print $2}' | sed 's/[()]//g'
nmap -sP 192.168.1.0/24 >/dev/null && arp -an | grep 1b-a9-f1-b4-8f | awk '{print $2}' | sed 's/[()]//g'
shopt extglob
~/.inputrc
chsh -s /bin/zsh
chsh -s /bin/zsh <usr>
firefox-esr -private
http://c.learncodethehardway.org/book/ex20.html
#Systemd
http://www.howtogeek.com/216454/how-to-manage-systemd-services-on-a-linux-system/
systemd --version
systemctl status cups.service
systemctl start cups.service
gnome-terminal --tab-with-profile=Unnamed --working-directory=/home/x --tab-with-profile=Unnamed --working-directory=/home/x/work
#$/etc/init.d/postgresql start
#[ ok ] Starting postgresql (via systemctl): postgresql.service.
systemctl start postgresql.service
#book
Get a Job, Build a Real Career, and Defy a Bewildering Economy
➜ xrc whereis sqlite
sqlite: /usr/bin/sqlite /usr/share/man/man1/sqlite.1.gz
➜ xrc file /usr/bin/sqlite
/usr/bin/sqlite: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 3.2.0, BuildID[sha1]=2a525971bb453b5055027afe95874abf3b94f530, stripped
➜ xrc whereis sqlite3
sqlite3: /usr/bin/sqlite3 /usr/share/man/man1/sqlite3.1.gz
➜ xrc file /usr/bin/sqlite3
/usr/bin/sqlite3: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 2.6.32, BuildID[sha1]=27fb684767059284231748075dd874bed1837485, stripped
FUD (fully undetecable) #backdoor with msfvenom ( part of metasploit framework )
Fear, uncertainty and doubt (often shortened to FUD) is a disinformation strategy used in sales, marketing, public relations, politics and propaganda. FUD is generally a strategy to influence perception by disseminating negative and dubious or false information and a manifestation of the appeal to fear.
#windows
winkey+r: mspaint, calc, excel, msword, snippingtool
GodMode.{ED7BA470-8E54-465E-825C-99712043E01C}
echo %windir%
echo %SystemRoot%/SysWOW64
echo %USERPROFILE%Envs
#excel formula
#always use & instead of concatenate()!
=$A$1&" = "&""""&$A$2&""""&";"
#list all group in linux
cut -d: -f1 /etc/group | sort
#Google Chrome Bookmarks Location
~/.config/google-chrome/Default/Bookmarks
#batch convert .png images to .jpg
bash -c 'for image in *.png; do convert "$image" "${image%.png}.jpg"; echo -n “$image:$?,”; done' #-n: do not output the trailing newline
#vlc
$HOME/.config/vlc/vlcrc
#Save snapshots in the same folder as the video;Save snapshots with timestamp(where is the snapshot in the video): filename+current_playback_time.jpg
Video snapshot directory: /$N_$T
Video snapshot file prefix: EMPTY
#youtube-dl
#download range: download byte ranges;determine which bytes correspond to (slice)begin/start and (slice)end times, most likely by peeking into the first or last bytes of the file;reassemble that sequence to play
https://github.com/rg3/youtube-dl/issues/622
<?xml version="1.0" encoding="UTF-8"?>
#clamav
awk -F: '/^[^#]/ { print $1 }' /etc/freshclam.conf | uniq
--exclude-dir=^/sys --exclude-dir=^/dev --exclude-dir=^/proc
sudo freshclam;sudo clamscan --exclude-dir="^/sys" -i --bell -r /;echo '$?':$?
{ echo "braced logging start."; sudo freshclam; sudo clamscan --exclude-dir='^/sys' -i --bell -r / ; echo "braced logging end."; } &> ~/.cache/clam.log
#braced group logging
#shell group output redirection
{echo $(date) ; /mnt/0/gthb/xrcs/py/sendmail.py /mnt/0/workspace/mail.txt ; echo $(date)} &>> /mnt/0/workspace/test.log && s0
(echo $(date) ; /mnt/0/gthb/xrcs/py/sendmail.py /mnt/0/workspace/mail.txt ; echo $(date)) &>> /mnt/0/workspace/test.log && s0 #execute in subshell
{echo $(date) ; /mnt/0/gthb/xrcs/py/sendmail.py /mnt/0/workspace/mail.txt ; echo $(date)} &>> /mnt/0/workspace/test.log ; s0
(echo $(date) ; /mnt/0/gthb/xrcs/py/sendmail.py /mnt/0/workspace/mail.txt ; echo $(date)) &>> /mnt/0/workspace/test.log ; s0 #execute in subshell
&>> |
# '&>' litter log files with tons of progress string(CTRL-M (^M))! Log only errors instead!
# keep track of wget's input file dir and CD to there if execute other commands and scripts first!
(echo $(date);wget -i dllst;utv;echo $(date);s0) 2>> ~/dl.log & # shutdown didn't perform successfully when put in background!
(echo $(date);wget -i dllst;utv;echo $(date)) 2>> ~/dl.log ; s0 &
#docker
Hello from Docker!
This message shows that your installation appears to be working correctly.
To generate this message, Docker took the following steps:
1. The Docker client contacted the Docker daemon.
2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
3. The Docker daemon created a new container from that image which runs the
executable that produces the output you are currently reading.
4. The Docker daemon streamed that output to the Docker client, which sent it
to your terminal.
To try something more ambitious, you can run an Ubuntu container with:
$ docker run -it ubuntu bash
Share images, automate workflows, and more with a free Docker ID:
https://cloud.docker.com/
For more examples and ideas, visit:
https://docs.docker.com/engine/userguide/
groupadd docker
systemctl restart docker
ll /var/run/docker.sock
srw-rw----. 1 root docker 0 Jun 25 21:21 /var/run/docker.sock
usermod -aG docker (user)
su - (user) #or log out and log back in again
#record voice from builtin Mic or speaker
pacmd list-sources|awk '/index:/ {print $0}; /name:/ {print $0}; /device\.description/ {print $0}'
ffmpeg -f pulse -i alsa_input.pci-0000_00_1b.0.analog-stereo -c:a libmp3lame Native-Mandarin-Voice-Sample.mp3
#python
#ll ~/.local/lib/
#ll ~/.local/bin/
#set one virtualenv per user:group and give proper system permissions to the folder containing python package? installed with pip install --user <EOL>
https://stackoverflow.com/questions/33412974/how-to-uninstall-a-package-installed-with-pip-install-user
pip install --user -U pip setuptools
https://docs.python.org/3/howto/pyporting.html
http://python-future.org/automatic_conversion.html
#futurize
pip install coverage future pylint caniusepython3 tox six configparser --user
futurize --stage1 -f idioms -w *.py
futurize --stage2 -w *.py
#Note that with recursive globbing in bash or zsh, you can apply stage 1 to all Python source files recursively with:
futurize --stage1 -f idioms -w **/*.py
futurize --stage2 -w **/*.py
###
RefactoringTool: There were 4 errors:
RefactoringTool: Can't parse download/tor-browser_en-US/Browser/TorBrowser/Tor/PluggableTransports/twisted/web/test/test_newclient.py: ParseError: bad input: type=22, value=u'=', context=(u' ', (1641, 17))
RefactoringTool: Can't parse pro-python-best-practices/maze_run-master/part1_debugging/event_loop.py: ParseError: bad input: type=1, value=u'print', context=('', (23, 15))
RefactoringTool: Can't parse pro-python-best-practices/maze_run-master/part1_debugging/to_debug/chapter02_load_tiles.py: ParseError: bad input: type=1, value=u'pygame', context=(u' ', (8, 6))
RefactoringTool: Can't parse pro-python-best-practices/maze_run-master/part1_debugging/to_debug/chapter04_event_loop.py: ParseError: bad input: type=1, value=u'print', context=('', (26, 15))
###
#pasteurize
pasteurize -w **/*.py
pip install --user beautifulsoup selenium chromedriver
##python excel
pip install --user openpyxl pillow
pip install --user kitchen
##html xml
pip install --user lxml requests
python -m site
#python interpreter
http://docs.python-guide.org/en/latest/dev/virtualenvs/#lower-level-virtualenv
export VIRTUALENVWRAPPER_PYTHON=/usr/bin/python3
1. pip install --user pipenv
cd myproject
pipenv install requests
pipenv run python main.py
2. Lower level: virtualenv
virtualenv -p /usr/bin/python3 py-prj_vrtenv
http://docs.python-guide.org/en/latest/writing/style/#general-concepts
pip install --user pycodestyle autopep8
pycodestyle optparse.py
autopep8 --in-place optparse.py
autopep8 --in-place --aggressive --aggressive <filename>
#fedora Reinstalling packages with missing/corrupt files
https://unix.stackexchange.com/questions/216697/reinstalling-packages-with-missing-corrupt-files?rq=1
rpm -qf $(rpm -Va 2>&1 | grep -vE '^$|prelink:' | sed 's|.* /|/|') | sort -u
#ll
ll **/*py
#systemd unit file
systemctl daemon-reload;echo $?
sudo systemctl status sysupdate.service
sudo journalctl -o verbose -u sysupdate.service
journalctl -xe
https://superuser.com/questions/476379/how-do-i-setup-a-systemd-service-to-be-started-by-a-non-root-user-as-a-user-daem
Systemd normally does not allow ordinary users to start system services. While it does support giving access via polkit, that part is still somewhat lacking, and you cannot yet allow only one specific service.
Since rtorrent is not actually a system service, and because you want every user to have their own instance of rtorrent, experiment with systemd's "user" mode.
When you log in, the system will start a user@<uid>.service system unit for you, which will launch a separate "--user" instance of systemd. The new user-systemd will read unit files (starting with default.target) from ~/.config/systemd/user/, /etc/systemd/user/ and /usr/lib/systemd/user/.
https://www.brendanlong.com/systemd-user-services-are-amazing.html
Auto-start and lingering
To enable autostart, I just had to run:
systemctl --user enable moin # or ghost or whatever
Then:
loginctl enable-linger moin # this will need authentication from a sudoer
#systemd user timer and service in ~/.config/systemd/user
systemctl --user daemon-reload && systemctl --user enable sysupdate.timer
systemctl --user list-timers -all
journalctl -o verbose -u sysupdate.service
journalctl -xe
#todo: NOT work
#1.sudo: effective uid is not 0, is /usr/bin/sudo on a file system with the 'nosuid' option set or an NFS file system without root privileges?
#2.systemd service: Failed to determine supplementary groups: Operation not permitted
#inside sysupdate.service
#User=nobody
#User=r
#Group=adm
#system startup time
last reboot
who -b
http://www.diveintopython.net/power_of_introspection/filtering_lists.html
Python list filtering syntax:
[mapping-expression for element in source-list if filter-expression]
methodList = [method for method in dir(object) if callable(getattr(object, method))]
#Python Flatten list of lists
#Python convert nested list into one-dimensional list
https://stackoverflow.com/questions/17485747/how-to-convert-a-nested-list-into-a-one-dimensional-list-in-python
The way to do nested list comprehensions is to put the for statements in the same order as they would go in regular nested for statements.
[... for inner_list in outer_list for item in inner_list]
flattened = [val for sublist in list_of_lists for val in sublist]
#git push multiple repos under a directory recursively from command line
for repo in xrcs note;do cd /mnt/0/gthb/$repo && ggpush;done
#check installed Linux Kernels
ls /boot/ | grep vmlinuz
#On RHEL / CentOS / Scientific Linux / Fedora:
sudo rpm -qa kernel
#On Debian / Ubuntu / Linux Mint:
dpkg --list | grep linux-image
rpm -qf $(rpm -Va 2>&1 | grep -vE '^$|prelink:' | sed 's|.* /|/|') | sort -u
#work
sudo find /mnt/0 ~ -xdev -user root -group root -execdir sudo chown -R r:adm {} \;
#NOT work
sudo find /mnt/0 ~ -xdev -user root -o -group root -execdir sudo chown -R r:adm {} \;
#validate with
sudo find /mnt/0 ~ -xdev -user root -group root
sudo find /mnt/0 ~ -xdev -user root -o -group root
#gawk
#output only distinct lines
gawk '!x[toupper($0)]++ {printf "%s ", $0} END {print ""}' dllst
cmd="\? $(gawk -v singlqt="'" '!seen[toupper($0)]++ {printf "%s%s%s ", singlqt, $0, singlqt} END {print ""}' $file)"
#Remove duplicate lines while keeping the order of the lines
https://en.wikipedia.org/wiki/Schwartzian_transform
https://unix.stackexchange.com/questions/194780/remove-duplicate-lines-while-keeping-the-order-of-the-lines
cat -n infile.txt | sort -k2 -k1n | uniq -f1 | sort -nk1,1 | cut -f2- > ._tmp_ && command mv -f ._tmp_ infile.txt
#shell Internal Variables: $$ $!
The $$ variable is the PID (Process IDentifier) of the currently running shell. This can be useful for creating temporary files, such as /tmp/my-script.$$ which is useful if many instances of the script could be run at the same time, and they all need their own temporary files.
The $! variable is the PID of the last run background process. This is useful to keep track of the process as it gets on with its job.
ll (*|.)vim*
-rw-r--r--. 1 r adm 2766 Oct 25 06:24 vimrc_etc
-rw-r-----+ 1 r r 7562 Oct 15 09:50 vim-rfrnc
-rw-r-----+ 1 r r 2785 Sep 10 21:55 .vimrc
ll {.,*}vim*
-rw-r--r--. 1 r adm 2766 Oct 25 06:24 vimrc_etc
-rw-r-----+ 1 r r 7562 Oct 15 09:50 vim-rfrnc
-rw-r-----+ 1 r r 2785 Sep 10 21:55 .vimrc
#algorithm-mnemonics.vim
https://github.com/dawikur/algorithm-mnemonics.vim
g:algorithm_mnemonics_const_return="Left"
#chatbot
http://itchat.readthedocs.io/zh/latest/
pip install --user --upgrade itchat
tr -t '[:upper:]' '[:lower:]' <<< $tst_var
cd ~otherUsrName
ctrl-\
coredump analysis
program record replay toolkit
pinplay Dr debug
time {cmd1 ; cmd2 ...}
#macOS
sw_vers
hostinfo
ls $(dirname $(whereis cat))
basename
PPID: ps -jp PID
history
https://stackoverflow.com/questions/864316/how-to-pipe-list-of-files-returned-by-find-command-to-cat-to-view-all-the-files
find ... -print0 | xargs -0 cat -n
#for each (for-each) in zsh
http://improve-future.com/en/for-each-in-bash-sh-and-zsh.html
local varZip=($(ls *Code.zip))
echo $varZip
for varZ in $varZip;do unzip -d /mnt/0/kod_coderprog $varZ;echo '$?':$?;done
#Linux Unix: Find Files Modified On Specific Date
https://www.cyberciti.biz/faq/unix-linux-list-all-files-modified-on-given-date/
find . -type f -iname '*.rar' -newerct 2017/11/1 ! -newerct 2017/12/25;echo $?
{find . -type f -iname '*.rar' -newerct '2017/12/01' ! -newerct '2017/12/20';echo $?} > 01.txt
{find . -type f -iname '*.rar' -newerct '2017/12/1' ! -newerct '2017/12/20';echo $?} > 1.txt
#mv/cp create destination directory if not exist?
https://stackoverflow.com/questions/547719/is-there-a-way-to-make-mv-create-the-directory-to-be-moved-to-if-it-doesnt-exis
mkdir -p angular-best-practice && mv angular-best-practices.part*rar $_ && cd $_ ; echo '$?':$?
mkdir /mnt/0/essential-git && mv essential-git*rar $_ && cd $_ && ll
DNS settings Linux
r:/etc/resolv.conf
/var/run/NetworkManager/resolv.conf
0. browser: Firefox about:config media.peerconnection.enabled:false, restart Firefox.
1. Open DNS
w:/etc/dhcp/dhclient.conf
exc:service network-manager restart
r:/etc/resolv.conf
2. OpenVPN: vpnbook.com/freevpn
3. DNS leak test: dnsleaktest.com
*nix shell:
<< : heredoc>
<<< : here string
tr -d '\\' <<< '[https://www.youtube.com/watch\?v\=QSPaL4aVjRo]'
[https://www.youtube.com/watch?v=QSPaL4aVjRo]
sed 's/\\//g' <<< '[https://www.youtube.com/watch\?v\=QSPaL4aVjRo]'
[https://www.youtube.com/watch?v=QSPaL4aVjRo]
sed 's/\\//g' <<< [https://www.youtube.com/watch\?v\=QSPaL4aVjRo]
[https://www.youtube.com/watch?v=QSPaL4aVjRo]
tr -d '\\' <<< [https://www.youtube.com/watch\?v\=QSPaL4aVjRo]
[https://www.youtube.com/watch?v=QSPaL4aVjRo]
declare -f delBkslsh
github https -> ssh
ll ktnwr/.git/config; less ktnwr/.git/config
➜ ktnwr git:(master) git remote set-url origin [email protected]:rrrgh/ktnwr.git
SSH
ssh-keygen -o -a 4096 -t ed25519
change email/label: ssh-keygen -c -C 'email@gitconifg' -f <prvt-key-file>
Add SSH key to the ssh-agent
1. eval "$(ssh-agent -s)"
2. Add your SSH key to the ssh-agent. If you are using an existing SSH key rather than generating a new SSH key, you'll need to replace id_rsa in the command with the name of your existing private key file. Enter this command $ ssh-add -K <prvt-key-file>
ssh-add -l
ssh-add -L
https://superuser.com/questions/380432/git-permission-denied-public-key-error
Set SSH configuration file (~/.ssh/config) so SSH knows which key to be used for which server.
Host github.com
HostName github.com
User git
IdentityFile ~/.ssh/<prvt-key-file>
Host github-client
HostName github.com
User git
IdentityFile /Users/XXXUser/.ssh/id_rsa_XXXSECONDUSER
https://superuser.com/questions/421074/ssh-the-authenticity-of-host-host-cant-be-established
➜ ssh-keyscan -t RSA github.com
# github.com:22 SSH-2.0-libssh_0.7.0
github.com ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAq2A7hRGmdnm9tUDbO9IDSwBK6TbQa+PXYPCPy6rbTrTtw7PHkccKrpp0yVhp5HdEIcKr6pLlVDBfOLX9QUsyCOV0wzfjIJNlGEYsdlLJizHhbn2mUjvSAHQqZETYP81eFzLQNnPHt4EVVUh7VfDESU84KezmD5QlWpXLmvU31/yMf+Se8xhHTvKSCZIFImWwoG6mbUoWf9nzpIoaSjB+weqqUUmpaaasXVal72J+UX2B+2RPW3RcT0eOzQgqlJL3RKrTJvdsjE3JEAvGq3lGHSZXy28G3skua2SmVi/w4yCE6gbODqnTWlg7+wC604ydGXA8VJiS5ap43JXiUFFAaQ==
➜ rtvl
$?:0
➜ ssh-keyscan -t RSA github.com | ssh-keygen -lv -f -
# github.com:22 SSH-2.0-libssh_0.7.0
2048 SHA256:nThbg6kXUpJWGl7E1IGOCspRomTxdCARLviKw6E5SY8 github.com (RSA)
+---[RSA 2048]----+
| =+o...+=o.. |
|o++... *o . |
|*.o. *o. |
|oo. ..o.= . |
|.+o. .. S = |
|*=+ . o = . |
|OE . . o |
| o . |
| |
+----[SHA256]-----+
https://stackoverflow.com/questions/2643502/git-permission-denied-publickey
Extensive troubleshooting and even automated fixing can be done with:
ssh -vT [email protected]
Source: http://help.github.com/ssh-issues/