Snippets Flashcards
1
Q
How to compress using tar
A
tar -zcvf archive-name.tar.gz directory-name
Where,
- <kbd>-z<kbd> : Compress archive using gzip program</kbd></kbd>
- <kbd>-c</kbd>: Create archive
- <kbd>-v</kbd>: Verbose i.e display progress while creating archive
- <kbd>-f</kbd>: Archive File name
2
Q
How to uncompress using tar
A
$ tar -zxvf prog-1-jan-2005.tar.gz
Where,
- <kbd>-x</kbd>: Extract files
3
Q
Checking the size of a folder
A
$ du -sh
4
Q
Tmux start a new session
A
tmux new -s [name of session]
5
Q
Check tmux sessions
A
tmux ls
6
Q
Detach from tmux session
A
ctrl+b d
7
Q
In tmux, to split a pane horizontally
A
ctrl+b "
8
Q
In tmux, To split pane vertically
A
ctrl+b %
9
Q
In tmux to move from pane to pane
A
ctrl+b [arrow key]
10
Q
In tmux, expand the pane down a few lines
A
ctrl+b :
11
Q
Tmux, Kill named session
A
tmux kill-session -t [name of session]
12
Q
tmux, Kill current pane
A
ctrl+b x
13
Q
Kill tmux server, along with all sessions:
A
tmux kill-server
14
Q
A very simple backup script
A
#!/bin/bash OF=/var/my-backup-$(date +%Y%m%d).tgz tar -czvf $OF /home/me/
15
Q
Functions and Local variables in bash.
A
HELLO=Hello function hello { local HELLO=World echo $HELLO } echo $HELLO hello echo $HELLO