/l3/users/6-6-2017/NT-Ladm/debian1.net.nt/root :1 :2 :3 |
|
#man bash | wc -l
5465 |
#man bash | wc -l
5465 |
#stty -a
speed 38400 baud; rows 24; columns 80; line = 0; intr = ^C; quit = ^\; erase = ^?; kill = ^U; eof = ^D; eol = <undef>; eol2 = <undef>; swtch = <undef>; start = ^Q; stop = ^S; susp = ^Z; rprnt = ^R; werase = ^W; lnext = ^V; flush = ^O; min = 1; time = 0; -parenb -parodd cs8 -hupcl -cstopb cread -clocal -crtscts -ignbrk -brkint -ignpar -parmrk -inpck -istrip -inlcr -igncr icrnl ixon -ixoff -iuclc -ixany -imaxbel -iutf8 opost -olcuc -ocrnl onlcr -onocr -onlret -ofill -ofdel nl0 cr0 tab0 bs0 vt0 ff0 isig icanon iexten echo echoe echok -echonl -noflsh -xcase -tostop -echoprt echoctl echoke |
#echo $[`man bash | wc -l`/60]
91 |
#echo $[$(man bash | wc -l)/60]
91 |
#ls
111 2352f346 24235 34634r d132 install |
#cp /etc/ssh/sshd_congig{,.old}
![]() cp: не удалось выполнить stat для «/etc/ssh/sshd_congig»: Нет такого файла или каталога |
#cp /etc/ssh/sshd_config{,.old}
|
#ls /etc/ssh
moduli sshd_config.old ssh_host_ecdsa_key ssh_host_rsa_key.pub ssh_config ssh_host_dsa_key ssh_host_ecdsa_key.pub sshd_config ssh_host_dsa_key.pub ssh_host_rsa_key |
#which vi
/usr/bin/vi |
#ls -l `which vi`
lrwxrwxrwx 1 root root 20 Июн 27 2014 /usr/bin/vi -> /etc/alternatives/vi |
#ls -l `which vi` | awk `{print $11}`
l3script: {print: команда не найдена |
#ls -l `which vi` | awk '{print $11}'
/etc/alternatives/vi |
#ls -l $(ls -l `which vi` | awk '{print $11}')
lrwxrwxrwx 1 root root 18 Июн 27 2014 /etc/alternatives/vi -> /usr/bin/vim.basic |
#ls
111 2352f346 24235 34634r d132 install |
#ls -l $(ls -l `which vi` | awk '{print $11}')
lrwxrwxrwx 1 root root 18 Июн 27 2014 /etc/alternatives/vi -> /usr/bin/vim.basic |
#echo +([0-9]) | xargs rm -v
удалён «111» удалён «24235» |
#cat passwd | grep '100'
![]() cat: passwd: Нет такого файла или каталога |
#cat passwd
![]() cat: passwd: Нет такого файла или каталога |
#cp /etc/passwd passwd
|
#cat passwd
root:x:0:0:root:/root:/bin/bash daemon:x:1:1:daemon:/usr/sbin:/bin/sh bin:x:2:2:bin:/bin:/bin/sh sys:x:3:3:sys:/dev:/bin/sh sync:x:4:65534:sync:/bin:/bin/sync games:x:5:60:games:/usr/games:/bin/sh man:x:6:12:man:/var/cache/man:/bin/sh lp:x:7:7:lp:/var/spool/lpd:/bin/sh mail:x:8:8:mail:/var/mail:/bin/sh news:x:9:9:news:/var/spool/news:/bin/sh ... list:x:38:38:Mailing List Manager:/var/list:/bin/sh irc:x:39:39:ircd:/var/run/ircd:/bin/sh gnats:x:41:41:Gnats Bug-Reporting System (admin):/var/lib/gnats:/bin/sh nobody:x:65534:65534:nobody:/nonexistent:/bin/sh libuuid:x:100:101::/var/lib/libuuid:/bin/sh Debian-exim:x:101:103::/var/spool/exim4:/bin/false user:x:1000:1000:user,,,:/home/user:/bin/bash sshd:x:102:65534::/var/run/sshd:/usr/sbin/nologin ivan:x:1001:1001::/home/ivan:/bin/bash petr:x:1002:1002::/home/petr:/bin/bash |
#cat passwd | grep '100'
libuuid:x:100:101::/var/lib/libuuid:/bin/sh user:x:1000:1000:user,,,:/home/user:/bin/bash ivan:x:1001:1001::/home/ivan:/bin/bash petr:x:1002:1002::/home/petr:/bin/bash |
#cat passwd | grep '^ivan'
ivan:x:1001:1001::/home/ivan:/bin/bash |
#cat passwd | grep '^[uip]'
uucp:x:10:10:uucp:/var/spool/uucp:/bin/sh proxy:x:13:13:proxy:/bin:/bin/sh irc:x:39:39:ircd:/var/run/ircd:/bin/sh user:x:1000:1000:user,,,:/home/user:/bin/bash ivan:x:1001:1001::/home/ivan:/bin/bash petr:x:1002:1002::/home/petr:/bin/bash |
#cat passwd | grep '^[dy-zia-c]'
daemon:x:1:1:daemon:/usr/sbin:/bin/sh bin:x:2:2:bin:/bin:/bin/sh backup:x:34:34:backup:/var/backups:/bin/sh irc:x:39:39:ircd:/var/run/ircd:/bin/sh ivan:x:1001:1001::/home/ivan:/bin/bash |
#cat passwd | grep '1..2'
petr:x:1002:1002::/home/petr:/bin/bash |
#cat passwd | grep '1.2'
sshd:x:102:65534::/var/run/sshd:/usr/sbin/nologin |
#cat passwd | grep '1.*2'
man:x:6:12:man:/var/cache/man:/bin/sh sshd:x:102:65534::/var/run/sshd:/usr/sbin/nologin petr:x:1002:1002::/home/petr:/bin/bash |
#cat passwd | grep '1.+2'
![]() |
#cat passwd | egrep '1.+2'
sshd:x:102:65534::/var/run/sshd:/usr/sbin/nologin petr:x:1002:1002::/home/petr:/bin/bash |
#cat passwd | egrep '1.{2}2'
petr:x:1002:1002::/home/petr:/bin/bash |
#cat passwd | egrep '1.?2'
man:x:6:12:man:/var/cache/man:/bin/sh sshd:x:102:65534::/var/run/sshd:/usr/sbin/nologin |
#cat passwd | egrep '1(..)?2'
man:x:6:12:man:/var/cache/man:/bin/sh petr:x:1002:1002::/home/petr:/bin/bash |
#cat passwd | egrep '^(ivan|petr|user)'
user:x:1000:1000:user,,,:/home/user:/bin/bash ivan:x:1001:1001::/home/ivan:/bin/bash petr:x:1002:1002::/home/petr:/bin/bash |
#vi ip.txt
![]() --- /dev/null 2017-06-02 15:39:53.528000002 +0300 +++ ip.txt 2017-06-07 14:38:54.356446865 +0300 @@ -0,0 +1,8 @@ +192.168.0.1 +500.8.4.5 +240.5.333.2 +a.4.4.9 +172.16.30.30 +4.6.70 +10.5.3.68 + |
#cat ip.txt
192.168.0.1 500.8.4.5 240.5.333.2 a.4.4.9 172.16.30.30 4.6.70 10.5.3.68 |
#cat ip.txt | egrep '^(0-255)'
![]() |
#cat ip.txt | egrep '^(0|1|2)'
192.168.0.1 240.5.333.2 172.16.30.30 10.5.3.68 |
#cat ip.txt | egrep '^(0|1|2)?'
192.168.0.1 500.8.4.5 240.5.333.2 a.4.4.9 172.16.30.30 4.6.70 10.5.3.68 |
#cat ip.txt | egrep '^(0|1|2)?.'
192.168.0.1 500.8.4.5 240.5.333.2 a.4.4.9 172.16.30.30 4.6.70 10.5.3.68 |
#cat ip.txt | egrep '^(0|1|2)?.(0|1|2|3|4|5|6|7|8|9)?.'
192.168.0.1 500.8.4.5 240.5.333.2 a.4.4.9 172.16.30.30 4.6.70 10.5.3.68 |
#'
|
#cat ip.txt | egrep '^(0|1|2)?(0|1|2|3|4|5|6|7|8|9)?(0|1|2|3|4|5|6|7|8|9^C'
![]() |
#cat ip.txt | egrep '^(0|1|2)?(0|1|2|3|4|5|6|7|8|9)?(0|1|2|3|4|5|6|7|8|9)?(0|1|2|3|4|5|6|7|8|9).'
192.168.0.1 500.8.4.5 240.5.333.2 172.16.30.30 4.6.70 10.5.3.68 |
#cat ip.txt | egrep '^[0-255]'
192.168.0.1 500.8.4.5 240.5.333.2 172.16.30.30 10.5.3.68 |
#cat ip.txt | egrep '^[0-255].[0-255].[0-255].[0-255]]'
![]() |
#cat ip.txt | egrep '^[0-2].[0-9].[0-9].[0-9]'
192.168.0.1 240.5.333.2 |
#cat ip.txt | egrep '^[0-2]\.[0-9].[0-9].[0-9]'
![]() |
#cat ip.txt | egrep '^[0-9]\.'
4.6.70 |
#cat ip.txt | egrep '^[0-9]{3}\.'
192.168.0.1 500.8.4.5 240.5.333.2 172.16.30.30 |
#cat ip.txt | egrep '^[0-9]{0,3}\.'
192.168.0.1 500.8.4.5 240.5.333.2 172.16.30.30 4.6.70 10.5.3.68 |
#cat ip.txt | egrep '([0-9]|[0-9]{2}|1[0-9]{2}|2[0-4][0-9]|25[0-5]\.'
![]() egrep: Непарная ( или \( |
#cat ip.txt | egrep '^([0-9]|[0-9]{2}|1[0-9]{2}|2[0-4][0-9]|25[0-5]\.)'
192.168.0.1 500.8.4.5 240.5.333.2 172.16.30.30 4.6.70 10.5.3.68 |
#cat ip.txt | egrep '^([0-9]|[0-9]{2}|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.'
192.168.0.1 240.5.333.2 172.16.30.30 4.6.70 10.5.3.68 |
#cat ip.txt | awk -F. '$1>=0 && $1<256 && $2>=0 && $2<256 && $3>=0 && $3<256 && $4>=0 && $4<256 && NF==4'
192.168.0.1 172.16.30.30 10.5.3.68 |
#netstat
Active Internet connections (w/o servers) Proto Recv-Q Send-Q Local Address Foreign Address State tcp 0 0 debian1.net.nt:ssh 192.168.16.154:64746 ESTABLISHED tcp 0 0 debian1.net.nt:ssh 192.168.16.154:64806 ESTABLISHED tcp 0 0 debian1.net.nt:ssh 192.168.16.154:64742 ESTABLISHED tcp 0 368 debian1.net.nt:ssh 192.168.16.154:64715 ESTABLISHED Active UNIX domain sockets (w/o servers) Proto RefCnt Flags Type State I-Node Path unix 7 [ ] DGRAM 5062 /dev/log unix 3 [ ] STREAM CONNECTED 12188 ... unix 3 [ ] STREAM CONNECTED 11544 unix 3 [ ] STREAM CONNECTED 11543 unix 2 [ ] DGRAM 11542 unix 3 [ ] STREAM CONNECTED 11445 unix 3 [ ] STREAM CONNECTED 11444 unix 2 [ ] DGRAM 11443 unix 2 [ ] DGRAM 11272 unix 2 [ ] DGRAM 5110 unix 3 [ ] DGRAM 3249 unix 3 [ ] DGRAM 3248 |
#netstat -tn
Active Internet connections (w/o servers) Proto Recv-Q Send-Q Local Address Foreign Address State tcp 0 0 192.168.13.1:22 192.168.16.154:64746 ESTABLISHED tcp 0 0 192.168.13.1:45749 5.9.243.178:18030 TIME_WAIT tcp 0 0 192.168.13.1:22 192.168.16.154:64806 ESTABLISHED tcp 0 0 192.168.13.1:22 192.168.16.154:64742 ESTABLISHED tcp 0 432 192.168.13.1:22 192.168.16.154:64715 ESTABLISHED |
#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 |
#^[0-9]{0,3}\.'
![]() |
#^[0-9]{0,3}\.'
|
#cat install | sed 's/h/\/bash/'
#!/bin/s/bash /bashostname=`hostname` uname -a | egrep -qi '(freebsd|darwin)' || /bashostname=`hostname -f` ############################################################################### # # Set t/bashis variables before installation: lilalo_user=13-10-2014 lab=NT-LNet install_l3bas/bashrc_for_this_users=${users:-"root user"} # users who will use l3agent and l3script lilalo_context="/users/${lilalo_user}/${lab}/${/bashostname}" ... 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 l3bas/bashrc to users home directories" install_to_users_homes $install_l3bashrc_for_this_users step "Adding l3bas/bashrc invocation to ~/.bashrc " install_to_users_bashrc $install_l3bashrc_for_this_users step "Adding l3-agent invocation to ~/.bas/bash_profile " install_to_users_bash_profile $install_l3bashrc_for_this_users cd / rm -rf ${temp_dir} s/bashow_final_message |
#cat install | sed 's/_/ /'
#!/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 | sed 's/_/ '
![]() sed: -e выражение #1, символ 5: незавершенная команда `s' |
#cat install | sed 's/_/ /g'
#!/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 |
#sort | uniq
|
#cat /etc/passwd | sed 's/:/ /g'
root x 0 0 root /root /bin/bash daemon x 1 1 daemon /usr/sbin /bin/sh bin x 2 2 bin /bin /bin/sh sys x 3 3 sys /dev /bin/sh sync x 4 65534 sync /bin /bin/sync games x 5 60 games /usr/games /bin/sh man x 6 12 man /var/cache/man /bin/sh lp x 7 7 lp /var/spool/lpd /bin/sh mail x 8 8 mail /var/mail /bin/sh news x 9 9 news /var/spool/news /bin/sh ... list x 38 38 Mailing List Manager /var/list /bin/sh irc x 39 39 ircd /var/run/ircd /bin/sh gnats x 41 41 Gnats Bug-Reporting System (admin) /var/lib/gnats /bin/sh nobody x 65534 65534 nobody /nonexistent /bin/sh libuuid x 100 101 /var/lib/libuuid /bin/sh Debian-exim x 101 103 /var/spool/exim4 /bin/false user x 1000 1000 user,,, /home/user /bin/bash sshd x 102 65534 /var/run/sshd /usr/sbin/nologin ivan x 1001 1001 /home/ivan /bin/bash petr x 1002 1002 /home/petr /bin/bash |
#cat /etc/passwd
root:x:0:0:root:/root:/bin/bash daemon:x:1:1:daemon:/usr/sbin:/bin/sh bin:x:2:2:bin:/bin:/bin/sh sys:x:3:3:sys:/dev:/bin/sh sync:x:4:65534:sync:/bin:/bin/sync games:x:5:60:games:/usr/games:/bin/sh man:x:6:12:man:/var/cache/man:/bin/sh lp:x:7:7:lp:/var/spool/lpd:/bin/sh mail:x:8:8:mail:/var/mail:/bin/sh news:x:9:9:news:/var/spool/news:/bin/sh ... list:x:38:38:Mailing List Manager:/var/list:/bin/sh irc:x:39:39:ircd:/var/run/ircd:/bin/sh gnats:x:41:41:Gnats Bug-Reporting System (admin):/var/lib/gnats:/bin/sh nobody:x:65534:65534:nobody:/nonexistent:/bin/sh libuuid:x:100:101::/var/lib/libuuid:/bin/sh Debian-exim:x:101:103::/var/spool/exim4:/bin/false user:x:1000:1000:user,,,:/home/user:/bin/bash sshd:x:102:65534::/var/run/sshd:/usr/sbin/nologin ivan:x:1001:1001::/home/ivan:/bin/bash petr:x:1002:1002::/home/petr:/bin/bash |
#cat /etc/passwd | sed 's/[^a]//g' | wc -c
71 |
#list
![]() l3script: list: команда не найдена |
#ls
2352f346 34634r d132 install ip.txt passwd |
#find /home -empty -type f -user ivan
|
#find /home -empty -type f -user ivan
/home/ivan/d4 /home/ivan/d3 |
#find /home -empty -type f -user ivan | xargs -i cp {} /tmp
|
#cd /temp
![]() l3script: cd: /temp: Нет такого файла или каталога |
#ls /temp
![]() ls: невозможно получить доступ к /temp: Нет такого файла или каталога |
#ls /tmp
d3 d4 etccopy p1 passwd |
#find /home -empty -type f -user ivan | xargs -i cp -v {} /tmp
«/home/ivan/d4» -> «/tmp/d4» «/home/ivan/d3» -> «/tmp/d3» |
#rm /tmp/*
![]() rm: невозможно удалить «/tmp/etccopy»: Это каталог |
#ls /tmp
etccopy |
#ls /tmp/etccopy
adduser.conf hosts.deny nanorc adjtime inittab networks aliases inputrc nsswitch.conf bash.bashrc insserv.conf os-release bash_completion issue pam.conf bindresvport.blacklist issue.net passwd blkid.tab kernel-img.conf profile blkid.tab.old ld.so.cache protocols ca-certificates.conf ld.so.conf rc.local console-cyrillic locale.alias reportbug.conf ... discover-modprobe.conf mailcap screenrc email-addresses mailcap.order securetty environment mailname services fstab manpath.config shells gai.conf mime.types staff-group-for-usr-local group mke2fs.conf sysctl.conf host.conf modules timezone hostname motd trafshow hosts mtab ucf.conf hosts.allow nail.rc wgetrc |
#find /home -empty -type f -user ivan -exec mv -v {} /tmp \;
«/home/ivan/d4» -> «/tmp/d4» «/home/ivan/d3» -> «/tmp/d3» |
#find / -regex ".*\.jpe?g"
/home/user/matrix.jpg /home/user/freebsd.jpg /home/user/press_any_key_to_continue.jpg /home/user/granata.jpg /home/user/ogo.jpg |
#find ~ -regex '.*(\.tar\.gz|\.tgz|\.rpm)'
|
#find / -regex ".*\.rpm"
|
#find / -regex ".*\.jpg"
/home/user/matrix.jpg /home/user/freebsd.jpg /home/user/press_any_key_to_continue.jpg /home/user/granata.jpg /home/user/ogo.jpg |
#find / -regex ".*\.tar"
|
#find / -regex ".*\.gz"
/etc/alternatives/mt.1.gz /etc/alternatives/ex.pl.1.gz /etc/alternatives/aptitude.ja.8.gz /etc/alternatives/awk.1.gz /etc/alternatives/traceroute6.1.gz /etc/alternatives/aptitude.pl.8.gz /etc/alternatives/c99.1.gz /etc/alternatives/aptitude.gl.8.gz /etc/alternatives/unlzma.1.gz /etc/alternatives/rcp.1.gz ... /var/log/apt/history.log.1.gz /var/log/dmesg.2.gz /var/log/syslog.3.gz /var/log/syslog.7.gz /var/log/user.log.3.gz /var/log/debug.2.gz /var/log/auth.log.3.gz /var/log/debug.3.gz /var/log/aptitude.1.gz /var/log/syslog.5.gz |
#find ~ -regex ".*\.gz"
|
#find ~ -regex ".*\.gz"
|
#~ -regex ".*\.gz"
|
#/ -regex '.*(\.tar|\.gz|\.tgz|\.rpm)' -regextype posix-egrep
|
#vi test.sh
|
#~
![]() chmod: неверный режим: «ux» Попробуйте «chmod --help» для получения более подробного описания. |
#chmod u+x test.sh
|
root:x:0:0:root:/root:/bin/bash daemon:x:1:1:daemon:/usr/sbin:/bin/sh bin:x:2:2:bin:/bin:/bin/sh sys:x:3:3:sys:/dev:/bin/sh sync:x:4:65534:sync:/bin:/bin/sync games:x:5:60:games:/usr/games:/bin/sh man:x:6:12:man:/var/cache/man:/bin/sh lp:x:7:7:lp:/var/spool/lpd:/bin/sh mail:x:8:8:mail:/var/mail:/bin/sh news:x:9:9:news:/var/spool/news:/bin/sh uucp:x:10:10:uucp:/var/spool/uucp:/bin/sh proxy:x:13:13:proxy:/bin:/bin/sh www-data:x:33:33:www-data:/var/www:/bin/sh backup:x:34:34:backup:/var/backups:/bin/sh list:x:38:38:Mailing List Manager:/var/list:/bin/sh irc:x:39:39:ircd:/var/run/ircd:/bin/sh gnats:x:41:41:Gnats Bug-Reporting System (admin):/var/lib/gnats:/bin/sh nobody:x:65534:65534:nobody:/nonexistent:/bin/sh libuuid:x:100:101::/var/lib/libuuid:/bin/sh Debian-exim:x:101:103::/var/spool/exim4:/bin/false user:x:1000:1000:user,,,:/home/user:/bin/bash sshd:x:102:65534::/var/run/sshd:/usr/sbin/nologin ivan:x:1001:1001::/home/ivan:/bin/bash petr:x:1002:1002::/home/petr:/bin/bash
#!/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
192.168.0.1 500.8.4.5 240.5.333.2 a.4.4.9 172.16.30.30 4.6.70 10.5.3.68
root:x:0:0:root:/root:/bin/bash daemon:x:1:1:daemon:/usr/sbin:/bin/sh bin:x:2:2:bin:/bin:/bin/sh sys:x:3:3:sys:/dev:/bin/sh sync:x:4:65534:sync:/bin:/bin/sync games:x:5:60:games:/usr/games:/bin/sh man:x:6:12:man:/var/cache/man:/bin/sh lp:x:7:7:lp:/var/spool/lpd:/bin/sh mail:x:8:8:mail:/var/mail:/bin/sh news:x:9:9:news:/var/spool/news:/bin/sh uucp:x:10:10:uucp:/var/spool/uucp:/bin/sh proxy:x:13:13:proxy:/bin:/bin/sh www-data:x:33:33:www-data:/var/www:/bin/sh backup:x:34:34:backup:/var/backups:/bin/sh list:x:38:38:Mailing List Manager:/var/list:/bin/sh irc:x:39:39:ircd:/var/run/ircd:/bin/sh gnats:x:41:41:Gnats Bug-Reporting System (admin):/var/lib/gnats:/bin/sh nobody:x:65534:65534:nobody:/nonexistent:/bin/sh libuuid:x:100:101::/var/lib/libuuid:/bin/sh Debian-exim:x:101:103::/var/spool/exim4:/bin/false user:x:1000:1000:user,,,:/home/user:/bin/bash sshd:x:102:65534::/var/run/sshd:/usr/sbin/nologin ivan:x:1001:1001::/home/ivan:/bin/bash petr:x:1002:1002::/home/petr:/bin/bash
Время первой команды журнала | 10:01:09 2017- 6- 7 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Время последней команды журнала | 10:11:00 2017- 6- 8 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Количество командных строк в журнале | 101 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Процент команд с ненулевым кодом завершения, % | 13.86 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Процент синтаксически неверно набранных команд, % | 1.98 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Суммарное время работы с терминалом *, час | 4.14 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Количество командных строк в единицу времени, команда/мин | 0.41 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Частота использования команд |
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Частота использования этих команд < 0.5% | 9).'1 , 2561 , &1 , $2>1 , 25[0-5]\.'1 , chmod1 , rm1 , cd1 , 2)?.'1 , 25[0-5]\.)'1 , $3>1 , \.gz1 , pwd1 , httpd1 , =01 , stty1 , NF==4'1 , 25[0-5])\.'1 , 2)'1 , 2)?.(01 , $3<1 , '1 , petr1 , $2<1 , 2)?'1 , user)'1 , 9^C'1 , 9)?.'1 , list1 , $4<1 , $4>1 , which1 , /1 , tr1 , $1<1 |
В журнал автоматически попадают все команды, данные в любом терминале системы.
Для того чтобы убедиться, что журнал на текущем терминале ведётся, и команды записываются, дайте команду 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 они отображаются не полностью, а вместо перевода строки выводится специальный символ.
Время ввода команды, показанное в журн