Professional Documents
Culture Documents
All Scripts
All Scripts
echo "**TP0: Get command name & path & parent command**"
get_command_info(){
local command_name="$1"
if [ -n "$command_path" ]; then
if [ -n "$parent_pid" ]; then
if [ -n "$parent_name" ]; then
parent_path="$(command -v "$parent_name")"
fi
fi
else
get_command_info "$name"
TP1:
while true
do
disabled_modules=()
case $choice in
fi
Done ;;
disabled_modules+=("$module_name") ;;
else
disabled_modules=("${disabled_modules[@]/$module_name}")
else
echo "le module n'est pas dans la liste des modules desactivés"
fi
Fi ;;
echo "$module"
Done ;;
5) exit ;;
esac
done
TP2
while true
do
read choix
case $choix in
1) init 0 ;;
2) r=$(who -r)
do
echo "32: Afficher dans l'ordre les apps d'arret du systeme. "
case $choice in
39) break ;;
99) exit ;;
esac
Done ;;
99) exit ;;
esac
Done
TP3
echo "**TP3:Time of startup and shutdown of system **"
TP4
echo "**TP4: process admin**"
while true
do
echo "2- Lister les process par utilisateur triés par PID (PID, NomProcess, PPID)"
echo "5- Lister les processus fils d'un processus donné (PID, NOM)"
echo "6- Lister les processus parents d'un processus donné (PID, NOM)"
case $choix in
2) u=$(whoami)
3) who | awk '{print $1, $6}' | sort -k2 | uniq | while read user tty;
Do
Done ;;
u=$(whoami)
f=$(ps -ef | grep -w "^$u" | awk '{printf("%d\t%s\t%d\n", $2, $8, $3)}' | awk
'{print $1}' | head -1)
kill -9 $f
#pkill -p -i $u ;;
5)
read process
read pid
if [ -n "$parent_pid" ]; then
else
Fi ;;
7) Exit ;;
esac
Done
TP5
echo "**TP5: Admin tool**"
while true
do
case $choice in
while true
do
disabled_modules=()
case $choice in
fi
Done ;;
;;
echo "$module"
Done ;;
19) break ;;
999) exit ;;
esac
Done ;;
while true
do
case $choice in
do
case $choice in
232) ls /etc/rc0.d \ | nl ;;
233) ls -l /etc/init.d/* \ | sed -n -e 's/^.*\///p' ;;
239) break ;;
999) exit ;;
Esac
Done ;;
29) break ;;
999) exit ;;
esac
Done ;;
while true
do
echo "32- Lister les processus par utilisateur tries par PID (PID, Nom Process,
PPID)"
echo "35- Lister les processus fils d'un processus donne (PID, Nom)"
echo "36- Lister les processus parents d'un processus donne (PID, Nom)"
echo "37- Gerer un processus"
case $choice in
32) u=$(whoami)
do
Done ;;
34) echo
if [[ -z "$user" ]]
then
user=$(whoami)
fi
pkill -p -i $user ;;
read pid
if [ -n "$parent_pid" ]; then
else
Fi ;;
36) echo
if [[ -z "$pid" ]]
then
pid=$$
fi
ps -p $pid -o pid,cmd
do
ps -p $pid -o pid,cmd --no-headers
Done ;;
37) echo
echo
echo
case $op in
1) op="SIGKILL" ;;
2) op="SIGSTOP" ;;
3) op="SIGCONT" ;;
esac
39) break ;;
999) exit ;;
esac
Done ;;
999) exit ;;
esac
Done
TP6:
echo "**TP6: Net Admin **"
while true; do
case $choix in
3) for interface in $(ip link show | awk -F: '/^[0-9]+:/ {print $2}'); do
done ;;
while true; do
pattern="(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])"
addr_pattern="^(${pattern}\.){3}${pattern}(\/(3[0-2]|[12][0-9]|[0-9]))?$"
continue
fi
sudo ifconfig “$interface” “$addr”
break
done ;;
8) read -p "Enter the name of the service (vsftpd, telnet, httpd, nfs-utils): "
service_name
read -p "Do you want to install (install) or uninstall (uninstall) the service? "
action
else
fi ;;
9) while true; do
pattern="(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])"
addr_pattern="^(${pattern}\.){3}${pattern}(\/(3[0-2]|[12][0-9]|[0-9]))?$"
continue
fi
ping $addr
break
done ;;
10) read -p "Donner l'url que vous cherchez l'@ IP: " URL
nslookup $URL ;;
port=21
fi
fi
remote_file=$local_file
Fi
port=23
fi
read url
13) exit ;;
Esac Done
TP7
echo "application secadmin"
while true; do
echo "99-Exit"
case $choix in
6) echo "Path:"
read path
found=0
found=1
fi
done
else
fi ;;
7)
echo "Path:"
read path
found=0
found=1
fi
done
else
fi ;;
echo "Path:"
read path
found=0
found=1
fi
done
else
Fi ;;
99) Exit ;;
esac
Done
TP8
echo "**TP8: save admin**"
while true;
do
case $choice in
if [[ -z "$dir" ]]
then
dir=.
fi
| sort -r -n \
| head –5 ;;
if [[ -z "$choice" ]]
then
choice=1
fi
case $choice in
cd "$input"
input=$(pwd)
cd - > /dev/null
if [[ ! "$input" = /* ]]
then
input="$(pwd)/$input"
Fi
cd /
cd - > /dev/null ;;
Esac ;;
echo
then
choice=1
fi
case $choice in
cd "$input"
input=$(pwd)
cd - > /dev/null
;;
cd "$input
cd - > /dev/null ;;
Esac ;;
if [[ -z "$choice" ]]
then
choice=1
fi
case $choice in
cd "$input"
input=$(pwd)
cd - > /dev/null
cd /
cd - > /dev/null ;;
Esac ;;
if [[ -z "$choice" ]]
then
choice=1
fi
case $choice in
cd /
cd - > /dev/null ;;
Esac ;;
9) exit;;
esac
done