meta data for this page
This is an old revision of the document!
Bash / Shell
<command> & | start and background |
<command> && | start and wait for success |
> | write to new file (file reset is first operation) |
>> | append to existing file |
| | pipe output |
diff | show differences |
Headline
tar -tvf | List with details |
tar czf data.tar.gz <folder/files> | compress file |
tar -cjf archive.tar.bz2 <folder/files> | compress with bzip2 |
tar -xzf data.tar.gz | decompress file |
tar -rvf archive.tar newfile | append to file |
Terminal Shortcuts
CTRL
| +a | Go to beginning of commandline |
| +e | Go to end of command line |
| +u | Delete to line begin |
| +k | Delete to line end |
| +c | kill current process |
| +z | put current process in background |
Background processes
jobs | list jobs |
fg %# | move to foreground |
bg | continue in background |
kill %# or kill <pid> | kill process |
kill -9 .. | terminate |
Filtering
grep | Find strings in files |
sort | Sort file |
sort | uniq, sort -u | Sort & remove duplicates |
wc | word count |
awk | don't ask |
sed | replace characters in file |
jq, jq . | filter json |
Search
Others
echo 'ABC=' | base64 -d | decode base64 |
md5sum <file>, sha256sum <file> | create checksum |
| visidata | search tabular/log files |
Visidata
<source> Control-h Open the help menu Control-c Abort the current command Control-q Force-quit VisiData entirely q Quit the current VisiData “sheet” gq Quit all VisiData sheets and exit gracefully Shift-U Undo Shift-R Redo </source>
<source> / + regex Search forward in current column ? + regex Search backward in current column g/ + regex Search forward in all columns g? + regex Search backward in all columns </source>
Log analysis
<source bash> sudo awk '{print $1" "$2" "$3, $4, $5, substr($0, index($0,$6))}' /var/log/auth.log | jq -R -c 'split(" ") | {timestamp: (.[0]+" "+.[1]+" "+.[2]), hostname: .[3], process: .[4], message: .[5:] | join(" ")}' > auth.json </source>