Журнал лабораторных работ

Содержание

Журнал

Вторник (09/29/15)

/dev/pts/0
09:42:56
#ls -l $(which chsh)
-rwsr-xr-x 1 root root 41272 Май 26  2012 /usr/bin/chsh
09:43:17
#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}!"
прошло 10 минут
09:53:49
#echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
09:55:24
#pwd
/root
09:55:29
#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
09:55:44
#chmod u+x privet.sh

09:56:14
#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
09:56:19
#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
09:56:38
#./privet.sh
Privet !
09:56:58
#./privet.sh Viktor
Privet Viktor!
09:58:26
#./privet.sh Viktor
Privet Viktor!
09:58:33
#./privet.sh
Privet Noname!
09:58:37
#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}!"
10:00:21
#./privet.sh
l3script: ./privet.sh: /bin/bashi: плохой интерпретатор: Нет такого файла или каталога
10:00:24
#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:+}!"
10:00:47
#./privet.sh
l3script: ./privet.sh: /bin/bashi: плохой интерпретатор: Нет такого файла или каталога
10:00:49
#echo $(7+5))
l3script: syntax error near unexpected token `)'
10:01:10
#echo $((7+5))
12
10:01:18
#echo $[7+5]
12
10:01:40
#i=1

10:02:37
#echo $i
1
10:02:49
#i=$[$i+1]

10:03:16
#echo $i
2
10:03:21
#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
10:05:20
#ps ax | wc -l
68
10:06:03
#$[$(ps ax | wc -l)-4]
l3script: 65: команда не найдена
10:07:46
#cat report

10:13:46
#cat
fu
fu
10:14:51
#cat &
[1] 9351
[1]+  Stopped                 cat
10:15:45
#jobs
[1]+  Stopped                 cat
10:15:54
#jobs -l
[1]+  9351 Остановлено (ввод с терминала)                               cat
10:16:05
#cd /proc/9351/fd

10:16:41
#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
10:16:54
#tty
/dev/pts/0
10:17:06
#cd

10:19:02
#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': Нет такого файла или каталога
10:19:48
#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
10:20:39
#ls
errors  file1  file2  file3  file4  file5  install  privet.sh  report  shadow
10:20:50
#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': Нет такого файла или каталога
10:21:02
#find / -user ivan -type f 2> errors >1 files

10:21:24
#ls
1  errors  file1  file2  file3  file4  file5  install  privet.sh  report  shadow
10:21:38
#find / -user ivan -type f 2> errors 1> files

10:22:09
#find / -user ivan -type f &>all

10:22:26
#mail ivan\
> ^C
10:22:40
#mail ivan
Subject: Hello
Privet Ivan
.
EOT
10:23:08
#mail -s report ivan < all

10:25:45
#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
10:27:27
#set -o
allexport       off
braceexpand     on
emacs           on
errexit         off
errtrace        off
functrace       off
hashall         on
histexpand      on
history         on
ignoreeof       off
...
notify          off
nounset         off
onecmd          off
physical        off
pipefail        off
posix           off
privileged      off
verbose         off
vi              off
xtrace          off
10:27:33
#set -o noclobber

10:28:10
#set -o
allexport       off
braceexpand     on
emacs           on
errexit         off
errtrace        off
functrace       off
hashall         on
histexpand      on
history         on
ignoreeof       off
...
notify          off
nounset         off
onecmd          off
physical        off
pipefail        off
posix           off
privileged      off
verbose         off
vi              off
xtrace          off
10:28:12
#find / -user ivan -type f 2> errors 1> files
l3script: errors: не могу переписать уже существующий файл
10:29:09
#lsapttr
l3script: lsapttr: команда не найдена
10:29:45
#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
10:29:53
#chattr +a report

10:30:22
#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
10:30:35
#find / -user ivan -type f 2> errors 1> files

10:30:56
#date >> report

10:31:34
#chattr -a report

10:31:47
#chattr +i report

10:31:55
#ls
1  all  errors  file1  file2  file3  file4  file5  files  install  privet.sh  report  shadow
прошло 24 минуты
10:56:00
#ls f*
file1  file2  file3  file4  file5  files
10:56:08
#ls -1 f* | sort -r
files
file5
file4
file3
file2
file1
10:56:39
#ls -1 f* | rm -f

10:57:16
#ls
1  all  errors  file1  file2  file3  file4  file5  files  install  privet.sh  report  shadow
10:57:18
#ls -1 f* | xargs rm -f

10:58:23
#ls
1  all  errors  install  privet.sh  report  shadow
10:58:25
#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
прошло 118 минут
12:57:17
#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
12:57:58
#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
12:58:23
#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
13:01:26
#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
13:01:35
#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
13:01:53
#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
13:02:20
#cat install | grep '^$'

13:02:33
#cat install | grep -v'^$'
grep: неверный параметр «^»
Использование: grep [ПАРАМЕТР]… ШАБÐФАЙÐ
rep --help» для получения более подробного описания.
13:03:14
#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
13:03:22
#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
13:06:07
#cat install | grep '^[abc]'
apt_get_install_this="perl make libmodule-build-perl libc6-dev gcc"
apt_get_install_deps()
cd ${temp_dir}
cd /
13:06:16
#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
13:06:46
#cat install | grep '^[[:alpha:]'
grep: Непарная [ или [^
13:14:38
#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
13:14:49
#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
13:15:12
#cat install | grep '^[[:almun:]]'
grep: Неверное имя класса знаков
13:15:34
#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
13:15:47
#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
13:17:05
#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
13:17:27
#cat install | grep 'xgu.ru
>
> l3script: unexpected EOF while looking for matching `''
l3script: ошибка синтаксиса: неожиданный конец файла
13:18:05
#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).
13:18:14
#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).
13:19:02
#cat install | grep 'ht+p'

