Cockpit is a web-based graphical interface for Linux users and admins.
Install
dnf install cockpit |
Start and Enable
systemctl start cockpit
systemctl enable cockpit.socket |
Status
systemctl status cockpit |
Web access
http://192.168.0.20:9090 |
cloud engineer
Cockpit is a web-based graphical interface for Linux users and admins.
Install
dnf install cockpit |
dnf install cockpit
Start and Enable
systemctl start cockpit
systemctl enable cockpit.socket |
systemctl start cockpit systemctl enable cockpit.socket
Status
systemctl status cockpit |
systemctl status cockpit
Web access
http://192.168.0.20:9090 |
http://192.168.0.20:9090
iptables can be saved or loaded from a file. Here’s a way to do it.
Saving to a file
# Debian/Ubuntu iptables-save > /etc/iptables/rules.v4 # Redhat/Centos/Rocky iptables-save > /etc/sysconfig/iptables |
# Debian/Ubuntu iptables-save > /etc/iptables/rules.v4 # Redhat/Centos/Rocky iptables-save > /etc/sysconfig/iptables
Loading from a file
# Debian/Ubuntu iptables-restore > /etc/iptables/rules.v4 # Redhat/Centos/Rocky iptables-restore > /etc/sysconfig/iptables |
# Debian/Ubuntu iptables-restore > /etc/iptables/rules.v4 # Redhat/Centos/Rocky iptables-restore > /etc/sysconfig/iptables
Listing rules
iptables -L |
iptables -L
How to integrate menus and functions in your Bash script.
#!/bin/bash function show_logs { ls -l /var/log/ } function show_users { cat /etc/passwd } echo '--------' echo 'My Menu' echo '--------' PS3='Choose an option: ' commands=("Show logs" "Show users" "Quit") COLUMNS=0 select cmd in "${commands[@]}"; do case $cmd in "Show logs") echo "Showing logs ... " show_logs ;; "Show users") echo "Showing users ... " show_users ;; "Quit") echo "Exiting ... " exit ;; *) echo "invalid option $REPLY";; esac done |
#!/bin/bash function show_logs { ls -l /var/log/ } function show_users { cat /etc/passwd } echo '--------' echo 'My Menu' echo '--------' PS3='Choose an option: ' commands=("Show logs" "Show users" "Quit") COLUMNS=0 select cmd in "${commands[@]}"; do case $cmd in "Show logs") echo "Showing logs ... " show_logs ;; "Show users") echo "Showing users ... " show_users ;; "Quit") echo "Exiting ... " exit ;; *) echo "invalid option $REPLY";; esac done
Result
-------- My Menu -------- 1) Show logs 2) Show users 3) Quit |
-------- My Menu -------- 1) Show logs 2) Show users 3) Quit
Here’s how to isolate a process via the top command.
top -c -p $(pgrep -f process_name | head -20 | tr "\\n" "," | sed 's/,$//') |
top -c -p $(pgrep -f process_name | head -20 | tr "\\n" "," | sed 's/,$//')
Here’s how to display history without the line numbers.
history -w /dev/stdout |
history -w /dev/stdout
Result
cd /etc/httpd/conf view httpd.conf vim wiki.conf vim ssl.conf |
cd /etc/httpd/conf view httpd.conf vim wiki.conf vim ssl.conf
Here’s a workaround if the df command takes too long to run.
This limits listing to local file systems only.
df -l |
df -l
Here’s how to run Jekyll in a Docker container.
mkdir blog cd blog docker run -v $(pwd):/site bretfisher/jekyll new . docker run -p 4000:4000 -v $(pwd):/site bretfisher/jekyll-serve |
mkdir blog cd blog docker run -v $(pwd):/site bretfisher/jekyll new . docker run -p 4000:4000 -v $(pwd):/site bretfisher/jekyll-serve
Another option is to use docker compose. Create a docker-compose.yml file.
version: 3.5 services: jekyll: image: bretfisher/jekyll-serve volumes: - .:/site ports: - '4000:4000' |
version: 3.5 services: jekyll: image: bretfisher/jekyll-serve volumes: - .:/site ports: - '4000:4000'
Run Jekyll.
cd blog docker-compose up -d |
cd blog docker-compose up -d
Stop Jekyll.
cd blog
docker-compose down |
cd blog docker-compose down
Here’s the script that looks mounts with stale file handles and removes them.
#!/bin/bash file='/tmp/stale.txt' df -h | grep Stale > $file sed -i -e 's/df: ‘/'""'/g' $file sed -i -e 's/’: Stale file handle/'""'/g' $file while IFS= read -r line; do echo 'unmounting '$line umount $line done < $file |
#!/bin/bash file='/tmp/stale.txt' df -h | grep Stale > $file sed -i -e 's/df: ‘/'""'/g' $file sed -i -e 's/’: Stale file handle/'""'/g' $file while IFS= read -r line; do echo 'unmounting '$line umount $line done < $file