Last active
December 17, 2015 00:59
-
-
Save iamricard/5524634 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
## author @grumpylionking | |
createuser() | |
{ | |
echo "desired user name: " | |
read user | |
echo "desired group name: " | |
read group | |
adduser $user | |
echo "user created" | |
addgroup $group | |
echo "group created" | |
adduser $user $group | |
echo "$user added to $group" | |
adduser $user sudo | |
echo "$user added to sudoers" | |
} | |
editvimrc() | |
{ | |
user=`whoami` | |
echo "edit vimrc of current user? (y/n)" | |
read selection | |
case "$selection" in | |
"y" | "Y") echo "ok, user=$user" ;; | |
"n" | "N") echo "ok, which user?" | |
read user | |
echo "user=$user" | |
;; | |
esac | |
echo "syntax on" > /home/$user/.vimrc | |
echo "set autoindent" >> /home/$user/.vimrc | |
echo "set background=dark" >> /home/$user/.vimrc | |
echo "set tabstop=2" >> /home/$user/.vimrc | |
echo "set nu" >> /home/$user/.vimrc | |
} | |
editbashrc() | |
{ | |
user=`whoami` | |
echo "edit bashrc of current user? (y/n)" | |
read selection | |
case "$selection" in | |
"y" | "Y") echo "ok, user=$user" ;; | |
"n" | "N") echo "ok, which user?" | |
read user | |
echo "user=$user" | |
;; | |
esac | |
echo "desired greeting: " | |
read greeting | |
echo "$greeting" >> /home/$user/.bashrc | |
} | |
changetouser() | |
{ | |
echo "which user?" | |
read user | |
su $user | |
} | |
changehostname() | |
{ | |
echo "new hostname: " | |
read newhostname | |
echo "$newhostname" > /etc/hostname | |
sudo service hostname start | |
gnome-terminal & | |
exit | |
} | |
howmuchmemory() | |
{ | |
ram=`top -n 1 | grep Mem` | |
swap=`top -n 1 | grep Swap` | |
echo $ram | |
echo $swap | |
} | |
ejercicio7() | |
{ | |
echo "Para saber el nombre de usuario actual utilizaria el comando 'whoami': " | |
whoami | |
echo "iniciando escucha" | |
nc -l 8080 > username & | |
echo "enviando usuario" | |
whoami | nc localhost 8080 | |
user=`cat username` | |
if [ "$user" = `whoami` ]; then | |
echo "abriendo firefox" | |
firefox -search `whoami` | |
fi | |
echo "PD. Para dar permisos de ejecucion haria chmod +x script.sh" | |
} | |
ejercicio8() | |
{ | |
echo "Para comprimir en tar.gz haria el comando:" | |
echo "tar -zcvf <archivo destino> <archivo/directorio original>" | |
echo "" | |
echo "Para que cron lo hiciera cada dia a las 13:30 tendria que editar" | |
echo "con vi (u otro editor, pero preferiblement vi) /etc/contrab annexando la linea:" | |
echo " 30 13 * * * <user> tar -zcvf /home/<user>" | |
echo "" | |
echo "Para mandarlo utilizaria el comando:" | |
echo "scp <nombre del archivo> [email protected]:" | |
echo "importantes los : del final" | |
echo "" | |
echo "Para conectarme a la maquina y descomprimirlo:" | |
echo "ssh -l ubuntu 192.168.1.2 (tienen que tener ssh instalado)" | |
echo "Navegaria al directorio donde estuviera el archivo y haria:" | |
echo "tar -zxvf <nombre del archivo comprimido>" | |
echo "Y se extraerian en el directorio en el que estuviera." | |
} | |
ejercicio9() | |
{ | |
echo "con chown, ej:" | |
echo "chown -R <username>:<group> <folder>" | |
} | |
ejercicio10() | |
{ | |
echo "lspci: lista todos los dispositivos PCI" | |
lspci | |
echo "" | |
echo "lsusb: lista todos los puertos usb (o hubs)" | |
lsusb | |
echo "" | |
echo "cat /proc/cpuinfo | grep -i bogomips: muestra las lineas que contiene bogomips en el archivo cpuinfo" | |
echo " BOGOMIPS DE MI PC!! | |
bogomips : 4788.95 | |
bogomips : 4788.95 | |
bogomips : 4788.95 | |
bogomips : 4788.95 | |
bogomips : 4788.95 | |
bogomips : 4788.95 | |
bogomips : 4788.95 | |
bogomips : 4788.95" | |
} | |
ejercicio11() | |
{ | |
cat /proc/cpuinfo | grep -i bogomips | festival --tts & | |
echo "para que cron dijera la hora cada hora en punto anexaria la linea:" | |
echo "0 * * * * <user> date \"+%R\" | festival --tts" | |
} | |
echo "ESTE SCRIPT ESTA PENSADO PARA SER EJECUTADO CON SUDO!!!" | |
echo "Que ejercicio quieres ver? (1,2,3...)" | |
read choice | |
case "$choice" in | |
"1") createuser ;; | |
"2") editvimrc ;; | |
"3") editbashrc ;; | |
"4") changetouser ;; | |
"5") changehostname ;; | |
"6") howmuchmemory ;; | |
"7") ejercicio7 ;; | |
"8") ejercicio8 ;; | |
"9") ejercicio9 ;; | |
"10") ejercicio10 ;; | |
"11") ejercicio11 ;; | |
esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment