Categories
Linux shell

Why you should switch to ZShell ( zsh )

Why use ZShell

It has some amazing features, but right out of the gate in no particular order:

  • Context based tab completion that puts most others out there to shame.
  • Shared history among tabs.
  • Dynamic Load modules
  • Spelling correction that out performs most others out there.
  • Globbing that works on magic. I am positive of this.
  • Themes that work wonders, there are tons of them out there and they fit everyone’s needs or just write your own!
  • Global aliases

I’m going to be an elitist and say bash is for the cavemen 😐 any machine you have a personal user account on: install zsh. life just became pretty… and pretty awesome. why zsh? well its powerful and configurable…. its awesome! and you can change a LOT about it and extend it via plugins.

sudo apt-get install zsh curl git-core ruby
wget --no-check-certificate https://github.com/robbyrussell/oh-my-zsh/raw/master/tools/install.sh -O - | sh

this should switch you to zsh and install an awesome script for zsh. if not then do the next two steps. They can be repeated at will. Note where your zsh is, most likely /bin/zsh.

which zsh
chsh

After that comes customization time! yay… etc.
(pick a theme, I prefer dallas so)
edit ~/.zshrc

ZSH_THEME="dallas"

Heres my plugins, you can remove the ones you dont need

plugins=(git ant cpanm debian github mercurial node npm svn)

Install rvm :

user$ bash -s stable < <(curl -s https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer )

add the following to your ~/.zshrc

[[ -s $HOME/.rvm/scripts/rvm ]] && source $HOME/.rvm/scripts/rvm

more to come later.

[/et_pb_text][/et_pb_column][/et_pb_row][/et_pb_section]

Categories
Linux shell

Alsa CLI Volume control

I couldn’t find the silly volume control in the system settings one day so i figured there had to be something I could use to control volume settings like mic boost without needing a gui or remembering names and numbers for the CLI. well there is and it’s so easy a caveman could do it (hah remember those ads….)…. so without further ado here’s a fun and great way to control your volume via Alsa CLI Volume control.

type the following then use your arrows to move right/left and make the volume higher or lower by using up/down keys:

alsamixer -c 0

