### Commands by knoppix5 (66) the last day the last week the last month all time sorted by date votes

• Meaning of switches (see man page too): v verbose p ignore mode (permissions) o ignore owner, group t ignore time of modification Disadvantage: If you modify any linked file, this will propagate to all other files which occupy the same space. Show Sample Output

1
· 2012-04-09 12:40:38
• optionally you can add |cut -d' ' -f2|uniq to the end of the command line.

0
for a in $(cat sample.txt); do echo "$(wc -m<<<$a)$a";done|sort -n
· 2012-03-15 08:51:42

• 0
strings -f sample.txt
· 2012-03-15 08:27:07
• Bash only, no sed, no awk. Multiple spaces/tabs if exists INSIDE the line will be preserved. Empty lines stay intact, except they will be cleaned from spaces and tabs if any available.

5
while read l; do echo -e "$l"; done <1.txt >2.txt · 2012-03-13 14:27:49 • 0 GET www.example.com · 2012-03-07 08:31:45 • Clean output, if used in scripts: GET checkip.dyndns.org|grep -o '[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}' or GET icanhazip.com Show Sample Output 2 GET checkip.dyndns.org · 2012-03-07 07:55:42 • Alternative if "Lazy unmount" (umount -l) doesn't obey. Alternative for NFS: umount -f /media/sdb1 Use with caution: forcing to unmount a busy partition can cause data loss! 1 fuser -km /media/sdb1 · 2012-02-27 13:41:05 • works in bash Show Sample Output 8 grep$'\t' sample.txt
· 2012-02-21 10:54:56
• Output of this command is the difference of recursive file lists in two directories (very quick!). To view differences in content of files too, use the command submitted by mariusbutuc (very slow!): diff -rq path_to_dir1 path_to_dir2 Show Sample Output

3
diff --suppress-common-lines -y <(cd path_to_dir1; find .|sort) <(cd path_to_dir2; find .|sort)
· 2012-02-13 12:49:33
• Every 20 minutes test if host with IP 192.168.0.14 is 'dead' or not reachable. The line should be put in your crontab file.

-4
10,30,50 * * * * ping -q -c1 -w3 192.168.0.14 | grep '1 received' - || mail -ne -s'Host 192.168.0.14 not reachable' [email protected]
· 2012-02-06 10:42:46
• Every 20 minutes ping host with IP address 192.168.0.14. If it's not 'alive' or not reachable, then display something eye-catching (here xeyes) on the desktop. Hint for newbies: edit crontab with crontab -e

-2
10,30,50 * * * * ping -q -c1 -w3 192.168.0.14 | grep '1 received' - || env DISPLAY=:0 xeyes
· 2012-02-06 09:40:11
• You can compare directories on two different remote hosts as well: diff -y <(ssh [email protected] find /boot|sort) <(ssh [email protected] find /boot|sort) To avoid password-prompt on remote host just generate the rsa key locally and copy it to remote host: ssh-keygen -t rsa then ssh [email protected] "mkdir .ssh" then scp .ssh/id_rsa.pub [email protected]:; .ssh/authorized_keys2

3
diff -y <(ssh [email protected] find /boot|sort) <(find /boot|sort)
· 2012-01-31 15:04:30
• If any changes have been made to the package while it was unpacked (ie, conffiles files in /etc modi‐fied), the new package will inherit the changes. This way you can make it easy to copy packages from one computer to another, or to recreate packages that are installed on your system, but no longer available elsewhere. Note: dpkg-repack will place the created package in the current directory. Show Sample Output

8
dpkg-repack firefox
· 2012-01-13 11:47:40
• This command does the following: - converts any sequence of multiple spaces/tabs to one space only - completely removes any space(s)/tab(s) at the end of each line (If spaces and tabs are mixed in a sequence i.e. [tab][tab][space][tab], you have to execute this command twice!) Show Sample Output

