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

Содержание

Журнал

Среда (09/09/09)

/dev/ttyp8
14:27:22
#[root@fbsd5:tmp]# chmod +x for3
~   for i in `jot - 500 600`
  3 do
  4 pw useradd user$i -s /usr/local/bin/bash -L russian -m -d /home/user$i
  5 echo password | pw usermod user$i -h 0
  6 done
  7
~
~
~
~
...
~
~
~
~
~
~
~
~
~
"for3" 7L, 172C written
14:27:41
#[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.
14:28:49
#[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
14:29:53
#[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.
14:30:06
$ls
for1  for2  for3
14:30:08
$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
14:30:12
$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
+
14:37:13
$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       Весь
14:37:17
$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
14:37:21
$./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
14:37:29
$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
14:37:38
$./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: ничего подходящего не найдено.
14:37:39
$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`
14:38:15
$./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
14:38:30
$./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
14:38:32
$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
14:38:42
$ls
for1  for2  for3  for4
прошло 14 минут
14:52:48
$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
+
14:55:54
$chmod +x select1
~   select os in FreeBSD Linux Windows "Mac OSx" Other
  4 do
~   echo "Your lovely Os is $os"
  5 done
  6 done
~
~
~
~
~
...
~
~
~
~
~
~
~
~
~
"select1" 6L, 139C записано                                            сь
14:56:15
$chmod -

14:56:49
$chmod +x select1
[user@debian1:scripts]$ ./select1
bash: ./select1: Permission denied
14:57:32
$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
14:57:43
$./select1
1) FreeBSD
2) Linux
3) Windows
4) Mac OSx
5) Other
Please, choise Your lovely OS: 1
Your lovely Os is FreeBSD
14:57:46
$select1
bash: select1: command not found
14:59:14
$echo $PATH
/usr/local/bin:/usr/bin:/bin:/usr/games
14:59:22
$PATH=$PATH:.

14:59:30
$select1
1) FreeBSD
2) Linux
3) Windows
4) Mac OSx
5) Other
Please, choise Your lovely OS: 4
Your lovely Os is Mac OSx
14:59:34
$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
14:59:42
$A=0

14:59:55
$while [ $A -lt 10 ]; do A=$((A+1)); echo $A; done
1
2
3
4
5
6
7
8
9
10
15:00:42
$echo
 > while1
15:02:27
$vim while1
15:02:32
$chmod +x while1

15:02:39
$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
15:02:49
$./while1
1
2
3
4
5
6
7
8
9
10
15:02:50
$cat ./while1
#!/bin/bash
A=0
while [ $A -lt 10 ]
do A=$((A+1))
echo $A
done
15:02:56
$vim ./while2
15:03:13
$cp ./while1 ./while2

15:07:16
$chmod +x while2
  3 do
  4 echo "Please, give the value to variable #1 or end for exit"
  4 echo Keypressvalue of Variable #1 is: $Keypress"
  5 echo "Given  value of Variable #1 is: $Keypress"
  6 done
~
~
~
~
~
...
~
 15 done
~
~
~
~
~
~
~
"./while2" 7L, 176C записано                                           сь
15:07:30
$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
15:07:48
$cat ./while1
#!/bin/bash
A=0
while [ $A -lt 10 ]
do A=$((A+1))
echo $A
done
15:08:27
$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
15:09:44
$arch
i686
15:09:48
$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
 
15:12:18
$chmod +x case1

15:12:22
$case1
Computer based on Pentium2 type of processor
15:12:27
$uname -r
2.6.18-5-xen-686
15:12:54
$uname -a
Linux debian1 2.6.18-5-xen-686 #1 SMP Fri Jun 1 05:05:24 UTC 2007 i686 GNU/Linux
15:12:56
$xm info
bash: xm: command not found
15:13:28
$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
15:14:18
$case1
Computer based on Pentium2 type of processor
15:14:21
$cp case1 case2

15:15:19
$arch
[user@debian1:scripts]$ vim case2
i686
15:15:22
$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
15:20:25
$chmod +x case2

15:21:05
$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
15:21:32
$vim /etc/init.d/
15:21:32
$vim /etc/init.d/ssh
15:24:11
$vim /etc/init.d/ssh
15:25:06
$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
15:26:20
$cat for1
#!/bin/bash
set -x
for planet in "Earth Sun Moon Mars Snikers"
do
echo $planet
done
15:26:26
$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
15:26:27
$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
15:26:29
$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
15:26:30
$cat for5
cat: for5: No such file or directory
15:26:32
$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
15:26:35
$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
15:26:40
$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
15:26:42
$cat case
case1  case2
15:26:42
$cat while1
#!/bin/bash
A=0
while [ $A -lt 10 ]
do A=$((A+1))
echo $A
done
15:26:49
$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
15:26:51
$ls
case1  case2  for1  for2  for3  for4  select1  while1  while2
15:27:35
$vimtutor ru
  4. Для замены всех вхождений последовательности символов между двумя
     строками,
     наберите :#,#s/было/стало/g  где #,# --- номера этих строк.
     Наберите :%s/было/стало/g    для замены всех вхождений во всем файле.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                                РЕЗЮМЕ УРОКА 4
  1. Ctrl-g показывает ваше положение в файле и информацию о нем.
     Shift-G перемещает Вас в конец файла. Номер, за которым следует Shift-G
NTER>
прошло 35 минут
16:02:36
$grep 3389 /etc/services

Четверг (09/10/09)

09:26:37
$grep 32

09:26:46
$vim /etc/services
09:27:30
$man rdesktop
/dev/ttyp3
09:27:53
$screen -x
/dev/ttyp8
09:28:29
$#!/bin/sh

09:29:10
$#set -x

09:29:15
$IP=`lynx -dump http://nt.ua/doc/ip | grep MY | sed 's/^MY\ IP\://'`