-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCS Cheatsheets.textexpander
2520 lines (2212 loc) · 85.1 KB
/
CS Cheatsheets.textexpander
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
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>groupInfo</key>
<dict>
<key>expandAfterMode</key>
<integer>0</integer>
<key>groupName</key>
<string>CS Cheatsheets</string>
</dict>
<key>snippetsTE2</key>
<array>
<dict>
<key>abbreviation</key>
<string>,cosx</string>
<key>abbreviationMode</key>
<integer>0</integer>
<key>creationDate</key>
<date>2015-03-25T16:40:43Z</date>
<key>extraInfo</key>
<dict>
<key>RTF</key>
<string>{\rtf1\ansi
{\fonttbl\f0\fnil\fcharset0 Helvetica;}
{\colortbl;}
\f0\fs24 \cf0 # **Cheatsheet:** OS X Terminal\
\
alias Create an alias \uc0\u8226 \
alloc List used and free memory\
apropos Search the whatis database for strings\
awk Find and Replace text within file(s)\
\
## B\
\
basename Convert a full pathname to just a filename\
bash Bourne-Again SHell\
bg Send to background \uc0\u8226 \
bind Display readline key and function bindings \uc0\u8226 \
bless Set volume bootability and startup disk options.\
break Exit from a For, While, Until or Select loop \
builtin Execute a shell builtin \uc0\u8226 \
bzip2 Compress or decompress files\
\
## C\
cal Display a calendar\
caller Return the context of a subroutine call \uc0\u8226 \
case Conditionally perform a command \uc0\u8226 \
cat Concatenate and print (display) the content of files\
cd Change Directory \uc0\u8226 \
chflags Change a file or folder's flags\
chgrp Change group ownership\
chmod Change access permissions\
chown Change file owner and group\
chroot Run a command with a different root directory\
cksum Print CRC checksum and byte counts\
clear Clear terminal screen\
cmp Compare two files\
comm Compare two sorted files line by line\
command Run a command (not a function) \uc0\u8226 \
complete Edit a command completion [word/pattern/list] \uc0\u8226 \
continue Resume the next iteration of a loop \uc0\u8226 \
cp Copy one or more files to another location\
cron Daemon to execute scheduled commands\
crontab Schedule a command to run at a later date/time\
curl Transfer data from or to a server\
cut Divide a file into several parts\
\
## D\
\
date Display or change the date & time\
dc Desk Calculator\
dd Data Dump - Convert and copy a file\
declare Declare variable & set attributes \uc0\u8226 \
defaults Set preferences, show hidden files\
df Display free disk space\
diff Display the differences between two files\
diff3 Show differences among three files\
dig DNS lookup\
dirname Convert a full pathname to just a path\
dirs Display list of remembered directories \uc0\u8226 \
diskutil Disk utilities - Format, Verify, Repair\
disown Unbind a job from the current login session \uc0\u8226 \
ditto Copy files and folders\
dot_clean Remove dot-underscore files\
drutil Interact with CD/DVD burners\
dscacheutil Query or flush the Directory Service/DNS cache\
dseditgroup Edit, create, manipulate, or delete groups\
dsenableroot Enable root access\
dsmemberutil View user and groups rights\
dscl Directory Service command line utility\
du Estimate file space usage\
\
## E\
\
echo Display message on screen \uc0\u8226 \
ed A line-oriented text editor (edlin)\
enable Enable and disable builtin shell commands \uc0\u8226 \
env List or Set environment variables\
eval Evaluate several commands/arguments \uc0\u8226 \
exec Execute a command \uc0\u8226 \
exit Exit the shell \uc0\u8226 \
expand Convert tabs to spaces\
expect Programmed dialogue with interactive programs\
Also see AppleScript\
export Set an environment variable \uc0\u8226 \
expr Evaluate expressions\
\
## F\
\
false Do nothing, unsuccessfully\
fc Fix command (history)\
fdisk Partition table manipulator for Darwin UFS/HFS/DOS\
fg Send job to foreground \uc0\u8226 \
file Determine file type\
find Search for files that meet a desired criteria\
fmt Reformat paragraph text\
fold Wrap text to fit a specified width\
for Loop command \uc0\u8226 \
fsck Filesystem consistency check and repair\
fsaclctl Filesystem enable/disable ACL support\
fs_usage Filesystem usage (process/pathname)\
ftp Internet file transfer program\
\
## G\
\
GetFileInfo Get attributes of HFS+ files\
getopt Parse positional parameters\
getopts Parse positional parameters \uc0\u8226 \
goto Jump to label and continue execution\
grep Search file(s) for lines that match a given pattern\
groups Print group names a user is in\
gzip Compress or decompress files\
\
## H\
\
halt Stop and restart the operating system\
hash Refresh the cached/remembered location of commands \uc0\u8226 \
head Display the first lines of a file\
hdiutil Manipulate iso disk images\
history Command History \uc0\u8226 \
hostname Print or set system name\
\
## I\
\
iconv Convert the character set of a file\
id Print user and group names/id's\
if Conditionally perform a command \uc0\u8226 \
ifconfig Configure network interface parameters\
info Help info\
install Copy files and set attributes\
\
## J\
\
jobs List active jobs \uc0\u8226 \
join Join lines on a common field\
\
## K\
\
kextfind List kernel extensions\
kickstart Configure Apple Remote Desktop\
kill Stop a process from running\
\
## L\
\
l List files in long format (ls -l)\
last Indicate last logins of users and ttys\
launchctl Load or unload daemons/agents\
ll List files in long format, showing invisible files (ls -la)\
less Display output one screen at a time\
let Evaluate expression \uc0\u8226 \
lipo Convert a universal binary\
ln Make links between files (hard links, symbolic links)\
local Set a local (function) variable \uc0\u8226 \
locate Find files\
logname Print current login name\
login log into the computer\
logout Exit a login shell (bye) \uc0\u8226 \
lpr Print files\
lprm Remove jobs from the print queue\
lpstat Printer status information\
ls List information about file(s)\
lsregister Reset the Launch Services database\
lsbom List a bill of materials file\
lsof List open files\
\
## M\
\
man Help manual\
mdfind Spotlight search\
mdutil Manage Spotlight metadata store\
mkdir Create new folder(s)\
mkfifo Make FIFOs (named pipes)\
more Display output one screen at a time\
mount Mount a file system\
mv Move or rename files or directories\
\
## M\
\
nano Simple text editor\
net Manage network resources\
netstat Show network status\
networksetup Network and System Preferences\
nice Set the priority of a command\
nohup Run a command immune to hangups\
ntfs.util NTFS file system utility\
\
## O\
\
onintr Control the action of a shell interrupt\
open Open a file/folder/URL/Application\
opensnoop Snoop file opens as they occur\
osacompile Compile Applescript\
osascript Execute AppleScript\
\
## P\
\
passwd Modify a user password\
paste Merge lines of files\
pbcopy Copy data to the clipboard\
pbpaste Paste data from the Clipboard\
ping Test a network connection\
pkgutil Query and manipulate installed packages\
plutil Property list utility\
pmset Power Management settings\
popd Restore the previous value of the current directory \uc0\u8226 \
pr Convert text files for printing\
printenv List environment variables\
printf Format and print data \uc0\u8226 \
ps Process status\
pushd Save and then change the current directory\
pwd Print Working Directory \uc0\u8226 \
\
## Q\
\
quota Display disk usage and limits\
\
## R\
\
rcp Copy files between machines\
read Read one line from standard input \uc0\u8226 \
readonly Mark a variable or function as read-only \uc0\u8226 \
reboot Stop and restart the system\
return Exit a function \uc0\u8226 \
rev Reverse lines of a file\
rm Remove files\
rmdir Remove folder(s)\
rpm Remote Package Manager\
rsync Remote file copy - Sync file tree (also RsyncX)\
\
## S\
\
say Convert text to audible speech\
screen Multiplex terminal, run remote shells via ssh\
screencapture Capture screen image to file or disk\
sdiff Merge two files interactively\
security Administer Keychains, keys, certificates and the Security framework\
sed Stream Editor\
select Generate a list of items \uc0\u8226 \
set Set a shell variable = value \uc0\u8226 \
setfile Set attributes of HFS+ files\
shift Shift positional parameters \uc0\u8226 \
shopt Set shell options \uc0\u8226 \
shutdown Shutdown or restart OS X\
sips Scriptable image processing system\
sleep Delay for a specified time\
softwareupdate System software update tool\
sort Sort text files\
source Execute commands from a file \uc0\u8226 \
split Split a file into fixed-size pieces\
stop Stop a job or process\
su Substitute user identity\
sudo Execute a command as another user\
sum Print a checksum for a file\
suspend Suspend execution of this shell \uc0\u8226 \
sw_vers Print Mac OS X operating system version\
system_profiler Report system configuration\
systemsetup Computer and display system settings\
\
## T\
\
tail Output the last part of files\
tar Tape ARchiver\
tcpdump Dump traffic on a network\
tee Redirect output to multiple files\
test Condition evaluation \uc0\u8226 \
textutil Manipulate text files in various formats (Doc,html,rtf)\
time Measure Program Resource Use\
times Print shell & shell process times \uc0\u8226 \
top Display process information\
touch Change file timestamps\
tr Translate, squeeze, and/or delete characters\
trap Execute a command when the shell receives a signal \uc0\u8226 \
traceroute Trace Route to Host\
true Do nothing, successfully\
tty Print filename of terminal on stdin\
type Describe a command \uc0\u8226 \
\
## U\
\
ufs.util Mount/unmount UFS file system\
ulimit limit the use of system-wide resources \uc0\u8226 \
umask Users file creation mask\
umount Unmount a device\
unalias Remove an alias \uc0\u8226 \
uname Print system information\
unexpand Convert spaces to tabs\
uniq Uniquify files\
units Convert units from one scale to another\
unset Remove variable or function names \uc0\u8226 \
until Loop command \uc0\u8226 \
uptime Show how long system has been running\
users Print login names of users currently logged in\
uuencode Encode a binary file \
uudecode Decode a file created by uuencode\
uuidgen Generate a Unique ID (UUID/GUID)\
uucp Unix to Unix copy\
\
## V\
\
vi Text Editor\
\
## W\
\
wait Wait for a process to complete \uc0\u8226 \
wc Print byte, word, and line counts\
whatis Search the whatis database for complete words\
where Report all known instances of a command\
which Locate a program file in the user's path\
while Loop command \uc0\u8226 \
who Print all usernames currently logged on\
whoami Print the current user id and name (`id -un')\
write Send a message to another user\
\
## X\
\
xargs Execute utility - passing arguments\
\
## Y\
\
yes Print a string until interrupted\
\
}</string>
</dict>
<key>label</key>
<string></string>
<key>modificationDate</key>
<date>2015-03-25T16:40:43Z</date>
<key>plainText</key>
<string># **Cheatsheet:** OS X Terminal
alias Create an alias •
alloc List used and free memory
apropos Search the whatis database for strings
awk Find and Replace text within file(s)
## B
basename Convert a full pathname to just a filename
bash Bourne-Again SHell
bg Send to background •
bind Display readline key and function bindings •
bless Set volume bootability and startup disk options.
break Exit from a For, While, Until or Select loop
builtin Execute a shell builtin •
bzip2 Compress or decompress files
## C
cal Display a calendar
caller Return the context of a subroutine call •
case Conditionally perform a command •
cat Concatenate and print (display) the content of files
cd Change Directory •
chflags Change a file or folder's flags
chgrp Change group ownership
chmod Change access permissions
chown Change file owner and group
chroot Run a command with a different root directory
cksum Print CRC checksum and byte counts
clear Clear terminal screen
cmp Compare two files
comm Compare two sorted files line by line
command Run a command (not a function) •
complete Edit a command completion [word/pattern/list] •
continue Resume the next iteration of a loop •
cp Copy one or more files to another location
cron Daemon to execute scheduled commands
crontab Schedule a command to run at a later date/time
curl Transfer data from or to a server
cut Divide a file into several parts
## D
date Display or change the date & time
dc Desk Calculator
dd Data Dump - Convert and copy a file
declare Declare variable & set attributes •
defaults Set preferences, show hidden files
df Display free disk space
diff Display the differences between two files
diff3 Show differences among three files
dig DNS lookup
dirname Convert a full pathname to just a path
dirs Display list of remembered directories •
diskutil Disk utilities - Format, Verify, Repair
disown Unbind a job from the current login session •
ditto Copy files and folders
dot_clean Remove dot-underscore files
drutil Interact with CD/DVD burners
dscacheutil Query or flush the Directory Service/DNS cache
dseditgroup Edit, create, manipulate, or delete groups
dsenableroot Enable root access
dsmemberutil View user and groups rights
dscl Directory Service command line utility
du Estimate file space usage
## E
echo Display message on screen •
ed A line-oriented text editor (edlin)
enable Enable and disable builtin shell commands •
env List or Set environment variables
eval Evaluate several commands/arguments •
exec Execute a command •
exit Exit the shell •
expand Convert tabs to spaces
expect Programmed dialogue with interactive programs
Also see AppleScript
export Set an environment variable •
expr Evaluate expressions
## F
false Do nothing, unsuccessfully
fc Fix command (history)
fdisk Partition table manipulator for Darwin UFS/HFS/DOS
fg Send job to foreground •
file Determine file type
find Search for files that meet a desired criteria
fmt Reformat paragraph text
fold Wrap text to fit a specified width
for Loop command •
fsck Filesystem consistency check and repair
fsaclctl Filesystem enable/disable ACL support
fs_usage Filesystem usage (process/pathname)
ftp Internet file transfer program
## G
GetFileInfo Get attributes of HFS+ files
getopt Parse positional parameters
getopts Parse positional parameters •
goto Jump to label and continue execution
grep Search file(s) for lines that match a given pattern
groups Print group names a user is in
gzip Compress or decompress files
## H
halt Stop and restart the operating system
hash Refresh the cached/remembered location of commands •
head Display the first lines of a file
hdiutil Manipulate iso disk images
history Command History •
hostname Print or set system name
## I
iconv Convert the character set of a file
id Print user and group names/id's
if Conditionally perform a command •
ifconfig Configure network interface parameters
info Help info
install Copy files and set attributes
## J
jobs List active jobs •
join Join lines on a common field
## K
kextfind List kernel extensions
kickstart Configure Apple Remote Desktop
kill Stop a process from running
## L
l List files in long format (ls -l)
last Indicate last logins of users and ttys
launchctl Load or unload daemons/agents
ll List files in long format, showing invisible files (ls -la)
less Display output one screen at a time
let Evaluate expression •
lipo Convert a universal binary
ln Make links between files (hard links, symbolic links)
local Set a local (function) variable •
locate Find files
logname Print current login name
login log into the computer
logout Exit a login shell (bye) •
lpr Print files
lprm Remove jobs from the print queue
lpstat Printer status information
ls List information about file(s)
lsregister Reset the Launch Services database
lsbom List a bill of materials file
lsof List open files
## M
man Help manual
mdfind Spotlight search
mdutil Manage Spotlight metadata store
mkdir Create new folder(s)
mkfifo Make FIFOs (named pipes)
more Display output one screen at a time
mount Mount a file system
mv Move or rename files or directories
## M
nano Simple text editor
net Manage network resources
netstat Show network status
networksetup Network and System Preferences
nice Set the priority of a command
nohup Run a command immune to hangups
ntfs.util NTFS file system utility
## O
onintr Control the action of a shell interrupt
open Open a file/folder/URL/Application
opensnoop Snoop file opens as they occur
osacompile Compile Applescript
osascript Execute AppleScript
## P
passwd Modify a user password
paste Merge lines of files
pbcopy Copy data to the clipboard
pbpaste Paste data from the Clipboard
ping Test a network connection
pkgutil Query and manipulate installed packages
plutil Property list utility
pmset Power Management settings
popd Restore the previous value of the current directory •
pr Convert text files for printing
printenv List environment variables
printf Format and print data •
ps Process status
pushd Save and then change the current directory
pwd Print Working Directory •
## Q
quota Display disk usage and limits
## R
rcp Copy files between machines
read Read one line from standard input •
readonly Mark a variable or function as read-only •
reboot Stop and restart the system
return Exit a function •
rev Reverse lines of a file
rm Remove files
rmdir Remove folder(s)
rpm Remote Package Manager
rsync Remote file copy - Sync file tree (also RsyncX)
## S
say Convert text to audible speech
screen Multiplex terminal, run remote shells via ssh
screencapture Capture screen image to file or disk
sdiff Merge two files interactively
security Administer Keychains, keys, certificates and the Security framework
sed Stream Editor
select Generate a list of items •
set Set a shell variable = value •
setfile Set attributes of HFS+ files
shift Shift positional parameters •
shopt Set shell options •
shutdown Shutdown or restart OS X
sips Scriptable image processing system
sleep Delay for a specified time
softwareupdate System software update tool
sort Sort text files
source Execute commands from a file •
split Split a file into fixed-size pieces
stop Stop a job or process
su Substitute user identity
sudo Execute a command as another user
sum Print a checksum for a file
suspend Suspend execution of this shell •
sw_vers Print Mac OS X operating system version
system_profiler Report system configuration
systemsetup Computer and display system settings
## T
tail Output the last part of files
tar Tape ARchiver
tcpdump Dump traffic on a network
tee Redirect output to multiple files
test Condition evaluation •
textutil Manipulate text files in various formats (Doc,html,rtf)
time Measure Program Resource Use
times Print shell & shell process times •
top Display process information
touch Change file timestamps
tr Translate, squeeze, and/or delete characters
trap Execute a command when the shell receives a signal •
traceroute Trace Route to Host
true Do nothing, successfully
tty Print filename of terminal on stdin
type Describe a command •
## U
ufs.util Mount/unmount UFS file system
ulimit limit the use of system-wide resources •
umask Users file creation mask
umount Unmount a device
unalias Remove an alias •
uname Print system information
unexpand Convert spaces to tabs
uniq Uniquify files
units Convert units from one scale to another
unset Remove variable or function names •
until Loop command •
uptime Show how long system has been running
users Print login names of users currently logged in
uuencode Encode a binary file
uudecode Decode a file created by uuencode
uuidgen Generate a Unique ID (UUID/GUID)
uucp Unix to Unix copy
## V
vi Text Editor
## W
wait Wait for a process to complete •
wc Print byte, word, and line counts
whatis Search the whatis database for complete words
where Report all known instances of a command
which Locate a program file in the user's path
while Loop command •
who Print all usernames currently logged on
whoami Print the current user id and name (`id -un')
write Send a message to another user
## X
xargs Execute utility - passing arguments
## Y
yes Print a string until interrupted
</string>
<key>snippetType</key>
<integer>1</integer>
<key>uuidString</key>
<string>78C363E2-6943-4FE8-AA3B-1E0E330ABB99</string>
</dict>
<dict>
<key>abbreviation</key>
<string>,clinux</string>
<key>abbreviationMode</key>
<integer>0</integer>
<key>creationDate</key>
<date>2015-03-25T16:43:59Z</date>
<key>extraInfo</key>
<dict>
<key>RTF</key>
<string>{\rtf1\ansi
{\fonttbl\f0\fnil\fcharset0 Helvetica;}
{\colortbl;}
\f0\fs24 \cf0 # **Cheatsheet:** Linux Shell\
\
\
###Common Linux Shell Commands\
\
\
ls : list files/directories in a directory, comparable to dir in windows/dos.\
ls -al : shows all files (including ones that start with a period), directories, and details attributes for each file. \
\
cd : change directory \uc0\u183 \uc0\u183 cd /usr/local/apache : go to /usr/local/apache/ directory \
cd ~ : go to your home directory \
cd - : go to the last directory you were in\
cd .. : go up a directory cat : print file contents to the screen \
\
cat filename.txt : cat the contents of filename.txt to your screen \
\
chmod: changes file access permissions\
The set of 3 go in this order from left to right:\
USER - GROUP - EVERONE\
\
0 = --- No permission\
1 = --X Execute only\
2 = -W- Write only\
3 = -WX Write and execute\
4 = R-- Read only\
5 = R-X Read and execute\
6 = RW- Read and write\
7 = RWX Read, write and execute\
\
Usage: \
chmod numberpermissions filename\
\
chmod 000 : No one can access \
chmod 644: Usually for HTML pages\
chmod 755: Usually for CGI scripts\
\
\
chown: changes file ownership permissions\
The set of 2 go in this order from left to right:\
USER - GROUP\
\
chown root myfile.txt : Changes the owner of the file to root\
chown root.root myfile.txt : Changes the owner and group of the file to root\
\
\
tail : like cat, but only reads the end of the file\
tail /var/log/messages : see the last 20 (by default) lines of /var/log/messages \
tail -f /var/log/messages : watch the file continuously, while it's being updated \
tail -200 /var/log/messages : print the last 200 lines of the file to the screen\
\
more : like cat, but opens the file one screen at a time rather than all at once \
more /etc/userdomains : browse through the userdomains file. hit Space to go to the next page, q to quit \
\
pico : friendly, easy to use file editor \
pico /home/burst/public_html/index.html : edit the index page for the user's website. \
\
\
### File Editing with VI commands\
\
\
vi : another editor, tons of features, harder to use at first than pico \
vi /home/burst/public_html/index.html : edit the index page for the user's website. \
Whie in the vi program you can use the following useful commands, you will need to hit SHIFT + : to go into command mode\
\
:q! : This force quits the file without saving and exits vi\
:w : This writes the file to disk, saves it\
:wq : This saves the file to disk and exists vi\
:LINENUMBER : EG :25 : Takes you to line 25 within the file\
:$ : Takes you to the last line of the file\
:0 : Takes you to the first line of the file\
\
grep : looks for patterns in files \
grep root /etc/passwd : shows all matches of root in /etc/passwd\
grep -v root /etc/passwd : shows all lines that do not match root \
\
ln : create's "links" between files and directories\
ln -s /usr/local/apache/conf/httpd.conf /etc/httpd.conf : Now you can edit /etc/httpd.conf rather than the original. changes will affect the orginal, however you can delete the link and it will not delete the original. \
\
last : shows who logged in and when\
last -20 : shows only the last 20 logins \
last -20 -a : shows last 20 logins, with the hostname in the last field \
\
w : shows who is currently logged in and where they are logged in from.\
who : This also shows who is on the server in an shell.\
\
netstat : shows all current network connections.\
netstat -an : shows all connections to the server, the source and destination ips and ports.\
netstat -rn : shows routing table for all ips bound to the server.\
\
top : shows live system processes in a nice table, memory information, uptime and other useful info. This is excellent for managing your system processes, resources and ensure everything is working fine and your server isn't bogged down.\
top then type Shift + M to sort by memory usage or Shift + P to sort by CPU usage\
\
ps: ps is short for process status, which is similar to the top command. It's used to show currently running processes and their PID.\
A process ID is a unique number that identifies a process, with that you can kill or terminate a running program on your server (see kill command).\
ps U username : shows processes for a certain user\
ps aux : shows all system processes\
ps aux --forest : shows all system processes like the above but organizes in a hierarchy that's very useful!\
\
touch : create an empty file \
touch /home/burst/public_html/404.html : create an empty file called 404.html in the directory /home/burst/public_html/ \
\
file : attempts to guess what type of file a file is by looking at it's content. \
file * : prints out a list of all files/directories in a directory \
\
du : shows disk usage. \
du -sh : shows a summary, in human-readble form, of total disk space used in the current directory, including subdirectories.\
du -sh * : same thing, but for each file and directory. helpful when finding large files taking up space. \
\
wc : word count\
wc -l filename.txt : tells how many lines are in filename.txt \
\
cp : copy a file \
cp filename filename.backup : copies filename to filename.backup\
cp -a /home/burst/new_design/* /home/burst/public_html/ : copies all files, retaining permissions form one directory to another. \
cp -av * ../newdir : Copies all files and directories recurrsively in the current directory INTO newdir\
\
mv : Move a file command\
mv oldfilename newfilename : Move a file or directory from oldfilename to newfilename\
\
rm : delete a file\
rm filename.txt : deletes filename.txt, will more than likely ask if you really want to delete it\
rm -f filename.txt : deletes filename.txt, will not ask for confirmation before deleting.\
rm -rf tmp/ : recursively deletes the directory tmp, and all files in it, including subdirectories. BE VERY CAREFULL WITH THIS COMMAND!!! \
\
TAR: Creating and Extracting .tar.gz and .tar files\
tar -zxvf file.tar.gz : Extracts the file\
tar -xvf file.tar : Extracts the file\
tar -cf archive.tar contents/ : Takes everything from contents/ and puts it into archive.tar\
gzip -d filename.gz : Decompress the file, extract it\
\
ZIP Files: Extracting .zip files shell command\
unzip file.zip\
\
\
### Firewall - iptables commands\
\
\
iptables -I INPUT -s IPADDRESSHERE -j DROP : This command stops any connections from the IP address\
iptables -L : List all rules in iptables\
iptables -F : Flushes all iptables rules (clears the firewall)\
iptables --save : Saves the currenty ruleset in memory to disk\
service iptables restart : Restarts iptables \
\
### Apache Shell Commands\
\
\
httpd -v : Outputs the build date and version of the Apache server. \
httpd -l : Lists compiled in Apache modules\
httpd status : Only works if mod_status is enabled and shows a page of active connections \
service httpd restart : Restarted Apache web server\
\
### MySQL Shell Commands\
\
mysqladmin processlist : Shows active mysql connections and queries\
mysqladmin drop databasenamehere : Drops/deletes the selected database\
mysqladmin create databasenamehere : Creates a mysql database\
\
#### Restore MySQL Database Shell Command\
\
mysql -u username -p password databasename < databasefile.sql : Restores a MySQL database from databasefile.sql \
\
#### Backup MySQL Database Shell Command\
\
mysqldump -u username -p password databasename > databasefile.sql : Backup MySQL database to databasefile.sql\
\
kill: terminate a system process\
kill -9 PID EG: kill -9 431\
kill PID EG: kill 10550\
Use top or ps ux to get system PIDs (Process IDs) \
\
EG:\
PID\ TTY\ TIME\ COMMAND\
10550\ pts/3\ 0:01\ /bin/csh\
10574\ pts/4\ 0:02\ /bin/csh\
10590\ pts/4\ 0:09\ APP\
Each line represents one process, with a process being loosely defined as a running instance of a program. The column headed PID (process ID) shows the assigned process numbers of the processes. The heading COMMAND shows the location of the executed process. \
\
### Putting commands together\
\
Often you will find you need to use different commands on the same line. Here are some examples. Note that the | character is called a pipe, it takes date from one program and pipes it to another.\
> means create a new file, overwriting any content already there. \
>> means tp append data to a file, creating a newone if it doesn not already exist. \
< send input from a file back into a command. \
\
grep User /usr/local/apache/conf/httpd.conf |more \
This will dump all lines that match User from the httpd.conf, then print the results to your screen one page at a time. \
\
last -a > /root/lastlogins.tmp \
This will print all the current login history to a file called lastlogins.tmp in /root/ \
\
tail -10000 /var/log/exim_mainlog |grep domain.com |more\
This will grab the last 10,000 lines from /var/log/exim_mainlog, find all occurances of domain.com (the period represents 'anything', \
-- comment it out with a so it will be interpretted literally), then send it to your screen page by page. \
\
netstat -an |grep :80 |wc -l\
Show how many active connections there are to apache (httpd runs on port 80) \
\
mysqladmin processlist |wc -l\
Show how many current open connections there are to mysql}</string>
</dict>
<key>label</key>
<string></string>
<key>modificationDate</key>
<date>2015-03-25T16:43:59Z</date>
<key>plainText</key>
<string># **Cheatsheet:** Linux Shell
###Common Linux Shell Commands
ls : list files/directories in a directory, comparable to dir in windows/dos.
ls -al : shows all files (including ones that start with a period), directories, and details attributes for each file.
cd : change directory ·· cd /usr/local/apache : go to /usr/local/apache/ directory
cd ~ : go to your home directory
cd - : go to the last directory you were in
cd .. : go up a directory cat : print file contents to the screen
cat filename.txt : cat the contents of filename.txt to your screen
chmod: changes file access permissions
The set of 3 go in this order from left to right:
USER - GROUP - EVERONE
0 = --- No permission
1 = --X Execute only
2 = -W- Write only
3 = -WX Write and execute
4 = R-- Read only
5 = R-X Read and execute
6 = RW- Read and write
7 = RWX Read, write and execute
Usage:
chmod numberpermissions filename
chmod 000 : No one can access
chmod 644: Usually for HTML pages
chmod 755: Usually for CGI scripts
chown: changes file ownership permissions
The set of 2 go in this order from left to right:
USER - GROUP
chown root myfile.txt : Changes the owner of the file to root
chown root.root myfile.txt : Changes the owner and group of the file to root
tail : like cat, but only reads the end of the file
tail /var/log/messages : see the last 20 (by default) lines of /var/log/messages
tail -f /var/log/messages : watch the file continuously, while it's being updated
tail -200 /var/log/messages : print the last 200 lines of the file to the screen
more : like cat, but opens the file one screen at a time rather than all at once
more /etc/userdomains : browse through the userdomains file. hit Space to go to the next page, q to quit
pico : friendly, easy to use file editor
pico /home/burst/public_html/index.html : edit the index page for the user's website.
### File Editing with VI commands
vi : another editor, tons of features, harder to use at first than pico
vi /home/burst/public_html/index.html : edit the index page for the user's website.
Whie in the vi program you can use the following useful commands, you will need to hit SHIFT + : to go into command mode
:q! : This force quits the file without saving and exits vi
:w : This writes the file to disk, saves it
:wq : This saves the file to disk and exists vi
:LINENUMBER : EG :25 : Takes you to line 25 within the file
:$ : Takes you to the last line of the file
:0 : Takes you to the first line of the file
grep : looks for patterns in files
grep root /etc/passwd : shows all matches of root in /etc/passwd
grep -v root /etc/passwd : shows all lines that do not match root
ln : create's "links" between files and directories
ln -s /usr/local/apache/conf/httpd.conf /etc/httpd.conf : Now you can edit /etc/httpd.conf rather than the original. changes will affect the orginal, however you can delete the link and it will not delete the original.
last : shows who logged in and when
last -20 : shows only the last 20 logins
last -20 -a : shows last 20 logins, with the hostname in the last field
w : shows who is currently logged in and where they are logged in from.
who : This also shows who is on the server in an shell.
netstat : shows all current network connections.
netstat -an : shows all connections to the server, the source and destination ips and ports.
netstat -rn : shows routing table for all ips bound to the server.
top : shows live system processes in a nice table, memory information, uptime and other useful info. This is excellent for managing your system processes, resources and ensure everything is working fine and your server isn't bogged down.
top then type Shift + M to sort by memory usage or Shift + P to sort by CPU usage
ps: ps is short for process status, which is similar to the top command. It's used to show currently running processes and their PID.
A process ID is a unique number that identifies a process, with that you can kill or terminate a running program on your server (see kill command).
ps U username : shows processes for a certain user
ps aux : shows all system processes
ps aux --forest : shows all system processes like the above but organizes in a hierarchy that's very useful!
touch : create an empty file
touch /home/burst/public_html/404.html : create an empty file called 404.html in the directory /home/burst/public_html/
file : attempts to guess what type of file a file is by looking at it's content.
file * : prints out a list of all files/directories in a directory
du : shows disk usage.
du -sh : shows a summary, in human-readble form, of total disk space used in the current directory, including subdirectories.
du -sh * : same thing, but for each file and directory. helpful when finding large files taking up space.
wc : word count
wc -l filename.txt : tells how many lines are in filename.txt