|
#!/bin/env bash
|
the shebang
|
|
./ file-name.sh
|
how to run a bash script
|
|
X="hello"
|
set variables
|
|
$X
|
use the variable
|
|
exit code
|
1 for false, 0 for true
|
|
[ ]
|
shorthand for test
|
|
[[ ]]
|
better shorthand for test, handles spaces better
|
|
if [[ ]]; then; fi
|
basic if-then-exit statement
|
|
if [[ ]]; then; else; fi
|
basic if-then-else
|
|
if [[ ]]; then; elif [[ ]]; then; else; fi
|
basic if-elif
|
|
$?
|
exit code of last run command
|
|
$1, $2 … $9
|
argument 1, arg 2, ...
|
|
env
|
see all variables already set
|
|
__ -eq __
|
check if things are equal
|
|
bash -x ____
|
debugger
|
|
for __ in __ ; do; commands; done
|
basic for loop, ; indicates new line
|
|
while true; do; commands; done
|
while loop
|
|
until true; do; commands; done
|
until loop
|
|
break
|
exit a loop
|
|
chown/chgrp [owner] [file]
|
change owner/group
|
|
chmod [u,g,o]+[permission] [file]
|
add permissions
|
|
chmod [u,g,o]-[permission] [file]
|
remove permission
|
|
[u, g, o]
|
user, group, other
|
|
[permission]
|
read (r), write (w), execute (x)
|
|
7
|
read, write and execute permissions
|
|
6
|
read and write permissions
|
|
5
|
read and execute permissions
|
|
4
|
read permissions
|
|
3
|
write and execute permissions
|
|
2
|
write permissions
|
|
1
|
execute permissions
|
|
0
|
no permissions
|
|
sudo dnf install samba
|
|
|
sudo nano /etc/samba/smb.conf
|
add gloabals
|
|
map archive = no
|
|
|
map hidden = no
|
|
|
map read only = no
|
|
|
map system = no
|
|
|
store dos attributes = yes
|
|
|
sudo firewall-cmd --add-service=samba
|
open the firewall
|
|
sudo systemctl start smb.service
|
|
|
sudo systemctl start nmb.service
|
|
|
sudo systemctl enable smb.service
|
|
|
sudo systemctl enable nmb.service
|
|
|
sudo smbpasswd -a [user]
|
add the user and give password for samba
|
|
sudo setsebool -P samba_export_all_rw 1
|
need this to let samba run because of a se fedora setting
|
|
TCP/IP
|
Transmission Control Protocol/Internet Protocol
|
|
ping [web address]
|
send packets to web address to test connection and speed
|
|
ping -s [number] [address]
|
change packet size sent
|
|
traceroute [web address]
|
shows route packets take when being sent
|
|
firewall-cmd --remove-port=[port #]/[port type]
|
take down firewall for specified port
|
|
firewall-cmd --add-port=[port #]/[port type]
|
put up firewall for specified port
|
|
firewall-cmd --add-service=[service]
|
some services are recognized by firewall command, use this to let them work
|
|
ssh [name]@[system name]
|
using the secure shell
|
|
scp [dir]/[file] [name]@[system name]:
|
copy from local to other system
|
|
scp [name]@[system name]:[dir]/[file] .
|
copy from other system to local
|
|
sudo !!
|
run previous command as sudo
|
|
man [command]
|
for manpages (give info about command)
|
|
mkdir
|
make directory
|
|
rmdir
|
remove directory
|
|
cp -r [source] [destination]
|
copy file recursively
|
|
which [filename]
|
gives location of file
|
|
less
|
read files and able to scroll through, better than 'more'
|
|
grep
|
search text
|
|
cat [filename]
|
shows content of file
|
|
head
|
shows beginning of file
|
|
tail
|
shows end of file
|
|
find . -name *.[pP][dD][fF]
|
find file, use -iname for case-insensitive
|
|
history
|
give a list of previously entered commands
|
|
![line #]
|
(use this with history) run the command from the history on given line
|
|
history | grep [word]
|
search history for commands including the word
|
|
script
|
record output from entire session
|
|
yes "string"
|
repeat string until manually stopped
|
|
cal
|
ascii calendar
|
|
date
|
gives current date
|
|
^this^that
|
run previous command replacing "this" with "that"
|
|
uptime
|
show system uptime
|
|
whoami
|
display current user name
|
|
**dnf ____ [package name]
|
____ can be filled with the words below
|
|
update (or upgrade)
|
update a package
|
|
install
|
install a package
|
|
remove
|
remove a package
|
|
systemctl daemon-reload
|
Reload systemd manager configuration
|
|
journalctl [service name]
|
check the logs of a servide
|
|
systemctl ____ [service name]
|
____ can be filled with the words below
|
|
start
|
start a system service
|
|
stop
|
stop a system service
|
|
status
|
check the status of a service
|
|
enable
|
let service start on boot
|
|
disable
|
make it so service does not start on boot
|
|
*
|
any character any number of times
|
|
?
|
any character one time
|
|
[cC]
|
one of these characters
|
|
/etc/skel
|
Sample startup files you can place in home directories for new users
|
|
[command] | [command]
|
piping
|
|
$
|
regular user
|
|
#
|
root user
|
|
~
|
home directory
|
|
nano and vi
|
text editors
|
|
&
|
run in background
|
|
ctrl+z
|
suspend process running
|
|
ctrl+c
|
kill process running
|
|
ctrl+s
|
stop output to terminal
|
|
ctrl+q
|
return from ctrl+s state
|
|
ctrl+a
|
go to start of a line
|
|
ctrl+e
|
go to end of a line
|
|
ctrl+k
|
cut from cursor to end of line
|
|
git clone /path/to/repository
|
create copy of git repository
|
|
git add filename
|
add file to git repository
|
|
git commit -am "message"
|
send the changes to git repository
|
|
git push
|
makes the changes to git repository
|
|
wget [url for file]
|
download file
|
|
tar -xzf [file]
|
extract tar file
|
|
/
|
root directory
|
|
/bin
|
contains Unix commands
|
|
/boot
|
contains files needed to boot the system
|
|
/dev
|
device files
|
|
/etc
|
contains most configuration files
|
|
/etc/passwd
|
contains user information (name, password, id, ...)
|
|
/etc/skel
|
sample files for making a new home directory
|
|
/home
|
home folder for user
|
|
/lib
|
contains files for /bin and /sbin
|
|
/tmp
|
location of temporary files for the system
|
No comments yet.
Cheatography n. The art of mapping complex subjects into clear, instantly navigable reference guides.