Linux Admin Daily Usage

Published on Author gryzli

Shell   Calculate the size of all files from a given type/extension Recently I need something for doing such calculations and end up with the following command line (found on stackexchange), which will calculate the size summary for all “*.jpg” files in “some_directory”. find some_directory/ -type f -name ‘*.jpg’ -exec du -ch {} + |… Continue reading Linux Admin Daily Usage

BASH – Automating SCP/SSH/RSYNC connections with EXPECT

Published on Author gryzli

Very often I need to automate some task which requires user input, most of the times this input is some type of credentials (user + password) or sometime some more. I have find that expect is very useful in such cases.   Before trying any of the scripts below, make sure you have expect installed on… Continue reading BASH – Automating SCP/SSH/RSYNC connections with EXPECT

BASH – Tips and tricks

Published on Author gryzli

Bash Variable String Manipulation A = “123456” # This prints the chars from 3 to 5 # Chars are counting from [0] echo ${A:3:5} # prints “456” echo ${A:1:4} # prints “2345” # Prints the number of chars echo ${#A} # prints “6”   Front Match These are the examples of a front matching Front… Continue reading BASH – Tips and tricks

Strace buggy php script running as cgi – Strace daemon

Published on Author gryzli

Very often I need to strace a script which is not “constantly” running, and must be “catch” during it’s execution. Today I had to debug some bad behaving php script, but because php was running as CGI (mod_suphp) it was hard a task. I had 3 choices in order to successfully attach the strace to the php… Continue reading Strace buggy php script running as cgi – Strace daemon

Change user password through BASH script

Published on Author gryzli

Very often I need to automate some bulk user password change. In the following examples we have: $user as username $pass as password in plain text Currently these are the methods I use to change user passwords: chpasswd method echo “$user:$pass” | chpasswd The old passwd method echo -e “$pass\n$pass” | passwd $user   Also… Continue reading Change user password through BASH script