13:20:56
#cat install | grep E 'ht+p'
grep: ht+p: Нет такого файла или каталога
13:22:22
#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).
13:22:27
#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).
13:22:35
#ls -l `which grep`
-rwxr-xr-x 1 root root 175488 Май 13  2012 /bin/grep
13:22:55
#ls -l `which egrep`
-rwxr-xr-x 1 root root 175456 Май 13  2012 /bin/egrep
13:22:59
#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).
13:24:02
#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).
13:24:17
#cat install | grep 'ht&p'

13:24:32
#cat install | grep 'ht?p'

13:24:38
#cat install | grep 'htt?p'

13:24:50
#cat install | egrep 'if (which)? apt-get'
    if which apt-get >& /dev/null

Файлы

  • &
  • cat
  • errors
  • install
  • report
  • &
    >
    [1] 9351
    [1]+  Stopped                 cat
    
    cat
    >
    fu
    fu
    
    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': Нет такого файла или каталога
    
    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}"
    #
    ###############################################################################
    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
    
    report
    >

    Статистика

    Время первой команды журнала09:42:56 2015- 9-29
    Время последней команды журнала13:24:50 2015- 9-29
    Количество командных строк в журнале101
    Процент команд с ненулевым кодом завершения, %18.81
    Процент синтаксически неверно набранных команд, % 0.99
    Суммарное время работы с терминалом *, час 1.72
    Количество командных строк в единицу времени, команда/мин 0.98
    Частота использования команд
    cat37|========================| 24.18%
    grep29|==================| 18.95%
    ls16|==========| 10.46%
    find7|====| 4.58%
    echo6|===| 3.92%
    privet.sh6|===| 3.92%
    errors5|===| 3.27%
    egrep3|=| 1.96%
    set3|=| 1.96%
    mail3|=| 1.96%
    vi3|=| 1.96%
    chattr3|=| 1.96%
    files3|=| 1.96%
    lsattr2|=| 1.31%
    cd2|=| 1.31%
    wc2|=| 1.31%
    all2|=| 1.31%
    >2|=| 1.31%
    jobs2|=| 1.31%
    i=$[$i+1]1|| 0.65%
    sort1|| 0.65%
    chmod1|| 0.65%
    rm1|| 0.65%
    ps1|| 0.65%
    top1|| 0.65%
    report1|| 0.65%
    pwd1|| 0.65%
    $[$(ps1|| 0.65%
    lsapttr1|| 0.65%
    xargs1|| 0.65%
    p'1|| 0.65%
    11|| 0.65%
    tty1|| 0.65%
    date1|| 0.65%
    shopt1|| 0.65%
    i=11|| 0.65%
    ____
    *) Интервалы неактивности длительностью 30 минут и более не учитываются

    Справка

    Для того чтобы использовать LiLaLo, не нужно знать ничего особенного: всё происходит само собой. Однако, чтобы ведение и последующее использование журналов было как можно более эффективным, желательно иметь в виду следующее:
    1. В журнал автоматически попадают все команды, данные в любом терминале системы.

    2. Для того чтобы убедиться, что журнал на текущем терминале ведётся, и команды записываются, дайте команду w. В поле WHAT, соответствующем текущему терминалу, должна быть указана программа script.

    3. Команды, при наборе которых были допущены синтаксические ошибки, выводятся перечёркнутым текстом:
      $ l s-l
      bash: l: command not found
      

    4. Если код завершения команды равен нулю, команда была выполнена без ошибок. Команды, код завершения которых отличен от нуля, выделяются цветом.
      $ test 5 -lt 4
      Обратите внимание на то, что код завершения команды может быть отличен от нуля не только в тех случаях, когда команда была выполнена с ошибкой. Многие команды используют код завершения, например, для того чтобы показать результаты проверки

    5. Команды, ход выполнения которых был прерван пользователем, выделяются цветом.
      $ 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
      

    6. Команды, выполненные с привилегиями суперпользователя, выделяются слева красной чертой.
      # id
      uid=0(root) gid=0(root) Gruppen=0(root)
      

    7. Изменения, внесённые в текстовый файл с помощью редактора, запоминаются и показываются в журнале в формате ed. Строки, начинающиеся символом "<", удалены, а строки, начинающиеся символом ">" -- добавлены.
      $ vi ~/.bashrc
      2a3,5
      >    if [ -f /usr/local/etc/bash_completion ]; then
      >         . /usr/local/etc/bash_completion
      >        fi
      

    8. Для того чтобы изменить файл в соответствии с показанными в диффшоте изменениями, можно воспользоваться командой patch. Нужно скопировать изменения, запустить программу patch, указав в качестве её аргумента файл, к которому применяются изменения, и всавить скопированный текст:
      $ patch ~/.bashrc
      В данном случае изменения применяются к файлу ~/.bashrc

    9. Для того чтобы получить краткую справочную информацию о команде, нужно подвести к ней мышь. Во всплывающей подсказке появится краткое описание команды.

      Если справочная информация о команде есть, команда выделяется голубым фоном, например: vi. Если справочная информация отсутствует, команда выделяется розовым фоном, например: notepad.exe. Справочная информация может отсутствовать в том случае, если (1) команда введена неверно; (2) если распознавание команды LiLaLo выполнено неверно; (3) если информация о команде неизвестна LiLaLo. Последнее возможно для редких команд.

    10. Большие, в особенности многострочные, всплывающие подсказки лучше всего показываются браузерами KDE Konqueror, Apple Safari и Microsoft Internet Explorer. В браузерах Mozilla и Firefox они отображаются не полностью, а вместо перевода строки выводится специальный символ.

    11. Время ввода команды, показанное в журнале, соответствует времени начала ввода командной строки, которое равно тому моменту, когда на терминале появилось приглашение интерпретатора

    12. Имя терминала, на котором была введена команда, показано в специальном блоке. Этот блок показывается только в том случае, если терминал текущей команды отличается от терминала предыдущей.

    13. Вывод не интересующих вас в настоящий момент элементов журнала, таких как время, имя терминала и других, можно отключить. Для этого нужно воспользоваться формой управления журналом вверху страницы.

    14. Небольшие комментарии к командам можно вставлять прямо из командной строки. Комментарий вводится прямо в командную строку, после символов #^ или #v. Символы ^ и v показывают направление выбора команды, к которой относится комментарий: ^ - к предыдущей, v - к следующей. Например, если в командной строке было введено:

      $ whoami
      
      user
      
      $ #^ Интересно, кто я?
      
      в журнале это будет выглядеть так:
      $ whoami
      
      user
      
      Интересно, кто я?

    15. Если комментарий содержит несколько строк, его можно вставить в журнал следующим образом:

      $ whoami
      
      user
      
      $ cat > /dev/null #^ Интересно, кто я?
      
      Программа whoami выводит имя пользователя, под которым 
      мы зарегистрировались в системе.
      -
      Она не может ответить на вопрос о нашем назначении 
      в этом мире.
      
      В журнале это будет выглядеть так:
      $ whoami
      user
      
      Интересно, кто я?
      Программа whoami выводит имя пользователя, под которым
      мы зарегистрировались в системе.

      Она не может ответить на вопрос о нашем назначении
      в этом мире.
      Для разделения нескольких абзацев между собой используйте символ "-", один в строке.

    16. Комментарии, не относящиеся непосредственно ни к какой из команд, добавляются точно таким же способом, только вместо симолов #^ или #v нужно использовать символы #=

    17. Содержимое файла может быть показано в журнале. Для этого его нужно вывести с помощью программы cat. Если вывод команды отметить симоволами #!, содержимое файла будет показано в журнале в специально отведённой для этого секции.
    18. Для того чтобы вставить скриншот интересующего вас окна в журнал, нужно воспользоваться командой l3shot. После того как команда вызвана, нужно с помощью мыши выбрать окно, которое должно быть в журнале.
    19. Команды в журнале расположены в хронологическом порядке. Если две команды давались одна за другой, но на разных терминалах, в журнале они будут рядом, даже если они не имеют друг к другу никакого отношения.
      1
          2
      3   
          4
      
      Группы команд, выполненных на разных терминалах, разделяются специальной линией. Под этой линией в правом углу показано имя терминала, на котором выполнялись команды. Для того чтобы посмотреть команды только одного сенса, нужно щёкнуть по этому названию.

    О программе

    LiLaLo (L3) расшифровывается как Live Lab Log.
    Программа разработана для повышения эффективности обучения Unix/Linux-системам.
    (c) Игорь Чубин, 2004-2008

    $Id$