Difference between revisions of "Linux"

From SpenchWiki
Jump to: navigation, search
(Console shortcuts)
Line 1: Line 1:
 +
== Console shortcuts ==
 +
 +
* Ctrl + Z: stop (fg/bg)
 +
* Ctrl + Y: stop only when process tries to read input from console
 +
* Ctrl + S/Q: XON/XOFF (Shift + PgUp/PgDn to scroll)
 +
* Ctrl + L: clear screen
 +
* Ctrl + A/E: beginning/end of line
 +
* Alt + F/B: forward/back one word
 +
 
== Useful apps ==
 
== Useful apps ==
  

Revision as of 22:35, 11 March 2010

Console shortcuts

  • Ctrl + Z: stop (fg/bg)
  • Ctrl + Y: stop only when process tries to read input from console
  • Ctrl + S/Q: XON/XOFF (Shift + PgUp/PgDn to scroll)
  • Ctrl + L: clear screen
  • Ctrl + A/E: beginning/end of line
  • Alt + F/B: forward/back one word

Useful apps

Squid:

  • squidtaild
  • squidclient
  • srg
  • squidview
  • calamaris
  • sarg

Highlighter:

  • ccze

Cleaning useless Debian items:

  • localepurge
  • deborphan
  • debfoster

Monitoring:

  • iptraf
  • bmon

WebDAV:

  • cadaver
  • nd

Redirection

  • stdout and/or stderr:
foo > bar 2>&1
command &>file
command >&file
foo 2>&1 | bar

command1 2> file1

Recording the screen

Recording:

script -t 2> tutorial.timing -a tutorial.session

Playback:

scriptreplay tutorial.timing tutorial.session

Prevent screen blanking

setterm -blank 0

Using rsync for local file comparisons

rsync -avnhW "Desktop/My Passport/Mitsubishi090109_10" "/Volumes/My Passport"

tcpdump with greater snarf size

tcpdump -s 1500 -w out-file.pcap <expression>

Scripts

  • lesspipe.sh

Use in conjuction with environment variables:

export LESS=-R
export LESSOPEN="|/usr/local/bin/lesspipe.sh %s"

Script:

#!/bin/sh
case "$1" in
*.log.[0-9]*.gz) gunzip -c $1 2>/dev/null | ccze -A
        ;;
*.log|*.log.[0-9]*) cat $1 | ccze -A
        ;;
*.gz) gunzip -c $1 2>/dev/null
        ;;
esac
  • Nice terminal colours:
export PAGER='less -R -s -i'
# Blink
export LESS_TERMCAP_mb=$'\E[05;31m'
# Bold
export LESS_TERMCAP_md=$'\E[01;33m'
# End above modes
export LESS_TERMCAP_me=$'\E[0m'
# End standout
export LESS_TERMCAP_se=$'\E[0m'
# Stand out
export LESS_TERMCAP_so=$'\E[00;44;33m'
# End underline
export LESS_TERMCAP_ue=$'\E[0m'
# Underline
export LESS_TERMCAP_us=$'\E[04;32m'
  • Log file viewers:
sudo tail -F -n 50 --max-unchanged-stats=5 /var/log/apache2/access.log | ccze
sudo tail -F --max-unchanged-stats=5 -n 50 /var/log/squid/access.log | ccze -C
sudo tail -F --max-unchanged-stats=5 -n 100000 /var/log/auth.log 2> /dev/null | grep --line-buffered -E "(sshd).*(Accepted)" | ccze
sudo watch -d -t 'netstat -p -t | grep ESTABLISHED'