-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.html
441 lines (440 loc) · 23.6 KB
/
main.html
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
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>¡¡¡THE MOST BIG COMPILATION LINUX COMMANDS OF ALL TIMES IN ALL THE MULTIVERSE!!!</title>
<style type="text/css">
body, td, th {
font-family: Lato, "Lato Light", "Lato Semibold";
font-style: normal;
font-weight: normal;
color: #FFFFFF;
font-size: 12px;
}
body {
background-color: rgba(34, 34, 34, 0.8); /* Color #222222 con 20% de transparencia */
}
</style>
</head>
<body>
<p>Run the last command as root<br>
$ sudo !!</p>
<p>Serve current directory tree at http://$HOSTNAME:8000/<br>
$ python -m SimpleHTTPServer</p>
<p>Runs previous command but replacing<br>
$ ^foo^bar</p>
<p>Rapidly invoke an editor to write a long, complex, or tricky command<br>
$ ctrl-x e</p>
<p>Place the argument of the most recent command on the shell<br>
$ 'ALT+.' or '<ESC> .'</p>
<p>currently mounted filesystems in nice layout<br>
$ mount | column -t</p>
<p>Salvage a borked terminal<br>
$ reset</p>
<p>Get your external IP address<br>
$ curl ifconfig.me</p>
<p>Execute a command at a given time<br>
$ echo "ls -l" | at midnight</p>
<p>Quick access to the ascii table.<br>
$ man ascii</p>
<p>output your microphone to a remote computer's speaker<br>
$ dd if=/dev/dsp | ssh -c arcfour -C username@host dd of=/dev/dsp</p>
<p>type partial command, kill this command, check something you forgot, yank the command, resume typing.<br>
$ <ctrl+u> [...] <ctrl+y></p>
<p>Query Wikipedia via console over DNS<br>
$ dig +short txt <keyword>.wp.dg.cx</p>
<p>Mount folder/filesystem through SSH<br>
$ sshfs name@server:/path/to/folder /path/to/mount/point</p>
<p>Mount a temporary ram partition<br>
$ mount -t tmpfs tmpfs /mnt -o size=1024m</p>
<p>Download an entire website<br>
$ wget --random-wait -r -p -e robots=off -U mozilla http://www.example.com</p>
<p>Clear the terminal screen<br>
$ ctrl-l</p>
<p>Compare a remote file with a local file<br>
$ ssh user@host cat /path/to/remotefile | diff /path/to/localfile -</p>
<p>SSH connection through host in the middle<br>
$ ssh -t reachable_host ssh unreachable_host</p>
<p>Update twitter via curl<br>
$ curl -u user:pass -d status="Tweeting from the shell" http://twitter.com/statuses/update.xml</p>
<p>A very simple and useful stopwatch<br>
$ time read (ctrl-d to stop)</p>
<p>Put a console clock in top right corner<br>
$ while sleep 1;do tput sc; tput cup 0 $(($( tput cols)-29));date; tput rc;done &</p>
<p>Make 'less' behave like 'tail -f'.<br>
$ less +F somelogfile</p>
<p>Close shell keeping all subprocess running<br>
$ disown -a && exit</p>
<p>Watch Star Wars via telnet<br>
$ telnet towel.blinkenlights.nl</p>
<p>32 bits or 64 bits?<br>
$ getconf LONG_BIT</p>
<p>List of commands you use most often<br>
$ history | awk '{a[$2]++}END{for(i in a){print a[i] " " i}}' | sort -rn | head</p>
<p>Simulate typing<br>
$ echo "You can simulate on-screen typing just like in the movies" | pv -qL 10</p>
<p>Set audible alarm when an IP address comes online<br>
$ ping -i 60 -a IP_address</p>
<p>Reboot machine when everything is hanging<br>
$ <alt> + <print screen/sys rq> + <R> - <S> - <E> - <I> - <U> - <B></p>
<p>quickly rename a file<br>
$ mv filename.{old,new}</p>
<p>Display the top ten running processes - sorted by memory usage<br>
$ ps aux | sort -nk +4 | tail</p>
<p>Delete all files in a folder that don't match a certain file extension<br>
$ rm !(*.foo|*.bar|*.baz)</p>
<p>Push your present working directory to a stack that you can pop later<br>
$ pushd /tmp</p>
<p>Create a script of the last executed command<br>
$ echo "!!" > foo.sh</p>
<p>Watch Network Service Activity in Real-time<br>
$ lsof -i</p>
<p>Easy and fast access to often executed commands that are very long and complex.<br>
$ some_very_long_and_complex_command # label</p>
<p>escape any command aliases<br>
$ \[command]</p>
<p>Show apps that use internet connection at the moment. (Multi-Language)<br>
$ lsof -P -i -n</p>
<p>diff two unsorted files without creating temporary files<br>
$ diff <(sort file1) <(sort file2)</p>
<p>Reuse all parameter of the previous command line<br>
$ !*</p>
<p>Backticks are evil<br>
$ echo "The date is: $( date +%D)"</p>
<p>Sharing file through http 80 port<br>
$ nc -v -l 80 < file.ext</p>
<p>Show File System Hierarchy<br>
$ man hier</p>
<p>Display a block of text with AWK<br>
$ awk '/start_pattern/,/stop_pattern/' file.txt</p>
<p>Set CDPATH to ease navigation<br>
$ CDPATH=:..:~:~/projects</p>
<p>save command output to image<br>
$ ifconfig | convert label:@- ip.png</p>
<p>Add Password Protection to a file your editing in vim.<br>
$ vim -x <FILENAME></p>
<p>Remove duplicate entries in a file without sorting.<br>
$ awk '!x[$0]++' <file></p>
<p>Copy your SSH public key on a remote machine for passwordless login - the easy way<br>
$ ssh-copy-id username@hostname</p>
<p>Find Duplicate Files (based on size first, then MD5 hash)<br>
$ find -not -empty -type f -printf "%s<br>
" | sort -rn | uniq -d | xargs -I{} -n1 find -type f -size {}c -print0 | xargs -0 md5sum | sort | uniq -w32 --all-repeated=separate</p>
<p>Kills a process that is locking a file.<br>
$ fuser -k filename</p>
<p>Insert the last command without the last argument (bash)<br>
$ !:-</p>
<p>Python smtp server<br>
$ python -m smtpd -n -c DebuggingServer localhost:1025</p>
<p>Display which distro is installed<br>
$ cat /etc/issue</p>
<p>Find the process you are looking for minus the grepped one<br>
$ ps aux | grep [p]rocess-name</p>
<p>Extract tarball from internet without local saving<br>
$ wget -qO - "http://www. tarball.com/ tarball.gz" | tar zxvf -</p>
<p>Copy your ssh public key to a server from a machine that doesn't have ssh-copy-id<br>
$ cat ~/. ssh/id_rsa.pub | ssh user@machine "mkdir ~/. ssh; cat >> ~/. ssh/authorized_keys"</p>
<p>Matrix Style<br>
$ tr -c "[:digit:]" " " < /dev/urandom | dd cbs=$COLUMNS conv=unblock | GREP_COLOR="1;32" grep --color "[^ ]"</p>
<p>Replace spaces in filenames with underscores<br>
$ rename 'y/ /_/' *</p>
<p>Rip audio from a video file.<br>
$ mplayer -ao pcm -vo null -vc dummy -dumpaudio -dumpfile <output-file> <input-file></p>
<p>Google Translate<br>
$ translate(){ wget -qO- "http://ajax.googleapis.com/ajax/services/language/translate?v=1.0&q=$1&langpair=$2|${3:-en}" | sed 's/.*"translatedText":"\([^"]*\)".*}/\1<br>
/'; }</p>
<p>Inserts the results of an autocompletion in the command line<br>
$ ESC *</p>
<p>Rapidly invoke an editor to write a long, complex, or tricky command<br>
$ fc</p>
<p>A fun thing to do with ram is actually open it up and take a peek. This command will show you all the string (plain text) values in ram<br>
$ sudo dd if=/dev/mem | cat | strings</p>
<p>Graphical tree of sub-directories<br>
$ ls -R | grep ":$" | sed -e 's/:$//' -e 's/[^-][^\/]*\//--/g' -e 's/^/ /' -e 's/-/|/'</p>
<p>intercept stdout/stderr of another process<br>
$ strace -ff -e trace=write -e write=1,2 -p SOME_PID</p>
<p>Copy a file using pv and watch its progress<br>
$ pv sourcefile > destfile</p>
<p>Define a quick calculator function<br>
$ ? () { echo "$*" | bc -l; }</p>
<p>Create a CD/DVD ISO image from disk.<br>
$ readom dev=/dev/scd0 f=/path/to/image.iso</p>
<p>mkdir & cd into it as single command<br>
$ mkdir /home/foo/doc/bar && cd $_</p>
<p>Create a pdf version of a manpage<br>
$ man -t manpage | ps2pdf - filename.pdf</p>
<p>Stream YouTube URL directly to mplayer.<br>
$ i="8uyxVmdaJ-w";mplayer -fs $(curl -s "http://www.youtube.com/get_video_info?&video_id=$i" | echo -e $(sed 's/%/\\x/g;s/.*\(v[0-9]\.lscache.*\)/http:\/\/\1/g') | grep -oP '^[^|,]*')</p>
<p>Make directory including intermediate directories<br>
$ mkdir -p a/long/directory/path</p>
<p>Easily search running processes (alias).<br>
$ alias 'ps?'='ps ax | grep '</p>
<p>Multiple variable assignments from command output in BASH<br>
$ read day month year <<< $(date +'%d %m %y')</p>
<p>Remove all but one specific file<br>
$ rm -f !(survivior.txt)</p>
<p>git remove files which have been deleted<br>
$ git add -u</p>
<p>Edit a file on a remote host using vim<br>
$ vim scp://username@host//path/to/somefile</p>
<p>Job Control<br>
$ ^Z $bg $disown</p>
<p>Generate a random password 30 characters long<br>
$ s trings /dev/urandom | grep -o '[[:alnum:]]' | head -n 30 | tr -d '<br>
'; echo</p>
<p>Show apps that use internet connection at the moment. (Multi-Language)<br>
$ ss -p</p>
<p>Graph # of connections for each hosts.<br>
$ netstat -an | grep ESTABLISHED | awk '{ print $5}' | awk -F: '{ print $1}' | sort | uniq -c | awk '{ printf("%s\t%s\t",$2,$1) ; for (i = 0; i < $1; i++) { printf("*")}; print "" }'</p>
<p>Record a screencast and convert it to an mpeg<br>
$ ffmpeg -f x11grab -r 25 -s 800x600 -i :0.0 /tmp/outputFile.mpg</p>
<p>Monitor progress of a command<br>
$ pv access.log | gzip > access.log.gz</p>
<p>Search for a <pattern> string inside all files in the current directory<br>
$ grep -RnisI <pattern> *</p>
<p>Monitor the queries being run by MySQL<br>
$ watch -n 1 mysqladmin --user=<user> --password=<password> processlist</p>
<p>Get the 10 biggest files/folders for the current direcotry<br>
$ du -s * | sort -n | tail</p>
<p>Show numerical values for each of the 256 colors in bash<br>
$ for code in {0..255}; do echo -e "\e[38;05;${ code}m $ code: Test"; done</p>
<p>Recursively remove all empty directories<br>
$ find . -type d -empty -delete</p>
<p>Display a cool clock on your terminal<br>
$ watch -t -n1 "date +%T|figlet"</p>
<p>Convert seconds to human-readable format<br>
$ date -d@1234567890</p>
<p>Nice weather forecast on your shell<br>
$ curl wttr.in/seville</p>
<p>Check your unread Gmail from the command line<br>
$ curl -u username:password --silent "https://mail.google.com/mail/feed/atom" | tr -d '<br>
' | awk -F '<en try>' '{for (i=2; i<=NF; i++) {print $i}}' | sed -n "s/<title>\(.*\)<\/title.*name>\(.*\)<\/name>.*/\2 - \1/p"</p>
<p>Search commandlinefu.com from the command line using the API<br>
$ cmdfu(){ curl "http://www.commandlinefu.com/commands/matching/$@/$(echo -n $@ | openssl base64)/plaintext"; }</p>
<p>Processor / memory bandwidthd? in GB/s<br>
$ dd if=/dev/zero of=/dev/null bs=1M count=32768</p>
<p>pretend to be busy in office to enjoy a cup of coffee<br>
$ cat /dev/urandom | hexdump -C | grep "ca fe"</p>
<p>Makes the permissions of file2 the same as file1<br>
$ chmod --reference file1 file2</p>
<p>Remove security limitations from PDF documents using ghostscript<br>
$ gs -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile=OUTPUT.pdf -c .setpdfwrite -f INPUT.pdf</p>
<p>Send pop-up notifications on Gnome<br>
$ notify-send ["<title>"] "<body>"</p>
<p>(Debian/Ubuntu) Discover what package a file belongs to<br>
$ dpkg -S /usr/bin/ls</p>
<p>Mount a .iso file in UNIX/Linux<br>
$ mount /path/to/file.iso /mnt/cdrom -oloop</p>
<p>Remove a line in a text file. Useful to fix<br>
$ ssh-keygen -R <the_offending_host></p>
<p>To print a specific line from a file<br>
$ sed -n 5p <file></p>
<p>Open Finder from the current Terminal location<br>
$ open .</p>
<p>Create a persistent connection to a machine<br>
$ ssh -MNf <user>@<host></p>
<p>Run a command only when load average is below a certain threshold<br>
$ echo "rm -rf /unwanted-but-large/folder" | batch</p>
<p>Create a quick back-up copy of a file<br>
$ cp file.txt{,.bak}</p>
<p>Start COMMAND, and kill it if still running after 5 seconds<br>
$ timeout 5s COMMAND</p>
<p>Attach screen over ssh<br>
$ ssh -t remote_host screen -r</p>
<p>Show a 4-way scrollable process tree with full details.<br>
$ ps awwfux | less -S</p>
<p>List all bash shortcuts<br>
$ bind -P</p>
<p>RTFM function<br>
$ rtfm() { help $@ || man $@ || $BROWSER "http://www.google.com/search?q=$@"; }</p>
<p>Eavesdrop on your system<br>
$ diff <( lsof -p 1234) <(sleep 10; lsof -p 1234)</p>
<p>Remove all files previously extracted from a tar(.gz) file.<br>
$ tar -tf <file. tar.gz> | xargs rm -r</p>
<p>Broadcast your shell thru ports 5000, 5001, 5002 ...<br>
$ script -qf | tee >(nc -kl 5000) >(nc -kl 5001) >(nc -kl 5002)</p>
<p>Directly ssh to host B that is only accessible through host A<br>
$ ssh -t hostA ssh hostB</p>
<p>which program is this port belongs to ?<br>
$ lsof -i tcp:80</p>
<p>What is my public IP-address?<br>
$ curl ifconfig.me</p>
<p>Retry the previous command until it exits successfully<br>
$ until !!; do :; done</p>
<p>Synchronize date and time with a server over ssh<br>
$ date --set="$(ssh user@server date)"</p>
<p>Edit a google doc with vim<br>
$ google docs edit --title "To-Do List" -- editor vim</p>
<p>Run a file system check on your next boot.<br>
$ sudo touch /forcefsck</p>
<p>List only the directories<br>
$ ls -d */</p>
<p>Share a terminal screen with others<br>
$ % screen -r someuser/</p>
<p>Google text-to-speech in mp3 format<br>
$ wget -q -U Mozilla -O output.mp3 "http://translate.google.com/translate_tts?ie=UTF-8&tl=en&q=hello+world</p>
<p>Download all images from a site<br>
$ wget -r -l1 --no-parent -nH -nd -P/tmp -A".gif,.jpg" http://example.com/images</p>
<p>Download Youtube video with wget!<br>
$ wget http://www.youtube.com/watch?v=dQw4w9WgXcQ -qO- | sed -n "/fmt_url_map/{s/[\'\"\|]/<br>
/g;p}" | sed -n '/^fmt_url_map/,/videoplayback/p' | sed -e :a -e '$q;N;5,$D;ba' | tr -d '<br>
' | sed -e 's/\(.*\),\(.\)\{1,3\}/\1/' | wget -i - -O surprise.flv</p>
<p>Python version 3: Serve current directory tree at http://$HOSTNAME:8000/<br>
$ python -m http.server</p>
<p>Get your outgoing IP address<br>
$ dig +short myip.opendns.com @resolver1.opendns.com</p>
<p>Binary Clock<br>
$ watch -n 1 'echo "obase=2;`date +%s`" | bc'</p>
<p>Sort the size usage of a directory tree by gigabytes, kilobytes, megabytes, then bytes.<br>
$ du -b --max-depth 1 | sort -nr | perl -pe 's{([0-9]+)}{sprintf "%.1f%s", $1>=2**30? ($1/2**30, "G"): $1>=2**20? ($1/2**20, "M"): $1>=2**10? ($1/2**10, "K"): ($1, "")}e'</p>
<p>Duplicate installed packages from one machine to the other (RPM-based systems)<br>
$ ssh [email protected] "rpm -qa" | xargs yum -y install</p>
<p>Draw kernel module dependancy graph.<br>
$ lsmod | perl -e ' print "digraph \" lsmod\" {";<>;while(<>){@_=split/\s+/; print "\"$_[0]\" -> \"$_\"<br>
" for split/,/,$_[3]} print "}"' | dot -Tpng | display -</p>
<p>Compare two directory trees.<br>
$ diff <(cd dir1 && find | sort) <(cd dir2 && find | sort)</p>
<p>Bring the word under the cursor on the :ex line in Vim<br>
$ :<C-R><C-W></p>
<p>Remind yourself to leave in 15 minutes<br>
$ leave +15</p>
<p>make directory tree<br>
$ mkdir -p work/{d1,d2}/{src,bin,bak}</p>
<p>Convert Youtube videos to MP3<br>
$ youtube-dl -t --extract-audio --audio-format mp3 YOUTUBE_URL_HERE</p>
<p>Find out how much data is waiting to be written to disk<br>
$ grep ^Dirty /proc/meminfo</p>
<p>Use tee to process a pipe with two or more processes<br>
$ echo "tee can split a pipe in two"|tee >(rev) >(tr ' ' '_')</p>
<p>Show apps that use internet connection at the moment.<br>
$ lsof -P -i -n | cut -f 1 -d " "| uniq | tail -n +2</p>
<p>Backup all MySQL Databases to individual files<br>
$ for I in $(mysql -e 'show databases' -s --skip-column-names); do mysqldump $I | gzip > "$I.sql.gz"; done</p>
<p>Port Knocking!<br>
$ knock <host> 3000 4000 5000 && ssh -p <port> user@host && knock <host> 5000 4000 3000</p>
<p>Add timestamp to history<br>
$ export HISTTIMEFORMAT="%F %T "</p>
<p>Recursively change permissions on files, leave directories alone.<br>
$ find ./ -type f -exec chmod 644 {} \;</p>
<p>Find files that have been modified on your system in the past 60 minutes<br>
$ sudo find / -mmin 60 -type f</p>
<p>Quick access to ASCII code of a key<br>
$ showkey -a</p>
<p>Using `!#$' to referance backward-word<br>
$ cp /work/host/phone/ui/main. cpp !#$:s/host/target</p>
<p>Search recursively to find a word or phrase in certain file types, such as C code<br>
$ find . -name "*.[ch]" -exec grep -i -H "search pharse" {} \;</p>
<p>Intercept, monitor and manipulate a TCP connection.<br>
$ mkfifo /tmp/fifo; cat /tmp/fifo | nc -l -p 1234 | tee -a to.log | nc machine port | tee -a from.log > /tmp/fifo</p>
<p>Block known dirty hosts from reaching your machine<br>
$ wget -qO - http://infiltrated.net/blacklisted|awk '!/#|[a-z]/&&/./{print "iptables -A INPUT -s "$1" -j DROP"}'</p>
<p>Check site ssl certificate dates<br>
$ echo | openssl s_client -connect www.google.com:443 2>/dev/null | openssl x509 -dates -noout</p>
<p>Find files in a date range<br>
$ find . -type f -newermt "2010-01-01" ! -newermt "2010-06-01"</p>
<p>Control ssh connection<br>
$ [enter]~?</p>
<p>Run complex remote shell cmds over ssh, without escaping quotes<br>
$ ssh host -l user $(<cmd.txt)</p>
<p>Create a directory and change into it at the same time<br>
$ md () { mkdir -p "$@" && cd "$@"; }</p>
<p>Colorized grep in less<br>
$ grep --color=always | less -R</p>
<p>Exclude multiple columns using AWK<br>
$ awk '{$1=$3=""}1' file</p>
<p>ls not pattern<br>
$ ls !(*.gz)</p>
<p>output your microphone to a remote computer's speaker<br>
$ arecord -f dat | ssh -C user@host aplay -f dat</p>
<p>analyze traffic remotely over ssh w/ wireshark<br>
$ ssh [email protected] 'tshark -f "port !22" -w -' | wireshark -k -i -</p>
<p>Given a file path, unplug the USB device on which the file is located (the file must be on an USB device !)<br>
$ echo $( sudo lshw -businfo | grep -B 1 -m 1 $(df "/path/to/file" | tail -1 | awk '{print $1}' | cut -c 6-8) | head -n 1 | awk '{print $1}' | cut -c 5- | tr ":" "-") | sudo tee /sys/bus/usb/drivers/usb/unbind</p>
<p>Remove a line in a text file. Useful to fix "ssh host key change" warnings<br>
$ sed -i 8d ~/.ssh/known_hosts</p>
<p>Save a file you edited in vim without the needed permissions (no echo)<br>
$ :w !sudo tee > /dev/null %</p>
<p>Remove blank lines from a file using grep and save output to new file<br>
$ grep . filename > newfilename</p>
<p>delete a line from your shell history<br>
$ history -d</p>
<p>Get the IP of the host your coming from when logged in remotely<br>
$ echo ${SSH_CLIENT%% *}</p>
<p>Random Number Between 1 And X<br>
$ echo $[RANDOM%X+1]</p>
<p>Lists all listening ports together with the PID of the associated process<br>
$ lsof -Pan -i tcp -i udp</p>
<p>easily find megabyte eating files or directories<br>
$ alias dush="du -sm *|sort -n|tail"</p>
<p>Exclude .svn, .git and other VCS junk for a pristine tarball<br>
$ tar --exclude-vcs -cf src. tar src/</p>
<p>exit without saving history<br>
$ kill -9 $$</p>
<p>How to establish a remote Gnu screen session that you can re-connect to<br>
$ ssh -t [email protected] /usr/bin/screen -xRR</p>
<p>Copy a MySQL Database to a new Server via SSH with one command<br>
$ mysqldump --add-drop-table --extended-insert --force --log-error=error.log -uUSER -pPASS OLD_DB_NAME | ssh -C user@newhost "mysql -uUSER -pPASS NEW_DB_NAME"</p>
<p>Convert PDF to JPG<br>
$ for file in `ls *.pdf`; do convert -verbose -colorspace RGB -resize 800 -interlace none -density 300 -quality 80 $ file `echo $ file | sed 's/\.pdf$/\.jpg/'`; done</p>
<p>Find usb device<br>
$ diff <(lsusb) <(sleep 3s && lsusb)</p>
<p>find all file larger than 500M<br>
$ find / -type f -size +500M</p>
<p>notify yourself when a long-running command which has ALREADY STARTED is finished<br>
$ <ctrl+z> fg; notify_me</p>
<p>Create colorized html file from Vim or Vimdiff<br>
$ :TOhtml</p>
<p>live ssh network throughput test<br>
$ yes | pv | ssh $host "cat > /dev/null"</p>
<p>Create a nifty overview of the hardware in your computer<br>
$ lshw -html > hardware.html</p>
<p>Save your sessions in vim to resume later<br>
$ :mksession! <filename></p>
<p>Tell local Debian machine to install packages used by remote Debian machine<br>
$ ssh remotehost ' dpkg --get-selections' | dpkg --set-selections && dselect install</p>
<p>Bind a key with a command<br>
$ bind -x '"\C-l":ls -l'</p>
<p>Take screenshot through SSH<br>
$ DISPLAY=:0.0 import -window root /tmp/shot.png</p>
<p>intersection between two files<br>
$ grep -Fx -f file1 file2</p>
<p>GREP a PDF file.<br>
$ pdftotext [file] - | grep 'YourPattern'</p>
<p>Colorful man<br>
$ apt-get install most && update-alternatives --set pager /usr/bin/ most</p>
<p>copy working directory and compress it on-the-fly while showing progress<br>
$ tar -cf - . | pv -s $(du -sb . | awk '{print $1}') | gzip > out.tgz</p>
<p>prints line numbers<br>
$ nl</p>
<p>convert unixtime to human-readable<br>
$ date -d @1234567890</p>
<p>A fun thing to do with ram is actually open it up and take a peek. This command will show you all the string (plain text) values in ram<br>
$ sudo strings /dev/mem</p>
<p>Diff on two variables<br>
$ diff <(echo "$a") <(echo "$b")</p>
<p>Prettify an XML file<br>
$ tidy -xml -i -m [file]</p>
<p>Encrypted archive with openssl and tar<br>
$ tar --create --file - --posix --gzip -- <dir> | openssl enc -e -aes256 -out <file></p>
<p>Convert seconds into minutes and seconds<br>
$ bc <<< 'obase=60;299'</p>
<p>Alias HEAD for automatic smart output<br>
$ alias head='head -n $((${LINES:-`tput lines 2>/dev/null||echo -n 12`} - 2))'</p>
<p>Pipe stdout and stderr, etc., to separate commands<br>
$ some_command > >(/bin/cmd_for_stdout) 2> >(/bin/cmd_for_stderr)</p>
<p>Manually Pause/Unpause Firefox Process with POSIX-Signals<br>
$ killall -STOP -m firefox</p>
<p>Gets a random Futurama quote from /.<br>
$ curl -Is slashdot.org | egrep '^X-(F|B|L)' | cut -d \- -f 2</p>
<p>Use lynx to run repeating website actions<br>
$ lynx -accept_all_cookies -cmd_script=/your/keystroke-file</p>
<p>runs a bash script in debugging mode<br>
$ bash -x ./post_to_commandlinefu.sh</p>
<p>Instead of writing a multiline if/then/else/fi construct you can do that by one line<br>
$ [[ test_condition ]] && if_true_do_this || otherwise_do_that</p>
<p>Display a list of committers sorted by the frequency of commits<br>
$ svn log -q|grep "|"|awk "{print \$3}"|sort|uniq -c|sort -nr<br>
</p>
</body>
</html>