= GNU Tools Reloaded =
title: "GNU Tools Reloaded"
page: http://www.guckes.net/talks/gnu_tools.txt
page: http://www.guckes.net/talks/gnu_tools.html
latest change: Fri Nov 11 14:23:42 CET 2016
"some GNU tools explained.."
= description =
show some GNU tools by examples.
practical stuff for everyday use.
= BEGIN =
welcome! :-)
"wir können über alles sprechen -
aber nicht über 40 minuten."
"we can talk about anything -
but not about/over 40 mins."
so.. 40mins first.. then a PAUSE.
then another 40mins. and Q&A.
and maybe more in another room
if you are interested in more.
download this file with:
$ wget http://www.guckes.net/talks/gnu_tools.txt
send questions to:
Sven Guckes mailto:gnu_tools@guckes.net
here we go..
= SHELL =
bash and zsh
moving the cursor, deleting+inserting, kill ring..
see also: http://www.guckes.net/Setup/bashrc
== moving about ==
CTRL-A CTRL-E
CTRL-B CTRL-F
ALT-B ALT-F
== deleting ==
CTRL-W
CTRL-K CTRL-U
== inserting ==
CTRL-Y
from "kill ring":
ALT-Y ALT-Y ..
== last word ==
inserting last word from last line -> M-. (meta-dot)
== clear ==
presentations of commands on an 80x25 terminal
is usually too small to be readable on videos.
so - use a bigger font, a shorter prompt - and
clear the screen for every new command/context.
$ clear
clears the screen
drawback:
[-] *six* keys to type!
[-] this adds an extra command to the history
CTRL-L:
[+] only 1.5 keys to type.
[+] does clear the screen.
[+] *keeps* the input!
[+] no extra entry in history.
== exit ==
exiting the shell:
$ exit
[+] should work for all shells. :-)
[-] five keys to type. :-(
alternative:
CTRL-D
[+] only 1.5 keys to type. \o/
catch: must be given as *first* character of input.
bash: IGNOREEOF
== prompts ==
changing prompt from long to short:
zsh> bash
4.3.30 guckes@kudu:~> echo $PS1
\V \u@\h:\w>
zsh:
alias __="PS1='%n@%m:%4c%1v> '"
alias _='PS1='\''$ '\'
switch to short prompt.
[zsh] guckes@kudu:~> _
$ ...
zsh> __
guckes@kudu:~>
= Jobs =
zsh> bindkey -s '^z' "fg\r"
$ sleep 42
^Z
$ ^Z
== Event Designators ==
$ touch filename
$ ls filename
$ !! -h
$ !! -l
zsh: inline expansion of "!!"
alternative:
$ touch filename
$ ls filename
$ ls M-. -hl
"grouped switches": "-hl"
$ mount /dev/foo /foo
mount: only root can do that
$ sudo !!
== substitution ==
"^foo^bar"
$ systemctl start dienst
$ ^start^status
s^...^...^
$ systemctl status dienst
TODO add function to make that substitution
see also: man bash -> "Event Designators"
== HISTORY ==
bash:
export HISTIGNORE=\
"bg:cd:date:df:du:exit:fg:ll:ls:pwd:rehash:source:su:sudo:top:w"
== pwd ==
might be a built-in:
$ which -a pwd
pwd: shell built-in command
/bin/pwd
pwd: options -L and -P
guckes@kudu:~/.P> pwd -L
/home/user/guckes/.P
guckes@kudu:~/.P> pwd -P
/home/www/guckes/public_html
= echo =
option "-n": "no newline"
$ echo -n foo; echo bar
foobar
= env =
just the variable names:
$ env | sed 's/=.*//'
$ env | sed 's/=.*//' | sort
= less =
$ man less | grep -A 1 NAME
NAME
less - opposite of more
configuration:
see also: http://www.guckes.net/less/index.html
19:45 PAUSE
19:57 cont..
= man =
$ man -k less
$ apropos less
option "-r": regular expression
$ apropos -r less$
$ apropos -r '^vi' | sort | less +/vi
= mount =
mount? mnt!
alias mnt='mount | column -t | less -S'
= od =
"od - dump files in octal and other formats"
option -a -> ASCII
$ od -a filename
$ xxd filename (comes with vim)
$ bvi filename binary editor
= shuf =
choose 6 random values from 1 to 49:
$ seq 49 | shuf -n 6
-------------------------------------------------------------------
BIGGER PROGRAMS
-------------------------------------------------------------------
= inxi =
$ inxi -nb
http://code.google.com/p/inxi/
https://storage.googleapis.com/google-code-archive-source/v2/code.google.com/inxi/source-archive.zip
admins: please install! :)
= mutt =
display-filter!
color for index and body - "bunt ist meine lieblingsfarbe"
list-reply
save-hook bedingung ~/Mail/foo
+ tag-prefix -> "save all tagged messages"
signatures:
:r ~/.signature
:r ~/.sig.linuxhotel
signature file -> extraction via agrep/awk
and now... neomutt!
= screen =
multiple views of the same session
copy mode
exchange file (readbuf, writebuf)
hardcopy
monitor for activity
monitor for silence
multi-user mode
-> screen training
20:48 PAUSE
20:53 cont..
= vim =
i_CTRL-D + foo() i_CTRL-T (de)indent current line
macro recording
regexes -> takes time!
:options
abbreviations: dddd -> YYYY-MM-DD [uses strftime()]
mappings: ,, -> :w
dG "delete to end" -> talk on "small commands"
:r!command -> read in output of "command" after current line
!!date -> replace current line with output of "date"
>> -> shift current line
g? -> rot13
gq -> zitierten text umbrechen in emails
:g/RE/ s:foo:bar
:v/./d
== vimdiff ==
editing /etc/passwd
-> vim training
21:37 ENDE
= zsh =
== global aliases ==
alias -g G='| grep'
G grep
GG grep --color
S sort
W wc -l
H head only
T tail only
L catch with less
U catch with urlview
V catch with vim
P pipe oooon! \o/ -> command1 P command2
-> zsh training
= Contact =
comments? questions? contact me! :-)
Sven Guckes gnu_tools@guckes.net
gpg keys: 1024R/57F77F09 and 8000R/0185391B
= Events =
when+where has it happened?
2016-11-10 Do 19-21h @LinuxHotel
https://pad.linuxhotel.de/p/cli
= Links =
https://wiki.lpi.org/wiki/LPIC-1#Topic_103:_GNU_and_Unix_Commands
bash echo env export pwd set+unset man uname history .bash_history
cat cut expand fmt head join less nl od paste
pr sed sort split tail tr unexpand uniq wc
= TODO =
smore more ideas..
find: find . -xdev -type f -print0 | sort -z | xargs -0 cksum > /run/cksum.backup
mkdir: option -p
shell: reverse-i-search CTRL-R and CTRL-S
shell: alias dfg -> df -h
shell: exec $SHELL
sort: option "-u" -> unique
uniq: option "-c" -> count
alias laststats="last|sed 's/ .*//'|sort|uniq -c|sort -n -r|less"
TODO gnuplot! get data from US elections.
TODO add a few tasks for the audience. "make them *work*." ;-)
$ grep change: gnu_tools.txt
$ wc -l gnu_tools.txt
vim: set et fenc=latin1 ft=sven tw=999 nowrap: THPXRF EOF