my collection of command cheatsheet on mac and linux
# Create User
sudo adduser new_user
## Get default pass
sudo grep test /etc/shadow
test:!!:123456:0:99999:7:::
## Remove Pass
$ sudo adduser test
$ sudo passwd -d test
Removing password for user test.
passwd: Success
$ su test
$ whoami
test
## set sudo
usermod -aG wheel username
# Get IP of Mac
ifconfig |grep inet
## IP Wireless
ipconfig getifaddr en1
## IP Ethernet
ipconfig getifaddr en0
#copy sha local machine into server
ssh-copy-id -i ~/.ssh/id_rsa.pub git@192.168.100.130
ssh-keygen -t rsa
#location rule
# /etc/firewalld/zones/public.xml
# reload
firewall-cmd --reload
# check port running
ss -plnt
# check all port
firewall-cmd --zone=public --list-ports
# check specific port
firewall-cmd --zone=<zone> --query-port=80/tcp
# add port open
firewall-cmd --zone=public --add-port=27017/tcp --permanent
# check all services
firewall-cmd --zone=public --list-services
# add http & https services
firewall-cmd --zone=public --add-service=http
firewall-cmd --zone=public --add-service=https
tree
#Level of Depth
tree -L 3
#Excluding Directory
tree -I "node_modules|www"
/usr/sbin/setsebool httpd_can_network_connect true
# Install semanage
yum install policycoreutils-python
which semanage
yum provides semanage
#check port
semanage port -l | grep http_port_t
# add port
semanage port -a -t http_port_t -p tcp 8090
# modify port
semanage port -m -t http_port_t -p tcp 8090
ln -s /home/tableau/ tableau
# /etc/ssh/sshd_config
PermitRootLogin No
AllowUsers admin1 admin2
//Check port
nc -zv 127.0.0.1 80
//lookup
nslookup 199.88.777.66
#START
sudo systemctl start firewalld
sudo systemctl enable firewalld
#STOP
sudo systemctl stop firewalld
sudo systemctl disable firewalld
sudo systemctl mask --now firewalld
du -h --max-depth=1 |sort -hr
journalctl -xe
journalctl -f
#cleanup
journalctl --vacuum-size=500M
journalctl --vacuum-time=2d
grep "PC_TRANSACTION_run.sh" /var/log/cron
# Cowsay
if [ -n "$BASH_VERSION" ]; then
# include .bashrc if it exists
if [ -f "$HOME/.bashrc" ]; then
. "$HOME/.bashrc"
fortune | cowsay -f elephant | lolcat
echo \n
fi
fi