Android ADB commands

Android ADB Commands can be a mysterious bunch, but they have saved me from some disasters and made my life easier overall so I figured I would write a small post today and list some useful commands, hopefully you may use in your android endeavors. First you need to have the actual binaries that let you use these commands. you can get minimal adb fastboot tools from this XDA topic (windows), or get the full android studio from here. adb devices Shows a list of devices currently attached. example : List of devices attached FA43KWM04187 device adb reboot Reboots a device currently attached. adb reboot recovery Reboots a device currently attached into recovery mode. This is usually a very minimal recovery mode for most OEM devices. You can install custom recoveries like TWRP or CWM etc that come with extra features. adb reboot download Reboots the connected device into download mode. This is different for most manufacturers. Download mode is for flashing radio firmware/ROM upgrade through official means. adb reboot bootloader Reboots a device into Bootloader.The bootloader configures the device to an initial known state and has a means to select where to start executing the kernel. Bootloaders are written by hardware vendors and are specialized for the hardware they run on. In Android the bootloader typically starts either android OS itself or a Recovery. Android bootloaders often have a basic interactive mode that can be triggered by holding the “volume down” button while the bootloader is executing. adb reboot fastboot Reboot a connected device […]

Remove spaces from file names via bash

if you need a simple way to remove spaces from file names and replace with an underscore or a hyphen or whatever else here is a bash one liner. You can also do this via python or perl or most likely via php (why? o.0) but since bash / zsh is here and readily available for me I choose to use bash / zsh. Remove spaces and replace with underscore: find /tmp/ -depth -name “* *” -execdir rename ‘s/ /_/g’ “{}” \; remove spaces and replace with hyphen : find /tmp/ -depth -name “* *” -execdir rename ‘s/ /-/g’ “{}” \; Remove spaces completely: find /tmp/ -depth -name “* *” -execdir rename ‘s/ //g’ “{}” \; Be careful with he above as it will remove all spaces from file and directory names. hope this helps. if you have a better way of doing it comment and let me know 🙂

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”] [/et_pb_text][/et_pb_column][/et_pb_row][/et_pb_section]

Start Xvfb on boot on Centos Linux

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”] [/et_pb_text][/et_pb_column][/et_pb_row][/et_pb_section]

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  

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.