-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgrml_tips
3286 lines (2330 loc) · 79.1 KB
/
grml_tips
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
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
Configure network:
# grml-network
Tags: configuration, network
--
Deactivate error correction of zsh:
% NOCOR=1 zsh
Run zsh-help for more information regarding zsh.
Tags: zsh, configuration
--
Disable automatic setting of title in GNU screen:
% NOPRECMD=1 zsh
Set it manually e.g. via:
% screen -X title foobar
Run zsh-help for more information regarding zsh.
Tags: zsh, configuration
--
Do not use menu completion in zsh:
% NOMENU=1 zsh
Run zsh-help for more information regarding zsh.
Tags: zsh, configuration
--
Run GNU screen with grml-configuration:
% grml-screen
or
% screen -c /etc/grml/screenrc
Tags: screen, configuration
--
Print out grml-version:
% grml-version
Tags: grml
--
Configure mutt:
% grml-mutt
Tags: mutt
--
Use encrypted files / partitions:
# grml-crypt <options>
Usage example:
Initialize:
# grml-crypt format /mnt/external1/encrypted_file /mnt/test
# cp big_file /mnt/test
# grml-crypt stop /mnt/test
Use:
# grml-crypt start /mnt/external1/encrypted_file /mnt/test
# grml-crypt stop /mnt/test
See: man grml-crypt
Tags: crypto, grml-crypt, dmcrypt, luks
--
Change resolution of X:
% xrandr -s '1024x768'
Tags: x11, xorg, resolution
--
Change resolution of framebuffer:
# fbset 800x600-60
Tags: resolution
--
Configure newsreader slrn:
% grml-slrn
Tags: slrn
--
Configure grml system:
# grml-config
Or directly run scripts:
# grml-config-root
% grml-config-user
Tags: grml, configuration
--
Lock screen (X / console):
% grml-lock
Press ctrl-alt-x to lock a GNU screen session.
Tags: grml, lock, grml-lock, screen
--
Change wallpaper in X:
% grml-wallpaper <press-tab>
Tags: grml, wallpaper
--
Start X window system (XFree86 / Xorg / X.org):
% grml-x $WINDOWMANAGER
Usage examples:
% grml-x fluxbox
% grml-x -mode '1024x768' fluxbox
% grml-x -nosync
Tags: grml-x, x11, xorg, graphic
--
Collect hardware information:
% grml-hwinfo
or run as root to collect some more information:
# grml-hwinfo
will generate a file named info.tar.bz2.
Tags: grml, hardware, hwinfo, collect
--
Configure hardware detection features of harddisk installation:
# grml-autoconfig
or manually edit /etc/grml/autoconfig[.small]
See: man grml-autoconfig
Tags: grml, installation, configuration
--
Bootoptions / cheatcodes / bootparams for booting grml:
On the grml-ISO if not running grml:
% less /cdrom/GRML/grml-cheatcodes.txt
When running grml:
% most /usr/share/doc/grml-docs/grml-cheatcodes.txt.gz
Tags: grml, cheatcodes, boot, bootoptions, bootparam
--
Report bugs to Debian's Bug Tracking System (BTS):
% reportbug --bts debian
or adjust /etc/reportbug.conf to your needs.
See:
http://grml.org/bugs/
http://www.debian.org/Bugs/
Tags: bug, reportbug, bts, debian
--
Offline documentation:
% grml-info
Online documentation:
http://grml.org/faq/
http://grml.org/docs/
http://wiki.grml.org/doku.php
Tags: info, grml, grml-info, documentation
--
Mount NTFS partition (read-write):
# mount.ntfs-3g /dev/sda1 /mnt/sda1
Tags: ntfs, mount
--
Overwrite specific file on an NTFS partition:
ntfscp /dev/hda1 /tmp/file_source path/to/file_target
--
Resize an NTFS partition:
# ntfsresize ..
Usage example:
ntfsresize -n -s 10G /dev/hda1 # testcase
ntfsresize -s 10G /dev/hda1 # testing was successfull, now really resize partition
cfdisk /dev/hda # delete partition hda1, create new one with 10000MB and fs-type 07 (NTFS)
Tags: ntfs, resize, ntfsresize
--
Modify resolution for intel graphic chipsets:
# 915resolution ..
Usage example:
# 915resolution 4d 1400 1050
--
Connect bluetooth mouse:
# bt-hid start
... and press 'connect' button on your bluetooth device.
--
Connect bluetooth headset:
# bt-audio start
... and press 'connect' button on your bluetooth device.
--
Secure delete file / directory / partition:
# wipe -kq /dev/hda1
See: man wipe
Also take a look at shred(1), sfill(1) and http://dban.sourceforge.net/
Tags: delete, secure, wipe, shred
--
Development information regarding grml:
http://blog.grml.org/
Tags: blog, grml, developmnet
--
Contact Grml team:
#grml on irc.freenode.org - http://grml.org/irc/
http://grml.org/contact/
Tags: contact, irc, freenode, email
--
Join the grml mailinglist:
http://grml.org/mailinglist/
Tags: grml, mailinglist
--
Help us - donate!
http://grml.org/donations/
Tags: grml, donation
--
Commercial support / system administration / adjusted live-cds:
grml-solutions: http://grml.org/solutions/
Tags: grml, commercial, customize
--
Information regarding the kernel provided by grml:
http://grml.org/kernel/
Tags: documentation, grml, kernel
--
SMTP command-line test tool:
% swaks <options>
Usage example:
% swaks -s $MAILSERVER -tlsc -a -au $ACCOUNT -ap $PASSWORD -f $MAILADRESSE -t $MAILADRESSE
See: man swaks
Tags: swak, smtp, test
--
NTFS related packages:
scrounge-ntfs
salvage-ntfs
ntfsprogs
Tags: utils, ntfs
--
Modify service through init script:
# Start ssh
# Stop samba
# Restart apache
# Reload postfix
# service gpm start
# /etc/init.d/lvm start
Tags: init, script, start, stop
--
Test joystick:
# jstest /dev/input/js0
--
Play movie:
% mplayer /path/to/movie
Tags: movie, mplayer
--
Use webcam with mplayer:
% mplayer tv:// -tv driver=v4l:width=352:height=288:outfmt=yv12:device=/dev/video0
Tags: webcam, mplayer
--
Powerful network discovery tool:
# scapy
Tags: network, python, tool
--
Grab an entire CD and compress it to Ogg/Vorbis,
MP3, FLAC, Ogg/Speex and/or MPP/MP+(Musepack) format:
% abcde
Tags: rip, abcde, mp3, transcode, audio
--
Show a console session in several terminals:
% gems
--
Switch behaviour of caps lock key:
% caps-ctrl
--
grep with Perl-compatible regular expressions:
% pcregrep
--
ncp: a fast file copy tool for LANs
Local (send file):
% npush file_to_copy
Remote (receive file):
% npoll
Tags: copy, file, network
--
utility for sorting records in complex ways:
% msort
--
a smaller, cheaper, faster SED implementation:
% minised
--
zsh tips:
% man zsh-lovers
See: http://grml.org/zsh/
--
zsh reference card for grml system:
http://grml.org/zsh/
/usr/share/doc/grml-docs/zsh/grml-zsh-refcard.pdf.gz
--
Multiple rename:
% for i in foo* ; do mv "$i" "bar${i/foo}" ; done
% qmv foo*
% prename 's/foo/bar/' foo*
% mmv "foo*" "bar#1"
% zmv 'foo(*)' 'bar$1'
--
Test TFT / LCD display:
% lcdtest
--
Test sound:
% soundtest
--
Improved grep version:
% glark
--
Grep with highlighting:
% grep --color=auto ...
% hgrep ...
Tags: grep, color, highlight
--
Extract matches when grepping:
Usage examples:
% ifconfig | grepc 'inet addr:(.*?)\s'
% ifconfig | glark --extract-matches 'inet addr:(.*?)\s'
--
Output text as sound:
% say 'ghroummel'
% xsay # when running X and text selected via mouse
--
Get information on movie files:
% tcprobe -i file.avi
--
Get an overview of your image files:
% convert 'vid:*.jpg' thumbnails.jpg
--
List all standard defines:
% gcc -dM -E - < /dev/null
--
Send a mail as reminder:
echo "mail -s 'check TODO-list' $MAILADDRESS < /dev/null" | at 23:42
--
ncurses-based presentation tool:
% tpp
See: man tpp and /usr/share/doc/tpp/examples/
--
Use ICQ / Jabber / Yahoo! / AIM / MSN /... on command line:
% centericq
--
Use IRC on command line:
% irssi
--
Diff / merge files:
% vimdiff file1 file2
Re-diffing:
:diffupdate
Moving between diffs:
[c
]c
Synchronizing:
:diffget
:diffput
--
Hardware monitoring without kernel dependencies:
% mbmon
--
Install grml-iso to usb-stick:
% grml2usb grml.iso /mount/point
Tags: usbpen, usbstick, installation, grml2usb
--
Use mplayer on framebuffer console:
% mplayer -vo fbdev ...
--
Use links2 on framebuffer console:
% links2 -driver fb ...
--
Switch language / keyboard:
* use the bootparam lang to set language environment ($LANG, $LC_ALL, $LANGUAGE)
* use the bootparams keyboard / xkeyboard to activate specific keyboard layout
Usage example: 'grml lang=us keyboard=de xkeyboard=de'
Or run one of the following commands:
% grml-lang de
or
# loadkeys i386/qwertz/de-latin1-nodeadkeys.kmap.gz # console
% setxkbmap de # X11
Tags: language, keyboard, configuration
--
Switch setting of caps-control key (switch between ctrl + shift) on keyboard:
# caps-ctrl
--
Mount usb device / usb stick:
% mount /mnt/external1 # corresponds to /dev/sda1
or
% mount /mnt/external # corresponds to /dev/sda
--
Install Sun Java packages:
Download j2re.bin-file from http://java.sun.com/downloads/index.html and run
# apt-get install java-package
# fakeroot make-jpkg j2re-*.bin
# dpkg -i sun-j2re*.deb
# update-alternatives --config java
--
Improved dd version:
ddrescue is an improved version of dd which tries to read and
if it fails it will go on with the next sectors, where tools
like dd will fail.
% ddrescue ...
See: man ddrescue
--
How to make an audio file (e.g. Musepack format) out of a DVD track:
% mkfifo /tmp/fifo.wav
% mppenc /tmp/fifo.wav track06.mpc &
% mplayer -vo null -vc null -ao pcm:fast:file=/tmp/fifo.wav -dvd-device /dev/dvd dvd://1 -chapter 6-6
Adjust the mppenc line with the encoder you would like to use,
for example 'oggenc -o track06.ogg /tmp/fifo.wav' for ogg files.
Alternative:
% mplayer -vo null -dumpaudio -dumpfile track06.raw -aid N -dvd-device /dev/dvd dvd://1 -chapter 6-6
to extract audio without processing, where 'N' is the corresponding audio channel (see 'man mplayer')
Usage example for getting a PCM/wave file from audio channel 128:
% mplayer -vo null -vc null -ao pcm:fast:file=track06.wav -aid 128 -dvd-device /dev/dvd dvd://6
--
Create simple chroot:
# make_chroot_jail $USERNAME
--
Convert DOS formated file to unix format:
sed 's/.$//' dosfile > unixfile # assumes that all lines end with CR/LF
sed 's/^M$//' dosfile > unixfile # in bash/tcsh, press Ctrl-V then Ctrl-M
sed 's/\x0D$//' dosfile > unixfile # gsed 3.02.80, but top script is easier
awk '{sub(/\r$/,"");print}' # assumes EACH line ends with Ctrl-M
gawk -v BINMODE="w" '1' infile >outfile # in DOS environment; cannot be done with
# DOS versions of awk, other than gawk
tr -d \r < dosfile > unixfile # GNU tr version 1.22 or higher
tr -d '\015' < dosfile > unixfile # use octal value for "\r" (see man ascii)
tr -d '[\015\032]' < dosfile > unixfile # sometimes ^Z is appended to DOS-files
vim -c ":set ff=unix" -c ":wq" file # convert using vim
vim -c "se ff=dos|x" file # ... and even shorter ;)
recode ibmpc..lat1 file # convert using recode
echo -e "s/\r//g" > dos2unix.sed; sed -f dos2unix.sed < dosfile > unixfile
Tags: windows, line, convert, recode, tr, line end,
--
Save live audio stream to file:
% mplayer -ao pcm:file=$FILE $URL
--
Save live stream to file:
% mplayer -dumpfile $FILE -dumpstream $STREAM
or
% mencoder mms://$URL -o $FILE -ovc copy -oac copy
or
% mimms mms://file.wmv
--
Merge video files:
AVI:
% avimerge -i *.avi -o blub.avi
MPEG:
% cat *.mpg > blub.mpg
WMV:
% mencoder file1.wmv -ovc lavc -oac lavc -ofps 25 -srate 48000 -mc 0 -noskip -forceidx -o file1.avi
% mencoder file2.wmv -ovc lavc -oac lavc -ofps 25 -srate 48000 -mc 0 -noskip -forceidx -o file2.avi
% avimerge -i file1.avi file2.avi -o blub.avi
--
Display MS-Word file:
% strings file.doc | fmt | less
or
% antiword file.doc
--
Convert MS-Word file to postscript:
% antiword -p a4 file.doc > file.ps
--
Convert manual to postscript:
% zcat /usr/share/man/man1/zsh.1.gz | groff -man > zsh.1.ps
or
% man -t zsh > zsh.ps
--
Read BIOS:
% dd if=/dev/mem bs=1k skip=768 count=256 2>/dev/null | strings -n 8
--
Read HTTP via netcat:
echo -e "GET / HTTP/1.1\r\nHost: $DOMAIN\r\n\r\n" | netcat $DOMAIN 80
--
Get X ressources for specific program:
% xrdb -q |grep -i xterm
--
Get windowid of specific X-window:
% xwininfo -int | grep "Window id:" | cut -d ' ' -f 4
--
Get titel of specific X-window:
% xprop WM_CLASS
--
check locale - LC_MESSAGES:
% locale -ck LC_MESSAGES
--
Create random password:
% pwgen
or
% dd if=/dev/urandom bs=14 count=1 | hexdump | cut -c 9-
--
Get tarballs of various Linux Kernel trees:
% ketchup 2.6
to get the current stable 2.6 release
% ketchup -l
to get a list of all supported trees
--
Transfer your SSH public key to another host:
% ssh-keygen # ssh-keygen / ssh-key-gen: if you don't have a key yet
[...]
% ssh-copy-id -i ~/.ssh/id_rsa.pub user@remote-system
or
% cat $HOME/.ssh/id_rsa.pub | ssh user@remote-system 'cat >> .ssh/authorized_keys'
Tags: ssh, ssh key, public key, ssh-copy-id, ssh-keygen
--
Fetch and potentially change SCSI device parameters:
# sdparm /dev/sda
See: man sdparm
--
reclaim disk space by linking identical files together:
% dupmerge...
--
Find and remove duplicate files:
% dupseek ...
--
Perform layer 2 attacks:
# yersinia ...
Tags: network, attack, security
--
rootsh
--
Guess PC-type hard disk partitions / partition table:
# gpart <options>
Perform a standard scan:
# gpart /dev/ice
Write back the guessed table:
# gpart -W /dev/ice /dev/ice
Tags: partition, recovery, disk
--
Develop, test and use exploit code with the Metasploit Framework:
cd /tmp
wget http://spool.metasploit.com/releases/framework-3.2.tar.gz
unp framework-3.2.tar.gz
cd framework-3.2
./msfcli
--
Useful documentation:
% w3m /usr/share/doc/Debian/reference/reference.en.html
or
% xpdf =(zcat /usr/share/doc/Debian/reference/reference.en.pdf.gz)
http://grml.org/docs/ grml Documentation
http://wiki.grml.org/ grml Wiki
http://www.debian.org/doc/ Debian Documentation
http://wiki.debian.org/ Debian Wiki
http://www.gentoo.org/doc/en/ Gentoo Documentation
http://gentoo-wiki.com/ Gentoo Wiki
http://www.tldp.org/ The Linux Documentation Project
Tips and tricks:
% fortune debian-hints
Tags: documentation
--
Fun stuff:
% fortune debian-hints
% dpkg -L funny-manpages
--
Backup master boot record (MBR):
# dd if=/dev/ice of=/tmp/backup_of_mbr bs=512 count=1
Tags: backup, mbr
--
Backup partition table:
# sfdisk -d /dev/hda > hda.out
Restore partition table:
# sfdisk /dev/hda < hda.out
Tags: backup, partition, sfdisk, recovery
--
Clone disk via network using netcat:
Listener:
# nc -vlp 30000 > hda1.img
Source:
# dd if=/dev/hda1 | nc -vq 0 192.168.1.2 30000
Adjust blocksize (dd's option bs=...) and include 'gzip -c'
to tune speed:
# dd if=/dev/hda1 bs=32M | gzip -c | nc -vq 0 192.168.1.2 30000
Tags: network, backup, dd, netcat
--
Backup specific directories via cpio and ssh:
# for f in directory_list; do find $f >> backup.list done
# cpio -v -o --format=newc < backup.list | ssh user@host "cat > backup_device"
Tags: backup
--
Clone disk via ssh:
This one uses CPU cycles on the remote server to compare the files:
# ssh target_address cat remotefile | diff - localfile
# cat localfile | ssh target_address diff - remotefile
This one uses CPU cycles on the local server to compare the files:
# ssh target_address cat <localfile "|" diff - remotefile
Tags: network, backup, ssh
--
Useful tools for cloning / backups:
* dd: convert and copy a file
* dd_rescue: copies data from one file (or block device) to another
* pcopy: a replacement for dd
* partimage: back up and restore disk partitions
* dirvish: Disk based virtual image network backup system
* devclone: in-place filesystem conversion -- device cloning
* ntfsclone: efficiently clone, image, restore or rescue an NTFS
* dump: ext2/3 filesystem backup
* udpcast: multicast file transfer tool
* cpio: copy files to and from archives
* pax: read and write file archives and copy directory hierarchies
* netcat / ssh / tar / gzip / bzip2: additional helper tools
Tags: network, backup, ssh, udp, rescue, recovery
--
Use grml as a rescue system:
Different tools:
* dd: convert and copy a file
* ddrescue: copies data from one file or block device to another
* partimage: Linux/UNIX utility to save partitions in a compressed image file
* cfdisk: Partition a hard drive
* nparted: Newt and GNU Parted based disk partition table manipulator
* parted-bf: The GNU Parted disk partition resizing program, small version
* testdisk: Partition scanner and disk recovery tool
* gpart: Guess PC disk partition table, find lost partitions
ext2/ext3:
* e2fsprogs: ext2 file system utilities and libraries
* e2tools: utilities for manipulating files in an ext2/ext3 filesystem
* e2undel: Undelete utility for the ext2 file system
* ext2resize: an ext2 filesystem resizer
* recover: Undelete files on ext2 partitions
ReiserFS/Reiser4:
* reiser4progs: administration utilities for the Reiser4 filesystem
* reiserfsprogs: User-level tools for ReiserFS filesystems
XFS:
* xfsdump: Administrative utilities for the XFS filesystem
* xfsprogs: Utilities for managing the XFS filesystem
JFS:
* jfsutils: utilities for managing the JFS filesystem
NTFS:
* ntfsprogs: tools for doing neat things in NTFS partitions from Linux
* salvage-ntfs: free NTFS data recovery tools
* scrounge-ntfs: data recovery program for NTFS file systems
* ntfsresize: resize ntfs partitions
Tags: ntfs, jfs, xfs, ext3, rescue, recovery, backup, filesystem, tools
--
Get ASCII value of a character with zsh:
% char=N ; print $((#char))
--
Convert a collection of mp3 files to wave or cdr using zsh:
% for i (./*.mp3){mpg321 --w - $i > ${i:r}.wav}
--
Convert images (foo.gif to foo.png) using zsh:
% for i in **/*.gif; convert $i $i:r.png
--
Remove all "non txt" files using zsh:
% rm ./^*.txt
--
Remote Shell Using SSH:
remote host:
% ssh -NR 3333:localhost:22 user@yourhost
local host:
% ssh user@localhost -p 3333
Tags: port forwarding, ssh, remote port, network
--
Reverse Shell with Netcat:
local host:
% netcat -v -l -p 3333 -e /bin/sh
remote host:
% netcat 192.168.0.1 3333
TagS: port forwarding, ssh, remote, network
--
Reverse Shell via SSH:
local host (inside the network):
% ssh -NR 1234:localhost:22 remote_host
remote host (outside the network):
% ssh localhost -p 1234
Tags: port forwarding, ssh, remote port, network
--
Remove empty directories with zsh:
% rmdir ./**/*(/od) 2> /dev/null
--
Find all the empty directories in a tree with zsh:
% ls -ld *(/^F)
--
Find all files without a valid owner and change ownership with zsh:
% chmod user /**/*(D^u:${(j.:u:.)${(f)"$(</etc/passwd)"}%%:*}:)
--
Display the 5-10 last modified files with zsh:
% print -rl -- /path/to/dir/**/*(D.om[5,10])
--
Find and list the ten newest files in directories and subdirs (recursive) with zsh:
% print -rl -- **/*(Dom[1,10])
--
Find most recent file in a directory with zsh:
% setopt dotglob ; print directory/**/*(om[1])
--
Tunnel all traffic through an external server:
% ssh -ND 3333 [email protected]
Then set the SOCKS4/5 proxy to localhost:3333.
Check whether it's working by surfing e.g. to checkip.dyndns.org
Tags: ssh, network, proxy, socks, tunnel
--
Tunnel everything through SSH via tsocks:
set up the SSH proxy on the client side:
% ssh -ND 3333 [email protected]
Adjust /etc/tsocks.conf afterwards (delete all other lines):
server = 127.0.0.1
server_port = 3333
For programs who natively support proxying connections (e.g. Mozilla
Firefox) you can now set the proxy address to localhost port 3333.
All other programs which's connections you want to tunnel through your
external host are prefixed with tsocks, e.g.:
% tsocks netcat example.com 80
% tsocks irssi -c irc.quakenet.eu.org -p 6667
If you call tsocks without parameters it executes a shell witht the
LD_PRELOAD environment variable already set and exported.
Tags: ssh, network, proxy, socks, tunnel, tsocks
--
smartctl - control and monitor utility for harddisks using Self-Monitoring,
Analysis and Reporting Technology (SMART):
# smartctl --all /dev/ice
If you want to use smartctl on S-ATA (sata) disks use:
# smartctl -d ata --all /dev/sda
Start offline test:
# smartctl -t offline /dev/ice
Start short test:
# smartctl -t short /dev/ice
Display results of test:
# smartctl -l selftest /dev/ice
Query device information:
# smartctl -i /dev/ice
Tags: smart, s.m.a.r.t, info, test, hardware
--
Mount a BSD / Solaris partition:
# mount -t ufs -o ufstype=ufs2 /dev/hda1 /mnt/hda1
Use ufstype 44bsd for FreeBSD, NetBSD, OpenBSD (read-write).
Use ufstype ufs2 for >= FreeBSD 5.x (read-only).
Use ufstype sun for SunOS (Solaris) (read-write).
Use ufstype sunx86 for SunOS for Intel (Solarisx86) (read-write).
See /usr/share/doc/linux-doc-$(uname -r)/Documentation/filesystems/ufs.txt.gz
for more details.
Tags: ufs, bsd, mount, solaris
--
Read BIOS (and or BIOS) password:
# dd if=/dev/mem bs=512 skip=2 count=1 | hexdump -C | head
--
Clone one of the kernel trees via git:
git clone rsync://rsync.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6.git
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
This path defines the tree. See http://kernel.org/git/ for an overview.
--
Mount filesystems over ssh protocol:
% sshfs user@host:/remote_dir /mnt/test
Unmount via:
% fusermount -u /mnt/test
(Notice: requires fuse kernel module)