• Skip to main content

Uly.me

cloud engineer

  • Home
  • About
  • Archives

Linux

Install Cockpit on Rocky 9

October 3, 2022

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

Filed Under: Linux Tagged With: admins, cockpit, install, interface, users, web

Saving and Restoring iptables

September 22, 2022

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

Filed Under: Linux Tagged With: iptables, list, restore, save

Bash Menu and Functions

September 22, 2022

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

Filed Under: Linux Tagged With: bash, functions, menu

Running Top by Process

September 11, 2022

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/,$//')

Filed Under: Linux Tagged With: isolate, process, run, top

History Without Line Numbers

September 8, 2022

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

Filed Under: Linux Tagged With: history, lines, list, without

DF command takes too long

September 7, 2022

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

Filed Under: Linux Tagged With: command, df, long, too

Jekyll on Docker Container

August 30, 2022

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

Filed Under: Linux Tagged With: container, docker, docker-compose, down, jekyll, up

Cleanup Stale CVS Snapshots

August 30, 2022

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

Filed Under: Linux Tagged With: bash, cvs, file, handles, snapshots, stale

  • « Go to Previous Page
  • Go to page 1
  • Go to page 2
  • Go to page 3
  • Go to page 4
  • Go to page 5
  • Interim pages omitted …
  • Go to page 59
  • Go to Next Page »
  • Home
  • About
  • Archives

Copyright © 2023