/l3/users/07-09-2009/nt-ladm/debian1.net.nt/user :1 :2 :3 :4 :5 :6 :7 :8 :9 :10 :11 :12 :13 :14 :15 :16 :17 |
|
#[root@fbsd5:tmp]# ssh 127.0.0.1 -l user600
+ for i in '`jot - 500 600`' + pw useradd user574 -s /usr/local/bin/bash -L russian -m -d /home/user574 + echo password + pw usermod user574 -h 0 + for i in '`jot - 500 600`' + pw useradd user575 -s /usr/local/bin/bash -L russian -m -d /home/user575 + echo password + pw usermod user575 -h 0 + for i in '`jot - 500 600`' + pw useradd user576 -s /usr/local/bin/bash -L russian -m -d /home/user576 ... You may also use sysinstall(8) to re-enter the installation and configuration utility. Edit /etc/motd to change this login announcement. You can often get answers to your questions about FreeBSD by searching in the FreeBSD mailing list archives at http://www.FreeBSD.org/search/search.html [user600@fbsd5 ~]$ pwd /home/user600 [user600@fbsd5 ~]$ exit logout Connection to 127.0.0.1 closed. |
#[root@fbsd5:tmp]# scp for3 192.168.16.1:/tmp/scritps/
![]() ~ ~ ~ ~ ~ ~ ~ "for3" 7L, 172C written The authenticity of host '192.168.16.1 (192.168.16.1)' can't be established. DSA key fingerprint is 85:66:04:0d:64:83:45:f3:35:58:eb:35:cc:e5:92:50. Are you sure you want to continue connecting (yes/no)? yser^?^? Please type 'yes' or 'no': yes Warning: Permanently added '192.168.16.1' (DSA) to the list of known hosts. root@192.168.16.1's password: scp: /tmp/scritps/: Is a directory |
#[root@fbsd5:tmp]# exit
[root@fbsd5:tmp]# scp for3 192.168.16.1:/tmp/scripts/ root@192.168.16.1's password: for3 100% 172 0.2KB/s 00:00 exit Connection to 192.168.16.25 closed. |
$ls
for1 for2 for3 |
$cat for3
#!/usr/local/bin/bash set -x for i in `jot - 500 600` do pw useradd user$i -s /usr/local/bin/bash -L russian -m -d /home/user$i echo password | pw usermod user$i -h 0 done |
$vim for4
![]() --- /dev/null 2009-09-07 08:26:30.044750476 +0300 +++ for4 2009-09-09 15:30:28.000000000 +0300 @@ -0,0 +1,2 @@ +#!/bin/bash + |
$chmod +x *
![]() 1 #!/bin/bash 2 FILES=" 3 /bin/bunzip2 4 /sbin/ifconfig 5 /usr/bin/passwd 6 /sbin/sergey-cherepenin" 7 for i in $FILES 8 do 9 if [ ! -e "$i" ] 10 then echo "File $i not found" ... 15 done chmod: изменение прав доступа для `for3': Operation not permitted 16 -rwxr-xr-x 1 root root 25304 2006-08-25 20:20 /bin/bunzip2 ~ ~ ~ ~ ~ ~ КА -- 13,0-1 Весь |
$ls -l
итого 16 -rwxr-xr-x 1 user user 85 2009-09-09 15:16 for1 -rwxr-xr-x 1 user user 129 2009-09-09 15:20 for2 -rwxr-xr-x 1 root root 172 2009-09-09 15:30 for3 -rwxr-xr-x 1 user user 243 2009-09-09 15:37 for4 |
$./for4
+ FILES=' /bin/bunzip2 /sbin/ifconfig /usr/bin/passwd /sbin/sergey-cherepenin' + for i in '$FILES' + '[' '!' -e /bin/bunzip2 ']' + ls -lh /bin/bunzip2 + awk '{print$8" have size: "$5}' /bin/bunzip2 have size: 25K ... + '[' '!' -e /sbin/sergey-cherepenin ']' + echo 'File /sbin/sergey-cherepenin not found' File /sbin/sergey-cherepenin not found + ls -lh /sbin/sergey-cherepenin ls: /sbin/sergey-cherepenin: No such file or directory + awk '{print$8" have size: "$5}' ++ basename /sbin/sergey-cherepenin + whatis sergey-cherepenin sergey-cherepenin: ничего подходящего не найдено. + exit 0 |
$vim for4
--- /tmp/l3-saved-30657.11138.9491 2009-09-09 15:37:34.000000000 +0300 +++ for4 2009-09-09 15:37:38.000000000 +0300 @@ -1,5 +1,5 @@ #!/bin/bash -set -x +#set -x FILES=" /bin/bunzip2 /sbin/ifconfig |
$./for4
/bin/bunzip2 have size: 25K bunzip2 (1) - a block-sorting file compressor, v1.0.3 /sbin/ifconfig have size: 58K ifconfig (8) - configure a network interface /usr/bin/passwd have size: 28K passwd (1) - change user password passwd (5) - the password file File /sbin/sergey-cherepenin not found ls: /sbin/sergey-cherepenin: No such file or directory sergey-cherepenin: ничего подходящего не найдено. |
$vim for4
--- /tmp/l3-saved-30657.24140.30516 2009-09-09 15:37:54.000000000 +0300 +++ for4 2009-09-09 15:38:15.000000000 +0300 @@ -9,6 +9,7 @@ do if [ ! -e "$i" ] then echo "File $i not found" +continue fi ls -lh $i | awk '{print$8" have size: "$5}' whatis `basename $i` |
$./for4
/bin/bunzip2 have size: 25K bunzip2 (1) - a block-sorting file compressor, v1.0.3 /sbin/ifconfig have size: 58K ifconfig (8) - configure a network interface /usr/bin/passwd have size: 28K passwd (1) - change user password passwd (5) - the password file File /sbin/sergey-cherepenin not found |
$./for4
18 exit 0 ~ ~ ~ ~ "for4" 18L, 254C записано сь /bin/bunzip2 have size: 25K bunzip2 (1) - a block-sorting file compressor, v1.0.3 File /sbin/sergey-cherepenin not found /sbin/ifconfig have size: 58K ifconfig (8) - configure a network interface /usr/bin/passwd have size: 28K passwd (1) - change user password passwd (5) - the password file |
$cat ./for4
#!/bin/bash #set -x FILES=" /bin/bunzip2 /sbin/sergey-cherepenin /sbin/ifconfig /usr/bin/passwd" for i in $FILES do if [ ! -e "$i" ] then echo "File $i not found" continue fi ls -lh $i | awk '{print$8" have size: "$5}' whatis `basename $i` done exit 0 |
$ls
for1 for2 for3 for4 |
$vim select1
![]() --- /dev/null 2009-09-07 08:26:30.044750476 +0300 +++ select1 2009-09-09 15:53:43.000000000 +0300 @@ -0,0 +1,2 @@ +#!/bin/bash + |
$chmod -
|
$chmod +x select1
[user@debian1:scripts]$ ./select1 bash: ./select1: Permission denied |
$vim select1
--- /tmp/l3-saved-30657.20313.4071 2009-09-09 15:57:36.000000000 +0300 +++ select1 2009-09-09 15:57:43.000000000 +0300 @@ -3,4 +3,5 @@ select os in FreeBSD Linux Windows "Mac OSx" Other do echo "Your lovely Os is $os" +break done |
$./select1
1) FreeBSD 2) Linux 3) Windows 4) Mac OSx 5) Other Please, choise Your lovely OS: 1 Your lovely Os is FreeBSD |
$select1
![]() bash: select1: command not found |
$echo $PATH
/usr/local/bin:/usr/bin:/bin:/usr/games |
$PATH=$PATH:.
|
$select1
1) FreeBSD 2) Linux 3) Windows 4) Mac OSx 5) Other Please, choise Your lovely OS: 4 Your lovely Os is Mac OSx |
$cat select1
#!/bin/bash PS3='Please, choise Your lovely OS: ' select os in FreeBSD Linux Windows "Mac OSx" Other do echo "Your lovely Os is $os" break done |
$A=0
|
$while [ $A -lt 10 ]; do A=$((A+1)); echo $A; done
1 2 3 4 5 6 7 8 9 10 |
$echo
> while1 |
$vim while1
|
$chmod +x while1
|
$vim while1
--- /tmp/l3-saved-30657.27431.9664 2009-09-09 16:02:42.000000000 +0300 +++ while1 2009-09-09 16:02:49.000000000 +0300 @@ -1,4 +1,5 @@ #!/bin/bash +A=0 while [ $A -lt 10 ] do A=$((A+1)) echo $A |
$./while1
1 2 3 4 5 6 7 8 9 10 |
$cat ./while1
#!/bin/bash A=0 while [ $A -lt 10 ] do A=$((A+1)) echo $A done |
$vim ./while2
![]() |
$cp ./while1 ./while2
|
$cat ./while2
[user@debian1:scripts]$ ./while2 Please, give the value to variable #1 or end for exit eee Given value of Variable #1 is: eee Please, give the value to variable #1 or end for exit www Given value of Variable #1 is: www Please, give the value to variable #1 or end for exit end Given value of Variable #1 is: end #!/bin/bash while [ "$Keypress" != "end" ] do echo "Please, give the value to variable #1 or end for exit" read Keypress echo "Given value of Variable #1 is: $Keypress" done |
$cat ./while1
#!/bin/bash A=0 while [ $A -lt 10 ] do A=$((A+1)) echo $A done |
$vim case1
![]() --- /dev/null 2009-09-07 08:26:30.044750476 +0300 +++ case1 2009-09-09 16:09:34.000000000 +0300 @@ -0,0 +1 @@ +#!/bin/bash |
$arch
i686 |
$vim case1
--- /tmp/l3-saved-30657.10856.18214 2009-09-09 16:09:50.000000000 +0300 +++ case1 2009-09-09 16:12:18.000000000 +0300 @@ -1,2 +1,9 @@ #!/bin/bash +case `arch` in +i386) echo "Computer based on 80386 type of processor" ;; +i486) echo "Computer based on 80486 type of processor" ;; +i586) echo "Computer based on Pentium type of processor" ;; +i686) echo "Computer based on Pentium2 type of processor" ;; +*) echo "Computer based on unknown type of processor" ;; +esac |
$chmod +x case1
|
$case1
Computer based on Pentium2 type of processor |
$uname -r
2.6.18-5-xen-686 |
$uname -a
Linux debian1 2.6.18-5-xen-686 #1 SMP Fri Jun 1 05:05:24 UTC 2007 i686 GNU/Linux |
$xm info
![]() bash: xm: command not found |
$ssh root@192.168.16.254 '
root@192.168.16.254's password: host : debian release : 2.6.18.8-xen version : #1 SMP Wed Nov 5 11:18:00 EET 2008 machine : i686 nr_cpus : 4 nr_nodes : 1 cores_per_socket : 1 threads_per_core : 4 cpu_mhz : 2405 ... xen_caps : xen-3.0-x86_32p hvm-3.0-x86_32 hvm-3.0-x86_32p xen_scheduler : credit xen_pagesize : 4096 platform_params : virt_start=0xf5800000 xen_changeset : unavailable cc_compiler : gcc version 4.3.2 (Ubuntu 4.3.2-1ubuntu9) cc_compile_by : buildd cc_compile_domain : buildd cc_compile_date : Mon Oct 6 18:09:12 UTC 2008 xend_config_format : 4 |
$case1
Computer based on Pentium2 type of processor |
$cp case1 case2
|
$arch
[user@debian1:scripts]$ vim case2 i686 |
$vim case2
--- /tmp/l3-saved-30657.7328.30795 2009-09-09 16:15:26.000000000 +0300 +++ case2 2009-09-09 16:20:25.000000000 +0300 @@ -1,9 +1,12 @@ #!/bin/bash -case `arch` in -i386) echo "Computer based on 80386 type of processor" ;; -i486) echo "Computer based on 80486 type of processor" ;; -i586) echo "Computer based on Pentium type of processor" ;; -i686) echo "Computer based on Pentium2 type of processor" ;; -*) echo "Computer based on unknown type of processor" ;; +while [ "$Keypress" != "X" ] +do +echo "Press only one any key and then enter or X for exit" +read Keypress +case "$Keypress" in +[a-z]) echo "This is a lower letter" ;; +[0-9]) echo "This is a digit" ;; +[A-Z]) echo "This is a upper letter" ;; +*) echo "This is a punct" ;; esac - +done |
$chmod +x case2
|
$vim case2
--- /tmp/l3-saved-30657.17847.27566 2009-09-09 16:21:08.000000000 +0300 +++ case2 2009-09-09 16:21:24.000000000 +0300 @@ -4,9 +4,9 @@ echo "Press only one any key and then enter or X for exit" read Keypress case "$Keypress" in -[a-z]) echo "This is a lower letter" ;; +[a-z]) echo "This is a letter" ;; [0-9]) echo "This is a digit" ;; -[A-Z]) echo "This is a upper letter" ;; +[A-Z]) echo "This is a letter" ;; *) echo "This is a punct" ;; esac done |
$vim /etc/init.d/
![]() |
$vim /etc/init.d/ssh
|
$vim /etc/init.d/ssh
|
$ls
[user@debian1:scripts]$ cat * #!/bin/bash case `arch` in i386) echo "Computer based on 80386 type of processor" ;; i486) echo "Computer based on 80486 type of processor" ;; i586) echo "Computer based on Pentium type of processor" ;; i686) echo "Computer based on Pentium2 type of processor" ;; *) echo "Computer based on unknown type of processor" ;; esac #!/bin/bash ... echo $A done #!/bin/bash while [ "$Keypress" != "end" ] do echo "Please, give the value to variable #1 or end for exit" read Keypress echo "Given value of Variable #1 is: $Keypress" done case1 case2 for1 for2 for3 for4 select1 while1 while2 |
$cat for1
#!/bin/bash set -x for planet in "Earth Sun Moon Mars Snikers" do echo $planet done |
$cat for2
#!/bin/bash set -x for i in `seq 500 600` do useradd -m -d /home/testuser$i testuser$i echo testuser$i:password | chpasswd done |
$cat for3
#!/usr/local/bin/bash set -x for i in `jot - 500 600` do pw useradd user$i -s /usr/local/bin/bash -L russian -m -d /home/user$i echo password | pw usermod user$i -h 0 done |
$cat for4
#!/bin/bash #set -x FILES=" /bin/bunzip2 /sbin/sergey-cherepenin /sbin/ifconfig /usr/bin/passwd" for i in $FILES do if [ ! -e "$i" ] then echo "File $i not found" continue fi ls -lh $i | awk '{print$8" have size: "$5}' whatis `basename $i` done exit 0 |
$cat for5
![]() cat: for5: No such file or directory |
$cat select1
#!/bin/bash PS3='Please, choise Your lovely OS: ' select os in FreeBSD Linux Windows "Mac OSx" Other do echo "Your lovely Os is $os" break done |
$cat case1
#!/bin/bash case `arch` in i386) echo "Computer based on 80386 type of processor" ;; i486) echo "Computer based on 80486 type of processor" ;; i586) echo "Computer based on Pentium type of processor" ;; i686) echo "Computer based on Pentium2 type of processor" ;; *) echo "Computer based on unknown type of processor" ;; esac |
$cat case2
#!/bin/bash while [ "$Keypress" != "X" ] do echo "Press only one any key and then enter or X for exit" read Keypress case "$Keypress" in [a-z]) echo "This is a letter" ;; [0-9]) echo "This is a digit" ;; [A-Z]) echo "This is a letter" ;; *) echo "This is a punct" ;; esac done |
$cat case
![]() case1 case2 |
$cat while1
#!/bin/bash A=0 while [ $A -lt 10 ] do A=$((A+1)) echo $A done |
$cat while2
#!/bin/bash while [ "$Keypress" != "end" ] do echo "Please, give the value to variable #1 or end for exit" read Keypress echo "Given value of Variable #1 is: $Keypress" done |
$ls
case1 case2 for1 for2 for3 for4 select1 while1 while2 |
$vimtutor ru
4. Для замены всех вхождений последовательности символов между двумя строками, наберите :#,#s/было/стало/g где #,# --- номера этих строк. Наберите :%s/было/стало/g для замены всех вхождений во всем файле. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ РЕЗЮМЕ УРОКА 4 1. Ctrl-g показывает ваше положение в файле и информацию о нем. Shift-G перемещает Вас в конец файла. Номер, за которым следует Shift-G NTER> |
$grep 3389 /etc/services
![]() |
$grep 32
![]() |
$vim /etc/services
|
$man rdesktop
|
$#set -x
|
$IP=`lynx -dump http://nt.ua/doc/ip | grep MY | sed 's/^MY\ IP\://'` |