-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathlinux.txt
439 lines (355 loc) · 24.9 KB
/
linux.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
man -k foo (search foo in man pages descriptions)
man -wK foo (search foo in man pages bodies)
whatis (displays short descript from the manual)
which foo (locate a command foo that will be executed - useful for debugging PATH problems)
whereis foo (locate the binary, source, and manual page files for a command)
command -v foo (write a string to standard output that indicates the pathname or command that will be used by the shell; can be used in bash script instead of which to find what file will be executed in curr. environment)
history (show history of all commands in shell) - bash history is written in the file ~/.bash_history
history -c (deletes shell history from RAM)
export HISTTIMEFORMAT="[%F] [%T] " (set the HISTTIMEFORMAT variable so that the history contains date and time for each command - only for current session - add to ~/.bash_profile to make it permanent)
fc (processes command line history - open and editor to modify and reexecute previously entered commands)
locate foobar (find files by name - updatedb must be started, usually by daily cron or manually)
find /foo/bar/ -name "foobar.pdf" -print0 | xargs -0 -I {} cp {} /tmp (find all files in /foo/bar folder with name that starts with foobar and ends with pdf and copy them to /tmp folder
find . -name "foo*" -type f -mtime 0 -delete (find and delete all files in the current directory with name that starts with foo and are modified today)
find . -not -name "*.foo" (find all files not ending with .foo)
find . -not -path "./*/etc/*" (find all files not under the /etc/ subfolder)
find ../foobar/ -type f -exec ln -s {} . \; (creates symbolic links to all files from foobar folder to current folder)
$? (reads the exit status of the last command executed. After a function returns, $? gives the exit status of the last command executed in the function)
$$ (current process PID)
$! (PID of the last backgrounded process)
!! (repeat last command - useful combo - sudo !!)
!$ (last argument of the previous command)
!:n (n-th argument of the previous command)
!n (execute n-th line in history)
!-5 (execute current -5 line in history)
!foo (execute the last foo command in history)
ps aux | grep foobar (show all processes with name foobar)
ps -p $$ (displays the current shell that is used)
pstree -a (display a tree of processes with command line arguments)
kill -9 12030 (kills process with PID 12030; -9 sends KILL signal to process so use it only when absolutely necessary)
pkill -f foobar (kills all processes with name foobar)
w (who is logged and what they are doing)
last (show listing of last logged in users)
lastlog (reports the most recent login of all users or of a given user)
whoami (shows your username)
id (prints info about user: real / effective userID, groupID etc.)
top (show linux tasks / processes)
htop (proces monitor more advanced than top; shows separate cores and threads)
atop (another process monitor)
dstat (generating system resource statistics; very useful monitor tool)
free -m (display amount of free and used memory in the system -m in MB)
vmstat (display information about processes, memory, paging, block IO, traps, disks and cpu activity)
iostat -d 2 (I/O statistics for devices and partitions)
iotop (top-like I/O monitor)
netstat (network statistics tool usefull in analyzing network connections, routing tables, network interfaces)
netstat -tulpn (show services that are liestening to the TCP/UDP ports)
nmap -sS 127.0.0.1 (network exploration tool and security / port scanner - show open ports on the server; WARNING don't use this to scan remote computers, because this can be considered an attack / hacking attempt)
ss (utility for investigating sockets and services alternative to netstat)
ifstat (ethernet traffic monitor)
iftop (network traffic monitor - bandwith usage by on interface by host)
apachetop -f /var/log/apache2/access.log (displays real-time web server statistics)
mytop -uroot -p (display MySQL server performance info like `top')
ifconfig -a (display all interfaces which are currently available, even if down; used for configuring a network interface)
iwconfig (configure a wireless network interface)
ethtool eth0 (query or control network driver and hardware settings for interface eth0; useful for finding out details about the network devices)
lsb_release -a (displays distribution version information)
cat /etc/*release (displays distribution version information - centOS)
uname -a (prints more general system information)
ulimit (get and sets user/process limits)
dmidecode (displays DMI (SMBIOS) - all system information)
sysctl -a (display all kernel parameters at runtime)
cat /etc/*-release (displays distribution name and version)
cat /proc/cpuinfo (display info about cpu)
cat /proc/meminfo (display info about memory)
cat /proc/<pid>/limits (displays ulimits for the process with process id <pid>)
cat /proc/mdstat (display status of RAID array)
mdadm --detail /dev/md0 (manage MD devices aka Linux Software RAID; --detail displays detail of the md0 device)
objdump -x vmware-tools-upgrader-64| grep NEEDED (display information from object file; displays needed libraries for the executable)
lshw (list all hardware info)
lshw -C disk (display only disk info)
lsusb (display information about USB buses in the system and devices connected to them)
lspci (display information about PCI buses in the system and devices connected to them)
du -sh (display total folder size)
df -ahT /foo/bar/ (displays file system disk usage and partition types; if path is ommited all mounted disk usage is displayed)
fdisk /dev/sda (tool for command line partitioning)
mkfs -t ext4 /dev/sda1 (build ext4 filesystem on a partition sda1)
blkid (print block device attributes - useful for finding UUID of the partitions)
mount (used for mounting filesystem or displaying the mounted filesystem if used without options)
mount -a (mounts all filesystems mentioned in the /etc/fstab except for those whose line contains noauto)
mount.cifs //hostname/sharename ~/destinationFoo -o user=username (mounts windows share to a local folder; requires cifs-utils package to be installed)
iperf -s (start a server listening on TCP port 5001; used for bandwith testing)
iperf -c foobar (starts a client that connects to a foobar host where iperf server is already started and performs network throughput test)
tc (show / manipulate traffic control settings - useful for emulating slow and flaky network connections)
tc qdisc change dev eth0 root netem delay 100ms 20ms distribution normal (slow down network - add 100ms +/-20ms normaly distributed variation in delay)
tc qdisc change dev eth0 root netem loss 0.3% 25% (flaky connection - where 0.3% packages are lost and each successive probability depends by a quarter on the last one)
tc qdisc delete dev eth0 root (deletes the restrictions)
dig -x 176.9.134.62 (DNS lookup - reverse lookup of IP adress)
route (show / manipulate the IP routing table - also displays gateway)
stat foo.txt (display file status; similar to properties on win systems; displays access/modify/change dates and other useful info for the file)
file foo.txt (detect file type; -bi will detect encoding; try to use chardet if cannot detect charset properly)
chardet foo.txt (universal character encoding detector)
lsof (display all open files)
fuser (identify processes using files or sockets)
fuser -4 -v -n tcp 80 (find all processes using TCP port 80, -v verbose, -4 - IPv4)
strace -p 123 (trace system calls and signals for process with PID 123 - usefull when debugging processes. Use -f to trace forked processes and -e to see only file activity - usefull when tracking evasive config files)
telinit (change system run level)
su - foobar (login as foobar user - but spawn shell in login mode - e.g. bash reads ~/.bash_profile in login mode and ~/.bashrc in nonlogin mode)
useradd foobar (create a new user with username foobar)
userdel foobar (delete user foobar)
passwd (change user password)
vipw (edits /etc/passwd file; -s to edit /etc/shadow)
vigr (edits /etc/group file; -s to edit /etc/gshadow)
chsh -s /bin/bash foobar (change login shell for the foobar user to bash. Normal users can change only their shell, root can change any account)
chmod 644 -R foo (change permissions to the folder foo recursively)
chown administrator foo (set admnistrator user as owner of the file / folder foo)
chown admin:admingrp foo (set administrator as owner and admingrp as group of the file/folder foo)
chgrp administrator foo (set admnistrator user as group of the file / folder foo)
setfacl/getfacl (get/set file ACL - more advanced version of default file permissions)
umask 022 (default umask; sets the default permissions on the file when created. The mask is reversed from chmod - eg. umask 777 will mean that the new file will not have ---/000 permission or umask 000 that the new file will have rwx/777 permission)
head -100 foo (output the first 100 lines of the file foo)
head -n-50 foo (output all lines from file but skip last 50 lines)
tail -f foo (output appended data as the file foo grows - very useful when monitoring log files)
tail -100 foo (output last 100 lines)
tail -n+50 foo (output all lines from file but skip first 50 lines)
cat foo (output the entire file in the standard output)
grep -i "foo" bar (print lines matching "foo" in bar folder/file; -i is case insensitive; -v lines not matching; -C 20 show in context; -o show only matching; -l show only files with matches)
zgrep "foo" bar (match lines in compressing files)
yes | nl | head -100 > foobar.txt (creates foobar.txt file that contains 100 lines, each line contains line numer and "yes" string)
touch foo.bar (create file with name foo.bar)
echo "foobar" > foo.bar (creates file foo.bar if does not exists or overwrites existing file and writes foobar inside)
echo "foobar" >> foo.bar (creates file foo.bar if does not exists and writes foobar inside, appends to the file if file already exits)
tee (read from standard input and write to standard output and files)
echo "bla" | sudo tee /etc/bla (usefull when trying to echo a string to a file for which you need sudo)
cat foobar 2>&1 | tee bar.txt (redirect stderr to stdout, write it to the bar.txt file and display it to the screen)
sh deploy.sh *** OR *** ./deploy.sh (start SH script - to start a script with ./deploy.sh the execute (+X) permission must be set on thescript)
./deploy.sh & (starts the script as a asynchronous job)
sh deploy.sh &! (only for zsh - starts the script as a asynchronous job and disown the process - the disowned process will not be suspended automatically)
time foobar (runs foobar, displays time needed for running the command and summarizes system resource usage)
watch -n 5 foobar (runs command foobar periodically every 5 seconds and displays output in full screen)
watch -d ls -lah /tmp (watch as the content of a directory changes every 2 seconds)
diff -y foo bar (compares two files side-by-side; also works with directories)
sed -i "s/foo/bar/g" bazfile (global inplace search and replace in files - replaces foo with bar in file bazfile)
sed -i '' "s|foo|bar|g" (macOS requires a extension for the backup when doing in place search and replace - other characters like | or # can be used as separators)
tar cvfz foo.tar bar/ (creates gzipped tar archive with name foo.tar from the folder bar)
tar xvfz foo.tar (extracts gzipped tar in current directory)
bc -l (invokes command line calculator; -l is preloading math library to support sin, cos, exponent etc. functions)
cal -3 (displays command line calendar for 3 months)
date (print system time and date)
tzselect (debian timezone select)
update-rc.d foobar defaults (installs the init script foobar for all run levels - foobar script must be in the /etc/init.d/. This will enable to call service foobar start)
update-rc.d foobar start 80 2 3 4 5 . stop 20 S 1 6 (foobar service will be started at sequence 20 in levels 2-5 and stoped at sequence 20 in level S, 1 and 6. On debian 6 if using dependency based boot "insserv" scripts must have LSB headers)
initctl list (lists all upstart jobs - to disable upstart job foo add file /etc/init/foo.override)
apport /foo/bar/crash.report - opens apport crash log (check /var/crash or /var/log/apport.log usually contains additinal info about crash reports and coredumps)
gdb /usr/bin/php5 /path/to/coredump (this will open GNU debugger for the file and you can see backtrace with "bt" or "bt full")
apport-retrace -R -g _usr_bin_php5.1000.crash (will open gdb with the coredump extracted from the report)
systemd-analyze (analyze system boot-up performance)
systemd-analyze blame (prints a list of running units; useful for optimizing boot time)
systemctl disable vmware.service (disables starting the vmware service on boot - only on OS that's using systemd)
rabbitmqctl list_queues (shows queue list)
!!!!!!!!!!!!!!!!!!!!!!!!!!!
YUM (Yellowdog updater, modified)/ RPM
!!!!!!!!!!!!!!!!!!!!!!!!!!!
yum whatprovides fooBar (what package provides some feature or file)
yum clean all (clean all cache and metadata)
yum autoremove (remove packages that are not required by any packages - "leaf" packages)
yum search fooBar (find packages that contain fooBar)
rpm -q --whatrequires fooBar (what package requires fooBar capability)
rpm -ql package-name (list the content of the installed package)
!!!!!!!!!!!!!!!!!!!!!!!!!!!
APT (Advance Package Tool) / DPKG
!!!!!!!!!!!!!!!!!!!!!!!!!!!
apt-get install packageNameFoo (installs a packageNameFoo program from the default repository)
apt-get update (resynchronizes package index from their sources - updates versions of the apps in the APT)
apt-get purge packageNameFoo (remove packageNameFoo program and clear configuration files for the package)
apt-cache show packageNameFoo (displays detailed info about current and installed package)
apt-cache policy packageNameFoo (displays only verision info about current and installed package)
apt-cache search packageNameFoo (performs full text search on all available packages in the APT cache)
apt-cache rdepends packageNameFoo (displays all packages that are dependen on the packageNameFoo)
dpkg-query -L packageNameFoo (debian package manager: list files installed from package)
!!!!!!!!!!!!!!!!!!!!!!!!!!!
SSH
!!!!!!!!!!!!!!!!!!!!!!!!!!!
ssh [email protected] -p 12345 *** OR *** ssh hostaname.example.com -l root -p 12345 (ssh connection on server hostaname.example.com with username root on port 12345)
ssh -N -L 1234:hostname.example:2345 [email protected] (-L port forwarding - when you want to connect on server hostname.example.com on port 2345, from your machine on port 1234 - usefull to connect to restricted services via ssh; -N do not execute remote command)
ssh -D 9999 -C [email protected] (-D application-level port forwarding - usefull when wanting to connect an application through proxy on another server - e.g. connecting with Firefox remotely to an server as it was connected locally)
~/.ssh/config
Host foobar
HostName server.example.com
User foo
Port 666
LocalForward 9999 localhost:10000
IdentityFile ~/.ssh/somkeynames.key
ssh -f -N foobar (open local port fowarding: -f execute in background, -N do not execute remote command)
foobar can be any string you like to represent server name
When you're connected with SSH from server A to server B you can open port fowarding on the existing connection from server B to server A (reverse ssh tunnel)
To reverse ssh tunnel on an existing connection type:
Enter
~C
Enter
-R 22222:localhost:33333
This will open port fowarding from the server B to server A (B port is 22222, connecting port on your machine A is 33333). Port 22222 must be unused.
To copy file foo from the server you can use:
-R 22222:localhost:22
scp -P 22222 foo localhost:
!!!!!!!!!!!!!!!!!!!!!!!!!!!
SSH Keygen
!!!!!!!!!!!!!!!!!!!!!!!!!!!
ssh-keygen -a 100 -t ed25519 -C "user@hostname" (generates a ssh key, -a numbers of KDF (Key Derivation Function) rounds (higher is better), -t type of key to create, -C comment)
!!!!!!!!!!!!!!!!!!!!!!!!!!!
SFTP - secure file transfer program
!!!!!!!!!!!!!!!!!!!!!!!!!!!
sftp [email protected] (SFTP connection to remote server)
get foo.txt (when connected with sftp download the file Foo.txt from remote server)
put foo.txt (upload the foo.txt to the remote server from your local directory)
commands are executed commands on the remote server, e.g.:
cd, mkdir, ls
commands that start with "l" are executed on the local server, e.g.
lcd, lmkdir, lls
!!!!!!!!!!!!!!!!!!!!!!!!!!
IPTABLES - firewall
!!!!!!!!!!!!!!!!!!!!!!!!!!
iptables -A INPUT -s 199.1.1.1 -p tcp --destination-port 27017 -j ACCEPT (allow incoming connections on TCP protocol going to local port 27017 from IP 199.1.1.1)
iptables -A INPUT -p tcp --destination-port 27017 -j DROP (drop all incoming TCP connections going to port 27017, that are not whitelisted above)
iptables -A OUTPUT -d 199.1.1.1 -p tcp --source-port 27017 -j ACCEPT (allow outgoing connections on TCP protocol going from local port 27017 to IP 199.1.1.1)
iptables -A OUTPUT -p tcp --source-port 27017 -j DROP (drop all outgoing TCP connections from port 27017, that are not whitelisted above)
!!!!!!!!!!!!!!!!!!!!!!!!!!!
EMACS
!!!!!!!!!!!!!!!!!!!!!!!!!!!
M-x mark-word (M-@; marks current word from point to the end of the word)
M-x select-text-in-quote (M-*; selects text in quotes, parenthesis etc. - custom shortcut)
C-x C-r (open list of recent files - custom shortcut)
C-c ; (comment whole block - custom shortcut)
C-x C-f ssh:[email protected]#12345:/ (opens a file over ssh on example.com server on port 12345)
C-c right or C-c left (undo/redo window configuration)
M-x reverse-region (reverses order of lines in the regions)
M-x flop-frame (flip open frames horizontaly)
M-x kill-emacs (kill emacs server)
M-x minimap-toggle (create/kill minimap)
!!!!!!!!!!!!!!!!!!!!!!!!!!!
VIM
!!!!!!!!!!!!!!!!!!!!!!!!!!!
INSERT (keyboard button) enables editing the file
ESCAPE (keyboard button) enables entering the commands in editor
:q! (command for force exiting without changes)
:wq (save changes and exit)
:$ or g (jump to end of file)
:1 or gg (jump to first line in a file)
/ search in file (go to next result with n)
:100 (go to line number 100)
:u (undo)
yy (copy current line)
dd (cut current line)
p (paste after the current line)
:%s/foo/bar/gci (replace foo with bar; g globally, c ask for confirmation, i - case insensitive)
!!!!!!!!!!!!!!!!!!!!!!!!!!!
APACHE2
!!!!!!!!!!!!!!!!!!!!!!!!!!!
service apache2 start|graceful|graceful-stop|restart|stop or /etc/init.d/apache2 start|graceful|graceful-stop|restart|stop (graceful restarts apache2 gracefuly)
a2ensite example.com (enable virtual host site in apache. mod_rewrite module must be installed)
a2dissite example.com (disable virtual host site in apache)
a2enmod foobar (enable apache2 module foobar)
a2dismod foobar (disable apache2 module foobar)
apache2ctl -M (list all enabled modules for apache)
htpasswd -cs /path/to/some/file/foo bar (creates a new file bar at specified path with password for user bar. This file can then be used with AuthBasicProvider file and apache auth mod. -s is encrypting with SHA encryption for password. Standard settings will encrypt only first 8 chars).
!!!!!!!!!!!!!!!!!!!!!!!!!!!
MYSQL
!!!!!!!!!!!!!!!!!!!!!!!!!!!
mysql -uroot -ppassword
mysqldump -uroot -ppassword --single-transaction --routines --triggers Foo > dumpfile.sql (safest way to dump database)
!!!!!!!!!!!!!!!!!!!!!!!!!!!
MONGODB
!!!!!!!!!!!!!!!!!!!!!!!!!!!
use admin
db.runCommand({getCmdLineOpts:1}); ## displays options with which the mongod process was started (Command line parameters + parsed parameters from the config file)
mongodump -d dbNameFoo -o folderNameBar
mongorestore folderFoo
mongotop
mongostat
var rst = new ReplSetTest({name : "rstest", nodes: 3});
rst.startSet();
rst.initiate();
!!!!!!!!!!!!!!!!!!!!!!!!!!!
PosgreSQL client
!!!!!!!!!!!!!!!!!!!!!!!!!!!
psql -h 127.0.0.1 -p 5432 -U foo bar (connect with interactive terminal to a db on localhost on standard port 5432, with user foo to db bar)
\q (quit client)
\? (help with commands)
\c (connect to db)
\l (list all databases)
\dt (list tables)
\dt .* (list tables in all schemas)
!!!!!!!!!!!!!!!!!!!!!!!!!!!
GIT
!!!!!!!!!!!!!!!!!!!!!!!!!!!
git init --bare (init empty git repository that will be a remote repo)
git remote add foo ssh://[email protected]/~/bar (add remote repository named foo on server example.com in folder ~/bar )
git remote set-url http://example.com/repo origin (moves the remote repo to the new URL; useful when location of the upstream changed)
git --no-pager log (execute the log command without having paginated results)
git log --all --format='%aN %ad' (show log across all branchs, format only shows the author name and date; full set of options available in PRETTY FORMAT docs)
git push foo bar (push to remote repository foo branch bar)
git svn dcommit (commit to svn repository)
git checkout foobar (switch to branch foobar)
git clone -b foo file:///root/bar (clone branch foo from a local file)
git branch -a --no-merged foobar (show all branches that are not merged into foobar branch)
git branch --merged (show branches merged into HEAD i.e. tip of current branch)
git diff origin/master HEAD (diff the commited local changes with master branch on origin repo)
git fetch && git log ..origin/master (show incoming changes from a remote branch before mergin them; similar to hg incoming)
git log --left-right --cherry-pick --oneline foo..bar (show different commits not shared between the branches foo and bar)
git cherry foo bar (show commits from branch bar that have to be applied to branch foo)
git commit --amend -m "New commit message" (amend the tip of the current branch)
GIT_COMMITTER_DATE="`date`" git commit --amend --date "`date`" (set the commiter and author date to now; useful when squashing changes and you want the the commit to be properly timestamped)
git rebase -i origin/master (interactive rebase to "squash" the commited changes on your local repo - WARNING - this changes history so use it only when you didn't push your changes to other repos)
git reset --soft HEAD~1 (delete the last commit - WARNING -changes history)
git clean -fdi (delete untracked files from repo; -f force; -d remove untracked directories also; -i interactive)
git stash (stash the changes in a dirty working directory away)
git stash pop (remove a single stashed state from the stash list and apply it on top of the current working tree)
git stash apply (same as but do not remove the state from the stash list)
git checkout stash -- foobar (restore the file foobar to the stashed version; that will force stash to restore the stashed version of the file)
git show abcdabcd (show the log message and textual diff for the commit with hash abcdabcd)
git mergetool -t fooBar (use GUI tool fooBar for merging conflicts; meld, kdiff3)
git tag -a release/2015 -m "Foo bar tag" (create an annotated tag with a message)
git push --tags (pushes local tags to remote)
git config --global user.email "[email protected]" (set global config e-mail for all git repos)
git config --global user.name "Name" (set global config name for all git repos)
git config --global credential.helper "cache --timeout=3600" (enable password caching for 1 hour; default is 15 min)
!!!!!!!!!!!!!!!!!!!!!!!!!!!
HG
!!!!!!!!!!!!!!!!!!!!!!!!!!!
hg id (displays summary of the current state of the repository - useful for detecting revision of the working folder)
hg status --rev .:tip (dry run for update - compare the pulled changes with current status of the working directory)
!!!!!!!!!!!!!!!!!!!!!!!!!!!
SVN
!!!!!!!!!!!!!!!!!!!!!!!!!!!
svn update --set-depth exclude foobar (excludes folder from svn update - usefull when do not want to update large folders e.g. containing db data files)
svn update --set-depth infinity (restores the excluded folders so that they can be updated)
!!!!!!!!!!!!!!!!!!!!!!!!!!!
PUPPET
!!!!!!!!!!!!!!!!!!!!!!!!!!!
puppet describe -s (Prints help about Puppet resource types, providers, and metaparameters)
facter (collects and displays facts about system. Installed with puppet)
!!!!!!!!!!!!!!!!!!!!!!!!!!!
SHELL SCRIPTING
!!!!!!!!!!!!!!!!!!!!!!!!!!!
$1 (1st command line argument)
$n (n-th command line argument)
$0 (name by which the script has been invoked)
$# (number of arguments supplied, without $0)
$* (all arguments at once, but without $0)
local foo (defines local var in the function)
read (read one line from standard input - usefull when writing shell scripts and prompting user for info)
!!!!!!!!!!!!!!!!!!!!!!!!!!!
TERMINAL SHORTCUTS
!!!!!!!!!!!!!!!!!!!!!!!!!!!
Ctrl+C (kills current process by sending interrupt signal: INT)
Ctrl+D (sends the quit signal to current process: QUIT)
Ctrl+L (clear the terminal screen)
Ctrl+R (search through your command line history)
Ctrl+P / Ctrl+N / Arrow up / down (displays the previous/next commands from your history)
Shift+Insert (paste - linux only)
Alt+SysRq+reisub (magic sysreq - safely reboot frozen linux machine)
!!!!!!!!!!!!!!!!!!!!!!!!!!!
USESFUL APPS
!!!!!!!!!!!!!!!!!!!!!!!!!!!
fail2ban (monitors log files and temporarily or persistently bans failure-prone addresses by updating existing firewall rules)
etckeeper (store /etc in git, mercurial, bzr or darcs)
jpegoptim --strip-all -m85 -o -p image.jpg (optimize jpg images; compress it to 85%; -o overwrite target; -p preserve modification times)