Category: Linux

  • [FIX] Clean up old puppet reports and reclaim mysql space (ibdata)

    MySQL for puppet dashboard gets BIG. You can make this smaller by deleting old records. Source for this article is here. To get the size in GB of the dashboard: # mysql -uroot -ppassword > SELECT CONCAT ( ROUND( ( ( SUM(DATA_LENGTH)+SUM(INDEX_LENGTH) ) / 1024 / 1024 / 1024 ) ,2 ), ” GB”) as…

  • [FIX] vfs unable to mount root fs unknown-block

    โ€”

    by

    in

    A RHEL update today fucked up a RHEL system, giving: “vfs unable to mount root fs unknown-block”. Fix: Boot from RHEL CD Choose rescue mode Start (with network) Type: chroot /mnt/sysimage (to work in the actual disk) Go and remove the oldest kernel, find oldest kernel by typing `rpm -q kernel` Remove by doing: `rpm…

  • Bash get full path of file

    Get the full path of a file via: $ readlink -f ./file Tip: make an alias: alias fullpath=’readlink -f’

  • Dell Linux Dock display switcher script

    This might be helpful for someone. A quick script I made for changing output modes on my Dell laptop. There are different configurations. laptop: laptop screen only vga: vga output + laptop screen mix: hdmi + vga output, laptop screen off dock: dell dock display setup #!/bin/bash LAPTOP=’LVDS-1′ DOCKLEFT=’DP-2′ DOCKRIGHT=’DP-1′ VGA=’VGA-1′ HDMI=’HDMI-1′ case $1 in…

  • Openssl encrypt & decrypt files

    โ€”

    by

    in

    Encrypt: openssl enc -aes-256-cbc -a -salt -in plain.txt -out encrypted.enc Decrypt: openssl enc -d -aes-256-cbc -a -in encrypted.enc -out plain.txt Functions: #!/bin/bash function encrypt() { openssl enc -aes-256-cbc -a -salt -in $1 -out ${1}.enc ; stat $_ ; } function decrypt() { openssl enc -d -aes-256-cbc -a -in $1 -out $( echo $1 | sed…

  • Bash: SSL x509 check enddate / expiration time of certificate with openssl

    โ€”

    by

    in

    You can check the endtime/end time/notafter/expiration date of a site by doing this: openssl s_client -connect google.com:443 2>/dev/null

  • Script: Puppet module create template

    Adjust to your needs ;) #!/bin/bash # Create puppet module layout if [[ -z “$1” ]];then echo “$0 modulename” exit 1 fi if [[ -d $1 ]]; then echo “Dir already exists” exit 1 fi # Actual work M=$1 mkdir -p \ $M \ $M/files \ $M/manifests \ $M/templates # Files cat $M/manifests/${file}.pp done #…

  • FIX has missing requires of

    โ€”

    by

    in

    From here.: yum check dependencies \ | grep ‘has missing requires’ \ | sed ‘s/.\+has missing requires of //’ \ | sed ‘s/ [=].\+//’ \ | while read dep; do yum -y install “$dep”; done

  • SSH: Don’t display motd and banner

    โ€”

    by

    in

    Stop display of motd on login: # On the machine of which you don’t want to see the banner $ touch ~/.hushlogin Stop display of banner on ssh login: # Method 1: $ ssh -q targethost #Method 2: # Add to .ssh/config: Host * LogLevel Quiet

  • Reposync errors: empty rpm’s

    โ€”

    by

    in

    I recently got empty rpm’s back from Red Hat. The system was registered properly. Problem was thet for reposync, I used a different .repo file. This file still had the old ssl/tls key sources. Update your reposync .repo file to reflect the current ssh/tls keys and things will work again :).

  • Backup and restore permissions linux (accidental chmod -R)

    โ€”

    by

    in ,

    cd /etc/ chmod -R 664 . *SHIT!* If you find you did an accidental chmod -R, you may be able to restore it. Make sure SSH login keeps working (chmod -R 0600 /etc/ssh ) Install a similar machine On that machine, issue this command: find /etc/ -exec stat –format “[ ! -L \”{}\” ] &&…

  • A better todo.txt repeated task inserter

    I have a scheduled.txt file like this: # Scheduled tasks for todo.txt # Format: # # a dow, Mon,Tue,Wed,… # b moy, Jan,Feb,Mar,… # d dom, 01..31 # D m/d/y 12/30/12 # F Y-m-d 2012-12-30 # j doy 001..366 # V woy 01..53 # # %2 = Division by 2 is possible # %N2= Devision…

  • Useful ‘command not found’ output for bash

    Add this to your .bashrc: clippy() { echo “I see you’re trying to use the terminal โ€ฆ”; echo ” v “; echo ” โ•ญโ”€โ•ฎ”; echo ” โŒพ โŒพ”; echo ” โ”‚โ–•โ”‚”; echo ” โ•ฐโ”€โ•ฏ”; } function command_not_found_handle { clippy $1; } It will result in: $ adsf I see you’re trying to use the terminal…

  • [SOLVED] Add date (and seconds) to GNOME3 bar/clock

    โ€”

    by

    in

    $ gsettings list-recursively | grep gnome.shell.clock org.gnome.shell.clock show-date false org.gnome.shell.clock show-seconds false Set via: $ gsettings set org.gnome.shell.clock show-date true $ gsettings set org.gnome.shell.clock show-seconds true

  • [SOLVED] Install native spotify on Fedora (with Spotify apps)(64bit+32bit)

    โ€”

    by

    in

    This cost me some hours to find out, but I am currently using the native spotify linux preview under fedora 16, 64 bit: Steps: Make sure you don’t use spotify free. It will not work on linux. Install some things: $ sudo yum install qt-webkitย perl-ExtUtils-MakeMaker libXScrnSaver nspr-devel openssl-devel For 64 bit, do: $sudo ln -s…

  • My tip: a temporary directory (for temporary files)

    โ€”

    by

    in ,

    My tip: make a temporary directory for all kinds of random stuff. Downloads, quick notes et cetera. I use it a lot. By using a crontab like this, the old files (+5 days) are automatically deleted: $ find /home/karlo/temp/ -type f -mtime +5 -delete && find /home/karlo/temp/ -empty -delete

  • Import mp3 in audacity (on fedora)

    โ€”

    by

    in

    Remove audacity (#yum remove audacity), install audacity-freeworld (#yum install audacity-freeworld ). That’s it. You might have to enable RPMFusion.

  • Clear BASH history

    Clear the BASH history easily via: $ >~/.bash_history Remember to log out after doing this.

  • ifconfig gone (command not found)

    โ€”

    by

    in

    Today, ifconfig was not working for me. I think this happened after I installed X11 on my headless server. $ ifconfig bash: ifconfig: command not found It turns out something removed /sbin from my $PATH. Read more about the $PATH here. The ifconfig-command resides in /sbin: $ whereis ifconfig ifconfig: /sbin/ifconfig The solution is to…

  • Use $top over SSH

    โ€”

    by

    in ,

    If you want to use `top` over SSH, use the -t option: $ ssh -t servername top This also works if you want to use `tail -f` over ssh: $ ssh -t servername “tail -f”