Linux
From SpenchWiki
Contents
[hide]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
Screen
- -S <session name> Start session with name
- -e <program to start>
- -r Attach
- -ls List sessions
- -x <session name> Attach to open session
^A followed by
- d detach
- c new window
- A rename window
- w list windows
- " selectable window list
- 0-9 select window 0-9
- TAB change region focus
- Q make current region only one visible
- X kill region
- ^\ kill everything (including all processes)!
- M monitor window for activity
- _ monitor window for inactivity
- a send ^A to session
- ? list all possible commands
- : screen command prompt
- :sessionname <name>
- :multiuser on
- :aclchg <user> +r "#" Read perms on all windows
- :acldel <user>
http://www.bangmoney.org/presentations/screen.html
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'