the 0 at the end is the number of your device. if a system only has one device you will use 0. if you have two devices you can use 0 or 1. it tells you the name of the device currently being edited so you don’t give yourself a heart attack by changing the wrong volume. picture of the control is attached.

 
[et_pb_section admin_label=”section”][et_pb_row admin_label=”row”][et_pb_column type=”4_4″][et_pb_text admin_label=”Text” background_layout=”light” text_orientation=”left” use_border_color=”off” border_color=”#ffffff” border_style=”solid”] [/et_pb_text][/et_pb_column][/et_pb_row][/et_pb_section]

Categories
Linux shell tuts

Find out whats taking up all the hdd space

[et_pb_section admin_label=”Section” fullwidth=”on” specialty=”off”][et_pb_fullwidth_post_title admin_label=”Fullwidth Post Title” title=”on” meta=”on” author=”off” date=”on” categories=”on” comments=”off” featured_image=”on” featured_placement=”background” parallax_effect=”off” parallax_method=”on” text_orientation=”center” text_color=”dark” text_background=”on” text_bg_color=”rgba(255,255,255,0.9)” module_bg_color=”rgba(255,255,255,0)” title_all_caps=”off” use_border_color=”off” border_color=”#ffffff” border_style=”solid”]

[/et_pb_fullwidth_post_title][/et_pb_section][et_pb_section admin_label=”section”][et_pb_row admin_label=”row”][et_pb_column type=”4_4″][et_pb_text admin_label=”Text” background_layout=”light” text_orientation=”left” use_border_color=”off” border_color=”#ffffff” border_style=”solid”]

Running out of hdd space is pretty annoying. So if you are running out of space and need to find out whats taking up all that space type the following command to find out more :

du -h  |grep '[0-9]G'

 

[/et_pb_text][/et_pb_column][/et_pb_row][et_pb_row admin_label=”row”][et_pb_column type=”4_4″][et_pb_text admin_label=”bottom above footer” background_layout=”light” text_orientation=”left” use_border_color=”off” border_color=”#ffffff” border_style=”solid”]

[/et_pb_text][et_pb_divider admin_label=”Divider” color=”#ffffff” show_divider=”off” divider_style=”solid” divider_position=”top” hide_on_mobile=”on”]

[/et_pb_divider][et_pb_text admin_label=”Text” background_layout=”light” text_orientation=”left” use_border_color=”off” border_color=”#ffffff” border_style=”solid”]

[jetpack-related-posts]

[/et_pb_text][/et_pb_column][/et_pb_row][/et_pb_section]

Categories
Linux shell

Start Xvfb on boot on Centos Linux

XVFB

Xvfb or X virtual framebuffer

X virtual framebuffer is a display server using the X11 protocol. In contrast to other display servers, it performs all graphical operations in memory without showing any screen output. which makes it ideal for some surprising uses. e.g.

Xvfb :1 &
xv -display :1 &
import -display :1 -window root image.png

(above snippet via Wikipedia)

I had to run xvfb automatically on boot on a centos system, here’s the init script I used to carry out the task. add the following as a script to /etc/init.d , chmod +x the script then chkconfig xvfb on

* Note: see the :11 in the middle of the script? change that to another number to change the display port.

   #!/bin/bash
   # chkconfig: 345 95 50
   # description: Starts xvfb on display 11
   # why 11? dunno I just work here. :( -FB
   # 9/30/13 r1 - initial addition -FB

   if [ -z "$1" ]; then
   echo "`basename $0` {start|stop}"
       exit
   fi

   case "$1" in
   start)
       /usr/bin/Xvfb :11 &
   ;;

   stop)
       killall Xvfb
   ;;
   esac

[/et_pb_text][/et_pb_column][/et_pb_row][et_pb_row admin_label=”row”][et_pb_column type=”4_4″][et_pb_text admin_label=”bottom above footer” background_layout=”light” text_orientation=”left” use_border_color=”off” border_color=”#ffffff” border_style=”solid”]

[/et_pb_text][et_pb_divider admin_label=”Divider” color=”#ffffff” show_divider=”off” divider_style=”solid” divider_position=”top” hide_on_mobile=”on”] [/et_pb_divider][et_pb_text admin_label=”Text” background_layout=”light” text_orientation=”left” use_border_color=”off” border_color=”#ffffff” border_style=”solid”]

[jetpack-related-posts]

[/et_pb_text][/et_pb_column][/et_pb_row][/et_pb_section]

Categories
Linux shell

Bash for loops sequential counting

 

Bash for loops are very useful in everyday life. I am going to post some simple examples where I combine bash for loops with other simple techniques like bash stepping etc.

Want to count from 1 – 100 and list each number sequentially?

for i in {1..100}; do   echo $i; done

Same as above but add a timestamp?

for i in {1..100}; do   echo $(date +"%D %I:%M:%S") - $i; done

Again same as above but now we step every 3 numbers instead of every 1

for i in {1..3..100}; do   echo $(date +"%D %I:%M:%S") - $i; done

 

now for something slightly harder, we add each successful result to the next number after it.

for i in {1..100}; do s=$((s+i)); done; echo $(date +"%D %I:%M:%S") - Total - $s

How about if we echo every resultant number before the total?

for i in {1..100}; do s=$((s+i)); echo $(date +"%D %I:%M:%S") - $s; done; echo $(date +"%D %I:%M:%S") - Total - $s

 

Categories
Linux

dpkg-divert local redirection of bins in Ubuntu

[et_pb_section admin_label=”Section” fullwidth=”on” specialty=”off”][et_pb_fullwidth_post_title admin_label=”Fullwidth Post Title” title=”on” meta=”on” author=”off” date=”on” categories=”on” comments=”off” featured_image=”on” featured_placement=”background” parallax_effect=”off” parallax_method=”on” text_orientation=”center” text_color=”dark” text_background=”on” text_bg_color=”rgba(255,255,255,0.9)” module_bg_color=”rgba(255,255,255,0)” title_all_caps=”off” use_border_color=”off” border_color=”#ffffff” border_style=”solid”]

[/et_pb_fullwidth_post_title][/et_pb_section][et_pb_section admin_label=”section”][et_pb_row admin_label=”row”][et_pb_column type=”4_4″][et_pb_text admin_label=”Text” background_layout=”light” text_orientation=”left” use_border_color=”off” border_color=”#ffffff” border_style=”solid”]

It seems sometimes you get a new package from somewhere and its just an update for an older package but from a different author, or a slightly different functioning bin. The dpkg-divert command allows you to replace a binary installed upon the system, and have this replacement persist even if you upgrade packages. One common reason to do this is if you’re using a mailserver such as qmail, and you wish to replace the file /usr/lib/sendmail with the version from that package. In this case making a diversion is a good solution. Well you can locally divert how you refer to the bin and make dpkg aware of this via the following command :

dpkg-divert --local --divert /usr/bin/sumguy --rename --add /usr/bin/sumguy-longer-name-newer-package

In this case our package provides sumguy-longer-name-newer-package  as the binary and hence the command, but thats a LOT to type 🙁 we just want to call it by its simpler name of
so we use the above divert command and voila! we are good to go.