• Skip to main content

Uly.me

cloud engineer

  • Home
  • About
  • Archives

Archives for August 2020

Increase SSH Timeout

August 25, 2020

Here’s how to keep your SSH timeout alive for a longer period.

Edit /etc/ssh/sshd_config. Adjust interval and count max.

ClientAliveInterval 1200
ClientAliveCountMax 3

ClientAliveInterval 1200 ClientAliveCountMax 3

ClientAliveInterval is set to 1200 and ClientAliveCountMax is set to the default which is 3. This means unresponsive SSH clients will be disconnected after approximately 3600 seconds or 1 hour.

Filed Under: Linux Tagged With: clientalivecountmax, clientaliveinterval, ssh, timeout

Git Bash Path

August 19, 2020

Here’s how to add or edit the PATH in Git Bash. Edit your bash_profile.

vi ~/.bash_profile

vi ~/.bash_profile

Set your path by adding the new path at the end.

PATH="/c/WINDOWS/system32:/c/Users/firstname.lastname/google-cloud-sdk/bin"

PATH="/c/WINDOWS/system32:/c/Users/firstname.lastname/google-cloud-sdk/bin"

The example path listed above is truncated for brevity.

Filed Under: Cloud, Linux Tagged With: add, bash_profile, gcloud, git bash, path

AWS List of Application LB

August 17, 2020

Here’s how to display a list of application load balancers.

aws elbv2 describe-load-balancers --profile --region us-east-1

aws elbv2 describe-load-balancers --profile --region us-east-1

Here’s how to display classic load balancers.

aws elb describe-load-balancers --profile --region us-east-1

aws elb describe-load-balancers --profile --region us-east-1

Filed Under: Cloud Tagged With: application, aws cli, elb, elbv2, load balancer

Audacity Copy

August 8, 2020

I was getting an error when launching Audacity.

The error was:

“The system has detected that another copy of Audacity is running.”

However, Audacity wasn’t running at all. Not one process. It turned out to be just a locked file located in /var/tmp/audacity-[your-username].

All you have to do is delete the entire directory and rerun Audacity.

rm -rf /var/tmp/audacity=[your-username]/

rm -rf /var/tmp/audacity=[your-username]/

Once deleted, Audacity starts right up with no issues.

Filed Under: Linux Tagged With: another, audacity, copy, file, locked, running

Linux Fuser

August 6, 2020

Who is accessing a particular directory? There’s a Linux command called fuser which will tell you who’s running processes in that directory.

fuser /etc/apache/
fuser /home/john/

fuser /etc/apache/ fuser /home/john/

Verbose.

fuser /data/exports/ -v

fuser /data/exports/ -v

Check out the fuser man page.

Filed Under: Linux Tagged With: directory, fuser, processes, running, who

Ansible Run Commands

August 2, 2020

Typically you will run Ansible using playbooks, just like the playbook that I ran from the previous post to patch a bunch of servers all at once. In addition to running playbooks, you can also run single ad hoc commands to a server or to a group of servers. Below are a few examples of that.

First, here’s my /etc/ansible/hosts file.

[servers]
server1
server2
[webservers]
server3
server4
[appservers]
server5
server6
[dbservers]
server7
server8

[servers] server1 server2 [webservers] server3 server4 [appservers] server5 server6 [dbservers] server7 server8

Here are the commands.

ansible servers -m ping
ansible webservers -m command -a "df -h"
ansible appservers -m command -a "crontab -l"
ansible dbservers -m command -a "cat /etc/hosts"
ansible all -m command -a "cat /etc/passwd"
ansible webservers -m command -a "systemctl status apache2"
ansible appservers -m command -a 'uptime'

ansible servers -m ping ansible webservers -m command -a "df -h" ansible appservers -m command -a "crontab -l" ansible dbservers -m command -a "cat /etc/hosts" ansible all -m command -a "cat /etc/passwd" ansible webservers -m command -a "systemctl status apache2" ansible appservers -m command -a 'uptime'

