Bash basics Flashcards

1
Q

What are standard streams?

A
  • 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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is redirection and what are the bash commands?

A

read from stdout
> write stdout to file (overwrites file)
» append stdout to file (e.g. for log files ls&raquo_space; test.log )
< read from stdin
2> read from stderr

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Command line: how do you show all running processes?

A

ps

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Command line: what does grep stand for?

A

general regular expression

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Command line: what are the two ways to find things on a unix machine?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly