/l3/users/28-09-2015/NT-Ladm/debian2.net.nt/root :1 :2 :3 :4 :5 :6 :7 |
|
#vi privet.sh
![]() --- /dev/null 2015-09-25 17:22:43.884000009 +0300 +++ privet.sh 2015-09-29 10:53:49.032969891 +0300 @@ -0,0 +1,2 @@ +#!/bin/bash +echo "Privet ${1}!" |
#echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin |
#pwd
/root |
#ls -l
итого 16 -rw-r--r-- 1 root root 0 Сен 29 10:35 file1 -rw-r--r-- 1 root root 0 Сен 29 10:35 file2 -rw-r--r-- 1 root root 0 Сен 29 10:35 file3 -rw-r--r-- 1 root root 0 Сен 29 10:35 file4 -rw-r--r-- 1 root root 0 Сен 29 10:35 file5 -rw-r--r-- 1 root root 5268 Окт 13 2014 install -rw-r--r-- 1 root root 32 Сен 29 10:53 privet.sh -rw-r--r-- 1 root root 0 Сен 28 14:24 report -rw-r----- 1 root root 1029 Сен 28 14:24 shadow |
#chmod u+x privet.sh
|
#ls -l
итого 16 -rw-r--r-- 1 root root 0 Сен 29 10:35 file1 -rw-r--r-- 1 root root 0 Сен 29 10:35 file2 -rw-r--r-- 1 root root 0 Сен 29 10:35 file3 -rw-r--r-- 1 root root 0 Сен 29 10:35 file4 -rw-r--r-- 1 root root 0 Сен 29 10:35 file5 -rw-r--r-- 1 root root 5268 Окт 13 2014 install -rwxr--r-- 1 root root 32 Сен 29 10:53 privet.sh -rw-r--r-- 1 root root 0 Сен 28 14:24 report -rw-r----- 1 root root 1029 Сен 28 14:24 shadow |
#ls -l --color
итого 16 -rw-r--r-- 1 root root 0 Сен 29 10:35 file1 -rw-r--r-- 1 root root 0 Сен 29 10:35 file2 -rw-r--r-- 1 root root 0 Сен 29 10:35 file3 -rw-r--r-- 1 root root 0 Сен 29 10:35 file4 -rw-r--r-- 1 root root 0 Сен 29 10:35 file5 -rw-r--r-- 1 root root 5268 Окт 13 2014 install -rwxr--r-- 1 root root 32 Сен 29 10:53 privet.sh -rw-r--r-- 1 root root 0 Сен 28 14:24 report -rw-r----- 1 root root 1029 Сен 28 14:24 shadow |
#./privet.sh
Privet ! |
#./privet.sh Viktor
Privet Viktor! |
#./privet.sh Viktor
Privet Viktor! |
#./privet.sh
Privet Noname! |
#vi privet.sh
--- /tmp/l3-saved-8516.24984.23770 2015-09-29 10:59:53.072969915 +0300 +++ privet.sh 2015-09-29 11:00:21.460969858 +0300 @@ -1,2 +1,2 @@ -#!/bin/bash -echo "Privet ${1:-Noname}!" +#!/bin/bashi +echo "Privet ${1:+Noname}!" |
#./privet.sh
![]() l3script: ./privet.sh: /bin/bashi: плохой интерпретатор: Нет такого файла или каталога |
#vi privet.sh
--- /tmp/l3-saved-8516.2508.13246 2015-09-29 11:00:35.848969892 +0300 +++ privet.sh 2015-09-29 11:00:47.820969857 +0300 @@ -1,2 +1,2 @@ #!/bin/bashi -echo "Privet ${1:+Noname}!" +echo "Privet ${1:+}!" |
#./privet.sh
![]() l3script: ./privet.sh: /bin/bashi: плохой интерпретатор: Нет такого файла или каталога |
#echo $(7+5))
![]() l3script: syntax error near unexpected token `)' |
#echo $((7+5))
12 |
#echo $[7+5]
12 |
#i=1
|
#echo $i
1 |
#i=$[$i+1]
|
#echo $i
2 |
#top
top - 11:05:00 up 3 days, 17:42, 4 users, load average: 1,02, 1,04, 1,05 Tasks: 66 total, 2 running, 64 sleeping, 0 stopped, 0 zombie %Cpu(s): 6,1 us, 0,0 sy, 46,2 ni, 0,0 id, 0,0 wa, 0,0 hi, 0,0 si, 47,7 st KiB Mem: 507368 total, 323256 used, 184112 free, 88312 buffers KiB Swap: 0 total, 0 used, 0 free, 116700 cached PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND 5037 root 39 19 20628 6392 860 R 86,3 1,3 1223:05 john 3376 root 20 0 50408 12m 1636 S 11,7 2,6 13:03.45 l3-agent 8515 root 20 0 18168 472 308 S 2,3 0,1 0:00.16 script 1 root 20 0 10648 828 696 S 0,0 0,2 0:05.79 init ... 7663 root 20 0 0 0 0 S 0,0 0,0 0:04.19 kworker/0:2 8073 root 20 0 0 0 0 S 0,0 0,0 0:00.23 kworker/0:0 8088 root 20 0 71384 3800 2900 S 0,0 0,7 0:00.73 sshd 8090 root 20 0 22168 2832 1696 S 0,0 0,6 0:00.13 bash 8135 root 20 0 71292 3608 2820 S 0,0 0,7 0:00.04 sshd 8137 ivan 20 0 71292 1864 1072 S 0,0 0,4 0:00.02 sshd 8138 ivan 20 0 22600 3200 1652 S 0,0 0,6 0:00.14 bash 8219 root 20 0 71292 3616 2824 S 0,0 0,7 0:00.03 sshd 8221 petr 20 0 71292 1868 1072 S 0,0 0,4 0:00.02 sshd 8222 petr 20 0 22600 3204 1652 S 0,0 0,6 0:00.20 bash |
#ps ax | wc -l
68 |
#$[$(ps ax | wc -l)-4]
l3script: 65: команда не найдена |
#cat report
|
#cat
fu fu |
#cat &
[1] 9351 [1]+ Stopped cat |
#jobs
[1]+ Stopped cat |
#jobs -l
[1]+ 9351 Остановлено (ввод с терминала) cat |
#cd /proc/9351/fd
|
#ls -l
итого 0 lrwx------ 1 root root 64 Сен 29 11:16 0 -> /dev/pts/6 lrwx------ 1 root root 64 Сен 29 11:16 1 -> /dev/pts/6 lrwx------ 1 root root 64 Сен 29 11:16 2 -> /dev/pts/6 |
#tty
/dev/pts/0 |
#cd
|
#find / -user ivan -type f
![]() /tmp/users /home/ivan/.bashrc /home/ivan/.bash_history /home/ivan/d4/d3/d1/f1 /home/ivan/d4/d3/d1/users /home/ivan/.profile /home/ivan/.viminfo /home/ivan/.bash_logout /proc/8138/task/8138/fdinfo/0 /proc/8138/task/8138/fdinfo/1 ... /proc/8537/oom_adj /proc/8537/oom_score_adj /proc/8537/loginuid /proc/8537/sessionid /proc/8537/coredump_filter /proc/8537/io find: `/proc/9405/task/9405/fd/5': Нет такого файла или каталога find: `/proc/9405/task/9405/fdinfo/5': Нет такого файла или каталога find: `/proc/9405/fd/5': Нет такого файла или каталога find: `/proc/9405/fdinfo/5': Нет такого файла или каталога |
#find / -user ivan -type f 2> errors
![]() /tmp/users /home/ivan/.bashrc /home/ivan/.bash_history /home/ivan/d4/d3/d1/f1 /home/ivan/d4/d3/d1/users /home/ivan/.profile /home/ivan/.viminfo /home/ivan/.bash_logout /proc/8138/task/8138/fdinfo/0 /proc/8138/task/8138/fdinfo/1 ... /proc/8537/stack /proc/8537/cpuset /proc/8537/cgroup /proc/8537/oom_score /proc/8537/oom_adj /proc/8537/oom_score_adj /proc/8537/loginuid /proc/8537/sessionid /proc/8537/coredump_filter /proc/8537/io |
#ls
errors file1 file2 file3 file4 file5 install privet.sh report shadow |
#cat errors
find: `/proc/9413/task/9413/fd/5': Нет такого файла или каталога find: `/proc/9413/task/9413/fdinfo/5': Нет такого файла или каталога find: `/proc/9413/fd/5': Нет такого файла или каталога find: `/proc/9413/fdinfo/5': Нет такого файла или каталога |
#find / -user ivan -type f 2> errors >1 files
![]() |
#ls
1 errors file1 file2 file3 file4 file5 install privet.sh report shadow |
#find / -user ivan -type f 2> errors 1> files
![]() |
#find / -user ivan -type f &>all
![]() |
#mail ivan\
![]() > ^C |
#mail ivan
Subject: Hello Privet Ivan . EOT |
#mail -s report ivan < all
|
#shopt
autocd off cdable_vars off cdspell off checkhash off checkjobs off checkwinsize on cmdhist on compat31 off compat32 off compat40 off ... no_empty_cmd_completion off nocaseglob off nocasematch off nullglob off progcomp on promptvars on restricted_shell off shift_verbose off sourcepath on xpg_echo off |
#set -o noclobber
|
#find / -user ivan -type f 2> errors 1> files
![]() l3script: errors: не могу переписать уже существующий файл |
#lsapttr
![]() l3script: lsapttr: команда не найдена |
#lsattr
-------------e-- ./errors -------------e-- ./file4 -------------e-- ./files -------------e-- ./1 -------------e-- ./all -------------e-- ./shadow -------------e-- ./file1 -------------e-- ./report -------------e-- ./file5 -------------e-- ./privet.sh -------------e-- ./file3 -------------e-- ./install -------------e-- ./file2 |
#chattr +a report
|
#lsattr
-------------e-- ./errors -------------e-- ./file4 -------------e-- ./files -------------e-- ./1 -------------e-- ./all -------------e-- ./shadow -------------e-- ./file1 -----a-------e-- ./report -------------e-- ./file5 -------------e-- ./privet.sh -------------e-- ./file3 -------------e-- ./install -------------e-- ./file2 |
#find / -user ivan -type f 2> errors 1> files
|
#date >> report
|
#chattr -a report
|
#chattr +i report
|
#ls
1 all errors file1 file2 file3 file4 file5 files install privet.sh report shadow |
#ls f*
file1 file2 file3 file4 file5 files |
#ls -1 f* | sort -r
files file5 file4 file3 file2 file1 |
#ls -1 f* | rm -f
|
#ls
1 all errors file1 file2 file3 file4 file5 files install privet.sh report shadow |
#ls -1 f* | xargs rm -f
|
#ls
1 all errors install privet.sh report shadow |
#cat install
#!/bin/sh hostname=`hostname` uname -a | egrep -qi '(freebsd|darwin)' || hostname=`hostname -f` ############################################################################### # # Set this variables before installation: lilalo_user=13-10-2014 lab=NT-LNet install_l3bashrc_for_this_users=${users:-"root user"} # users who will use l3agent and l3script lilalo_context="/users/${lilalo_user}/${lab}/${hostname}" ... step "Downloading l3prompt" ${wget} ${url_l3prompt} step "Downloading l3-agent" '${wget} ${url_l3agent}; ${wget} ${url_l3config_pm}; ${wget} ${url_l3config}' step "Downloading perl modules for l3-agent" '{ for i in ${perl_modules}; do ${wget} ${url_perl_modules}/$i.tar.gz; done; }' step "Installing perl modules for l3-agent" '{ for i in ${perl_modules}; do tar xvfz $i.tar.gz; cd $i*[^z]; perl Makefile.PL; make; make install; cd ..; done; }' step "Installing l3bashrc to users home directories" install_to_users_homes $install_l3bashrc_for_this_users step "Adding l3bashrc invocation to ~/.bashrc " install_to_users_bashrc $install_l3bashrc_for_this_users step "Adding l3-agent invocation to ~/.bash_profile " install_to_users_bash_profile $install_l3bashrc_for_this_users cd / rm -rf ${temp_dir} show_final_message |
#cat install | grep users
install_l3bashrc_for_this_users=${users:-"root user"} # users who will use l3agent and l3script lilalo_context="/users/${lilalo_user}/${lab}/${hostname}" install_to_users_homes() users="$@" for user in $users install_to_users_bashrc() users="$@" for user in $users install_to_users_bash_profile() users="$@" for user in $users step "Installing l3bashrc to users home directories" install_to_users_homes $install_l3bashrc_for_this_users step "Adding l3bashrc invocation to ~/.bashrc " install_to_users_bashrc $install_l3bashrc_for_this_users step "Adding l3-agent invocation to ~/.bash_profile " install_to_users_bash_profile $install_l3bashrc_for_this_users |
#cat install | grep -n users
12:install_l3bashrc_for_this_users=${users:-"root user"} # users who will use l3agent and l3script 13:lilalo_context="/users/${lilalo_user}/${lab}/${hostname}" 85:install_to_users_homes() 88: users="$@" 90: for user in $users 110:install_to_users_bashrc() 112: users="$@" 113: for user in $users 121:install_to_users_bash_profile() 123: users="$@" 124: for user in $users 178:step "Installing l3bashrc to users home directories" install_to_users_homes $install_l3bashrc_for_this_users 179:step "Adding l3bashrc invocation to ~/.bashrc " install_to_users_bashrc $install_l3bashrc_for_this_users 180:step "Adding l3-agent invocation to ~/.bash_profile " install_to_users_bash_profile $install_l3bashrc_for_this_users |
#cat install | grep 'users'
install_l3bashrc_for_this_users=${users:-"root user"} # users who will use l3agent and l3script lilalo_context="/users/${lilalo_user}/${lab}/${hostname}" install_to_users_homes() users="$@" for user in $users install_to_users_bashrc() users="$@" for user in $users install_to_users_bash_profile() users="$@" for user in $users step "Installing l3bashrc to users home directories" install_to_users_homes $install_l3bashrc_for_this_users step "Adding l3bashrc invocation to ~/.bashrc " install_to_users_bashrc $install_l3bashrc_for_this_users step "Adding l3-agent invocation to ~/.bash_profile " install_to_users_bash_profile $install_l3bashrc_for_this_users |
#cat install | grep 'users$'
for user in $users for user in $users for user in $users step "Installing l3bashrc to users home directories" install_to_users_homes $install_l3bashrc_for_this_users step "Adding l3bashrc invocation to ~/.bashrc " install_to_users_bashrc $install_l3bashrc_for_this_users step "Adding l3-agent invocation to ~/.bash_profile " install_to_users_bash_profile $install_l3bashrc_for_this_users |
#cat install | grep '^step'
step() step "Installing dependencies" apt_get_install_deps step "Downloading l3bashrc" ${wget} ${url_l3bashrc} step "Downloading l3prompt" ${wget} ${url_l3prompt} step "Downloading l3-agent" '${wget} ${url_l3agent}; ${wget} ${url_l3config_pm}; ${wget} ${url_l3config}' step "Downloading perl modules for l3-agent" '{ for i in ${perl_modules}; do ${wget} ${url_perl_modules}/$i.tar.gz; done; }' step "Installing perl modules for l3-agent" '{ for i in ${perl_modules}; do tar xvfz $i.tar.gz; cd $i*[^z]; perl Makefile.PL; make; make install; cd ..; done; }' step "Installing l3bashrc to users home directories" install_to_users_homes $install_l3bashrc_for_this_users step "Adding l3bashrc invocation to ~/.bashrc " install_to_users_bashrc $install_l3bashrc_for_this_users step "Adding l3-agent invocation to ~/.bash_profile " install_to_users_bash_profile $install_l3bashrc_for_this_users |
#cat install | grep '^ '
return 0 if which apt-get >& /dev/null then apt-get install -y $apt_get_install_this else echo "Please install this dependencies manually:" echo $apt_get_install_this echo "Have you installed this already (y/n)?" echo y | read answer if echo $answer | grep -q ^[yY] ... do user_home=`get_user_home "$user"` grep -q l3-agent ${user_home}/.bash_profile 2> /dev/null \ || { echo >> ${user_home}/.bash_profile ; cat ${user_home}/.bash_profile | sed '1s/^/l3-agentX/' | tr X '\n' > /tmp/$$$$l3 ; mv /tmp/$$$$l3 ${user_home}/.bash_profile; chown -R ${user} ${user_home}/.bash_profile; } done cat <<USAGE $0 cat <<FINAL_MESSAGE $ l3cd ${lilalo_context%/*/*}/MY-NEW-CONTEXT/${hostname}/USER $ l3pwd |
#cat install | grep '^$'
|
#cat install | grep -v'^$'
![]() grep: невеÑнÑй паÑамеÑÑ Â«^» ÐÑполÑзование: grep [ÐÐÐ ÐÐÐТР]⦠ШÐÐÐФÐÐÐ rep --help» Ð´Ð»Ñ Ð¿Ð¾Ð»ÑÑÐµÐ½Ð¸Ñ Ð±Ð¾Ð»ÐµÐµ подÑобного опиÑаниÑ. |
#cat install | grep -v '^$'
#!/bin/sh hostname=`hostname` uname -a | egrep -qi '(freebsd|darwin)' || hostname=`hostname -f` ############################################################################### # # Set this variables before installation: lilalo_user=13-10-2014 lab=NT-LNet install_l3bashrc_for_this_users=${users:-"root user"} # users who will use l3agent and l3script lilalo_context="/users/${lilalo_user}/${lab}/${hostname}" ... step "Downloading l3prompt" ${wget} ${url_l3prompt} step "Downloading l3-agent" '${wget} ${url_l3agent}; ${wget} ${url_l3config_pm}; ${wget} ${url_l3config}' step "Downloading perl modules for l3-agent" '{ for i in ${perl_modules}; do ${wget} ${url_perl_modules}/$i.tar.gz; done; }' step "Installing perl modules for l3-agent" '{ for i in ${perl_modules}; do tar xvfz $i.tar.gz; cd $i*[^z]; perl Makefile.PL; make; make install; cd ..; done; }' step "Installing l3bashrc to users home directories" install_to_users_homes $install_l3bashrc_for_this_users step "Adding l3bashrc invocation to ~/.bashrc " install_to_users_bashrc $install_l3bashrc_for_this_users step "Adding l3-agent invocation to ~/.bash_profile " install_to_users_bash_profile $install_l3bashrc_for_this_users cd / rm -rf ${temp_dir} show_final_message |
#cat install | grep -v '^[abc]'
#!/bin/sh hostname=`hostname` uname -a | egrep -qi '(freebsd|darwin)' || hostname=`hostname -f` ############################################################################### # # Set this variables before installation: lilalo_user=13-10-2014 lab=NT-LNet install_l3bashrc_for_this_users=${users:-"root user"} # users who will use l3agent and l3script lilalo_context="/users/${lilalo_user}/${lab}/${hostname}" ... step "Downloading l3bashrc" ${wget} ${url_l3bashrc} step "Downloading l3prompt" ${wget} ${url_l3prompt} step "Downloading l3-agent" '${wget} ${url_l3agent}; ${wget} ${url_l3config_pm}; ${wget} ${url_l3config}' step "Downloading perl modules for l3-agent" '{ for i in ${perl_modules}; do ${wget} ${url_perl_modules}/$i.tar.gz; done; }' step "Installing perl modules for l3-agent" '{ for i in ${perl_modules}; do tar xvfz $i.tar.gz; cd $i*[^z]; perl Makefile.PL; make; make install; cd ..; done; }' step "Installing l3bashrc to users home directories" install_to_users_homes $install_l3bashrc_for_this_users step "Adding l3bashrc invocation to ~/.bashrc " install_to_users_bashrc $install_l3bashrc_for_this_users step "Adding l3-agent invocation to ~/.bash_profile " install_to_users_bash_profile $install_l3bashrc_for_this_users rm -rf ${temp_dir} show_final_message |
#cat install | grep '^[abc]'
apt_get_install_this="perl make libmodule-build-perl libc6-dev gcc" apt_get_install_deps() cd ${temp_dir} cd / |
#cat install | grep '^[^abc]'
#!/bin/sh hostname=`hostname` uname -a | egrep -qi '(freebsd|darwin)' || hostname=`hostname -f` ############################################################################### # # Set this variables before installation: lilalo_user=13-10-2014 lab=NT-LNet install_l3bashrc_for_this_users=${users:-"root user"} # users who will use l3agent and l3script lilalo_context="/users/${lilalo_user}/${lab}/${hostname}" ... step "Downloading l3bashrc" ${wget} ${url_l3bashrc} step "Downloading l3prompt" ${wget} ${url_l3prompt} step "Downloading l3-agent" '${wget} ${url_l3agent}; ${wget} ${url_l3config_pm}; ${wget} ${url_l3config}' step "Downloading perl modules for l3-agent" '{ for i in ${perl_modules}; do ${wget} ${url_perl_modules}/$i.tar.gz; done; }' step "Installing perl modules for l3-agent" '{ for i in ${perl_modules}; do tar xvfz $i.tar.gz; cd $i*[^z]; perl Makefile.PL; make; make install; cd ..; done; }' step "Installing l3bashrc to users home directories" install_to_users_homes $install_l3bashrc_for_this_users step "Adding l3bashrc invocation to ~/.bashrc " install_to_users_bashrc $install_l3bashrc_for_this_users step "Adding l3-agent invocation to ~/.bash_profile " install_to_users_bash_profile $install_l3bashrc_for_this_users rm -rf ${temp_dir} show_final_message |
#cat install | grep '^[[:alpha:]'
![]() grep: Непарная [ или [^ |
#cat install | grep '^[[:alpha:]]'
hostname=`hostname` uname -a | egrep -qi '(freebsd|darwin)' || hostname=`hostname -f` lilalo_user=13-10-2014 lab=NT-LNet install_l3bashrc_for_this_users=${users:-"root user"} # users who will use l3agent and l3script lilalo_context="/users/${lilalo_user}/${lab}/${hostname}" lilalo_rc=.l3rc lilalo_home=.lilalo url_lilalo="http://xgu.ru/lilalo" url_l3bashrc="${url_lilalo}"/l3bashrc ... step "Downloading l3prompt" ${wget} ${url_l3prompt} step "Downloading l3-agent" '${wget} ${url_l3agent}; ${wget} ${url_l3config_pm}; ${wget} ${url_l3config}' step "Downloading perl modules for l3-agent" '{ for i in ${perl_modules}; do ${wget} ${url_perl_modules}/$i.tar.gz; done; }' step "Installing perl modules for l3-agent" '{ for i in ${perl_modules}; do tar xvfz $i.tar.gz; cd $i*[^z]; perl Makefile.PL; make; make install; cd ..; done; }' step "Installing l3bashrc to users home directories" install_to_users_homes $install_l3bashrc_for_this_users step "Adding l3bashrc invocation to ~/.bashrc " install_to_users_bashrc $install_l3bashrc_for_this_users step "Adding l3-agent invocation to ~/.bash_profile " install_to_users_bash_profile $install_l3bashrc_for_this_users cd / rm -rf ${temp_dir} show_final_message |
#cat install | grep '^[[:lower:]]'
hostname=`hostname` uname -a | egrep -qi '(freebsd|darwin)' || hostname=`hostname -f` lilalo_user=13-10-2014 lab=NT-LNet install_l3bashrc_for_this_users=${users:-"root user"} # users who will use l3agent and l3script lilalo_context="/users/${lilalo_user}/${lab}/${hostname}" lilalo_rc=.l3rc lilalo_home=.lilalo url_lilalo="http://xgu.ru/lilalo" url_l3bashrc="${url_lilalo}"/l3bashrc ... step "Downloading l3prompt" ${wget} ${url_l3prompt} step "Downloading l3-agent" '${wget} ${url_l3agent}; ${wget} ${url_l3config_pm}; ${wget} ${url_l3config}' step "Downloading perl modules for l3-agent" '{ for i in ${perl_modules}; do ${wget} ${url_perl_modules}/$i.tar.gz; done; }' step "Installing perl modules for l3-agent" '{ for i in ${perl_modules}; do tar xvfz $i.tar.gz; cd $i*[^z]; perl Makefile.PL; make; make install; cd ..; done; }' step "Installing l3bashrc to users home directories" install_to_users_homes $install_l3bashrc_for_this_users step "Adding l3bashrc invocation to ~/.bashrc " install_to_users_bashrc $install_l3bashrc_for_this_users step "Adding l3-agent invocation to ~/.bash_profile " install_to_users_bash_profile $install_l3bashrc_for_this_users cd / rm -rf ${temp_dir} show_final_message |
#cat install | grep '^[[:almun:]]'
![]() grep: Неверное имя класса знаков |
#cat install | grep '^[[:alnum:]]'
hostname=`hostname` uname -a | egrep -qi '(freebsd|darwin)' || hostname=`hostname -f` lilalo_user=13-10-2014 lab=NT-LNet install_l3bashrc_for_this_users=${users:-"root user"} # users who will use l3agent and l3script lilalo_context="/users/${lilalo_user}/${lab}/${hostname}" lilalo_rc=.l3rc lilalo_home=.lilalo url_lilalo="http://xgu.ru/lilalo" url_l3bashrc="${url_lilalo}"/l3bashrc ... step "Downloading l3prompt" ${wget} ${url_l3prompt} step "Downloading l3-agent" '${wget} ${url_l3agent}; ${wget} ${url_l3config_pm}; ${wget} ${url_l3config}' step "Downloading perl modules for l3-agent" '{ for i in ${perl_modules}; do ${wget} ${url_perl_modules}/$i.tar.gz; done; }' step "Installing perl modules for l3-agent" '{ for i in ${perl_modules}; do tar xvfz $i.tar.gz; cd $i*[^z]; perl Makefile.PL; make; make install; cd ..; done; }' step "Installing l3bashrc to users home directories" install_to_users_homes $install_l3bashrc_for_this_users step "Adding l3bashrc invocation to ~/.bashrc " install_to_users_bashrc $install_l3bashrc_for_this_users step "Adding l3-agent invocation to ~/.bash_profile " install_to_users_bash_profile $install_l3bashrc_for_this_users cd / rm -rf ${temp_dir} show_final_message |
#cat install | grep '^.[[:alnum:]]'
hostname=`hostname` uname -a | egrep -qi '(freebsd|darwin)' || hostname=`hostname -f` lilalo_user=13-10-2014 lab=NT-LNet install_l3bashrc_for_this_users=${users:-"root user"} # users who will use l3agent and l3script lilalo_context="/users/${lilalo_user}/${lab}/${hostname}" lilalo_rc=.l3rc lilalo_home=.lilalo url_lilalo="http://xgu.ru/lilalo" url_l3bashrc="${url_lilalo}"/l3bashrc ... step "Downloading l3prompt" ${wget} ${url_l3prompt} step "Downloading l3-agent" '${wget} ${url_l3agent}; ${wget} ${url_l3config_pm}; ${wget} ${url_l3config}' step "Downloading perl modules for l3-agent" '{ for i in ${perl_modules}; do ${wget} ${url_perl_modules}/$i.tar.gz; done; }' step "Installing perl modules for l3-agent" '{ for i in ${perl_modules}; do tar xvfz $i.tar.gz; cd $i*[^z]; perl Makefile.PL; make; make install; cd ..; done; }' step "Installing l3bashrc to users home directories" install_to_users_homes $install_l3bashrc_for_this_users step "Adding l3bashrc invocation to ~/.bashrc " install_to_users_bashrc $install_l3bashrc_for_this_users step "Adding l3-agent invocation to ~/.bash_profile " install_to_users_bash_profile $install_l3bashrc_for_this_users cd / rm -rf ${temp_dir} show_final_message |
#cat install | grep '^.[f-k]'
lilalo_user=13-10-2014 lilalo_context="/users/${lilalo_user}/${lab}/${hostname}" lilalo_rc=.l3rc lilalo_home=.lilalo wget=wget whiteC='\033[1;37m' show_usage() show_final_message() If you use xgu.ru backend, your labs will be available at Thank you gor using LiLaLo. mkdir -p ${temp_dir} show_final_message |
#cat install | grep 'xgu.ru
![]() > > l3script: unexpected EOF while looking for matching `'' l3script: ошибка синтаксиса: неожиданный конец файла |
#cat install | grep 'xgu.ru
' url_lilalo="http://xgu.ru/lilalo" If you use xgu.ru backend, your labs will be available at http://xgu.ru/l3/${lilalo_context} For further information see http://xgu.ru/lilalo/ (in Russian). |
#cat install | grep 'xgu\.ru'
url_lilalo="http://xgu.ru/lilalo" If you use xgu.ru backend, your labs will be available at http://xgu.ru/l3/${lilalo_context} For further information see http://xgu.ru/lilalo/ (in Russian). |
#cat install | grep 'ht+p'
![]() |
#cat install | grep E 'ht+p'
![]() grep: ht+p: Нет такого файла или каталога |
#cat install | grep -E 'ht+p'
url_lilalo="http://xgu.ru/lilalo" http://xgu.ru/l3/${lilalo_context} For further information see http://xgu.ru/lilalo/ (in Russian). |
#cat install | egrep 'ht+p'
url_lilalo="http://xgu.ru/lilalo" http://xgu.ru/l3/${lilalo_context} For further information see http://xgu.ru/lilalo/ (in Russian). |
#ls -l `which grep`
-rwxr-xr-x 1 root root 175488 Май 13 2012 /bin/grep |
#ls -l `which egrep`
-rwxr-xr-x 1 root root 175456 Май 13 2012 /bin/egrep |
#cat install | egrep 'ht*p'
url_lilalo="http://xgu.ru/lilalo" http://xgu.ru/l3/${lilalo_context} For further information see http://xgu.ru/lilalo/ (in Russian). |
#cat install | grep 'ht*p'
url_lilalo="http://xgu.ru/lilalo" http://xgu.ru/l3/${lilalo_context} For further information see http://xgu.ru/lilalo/ (in Russian). |
#cat install | grep 'ht&p'
![]() |
#cat install | grep 'ht?p'
![]() |
#cat install | grep 'htt?p'
![]() |
#cat install | egrep 'if (which)? apt-get'
if which apt-get >& /dev/null |
[1] 9351 [1]+ Stopped cat
fu fu
find: `/proc/9413/task/9413/fd/5': Нет такого файла или каталога find: `/proc/9413/task/9413/fdinfo/5': Нет такого файла или каталога find: `/proc/9413/fd/5': Нет такого файла или каталога find: `/proc/9413/fdinfo/5': Нет такого файла или каталога
#!/bin/sh hostname=`hostname` uname -a | egrep -qi '(freebsd|darwin)' || hostname=`hostname -f` ############################################################################### # # Set this variables before installation: lilalo_user=13-10-2014 lab=NT-LNet install_l3bashrc_for_this_users=${users:-"root user"} # users who will use l3agent and l3script lilalo_context="/users/${lilalo_user}/${lab}/${hostname}" # ############################################################################### lilalo_rc=.l3rc lilalo_home=.lilalo url_lilalo="http://xgu.ru/lilalo" url_l3bashrc="${url_lilalo}"/l3bashrc url_l3agent="${url_lilalo}"/l3-agent url_l3config_pm="${url_lilalo}"/l3config.pm url_l3config="${url_lilalo}"/l3-config url_l3prompt="${url_lilalo}"/l3prompt url_perl_modules=${url_lilalo}/ perl_modules="Term-VT102 Text-Iconv" apt_get_install_this="perl make libmodule-build-perl libc6-dev gcc" wget=wget uname -a | egrep -qi '(bsd|darwin)' && wget=fetch normC='\033[0;39m' whiteC='\033[1;37m' redC='\033[0;31m' greenC='\033[0;32m' apt_get_install_deps() { return 0 if which apt-get >& /dev/null then apt-get install -y $apt_get_install_this else echo "Please install this dependencies manually:" echo $apt_get_install_this echo "Have you installed this already (y/n)?" echo y | read answer if echo $answer | grep -q ^[yY] then true else echo Please install the dependencies and rerun the script exit 1 fi fi } step() { msg="$1" shift printf "${whiteC}""$msg""...${normC}\n" # eval "$@" 2>&1 | sed 's/^/|\ \ \ /' && printf "Ok\n" || printf "Failed\n" eval "$@" 2>&1 > log 2>&1 && \ { cat log | sed 's/^/|\ \ \ /' printf "${greenC}""Ok\n""${normC}" } || \ { cat log | sed 's/^/|\ \ \ /' printf "${redC}""Failed\n""${normC}" } } get_user_home() { uname -a | egrep -qi '(freebsd|darwin)' && pw user show "$@"| awk -F: '{print $9}' || getent passwd "$@"| awk -F: '{print $6}' } install_to_users_homes() { . l3bashrc users="$@" set -x for user in $users do user_home=`get_user_home "$user"` mkdir -p ${user_home}/${lilalo_home} mkdir /etc/lilalo/ cp l3config.pm /etc/lilalo/ cp l3-agent /usr/local/bin cp l3-config /usr/local/bin ln -s `which bash` /usr/local/bin/l3script chmod 755 /usr/local/bin/l3-{agent,config} cp l3bashrc ${user_home}/${lilalo_home} cp l3prompt ${user_home}/${lilalo_home} chmod 755 ${user_home}/${lilalo_home}/l3prompt chown -R $user ${user_home}/${lilalo_home} echo l3cd=${lilalo_context}/$user > ${user_home}/${lilalo_rc} chown -R $user ${user_home}/${lilalo_rc} done set +x } install_to_users_bashrc() { users="$@" for user in $users do user_home=`get_user_home "$user"` grep -q lilalo ${user_home}/.bashrc 2> /dev/null\ || echo "[ \$0 == l3script ] && . ${user_home}/.lilalo/l3bashrc && _l3_start" >> ${user_home}/.bashrc; chown -R ${user} ${user_home}/.bashrc done } install_to_users_bash_profile() { users="$@" for user in $users do user_home=`get_user_home "$user"` grep -q l3-agent ${user_home}/.bash_profile 2> /dev/null \ || { echo >> ${user_home}/.bash_profile ; cat ${user_home}/.bash_profile | sed '1s/^/l3-agentX/' | tr X '\n' > /tmp/$$$$l3 ; mv /tmp/$$$$l3 ${user_home}/.bash_profile; chown -R ${user} ${user_home}/.bash_profile; } done } show_usage() { cat <<USAGE Usage: $0 USAGE } show_final_message() { cat <<FINAL_MESSAGE Installation is successfully completed. Now restart your shell or relogin to start script writing. Your current lilalo context is ${lilalo_context}/USER If you use xgu.ru backend, your labs will be available at http://xgu.ru/l3/${lilalo_context} Use commands $ l3cd ${lilalo_context%/*/*}/MY-NEW-CONTEXT/${hostname}/USER $ l3pwd to change and to know your current context. For further information see http://xgu.ru/lilalo/ (in Russian). Thank you gor using LiLaLo. Happy Labbing! (don't forget to restart bash or relogin) FINAL_MESSAGE } temp_dir=/tmp/lilalo-install-temp-$$ mkdir -p ${temp_dir} cd ${temp_dir} step "Installing dependencies" apt_get_install_deps step "Downloading l3bashrc" ${wget} ${url_l3bashrc} step "Downloading l3prompt" ${wget} ${url_l3prompt} step "Downloading l3-agent" '${wget} ${url_l3agent}; ${wget} ${url_l3config_pm}; ${wget} ${url_l3config}' step "Downloading perl modules for l3-agent" '{ for i in ${perl_modules}; do ${wget} ${url_perl_modules}/$i.tar.gz; done; }' step "Installing perl modules for l3-agent" '{ for i in ${perl_modules}; do tar xvfz $i.tar.gz; cd $i*[^z]; perl Makefile.PL; make; make install; cd ..; done; }' step "Installing l3bashrc to users home directories" install_to_users_homes $install_l3bashrc_for_this_users step "Adding l3bashrc invocation to ~/.bashrc " install_to_users_bashrc $install_l3bashrc_for_this_users step "Adding l3-agent invocation to ~/.bash_profile " install_to_users_bash_profile $install_l3bashrc_for_this_users cd / rm -rf ${temp_dir} show_final_message
Время первой команды журнала | 09:42:56 2015- 9-29 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Время последней команды журнала | 13:24:50 2015- 9-29 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Количество командных строк в журнале | 101 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Процент команд с ненулевым кодом завершения, % | 18.81 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Процент синтаксически неверно набранных команд, % | 0.99 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Суммарное время работы с терминалом *, час | 1.72 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Количество командных строк в единицу времени, команда/мин | 0.98 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Частота использования команд |
|
В журнал автоматически попадают все команды, данные в любом терминале системы.
Для того чтобы убедиться, что журнал на текущем терминале ведётся, и команды записываются, дайте команду w. В поле WHAT, соответствующем текущему терминалу, должна быть указана программа script.
Команды, при наборе которых были допущены синтаксические ошибки, выводятся перечёркнутым текстом:
$ l s-l bash: l: command not found |
Если код завершения команды равен нулю, команда была выполнена без ошибок. Команды, код завершения которых отличен от нуля, выделяются цветом.
$ test 5 -lt 4 |
Команды, ход выполнения которых был прерван пользователем, выделяются цветом.
$ find / -name abc find: /home/devi-orig/.gnome2: Keine Berechtigung find: /home/devi-orig/.gnome2_private: Keine Berechtigung find: /home/devi-orig/.nautilus/metafiles: Keine Berechtigung find: /home/devi-orig/.metacity: Keine Berechtigung find: /home/devi-orig/.inkscape: Keine Berechtigung ^C |
Команды, выполненные с привилегиями суперпользователя, выделяются слева красной чертой.
# id uid=0(root) gid=0(root) Gruppen=0(root) |
Изменения, внесённые в текстовый файл с помощью редактора, запоминаются и показываются в журнале в формате ed. Строки, начинающиеся символом "<", удалены, а строки, начинающиеся символом ">" -- добавлены.
$ vi ~/.bashrc
|
Для того чтобы изменить файл в соответствии с показанными в диффшоте изменениями, можно воспользоваться командой patch. Нужно скопировать изменения, запустить программу patch, указав в качестве её аргумента файл, к которому применяются изменения, и всавить скопированный текст:
$ patch ~/.bashrc |
Для того чтобы получить краткую справочную информацию о команде, нужно подвести к ней мышь. Во всплывающей подсказке появится краткое описание команды.
Если справочная информация о команде есть, команда выделяется голубым фоном, например: vi. Если справочная информация отсутствует, команда выделяется розовым фоном, например: notepad.exe. Справочная информация может отсутствовать в том случае, если (1) команда введена неверно; (2) если распознавание команды LiLaLo выполнено неверно; (3) если информация о команде неизвестна LiLaLo. Последнее возможно для редких команд.
Большие, в особенности многострочные, всплывающие подсказки лучше всего показываются браузерами KDE Konqueror, Apple Safari и Microsoft Internet Explorer. В браузерах Mozilla и Firefox они отображаются не полностью, а вместо перевода строки выводится специальный символ.
Время ввода команды, показанное в журнале, соответствует времени начала ввода командной строки, которое равно тому моменту, когда на терминале появилось приглашение интерпретатора
Имя терминала, на котором была введена команда, показано в специальном блоке. Этот блок показывается только в том случае, если терминал текущей команды отличается от терминала предыдущей.
Вывод не интересующих вас в настоящий момент элементов журнала, таких как время, имя терминала и других, можно отключить. Для этого нужно воспользоваться формой управления журналом вверху страницы.
Небольшие комментарии к командам можно вставлять прямо из командной строки. Комментарий вводится прямо в командную строку, после символов #^ или #v. Символы ^ и v показывают направление выбора команды, к которой относится комментарий: ^ - к предыдущей, v - к следующей. Например, если в командной строке было введено:
$ whoami
user
$ #^ Интересно, кто я?в журнале это будет выглядеть так:
$ whoami
user
Интересно, кто я? |
Если комментарий содержит несколько строк, его можно вставить в журнал следующим образом:
$ whoami
user
$ cat > /dev/null #^ Интересно, кто я?
Программа whoami выводит имя пользователя, под которым мы зарегистрировались в системе. - Она не может ответить на вопрос о нашем назначении в этом мире.В журнале это будет выглядеть так:
$ whoami user
|
Комментарии, не относящиеся непосредственно ни к какой из команд, добавляются точно таким же способом, только вместо симолов #^ или #v нужно использовать символы #=
1 2 3 4Группы команд, выполненных на разных терминалах, разделяются специальной линией. Под этой линией в правом углу показано имя терминала, на котором выполнялись команды. Для того чтобы посмотреть команды только одного сенса, нужно щёкнуть по этому названию.
LiLaLo (L3) расшифровывается как Live Lab Log.
Программа разработана для повышения эффективности обучения Unix/Linux-системам.
(c) Игорь Чубин, 2004-2008