The first command runs ping on server1 and server2. The second command displays disk information of server3 and server4. The third command displays the crontab of server5 and server6, and so on and on. You get the drift.

Filed Under: Linux Tagged With: ansible, commands, groups

Ansible Update Playbook

August 1, 2020

I have an Ansible playbook that will patch all Ansible clients defined in the Ansible hosts file. The following are contents of my hosts file, and the update playbook.

File: /etc/ansible/hosts

[all:vars]
ansible_user='ubuntu'
ansible_become=yes
ansible_become_method=sudo
ansible_python_interpreter='/usr/bin/env python3'
[servers]
server1
server2
server3
[servers:vars]
ansible_python_interpreter=/usr/bin/python3

[all:vars] ansible_user='ubuntu' ansible_become=yes ansible_become_method=sudo ansible_python_interpreter='/usr/bin/env python3' [servers] server1 server2 server3 [servers:vars] ansible_python_interpreter=/usr/bin/python3

File: /etc/ansible/update.yml

---
- hosts: servers
  become: true
  become_user: root
  tasks:
    - name: Update apt repo and cache on all Debian/Ubuntu boxes
      apt: update_cache=yes force_apt_get=yes cache_valid_time=3600

    - name: Upgrade all packages on servers
      apt: upgrade=dist force_apt_get=yes

    - name: Check if a reboot is needed on all servers
      register: reboot_required_file
      stat: path=/var/run/reboot-required get_md5=no

    - name: Reboot the box if kernel updated
      reboot:
        msg: "Reboot initiated by Ansible for kernel updates"
        connect_timeout: 5
        reboot_timeout: 300
        pre_reboot_delay: 0
        post_reboot_delay: 30
        test_command: uptime
      when: reboot_required_file.stat.exist

--- - hosts: servers become: true become_user: root tasks: - name: Update apt repo and cache on all Debian/Ubuntu boxes apt: update_cache=yes force_apt_get=yes cache_valid_time=3600 - name: Upgrade all packages on servers apt: upgrade=dist force_apt_get=yes - name: Check if a reboot is needed on all servers register: reboot_required_file stat: path=/var/run/reboot-required get_md5=no - name: Reboot the box if kernel updated reboot: msg: "Reboot initiated by Ansible for kernel updates" connect_timeout: 5 reboot_timeout: 300 pre_reboot_delay: 0 post_reboot_delay: 30 test_command: uptime when: reboot_required_file.stat.exist

Here’s how I run my Ansible update playbook.

ansible-playbook -i /etc/ansible/hosts /etc/ansible/update.yml

ansible-playbook -i /etc/ansible/hosts /etc/ansible/update.yml

The advantage of using Ansible is, I can run a single playbook to update dozens of servers. It’s also a great tool for rolling out software as well as executing commands to a group of servers.

Filed Under: Linux Tagged With: ansible, hosts, patch, playbook, update

Center Search Widget

August 1, 2020

Here’s how to center the Search widget in a WordPress Page or a post. This applies only if you’re using the default Search Widget. Div classes may vary based on theme being used. The CSS example below may not work for your theme. Check your theme’s source code to be sure.

.entry-content .wp-block-search {
  display:block;
  margin-left:auto;
  margin-right:auto;
  text-align: center;
}
.entry-content .wp-block-search label {
  display:none;
}
.entry-content .wp-block-search input {
  width:250px;
}

.entry-content .wp-block-search { display:block; margin-left:auto; margin-right:auto; text-align: center; } .entry-content .wp-block-search label { display:none; } .entry-content .wp-block-search input { width:250px; }

The CSS above centers the search block. It suppresses the search label, and finally sets the form’s input to a fixed width of 250px.

Filed Under: WP Tagged With: center, class, css, div, search, wordpress

  • Home
  • About
  • Archives

Copyright © 2023