• Skip to main content

Uly.me

cloud engineer

  • Home
  • About
  • Archives

FFMPEG Resize

October 25, 2022

How to resize JPEG using FFMPEG.

ffmpeg -i TREE.JPG -y -vf scale=iw*.2:ih*.2 tree.jpg

ffmpeg -i TREE.JPG -y -vf scale=iw*.2:ih*.2 tree.jpg

Another option is to set resolution.

ffmpeg -i TREE.JPG -y -vf scale=-1:720 tree.jpg

ffmpeg -i TREE.JPG -y -vf scale=-1:720 tree.jpg

How to resize video using FFMPEG.

ffmpeg -i TREE.MP4 -s 640x360 -pix_fmt yuv420p -crf 18 tree.mp4

ffmpeg -i TREE.MP4 -s 640x360 -pix_fmt yuv420p -crf 18 tree.mp4

How to create a thumbnail from a video.

ffmpeg -ss 00:00:00 -i tree.mp4 -vframes 1 tree.jpg

ffmpeg -ss 00:00:00 -i tree.mp4 -vframes 1 tree.jpg

Filed Under: Linux Tagged With: create, ffmpeg, image, resize, thumbnail, video

Vim Colors

October 25, 2022

I had trouble getting my vi editor to display all black background color. This includes the background color after the end of the file. I just wanted an all black background for better visibility. I did a little bit of googling and found this nice little gem. I happen to like the dessert theme and went with that instead of the recommended mustang theme which I don’t have installed. Hope you’ll find this helpful.

set t_Co=256
set background=dark
colorscheme dessert
highlight Normal ctermbg=NONE
highlight nonText ctermbg=NONE

set t_Co=256 set background=dark colorscheme dessert highlight Normal ctermbg=NONE highlight nonText ctermbg=NONE

Filed Under: Linux Tagged With: background, black, dark, theme, vim

Git Remove Files From Repo After Commit

October 4, 2022

If you need to remove files from a repo after committing, use …

Remove file

git rm --cached file.ext

git rm --cached file.ext

Push to repo

git push

git push

Filed Under: Linux Tagged With: cache, commit, git, push, rm

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

GCP List of BMS Servers

September 15, 2022

Here’s how to list Bare Metal Servers in Google Cloud Platform via gcloud.

gcloud bms instances list --region REGION --project PROJECT

gcloud bms instances list --region REGION --project PROJECT

Result

NAME            ID                 PROJECT         REGION       MACHINE_TYPE           CLIENT_IPS    PRIVATE_IPS                    STATE
server-001      at-xxxxxxx-svr001  project-01      us-central1  o2-ultramem-896-metal  10.0.0.1      192.168.253.1,192.168.252.1    RUNNING
server-002      at-xxxxxxx-svr002  project-02      us-central1  o2-ultramem-896-metal  10.0.0.2      192.168.253.2,192.168.252.2    RUNNING

NAME ID PROJECT REGION MACHINE_TYPE CLIENT_IPS PRIVATE_IPS STATE server-001 at-xxxxxxx-svr001 project-01 us-central1 o2-ultramem-896-metal 10.0.0.1 192.168.253.1,192.168.252.1 RUNNING server-002 at-xxxxxxx-svr002 project-02 us-central1 o2-ultramem-896-metal 10.0.0.2 192.168.253.2,192.168.252.2 RUNNING

Obviously you can see the same from GCP’s Console.

Filed Under: Cloud Tagged With: bms, gcp, instances, list

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

  • « 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 123
  • Go to Next Page »
  • Home
  • About
  • Archives

Copyright © 2023