<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DZone Snippets: shell code</title>
    <link>http://snippets.dzone.com/posts</link>
    <pubDate>Wed, 20 Aug 2008 22:20:06 GMT</pubDate>
    <description>DZone Snippets: shell code</description>
    <item>
      <title>find something with another execution command example</title>
      <link>http://snippets.dzone.com/posts/show/5936</link>
      <description>&lt;code&gt; find . -type f -size +10000 -exec ls -al {} \;&lt;/code&gt;</description>
      <pubDate>Sun, 17 Aug 2008 17:06:31 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/5936</guid>
      <author>flynets (Flynets is an italian student of computer science with passion for GNU/Linux and hacktivism.)</author>
    </item>
    <item>
      <title>WikiMedia change WikiSysOp password</title>
      <link>http://snippets.dzone.com/posts/show/5935</link>
      <description>command from shell&lt;br /&gt;&lt;code&gt;$ php WIKIMEDIA-DIR/admin/changePassword.php --user=WikiSysop --password=new-pass&lt;/code&gt;</description>
      <pubDate>Sun, 17 Aug 2008 16:57:56 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/5935</guid>
      <author>flynets (Flynets is an italian student of computer science with passion for GNU/Linux and hacktivism.)</author>
    </item>
    <item>
      <title>Linux Shell script to rename files</title>
      <link>http://snippets.dzone.com/posts/show/5192</link>
      <description>Before rename command I was using following shell script to rename my mp3s&lt;br /&gt;&lt;code&gt;&lt;br /&gt;#!/bin/bash&lt;br /&gt;# To remove blank space&lt;br /&gt;if [ $# -eq 0 ];&lt;br /&gt;then&lt;br /&gt; echo "Syntax: $(basename $0) file-name [command]"&lt;br /&gt; exit 1&lt;br /&gt;fi&lt;br /&gt;FILES=$1&lt;br /&gt;CMD=$2&lt;br /&gt;for i in $FILES&lt;br /&gt;do&lt;br /&gt;# remove all blanks and store them OUT&lt;br /&gt;OUT=$(echo $i | sed 's/  *//g')&lt;br /&gt;if [ "$CMD" == "" ];&lt;br /&gt;then&lt;br /&gt;#just show file&lt;br /&gt;echo $OUT&lt;br /&gt;else&lt;br /&gt;#else execute command such as mv or cp or rm&lt;br /&gt;[ "$i" != "$OUT" ] &amp;&amp; $($CMD  "$i"  "$OUT")&lt;br /&gt;fi&lt;br /&gt;done&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Sun, 02 Mar 2008 16:13:16 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/5192</guid>
      <author>flynets (Flynets is an italian student of computer science with passion for GNU/Linux and hacktivism.)</author>
    </item>
    <item>
      <title>Block many users in a system v0.1.1</title>
      <link>http://snippets.dzone.com/posts/show/5191</link>
      <description>Block many users in a system using a text file as argument&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;#!/bin/bash&lt;br /&gt;&lt;br /&gt;#******************************************************************************#&lt;br /&gt;# BlockManyUsers.sh - Block many users in a system using a text file           #&lt;br /&gt;#                       as argument                                            #&lt;br /&gt;#   Copyright (C) 2008 - written by flynets - &lt;flynets&lt;at&gt;autistici&lt;dot&gt;org&gt;   #&lt;br /&gt;#   BlockManyUsers is free software: you can redistribute it and/or modify     #&lt;br /&gt;#   it under the terms of the GNU General Public License as published by       #&lt;br /&gt;#   the Free Software Foundation, either version 3 of the License, or          #&lt;br /&gt;#   any later version.                                                         #&lt;br /&gt;#                                                                              #&lt;br /&gt;#   BlockManyUsers is distributed in the hope that it will be useful,          #&lt;br /&gt;#   but WITHOUT ANY WARRANTY; without even the implied warranty of             #&lt;br /&gt;#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the               #&lt;br /&gt;#   GNU General Public License for more details.                               #&lt;br /&gt;#                                                                              #&lt;br /&gt;#   You should have received a copy of the GNU General Public License          #&lt;br /&gt;#   along with this program.  If not, see &lt;http://www.gnu.org/licenses/&gt;.      #&lt;br /&gt;#******************************************************************************#&lt;br /&gt;&lt;br /&gt;# Checks if you have the right privileges&lt;br /&gt;if [ "$USER" = "root" ];then&lt;br /&gt;   # Checks if there is an argument&lt;br /&gt;   [ $# -eq 0 ] &amp;&amp; { echo &gt;&amp;2 ERROR: You may enter as an argument a text file containing users, one per line. ; exit 1; }&lt;br /&gt;   # checks if there a regular file&lt;br /&gt;   [ -f "$1" ] || { echo &gt;&amp;2 ERROR: The input file does not exists. ; exit 1; }&lt;br /&gt;   TMPIN=$(mktemp)&lt;br /&gt;   # Remove blank lines and delete duplicates&lt;br /&gt;   sed '/^$/d' "$1"| sort -g | uniq &gt; "$TMPIN"&lt;br /&gt;   &lt;br /&gt;   NOW=$(date +"%Y-%m-%d-%X")&lt;br /&gt;   LOGFILE="BMU-log-$NOW.log"&lt;br /&gt;&lt;br /&gt;   for user in $(more "$TMPIN"); do&lt;br /&gt;      # Checks if the user already exists.&lt;br /&gt;      cut -d: -f1 /etc/passwd | grep "$user" &gt; /dev/null&lt;br /&gt;      OUT=$?&lt;br /&gt;      if [ $OUT -eq 0 ];then&lt;br /&gt;         # block selected user&lt;br /&gt;         /usr/sbin/usermod -L "$user"&lt;br /&gt;         # save user info in a file&lt;br /&gt;         echo The user \"$user\" has been blocked. &gt;&gt; "$LOGFILE"&lt;br /&gt;      else&lt;br /&gt;        echo &gt;&amp;2 Error the user account \"$user\" doesnt exists! &gt;&gt; "$LOGFILE"&lt;br /&gt;      fi&lt;br /&gt;   done&lt;br /&gt;   rm -f $TMPIN&lt;br /&gt;   exit 0&lt;br /&gt;else&lt;br /&gt;   echo &gt;&amp;2 ERROR: You must be a root user to execute this script.&lt;br /&gt;   exit 1&lt;br /&gt;fi&lt;br /&gt;exit 0&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Sun, 02 Mar 2008 14:23:38 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/5191</guid>
      <author>flynets (Flynets is an italian student of computer science with passion for GNU/Linux and hacktivism.)</author>
    </item>
    <item>
      <title>Add many users in a Debian system v0.2</title>
      <link>http://snippets.dzone.com/posts/show/4980</link>
      <description>Create many users in a Debian system using a text file as argument&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;#!/bin/bash&lt;br /&gt;&lt;br /&gt;#******************************************************************************#&lt;br /&gt;# AddManyUsers-deb.sh - Create many users in a Debian system using a text file #&lt;br /&gt;# 			as argument					       #&lt;br /&gt;#   Copyright (C) 2008 - written by flynets - &lt;flynets&lt;at&gt;autistici&lt;dot&gt;org&gt;   # &lt;br /&gt;#   AddManyUsers-deb is free software: you can redistribute it and/or modify   #&lt;br /&gt;#   it under the terms of the GNU General Public License as published by       #&lt;br /&gt;#   the Free Software Foundation, either version 3 of the License, or          #&lt;br /&gt;#   any later version.							       #&lt;br /&gt;#									       #&lt;br /&gt;#   AddManyUsers-deb is distributed in the hope that it will be useful,	       #&lt;br /&gt;#   but WITHOUT ANY WARRANTY; without even the implied warranty of             #&lt;br /&gt;#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the	       #&lt;br /&gt;#   GNU General Public License for more details.			       #&lt;br /&gt;#									       #&lt;br /&gt;#   You should have received a copy of the GNU General Public License	       #&lt;br /&gt;#   along with this program.  If not, see &lt;http://www.gnu.org/licenses/&gt;.      #&lt;br /&gt;#******************************************************************************#&lt;br /&gt;&lt;br /&gt;# Checks if you have the right privileges&lt;br /&gt;if [ "$USER" = "root" ]&lt;br /&gt;then&lt;br /&gt;&lt;br /&gt;# CHANGE THIS PARAMETERS FOR A PARTICULAR USE&lt;br /&gt;PERS_HOME="/home/"&lt;br /&gt;PERS_SH="/bin/bash"&lt;br /&gt;&lt;br /&gt;   # Checks if there is an argument&lt;br /&gt;   [ $# -eq 0 ] &amp;&amp; { echo &gt;&amp;2 ERROR: You may enter as an argument a text file containing users, one per line. ; exit 1; }&lt;br /&gt;   # checks if there a regular file&lt;br /&gt;   [ -f "$1" ] || { echo &gt;&amp;2 ERROR: The input file does not exists. ; exit 1; }&lt;br /&gt;   TMPIN=$(mktemp)&lt;br /&gt;   # Remove blank lines and delete duplicates &lt;br /&gt;   sed '/^$/d' "$1"| sort -g | uniq &gt; "$TMPIN"&lt;br /&gt;   &lt;br /&gt;   NOW=$(date +"%Y-%m-%d-%X")&lt;br /&gt;   LOGFILE="AMU-log-$NOW.log"&lt;br /&gt;   &lt;br /&gt;   for user in $(more "$TMPIN"); do&lt;br /&gt;      # Checks if the user already exists.&lt;br /&gt;      cut -d: -f1 /etc/passwd | grep "$user" &gt; /dev/null&lt;br /&gt;      OUT=$?&lt;br /&gt;      if [ $OUT -eq 0 ];then&lt;br /&gt;   	 echo &gt;&amp;2 "ERROR: User account: \"$user\" already exists."&lt;br /&gt;	 echo &gt;&amp;2 "ERROR: User account: \"$user\" already exists." &gt;&gt; "$LOGFILE"&lt;br /&gt;      else&lt;br /&gt;	 # Create a new user&lt;br /&gt;         /usr/sbin/useradd -d "$PERS_HOME""$user" -s "$PERS_SH" -m "$user"&lt;br /&gt;	 # gpw must be installed on debian system&lt;br /&gt;	 pass=$(gpw 1 8)&lt;br /&gt;         echo $user:$pass | chpasswd&lt;br /&gt;	 # save user and password in a file&lt;br /&gt;	 echo -e $user"\t"$pass &gt;&gt; "$LOGFILE"&lt;br /&gt;	 echo "The user \"$user\" has been created and has the password: $pass"&lt;br /&gt;      fi&lt;br /&gt;   done&lt;br /&gt;   rm -f "$TMPIN"&lt;br /&gt;   exit 0&lt;br /&gt;else&lt;br /&gt;   echo &gt;&amp;2 "ERROR: You must be a root user to execute this script."&lt;br /&gt;   exit 1&lt;br /&gt;fi&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Sun, 13 Jan 2008 17:25:42 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/4980</guid>
      <author>flynets (Flynets is an italian student of computer science with passion for GNU/Linux and hacktivism.)</author>
    </item>
    <item>
      <title>Add many users in a Red Hat system v0.2</title>
      <link>http://snippets.dzone.com/posts/show/4979</link>
      <description>Create many users in a RedHat system using a text file as argument&lt;br /&gt;&lt;code&gt;&lt;br /&gt;#!/bin/bash&lt;br /&gt;&lt;br /&gt;#******************************************************************************#&lt;br /&gt;# AddManyUsers-rh.sh - Create many users in a Red Hat system using a text file #&lt;br /&gt;# 			as argument					       #&lt;br /&gt;#   Copyright (C) 2008 - written by flynets - &lt;flynets&lt;at&gt;autistici&lt;dot&gt;org&gt;   # &lt;br /&gt;#   AddManyUsers-rh is free software: you can redistribute it and/or modify    #&lt;br /&gt;#   it under the terms of the GNU General Public License as published by       #&lt;br /&gt;#   the Free Software Foundation, either version 3 of the License, or          #&lt;br /&gt;#   any later version.							       #&lt;br /&gt;#									       #&lt;br /&gt;#   AddManyUsers-rh is distributed in the hope that it will be useful,	       #&lt;br /&gt;#   but WITHOUT ANY WARRANTY; without even the implied warranty of             #&lt;br /&gt;#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the	       #&lt;br /&gt;#   GNU General Public License for more details.			       #&lt;br /&gt;#									       #&lt;br /&gt;#   You should have received a copy of the GNU General Public License	       #&lt;br /&gt;#   along with this program.  If not, see &lt;http://www.gnu.org/licenses/&gt;.      #&lt;br /&gt;#******************************************************************************#&lt;br /&gt;&lt;br /&gt;# Checks if you have the right privileges&lt;br /&gt;if [ "$USER" = "root" ]&lt;br /&gt;then&lt;br /&gt;&lt;br /&gt;# CHANGE THIS PARAMETERS FOR A PARTICULAR USE&lt;br /&gt;PERS_HOME="/home/"&lt;br /&gt;PERS_SH="/bin/bash"&lt;br /&gt;&lt;br /&gt;   # Checks if there is an argument&lt;br /&gt;   [ $# -eq 0 ] &amp;&amp; { echo &gt;&amp;2 ERROR: You may enter as an argument a text file containing users, one per line. ; exit 1; }&lt;br /&gt;   # checks if there a regular file&lt;br /&gt;   [ -f "$1" ] || { echo &gt;&amp;2 ERROR: The input file does not exists. ; exit 1; }&lt;br /&gt;   TMPIN=$(mktemp)&lt;br /&gt;   # Remove blank lines and delete duplicates &lt;br /&gt;   sed '/^$/d' "$1"| sort -g | uniq &gt; "$TMPIN"&lt;br /&gt;   &lt;br /&gt;   NOW=$(date +"%Y-%m-%d-%X")&lt;br /&gt;   LOGFILE="AMU-log-$NOW.log"&lt;br /&gt;   &lt;br /&gt;   for user in $(more "$TMPIN"); do&lt;br /&gt;      # Checks if the user already exists.&lt;br /&gt;      cut -d: -f1 /etc/passwd | grep "$user" &gt; /dev/null&lt;br /&gt;      OUT=$?&lt;br /&gt;      if [ $OUT -eq 0 ];then&lt;br /&gt;   	 echo &gt;&amp;2 "ERROR: User account: \"$user\" already exists."&lt;br /&gt;	 echo &gt;&amp;2 "ERROR: User account: \"$user\" already exists." &gt;&gt; "$LOGFILE"&lt;br /&gt;      else&lt;br /&gt;	 # Create a new user&lt;br /&gt;         /usr/sbin/useradd -d "$PERS_HOME""$user" -s "$PERS_SH" -m "$user"&lt;br /&gt;	 # passwdgen must be installed&lt;br /&gt;	 pass=$(passwdgen -paq --length 8)&lt;br /&gt;         echo $pass | passwd --stdin $user&lt;br /&gt;	 # save user and password in a file&lt;br /&gt;	 echo -e $user"\t"$pass &gt;&gt; "$LOGFILE"&lt;br /&gt;	 echo "The user \"$user\" has been created and has the password: $pass"&lt;br /&gt;      fi&lt;br /&gt;   done&lt;br /&gt;   rm -f "$TMPIN"&lt;br /&gt;   exit 0&lt;br /&gt;else&lt;br /&gt;   echo &gt;&amp;2 "ERROR: You must be a root user to execute this script."&lt;br /&gt;   exit 1&lt;br /&gt;fi&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Sun, 13 Jan 2008 17:21:34 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/4979</guid>
      <author>flynets (Flynets is an italian student of computer science with passion for GNU/Linux and hacktivism.)</author>
    </item>
  </channel>
</rss>
