|
File system Root
|
/ - top of file hierarchy
|
|
Path
|
either absolute or relative
|
|
pwd
|
present working directory
|
|
cd
|
change directory
|
|
~
|
indicates home directory
|
|
..
|
moving up to folder above current
|
|
.
|
current folder
|
|
ls
|
lists all
|
|
ls -F
|
lists only folders
|
|
ls -l
|
show details
|
|
ls -a
|
show hidden files
|
|
ls -al
|
show hidden files + details
|
|
mkdir
|
creates folders
|
|
rmdir
|
removes folders
|
|
cp
|
copy
|
|
mv
|
move; can also be used to rename a file
|
|
rm
|
remove command
|
|
-i
|
adds interactivity; warning if will delete an existing file
|
|
ls -al
|
10 charactesr; (1)file type + (9)file permissions
|
|
rwx
|
read, write, execute
|
|
owner, group, world
|
order which permissions are displayed
|
|
r
|
4 - indicates read permission
|
|
w
|
2 - indicates write permission
|
|
x
|
1 - indicates execute permission
|
|
r-x
|
read and execute (5)
|
|
755
|
rwe-er-er
|
|
IF/THEN
|
if [ <condition> ] then <commands> fi
|
|
fi
|
terminates IF/THEN
|
|
if_[_<equation>_]
|
|
|
-eq
|
is equal to (integer)
|
|
-ne
|
is not equal to (integer)
|
|
-gt
|
greater than (integer)
|
|
-lt
|
less than (integer)
|
|
-ge
|
greater than or equal to (integer)
|
|
-le
|
less than or equal to (integer)
|
|
=
|
is equal to (string)
|
|
!=
|
is not equal to (string)
|
|
ELIF
|
alternative to nested-if statements
|
|
read
|
reads user input
|
|
bash <directory> <variables>
|
remember to put variables at end if variables are needed for command
|
|
grep <word>
|
print lines matching a pattern
|
|
redirect operator
|
(>) send output to file instead of displaying on screen
|
|
append operator
|
(>>) appends data instead of displaying on screen
|
|
cut -d" "
|
cut empty columns
|
|
cut -d, -f1,2,4
|
cuts out only columns 1,2,4
|
|
sort
|
sorts alphabetically
|
|
sort -n
|
sorts numerically
|
|
uniq
|
removes duplicate lines from a text file; MUST BE SORTED FORT
|
|
tr "abc" "xyz"
|
subsitute <v1> to <v2>
|
|
tr "[:lower:]""[:upper:]"
|
specify all lowercase letters to turn uppercase
|
|
new variable
|
supply variable name and its value; no spaces inbetween
|
|
variable1=2
|
valid; no spaces between equals
|
|
$((<equation>))
|
arithmetic expansion
|
|
echo $<variable>
|
prints <variable value>
|
|
" "
|
does not affect use
|
|
' '
|
used literally, does not call variables
|
|
$USER
|
lists current user
|
|
$PWD
|
prints present working directory
|
|
$HOME
|
home directory of current user
|
|
$RANDOM
|
o and 32767
|
|
sleep #
|
sleeps for # seconds
|
|
find
|
search for files
|
|
find [where to start searching from][expression to fine][-options][what to find]
|
takes 2 arguements; where to search & what to find; wildcards can be used
|
|
find /home -user alice -empty
|
finds files in the home folder from alice which are empty
|
|
Wildcards
|
|
|
?
|
matches a single character
|
|
*
|
matches any zero or more characters
|
|
[x..y]
|
matches a range of letters or numbers
|
|
Examples
|
|
|
ls
|
lists all files + extensions
|
|
ls *.doc
|
lists only files with .doc extensions
|
|
re - r <target>
|
removes folders with content; be very careful
|
|
while
|
run until a specific conditions is met
|
|
CTRL+C
|
to close script
|
|
vim "filename"
|
starts up in command mode
|
|
i
|
insert mode - start typing
|
|
:w
|
write
|
|
:q
|
quit vim type
|
|
:wp
|
save and quit
|
|
:q!
|
quit w/o saving
|
|
/word
|
search towards end of file for first occurance of word
|
|
?word
|
search towards beginning of the file for the word
|
|
n
|
search for next occurance
|
|
N
|
search for previous occurance
|
|
less
|
view file contents one screen at a time
|
|
head
|
top of file to see if it is the one you need
|
|
head -3
|
show the first three results
|
|
tail
|
bottom of file to see new log entries
|
|
-n
|
default output of ten line
|
|
-n#
|
changes number of lines outputed
|
|
-n & -n#
|
to be used with head or tail
|
|
YUM
|
|
|
YUM
|
yellowdog updater modifier - package modifier
|
|
chmod
|
updates permissions on files and folders
|
|
su
|
grants super user privileges
|
|
ls -laF
|
lists all folders + access
|
|
chmod 775 engineering
|
changes permissions for the engineering folders
|
|
chown
|
change ownership
|
|
chgrp
|
change group
|
|
chown dave README
|
changes owner of README to dave
|
|
chgrp sales_grp README
|
changes the group that can access README to sales_grp
|
|
aescrypt
|
secret key encryption
|
|
-e
|
encrypt the file
|
|
-d
|
decrypt the file
|
|
-p <password>
|
password to use; if omitted, the command will prompt the user
|
|
-o <filename>
|
output file
|
|
md5sum
|
easy way to generate a checksum
|
|
#! /bin/bash
|
turns list of commands into one command // no need for bash ...
|
|
for var in <item/directory> do <commands> done
|
how to format for loops
|
|
Sequences
|
{#..#}
|
|
#..#
|
first # starting value .. second# ending value
|
|
#1..#2..#3
|
#3 is increment between each number series
|
No comments yet.
Cheatography n. The art of mapping complex subjects into clear, instantly navigable reference guides.