Bash basics Flashcards
What are standard streams?
- standard output (stdout)
- standard input (stdin)
- standard error (stderr)
This is the standard for almost all unix apps. Lets us pipe input/output/error to a standard place, and know that it will work because they share this common api.
They let us use redirection.
What is redirection and what are the bash commands?
read from stdout
> write stdout to file (overwrites file)
» append stdout to file (e.g. for log files ls»_space; test.log )
< read from stdin
2> read from stderr
Command line: how do you show all running processes?
ps
Command line: what does grep stand for?
general regular expression
Command line: what are the two ways to find things on a unix machine?
grep -i ‘hey’ /opt/iul
grep options search expression directory
- a cool use case would be to grep the auth.log with a regex that catches all unauthorised users, take their IP addresses and pipe them to a ban list.
(zgrep file - searches inside gzip file, this is useful for logs bc over time, logfiles get automatically concatenated into gzip files)
find /bar -name file.txt
find directory options file/folder
useful options:
- type
- name
- empty
- executable
- writable
** finding executable/writable files would for example be useful if you want to check that you set all your permissions correctly.