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

Содержание

Журнал

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

/dev/pts/6
11:24:30
$ls
_1_2_3     acpi      __asterisk  bjen  core.c   -file1  -hello   isdn_ttyfax.c  modules  Regexp.H  term.h
1cdesktop  alloca.H  bjan        bjon  fcntl.h  group   _hrypun  _kik_my        passwd   s_tol_
11:24:32
$echo $PATH
/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games
11:26:13
$echo$((2/3))
l3script: echo0: команда не найдена
11:27:19
$echo $((2/3))
0
11:27:23
$a=1

11:27:33
$b=5

11:27:35
$echo $((a-b))
-4
11:27:48
$echo ((a+$b))
l3script: syntax error near unexpected token `('
11:29:44
$echo (($a+$b))
l3script: syntax error near unexpected token `('
11:30:37
$echo $($(a+$b))
l3script: a+5: команда не найдена
11:31:01
$echo $(($a+$b))
6
11:31:14
$echo $((a+b))
6
11:31:24
$$a+$b
l3script: 1+5: команда не найдена
11:31:50
$echo ($a+$b)
l3script: syntax error near unexpected token `$a+$b'
11:32:04
$echo (($a+$b))
l3script: syntax error near unexpected token `('
11:32:11
$echo ($a+$b))
l3script: syntax error near unexpected token `$a+$b'
11:32:18
$$a+$b
l3script: 1+5: команда не найдена
11:32:27
$echo $a+$b
1+5
11:32:32
$echo $a+$b=$(a+b)
l3script: a+b: команда не найдена
1+5=
11:32:49
$echo $a+$b=echo $(a+b)
l3script: a+b: команда не найдена
1+5=echo
11:32:59
$echo $a+$b= echo $(a+b)
l3script: a+b: команда не найдена
1+5= echo
11:33:02
$echo $a+$b=($((a+b))
l3script: syntax error near unexpected token `('
11:33:20
$echo $a+$b=$((a+b))
1+5=6
11:33:24
$cat /etc/passwd > newfile

11:34:16
$les newfile
l3script: les: команда не найдена
11:34:21
$less newfile
11:34:30
$sort < /etc/passwd
backup:x:34:34:backup:/var/backups:/bin/sh
bin:x:2:2:bin:/bin:/bin/sh
daemon:x:1:1:daemon:/usr/sbin:/bin/sh
Debian-exim:x:101:103::/var/spool/exim4:/bin/false
games:x:5:60:games:/usr/games:/bin/sh
gnats:x:41:41:Gnats Bug-Reporting System (admin):/var/lib/gnats:/bin/sh
irc:x:39:39:ircd:/var/run/ircd:/bin/sh
ivan:x:1001:1001::/home/ivan:/bin/bash
libuuid:x:100:101::/var/lib/libuuid:/bin/sh
list:x:38:38:Mailing List Manager:/var/list:/bin/sh
...
nobody:x:65534:65534:nobody:/nonexistent:/bin/sh
petr:x:1002:1002::/home/petr:/bin/bash
proxy:x:13:13:proxy:/bin:/bin/sh
root:x:0:0:root:/root:/bin/bash
sshd:x:102:65534::/var/run/sshd:/usr/sbin/nologin
sync:x:4:65534:sync:/bin:/bin/sync
sys:x:3:3:sys:/dev:/bin/sh
user:x:1000:1000:user,,,:/home/user:/bin/bash
uucp:x:10:10:uucp:/var/spool/uucp:/bin/sh
www-data:x:33:33:www-data:/var/www:/bin/sh
11:34:54
$news
l3script: news: команда не найдена
11:35:11
$mail
No mail for user
11:35:17
$mail
Heirloom mailx version 12.5 6/20/10.  Type ? for help.
"/var/mail/user": 1 message 1 new
>N  1 root               Tue Sep 29 12:35   20/672   12
? 1
Message  1:
From root@based-debian.net.nt Tue Sep 29 12:35:30 2015
Return-path: <root@based-debian.net.nt>
Envelope-to: user@based-debian.net.nt
Delivery-date: Tue, 29 Sep 2015 12:35:30 +0300
Date: Tue, 29 Sep 2015 12:35:30 +0300
To: user@based-debian.net.nt
Subject: 12
User-Agent: Heirloom mailx 12.5 6/20/10
Content-Type: text/plain; charset=us-ascii
From: root <root@based-debian.net.nt>
Status: R
lox
? q
Held 1 message in /var/mail/user
У вас есть почта в /var/mail/user
11:35:38
$mv /etc/passwd /tmp 2> erlog

11:36:40
$cat erlog
mv: невозможно переместить «/etc/passwd» в «/tmp/passwd»: Отказано в доступе
11:36:46
$mv erlog errlog

11:37:23
$cat erlog
cat: erlog: Нет такого файла или каталога
11:37:27
$cat errlog
mv: невозможно переместить «/etc/passwd» в «/tmp/passwd»: Отказано в доступе
11:37:30
$cat erlog 2>> errlog

11:37:47
$cat errlog
mv: невозможно переместить «/etc/passwd» в «/tmp/passwd»: Отказано в доступе
cat: erlog: Нет такого файла или каталога
11:37:51
$cat >> unsorted
Windows
Kubuntu
Lubuntu
Windows SRV
Win2k3
Win2k8
Win2k12
LNX
FreeBSD
11:39:03
$sort < unsorted > sorted

11:39:32
$cat sorted
FreeBSD
Kubuntu
LNX
Lubuntu
Win2k12
Win2k3
Win2k8
Windows
Windows SRV
11:39:35
$cat > file
hgfkj
fnfkgn
hfgknlgf
hgfjkhlfg
fhglk
11:39:54
$cat file
hgfkj
fnfkgn
hfgknlgf
hgfjkhlfg
fhglk
11:39:58
$cat >> file
flgfdkl
fghgkg
ghfgkh
hfghjkl
11:40:19
$cat file
hgfkj
fnfkgn
hfgknlgf
hgfjkhlfg
fhglk
flgfdkl
fghgkg
ghfgkh
hfghjkl
11:40:21
$cat bigfile " more
> cat bigfile | more
> ^C
11:40:38
$cat bigfile " more
                      cat bigfile | more
cat: bigfile: Нет такого файла или каталога
11:40:59
$cat /etc/passwd | sort | tee sorted_passwd | less
11:48:59
$clear

11:49:02
$cat > *
l3script: *: ambiguous redirect
11:49:33
$touch > *
l3script: *: ambiguous redirect
11:49:44
$cat > -r

11:50:10
$ls
_1_2_3     alloca.H    bjen    errlog   -file1  _hrypun        modules  -r        sorted_passwd  unsorted
1cdesktop  __asterisk  bjon    fcntl.h  group   isdn_ttyfax.c  newfile  Regexp.H  s_tol_
acpi       bjan        core.c  file     -hello  _kik_my        passwd   sorted    term.h
11:50:11
$cat > \*

11:50:45
$ls
*          acpi        bjan  core.c   file    -hello         _kik_my  passwd    sorted         term.h
_1_2_3     alloca.H    bjen  errlog   -file1  _hrypun        modules  -r        sorted_passwd  unsorted
1cdesktop  __asterisk  bjon  fcntl.h  group   isdn_ttyfax.c  newfile  Regexp.H  s_tol_
11:50:47
$rm '\*' '-r'
rm: невозможно удалить «\\*»: Нет такого файла или каталога
11:51:10
$rm '*' '-r'

11:51:14
$ls
_1_2_3     alloca.H    bjen    errlog   -file1  _hrypun        modules  -r        sorted_passwd  unsorted
1cdesktop  __asterisk  bjon    fcntl.h  group   isdn_ttyfax.c  newfile  Regexp.H  s_tol_
acpi       bjan        core.c  file     -hello  _kik_my        passwd   sorted    term.h
11:51:18
$rm "-r"
rm: пропущен операнд
Попробуйте «rm --help» для получения более подробного описания.
11:51:41
$rm -f "-r"

11:51:47
$ls
_1_2_3     alloca.H    bjen    errlog   -file1  _hrypun        modules  -r        sorted_passwd  unsorted
1cdesktop  __asterisk  bjon    fcntl.h  group   isdn_ttyfax.c  newfile  Regexp.H  s_tol_
acpi       bjan        core.c  file     -hello  _kik_my        passwd   sorted    term.h
11:51:51
$rm
rm: пропущен операнд
Попробуйте «rm --help» для получения более подробного описания.
11:51:56
$rm --help
Использование: rm [КÐ
‹).
  -f, --force         игнорировать несуществующие файлы, ни о чем не спрашивать
  -i                  запрашивать подтверждение перед каждым удалением
  -I                  запрашивать подтверждение один раз перед удалением более
                        чем трех файлов или перед рекурсивным удалением.  Не так
                        назойливо, как -i, но все же предоставляет защиту от
                        большинства ошибок.
      --interactive[=КОГДА] запрашивать подтверждение, КОГДА указано: never
                        (никогда), once (-I, один раз) или always (-i, всегда).
...
  rm ./-foo
Заметим, что при использовании rm для удаления файла его содержимое
обычно можно восстановить, имея соответствующий опыт и время.
Используйте shred, если вам необходима большая
уверенность в невозможности восстановления содержимого.
Об ошибках в rm сообщайте по адресу bug-coreutils@gnu.org.
Домашняя страница GNU coreutils: <http://www.gnu.org/software/coreutils/>
Справка по работе с программами GNU: <http://www.gnu.org/gethelp/>
Об ошибках в переводе сообщений «rm» сообщайте по адресу <gnu@mx.ru>
Полная документация доступна по команде: info coreutils 'rm invocation'
11:51:59
$rm -r '-r'
rm: пропущен операнд
Попробуйте «rm --help» для получения более подробного описания.
11:52:25
$rm -- -r

11:52:43
$ls
_1_2_3     alloca.H    bjen    errlog   -file1  _hrypun        modules  Regexp.H       s_tol_
1cdesktop  __asterisk  bjon    fcntl.h  group   isdn_ttyfax.c  newfile  sorted         term.h
acpi       bjan        core.c  file     -hello  _kik_my        passwd   sorted_passwd  unsorted
11:52:45
$cd

прошла 61 минута
12:54:38
$top
top - 14:45:41 up 3 days, 21:23,  4 users,  load average: 2,27, 1,67, 1,31
Tasks:  73 total,   4 running,  68 sleeping,   1 stopped,   0 zombie
%Cpu(s): 49,6 us,  4,4 sy,  0,6 ni,  0,0 id,  0,0 wa,  0,0 hi,  0,3 si, 45,1 st
KiB Mem:    507368 total,   369604 used,   137764 free,    95260 buffers
KiB Swap:        0 total,        0 used,        0 free,   151228 cached
  PID USER      PR  NI  VIRT  RES  SHR S  %CPU %MEM    TIME+  COMMAND
 3409 root      20   0 49500  11m 1644 R  45,5  2,4  23:50.21 l3-agent
13557 root      20   0 10140 1220  840 R  41,5  0,2   0:11.69 egrep
13002 root      20   0 71292 3688 2892 S  10,0  0,7   0:04.12 sshd
13084 root      20   0 18168  468  308 S   1,7  0,1   0:01.51 script
13493 root      20   0     0    0    0 S   1,0  0,0   0:00.83 kworker/0:2
 5748 root      39  19 20628 6384  856 R   0,7  1,3   1430:06 john
13558 user      20   0 25284 1504 1128 R   0,3  0,3   0:00.01 top
    1 root      20   0 10648  828  696 S   0,0  0,2   0:06.25 init
    2 root      20   0     0    0    0 S   0,0  0,0   0:00.00 kthreadd
    3 root      20   0     0    0    0 S   0,0  0,0   0:00.26 ksoftirqd/0
    5 root      20   0     0    0    0 S   0,0  0,0   0:00.00 kworker/u:0
    6 root      rt   0     0    0    0 S   0,0  0,0   0:00.00 migration/0
прошла 51 минута
13:45:44
$? 0:00 sshd: user [priv]
l3script: ?: команда не найдена
13:46:21
$? 0:00 sshd: user [priv]
l3script: ?: команда не найдена
13:46:29
$ps lax
F   UID   PID  PPID PRI  NI    VSZ   RSS WCHAN  STAT TTY        TIME COMMAND
4     0     1     0  20   0  10648   828 ?      Ss   ?          0:06 init [2]
1     0     2     0  20   0      0     0 ?      S    ?          0:00 [kthreadd]
1     0     3     2  20   0      0     0 ?      S    ?          0:00 [ksoftirqd/0]
1     0     5     2  20   0      0     0 ?      S    ?          0:00 [kworker/u:0]
1     0     6     2 -100  -      0     0 ?      S    ?          0:00 [migration/0]
5     0     7     2 -100  -      0     0 ?      S    ?          0:02 [watchdog/0]
1     0     8     2   0 -20      0     0 ?      S<   ?          0:00 [cpuset]
1     0     9     2   0 -20      0     0 ?      S<   ?          0:00 [khelper]
5     0    10     2  20   0      0     0 ?      S    ?          0:00 [kdevtmpfs]
...
1     0 10756     1  20   0  18168   468 ?      S    ?          0:00 script -f -c l3script -q /root/.lilalo//302573
0     0 10757 10756  20   0  23960  2492 ?      Ss+  pts/10     0:00 l3script
0     0 11252 10757  20   0   7728   324 ?      T    pts/10     0:00 cat
4     0 13002  2293  20   0  71292  3688 ?      Ss   ?          0:04 sshd: root@pts/13
4     0 13004 13002  20   0  22092  2752 ?      Ss   pts/13     0:00 -bash
0     0 13053 13004  20   0  18164   840 ?      S+   pts/13     0:00 script -f -c l3script -q /root/.lilalo//106625
1     0 13084 13053  20   0  18168   468 ?      S+   pts/13     0:01 script -f -c l3script -q /root/.lilalo//106625
0     0 13085 13084  20   0  21672  2340 ?      Ss+  pts/11     0:01 l3script
1     0 13493     2  20   0      0     0 ?      S    ?          0:01 [kworker/0:2]
0  1000 13597  9945  20   0  10536   844 -      R+   pts/8      0:00 ps lax
13:46:44
$ps lax | awk '$11~/?/'
awk: line 1: regular expression compile failed (missing operand)
?
13:47:20
$ps lax | awk '$11~/`?`/'

13:47:32
$sed 's/:/ /g' /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
прошло 49 минут
14:36:56
$sed 's/:/ /g' /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
14:37:11
$sed 's/:.*//' /etc/passwd
root
daemon
bin
sys
sync
games
man
lp
mail
news
...
list
irc
gnats
nobody
libuuid
Debian-exim
user
sshd
ivan
petr
14:37:37
$sed 's/[^a]//g' /etc/passwd | wc -c
71
14:38:05
$sed 's/[^b]//g' /etc/passwd | wc -c
68
14:38:17
$vi shhh.sh
--- /dev/null	2015-09-25 17:22:27.807999997 +0300
+++ shhh.sh	2015-09-29 15:40:36.181253361 +0300
@@ -0,0 +1,5 @@
+#!/bin/bash
+fir i in *\ *
+	do
+	mv "$i" "`echo $i | sed 's/ /_/g' `"
+	done