Tools

Shell

From personal use

^ : Control key
meta : Alt key

  • command-line calculations using bc by Rob Newcater, Basically Tech 2006
  • using SSH for tunneling
    • man:ssh and man:sshd
    • see Censorship#DIY to tunnel your way out (get)
    • -R on ssh and GatewayPorts yes on sshd to tunnel your way in (share)
      • Breaking Firewalls with OpenSSH and PuTTY Mike Chirico
      • ssh me@server.tld -R binding_address.tld:remoteport:127.0.0.1:443 -N
        • ideally you would share an encrypted protocol else anybody monitoring the client to your shared service will be able to record the content
      • consider Lighttpd/Apache mod_proxy or CGI to convert the specific port to a proper URL
  • PATH=$PATH:~/bin/ && export PATH
  • ^T : transpose_characters
    • note that those text edits are coherent with irssi (cf Irssi)
  • ^K : erase_to_end_of_line
  • meta-b : backward_word
  • meta-f : forward_word
  • meta-d : delete_next_word
  • meta-Delete : delete_previous_word
  • man : help for most available commands
  • apropos : find the command that does what you want to do
  • locate : find files listed thanks to updatedb
  • ^R : history search
  • cd - : go back to the last changed directory
  • env : ...
  • encapsulate through pipes (thanks to sed)
    • grep term ~/file | sed "s/$/<br \/>/" | sed "$ s/^/<html>/" | tac | sed "$ s/$/<\/html>/" > ~/web/mypaths/myfile.html

Windows cmd.exe shell

  • devcon to unmount devices including USB keys
    • devcon remove @usb\vid*
  • Windows Server 2003 Resource Kit Tools including timeit
  • fsutil volume diskfree C: : free space (in bytes) in the C: hard drive
  • shutdown -r -t 0 : reboot now
    • shutdown -a : abort shutdown
  • cd /D x:\path\
    • actually switches to the other directory on the other drive
  • packing and sending daily backup
    • set dt=%date:~10,4%%date:~4,2%%date:~7,2%
    • 7z a internalwiki_%dt%.tar wiki
    • 7z a internalwiki_%dt%.tar.bz2 internalwiki_%dt%.tar
    • del internalwiki_%dt%.tar
    • pscp internalwiki_%dt%.tar.bz2 user@server.tld:/home/user/backups_path/
  • tasklist : list the active processes
    • WMIC PROCESS get Caption,Commandline,Processid
  • doskey /history > mycommands.txt : save the commands you typed in the mycommands.txt file
  • path %path%;c:\myother\bin\path\; : appends the directory to the current path
    • note that this is not a permanent change
  • 7z : use 7zip command-line interface
    • 7z a internalwiki.tar wiki then 7z a internalwiki.tar.bz2 internalwiki.tar
  • Stupid Command Prompt Tricks by Jeff Atwood, Coding Horror 2005
  • Windows : Command Processor, PC Tools
  • PowerShell by Microsoft
    • recommended by Jonathan

Useful tools

  • backup with relative path and checksum
    • DATE=$(date +%F-%HH%M) && tar -C /home/user/path/data/ -cvf ~/place/to/share/backup.${DATE}.tar . && md5sum ~/place/to/share/backup.${DATE}.tar > ~/place/to/share/backup.${DATE}.tar.md5
    • this should be put within a script and in crontab

Scripting

Warning, this section is really shell specific (i.e. bash != zsh ...)

  • this does that
  • this other command is nice

Check my ~/backups/*.sh and ~/bin/*.sh for examples

Bash

  • $((do some math))
  • echo $(( $(cat file | sed "s/.*\d//" | wc -l) * 1024))

Awk

  • awk '{print $2}'
  • grep action=edit page_generated.txt | awk '{ SUM += $2} END {print SUM}'

Distributions

Debian

  • http://packages.qa.debian.org/w/win32-loader.html
    • parameters to load an ISO file
  • Debian Backports
    • recompiled packages from testing (mostly) and unstable (in a few cases only, e.g. security updates), so they will run without new libraries (wherever it is possible) on a stable Debian distribution.
  • installing from source
    • apt-get update
    • apt-get install build-essential
    • apt-get -b source package
    • dpkg -i package_versionnumber_arch.deb
    • updatedb
    • locate package | more
  • cat /etc/debian_version

Configuration management software

See also the WebWorkersCampParis talk and the "infrastructure as code" paradigm presented during Automated Infrastructure is on the Menu with Chef, O'Reilly Webcast July 2010 .

To explore

See also

  • my related tools pages
  • shell_sink web accessible version of your bash history, you can search, annotate and tag it.
  • commandlinefu.com the place to record those command-line gems that you return to again and again.
  • Blinkenshell.org
  • Embedding shell clients
  • PuTTY Tray improved version of PuTTY (Win32). It features some cosmetic changes, and a number of addons to make it more useful and much more fun to use.
  • Stow GNU Project
    • program for managing the installation of software packages, keeping them separate (/usr/local/stow/emacs vs. /usr/local/stow/perl, for example) while making them appear to be installed in the same place (/usr/local).
  • Advanced Bash-Scripting Guide An in-depth exploration of the art of shell scripting by Mendel Cooper
  • Linux-libre project removing software that is included without source code, with obfuscated or obscured source code, under non-Free Software licenses, that do not permit you to change the software so that it does what you wish, and that induces or requires you to install additional pieces of non-Free Software.
  • Shell Commander PHP script, that allows remote execution of shell commands (like SSH client) through a web browser.

Note

My notes on Tools gather what I know or want to know. Consequently they are not and will never be complete references. For this, official manuals and online communities provide much better answers.

Green Marinee theme adapted by David Gilbert, powered by PmWiki