-4
sed -i "s/$$\x09\{1,\}$$\|$$\{1,\}$$/ /g;s/$$\x09\{1,\}$$\|$$\{1,\}$$//g" brisati.txt
· 2011-12-12 10:24:03
• Schematics: command [options] [paste your variable here] parameter command [options] [paste entire column of variables here] parameter ... (hard-code command "c" and parameter "e" according to your wishes: in example shown command = "cp -a" and parameter = "~") Features: - Quick exchange only variable part of a long command line - Make variable part to be an entire column of data (i.e. file list) - Full control while processing every single item Hints: Paste column of data from anywhere. I.e. utilize the Block Select Mode to drag, select and copy columns (In KDE Konsole with Ctrl+Alt pressed, or only Ctrl pressed in GNOME Terminal respectively). Disadvantages: You can paste only one single variable in a row. If there are more space separated variables in a row only first one will be processed, but you can arrange your variables in a column instead. To transpose rows to columns or vice versa look at Linux manual pages for 'cut' and 'paste'. TODO: - add edit mode to vary command "c" and parameter "e" on the fly - add one edit mode more to handle every list item different - add y/n/a (=All) instead of only y(=default)/n to allowed answers Disclaimer: The code is not optimized, only the basic idea is presented here. It's up to you to shorten code or extend the functionality. Show Sample Output

-1
c="cp -a";e="~";echo -e "\npaste\n";i=0;k="1"; while [[ "$k" != "" ]]; do read -a k;r[i]=$k;((i++));done;i=0;while :;do t=${r[i]};[ "$t" == "" ] && break; g=$(echo$c ${r[i]}$e);echo -e $g "\ny/n?";read y;[ "$y" != "n" ] && eval $g;((i++));done · 2011-12-04 12:45:44 • This alias is meant to append n (here is n=10) most recently used cd commands to the bottom of history file. This way you can easily change to one of previous visited directories simply by hitting 1-10 times arrow up key. Hint: You can make more aliases implying the same rule for any set of frequently used long and complex commands like: mkisof, rdesktop, gpg... 1 alias cdd="history -a && grep '^ *[0-9]* *cd ' ~/.bash_history| tail -10 >>~/.bash_history && history -r ~/.bash_history" · 2011-07-13 09:44:16 • < 1 2 3 ### What's this? commandlinefu.com is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down. ### Check These Out HTTP Get of a web page via proxy server with login credentials If you are behind a proxy server and have to authenticate with proxy server to browser web pages then you have to pass proxy server address and its port number along with user credentials to curl to got GET the page using curl. Example : "curl -U srikanth -x 167.85.103.70:8080 http://www.yahoo.com". In case you don't specify the password (as in the above example), curl will prompt to enter the password at the command line. use the real 'rm', distribution brain-damage notwithstanding The backslash avoids any 'rm' alias that might be present and runs the 'rm' command in$PATH instead. In a misguided attempt to be more "friendly", some Linux distributions (or sites/etc.) alias 'rm' to 'rm -i'. Unfortunately, this trains users to expect that files won't actually be deleted until they okay it. This expectation will fail with catastrophic results when they use other distributions, move to other sites, etc., and doesn't really even work 100% even with the alias. It's too late to fix 'rm', but '\rm' should work everywhere (under bash).

Based on capsule8 agent examples, not rigorously tested

Install pip with Proxy
Installs pip packages defining a proxy

Batch Convert SVG to PNG (in parallel)
Use GNU Parallel: short, easy to read, and will run one job per core.

Based on capsule8 agent examples, not rigorously tested

Vi - Matching Braces, Brackets, or Parentheses
This is a simple command for jumping to the matching brace, square bracket, or parentheses. For example, it can take you from the beginning of a function to the end with one key stroke. To delete everything between the pairs of {}, [], or (), issue the command: $d% To replace text between pairs of braces, brackets, or parentheses, issue the command:$ c% You can also use this command to find out if an opening brace has been properly closed.

ruby one-liner to get the current week number

Length of longest line of code
Here's an awk version.

Quickly (soft-)reboot skipping hardware checks
If you are doing some tests which require reboots (e. g. startup skripts, kernel module parameters, ...), this is very time intensive, if you have got a hardware with a long pre-boot phase due to hardware checks. At this time, kexec can help, which only restarts the kernel with all related stuff. First the kernel to be started is loaded, then kexec -e jumps up to start it. Is as hard as a reboot -f, but several times faster (e. g. 1 Minute instead of 12 on some servers here).