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

Содержание

Журнал

Вторник (09/13/16)

/dev/pts/2
13:33:19
$ls -a
.          acpi        ._bash   bjon     group          .j_bash  .passwd
..         alloca.H    .._bash  core.c   -hello         _kik_my  Regexp.H
_1_2_3     __asterisk  bjan     fcntl.h  _hrypun        modules  s_tol_
1cdesktop  .bash       bjen     -file1   isdn_ttyfax.c  passwd   term.h
13:34:12
$ls .[^.]*
.bash  ._bash  .j_bash  .passwd
13:35:45
$ls .*
.bash  ._bash  .._bash  .j_bash  .passwd
.:
_1_2_3     alloca.H    bjen    fcntl.h  -hello         _kik_my  Regexp.H
1cdesktop  __asterisk  bjon    -file1   _hrypun        modules  s_tol_
acpi       bjan        core.c  group    isdn_ttyfax.c  passwd   term.h
..:
backup                                 lpi 2                          proj
bigfile                                man_smb_conf                   sh
bin                                    matrix.jpg                     source
freebsd.jpg                            names                          text
granata.jpg                            ogo.jpg                        touchlist
Light_Alloy_4.4.784_RC2_by_FAFNIR.exe  pamyatka.pdf
lpi 1                                  press_any_key_to_continue.jpg
13:36:22
$touch "file with spaces at the name"

13:39:09
$ls
_1_2_3      bjan     -file1                        isdn_ttyfax.c  s_tol_
1cdesktop   bjen     file with spaces at the name  _kik_my        term.h
acpi        bjon     group                         modules
alloca.H    core.c   -hello                        passwd
__asterisk  fcntl.h  _hrypun                       Regexp.H
13:39:11
$touch 'another very long file name'

13:39:35
$touch one\ space

13:39:49
$ls
_1_2_3                       bjan     file with spaces at the name  modules
1cdesktop                    bjen     group                         one space
acpi                         bjon     -hello                        passwd
alloca.H                     core.c   _hrypun                       Regexp.H
another very long file name  fcntl.h  isdn_ttyfax.c                 s_tol_
__asterisk                   -file1   _kik_my                       term.h
13:39:51
$touch "O'Reilly"

13:40:15
$ls
_1_2_3                       core.c                        modules
1cdesktop                    fcntl.h                       one space
acpi                         -file1                        O'Reilly
alloca.H                     file with spaces at the name  passwd
another very long file name  group                         Regexp.H
__asterisk                   -hello                        s_tol_
bjan                         _hrypun                       term.h
bjen                         isdn_ttyfax.c
bjon                         _kik_my
13:40:16
$touch 'A:\WINDOWS\SYSTEM32'

13:40:40
$touch "Queen \"Live at Wembley '86\""

13:41:32
$echo *
_1_2_3 1cdesktop acpi alloca.H another very long file name __asterisk A:\WINDOWS\SYSTEM32 bjan bjen bjon core.c fcntl.h -file1 file with spaces at the name group -hello _hrypun isdn_ttyfax.c _kik_my modules one space O'Reilly passwd Queen "Live at Wembley '86" Regexp.H s_tol_ term.h
13:41:50
$touch -bad-name-
touch: неверный ключ -- b
Попробуйте «touch --help» для получения более подробного описания.
13:42:50
$touch "-bad-name-"
touch: неверный ключ -- b
Попробуйте «touch --help» для получения более подробного описания.
13:42:57
$touch --bad--name--
touch: ключ --bad--name-- не распознан
Попробуйте «touch --help» для получения более подробного описания.
13:43:21
$touch ./-bad./-name./-
touch: невозможно выполнить touch для «./-bad./-name./-»: Нет такого файла или каталога
13:43:42
$cd

13:44:07
$ls
backup                                 lpi 2                          proj
bigfile                                man_smb_conf                   sh
bin                                    matrix.jpg                     source
freebsd.jpg                            names                          text
granata.jpg                            ogo.jpg                        touchlist
Light_Alloy_4.4.784_RC2_by_FAFNIR.exe  pamyatka.pdf
lpi 1                                  press_any_key_to_continue.jpg
13:44:09
$cat touchlist
file1
file2
file3
directory1
directory2
directory3
aba
abb
abc
abd
killall
13:44:28
$cd names/

13:44:51
$touch 'cat ~/touchlist'
touch: невозможно выполнить touch для «cat ~/touchlist»: Нет такого файла или каталога
13:45:15
$touch `cat ~/touchlist`

13:45:30
$cd

13:45:38
$cd names/

13:46:01
$ls
_1_2_3                       file1
1cdesktop                    -file1
aba                          file2
abb                          file3
abc                          file with spaces at the name
abd                          group
acpi                         -hello
alloca.H                     _hrypun
another very long file name  isdn_ttyfax.c
__asterisk                   _kik_my
A:\WINDOWS\SYSTEM32          killall
bjan                         modules
bjen                         one space
bjon                         O'Reilly
core.c                       passwd
directory1                   Queen "Live at Wembley '86"
directory2                   Regexp.H
directory3                   s_tol_
fcntl.h                      term.h
13:46:02
$echo date
date
13:46:19
$echo $date

13:46:24
$echo `date`
Втр Сен 13 14:46:35 EEST 2016
13:46:35
$echo `date +%Y`
2016
13:46:56
$echo `date +%Y+1`
2016+1
13:47:16
$echo $(expr `date +%Y+1`)
2016+1
13:47:44
$echo $(expr `date +%Y + 1`)
date: лишний операнд «+»
Попробуйте «date --help» для получения более подробного описания.
expr: пропущен операнд
Попробуйте «expr --help» для получения более подробного описания.
13:47:55
$echo $(expr `date +%Y +1`)
date: лишний операнд «+1»
Попробуйте «date --help» для получения более подробного описания.
expr: пропущен операнд
Попробуйте «expr --help» для получения более подробного описания.
13:47:59
$echo $(expr `date +%Y+1`)
2016+1
13:48:02
$echo $(expr `date +%Y`+1)
2016+1
13:49:42
$echo $(`date +%Y`+1)
l3script: 2016+1: команда не найдена
13:50:02
$echo $((`date +%Y`+1))
2017
13:50:09
$ls
_1_2_3                       file1
1cdesktop                    -file1
aba                          file2
abb                          file3
abc                          file with spaces at the name
abd                          group
acpi                         -hello
alloca.H                     _hrypun
another very long file name  isdn_ttyfax.c
__asterisk                   _kik_my
A:\WINDOWS\SYSTEM32          killall
bjan                         modules
bjen                         one space
bjon                         O'Reilly
core.c                       passwd
directory1                   Queen "Live at Wembley '86"
directory2                   Regexp.H
directory3                   s_tol_
fcntl.h                      term.h
13:50:47
$rm -f `find ~ -name core`

13:51:19
$ls
_1_2_3                       file1
1cdesktop                    -file1
aba                          file2
abb                          file3
abc                          file with spaces at the name
abd                          group
acpi                         -hello
alloca.H                     _hrypun
another very long file name  isdn_ttyfax.c
__asterisk                   _kik_my
A:\WINDOWS\SYSTEM32          killall
bjan                         modules
bjen                         one space
bjon                         O'Reilly
core.c                       passwd
directory1                   Queen "Live at Wembley '86"
directory2                   Regexp.H
directory3                   s_tol_
fcntl.h                      term.h
13:51:21
$cd ..

13:51:39
$ls
backup                                 lpi 2                          proj
bigfile                                man_smb_conf                   sh
bin                                    matrix.jpg                     source
freebsd.jpg                            names                          text
granata.jpg                            ogo.jpg                        touchlist
Light_Alloy_4.4.784_RC2_by_FAFNIR.exe  pamyatka.pdf
lpi 1                                  press_any_key_to_continue.jpg
13:51:40
$echo $PATH
/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games
13:52:17
$echo HHHHHHHHHHHHHH$PATHHHHHHHHHHHHHHHHHHHhh
HHHHHHHHHHHHHH
13:52:36
$echo HHHHHHHHHHHHHH${PATH}HHHHHHHHHHHHHHHHHHhh
HHHHHHHHHHHHHH/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/gamesHHHHHHHHHHHHHHHHHHhh
13:52:52
$echo $(((1+2+3)*4*5+1))
121
13:53:29
$A=1

13:54:07
$B=2

13:54:09
$echo $((A+B))
3
13:54:23
$echo ((A+$B))
l3script: syntax error near unexpected token `('
/dev/pts/2
13:55:36
$cd

13:55:56
$cat /etc/passwd >newfile

13:56:09
$less newfile
13:56:23
$sort < newfile
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
13:56:43
$ls
backup                                 names
bigfile                                newfile
bin                                    ogo.jpg
freebsd.jpg                            pamyatka.pdf
granata.jpg                            press_any_key_to_continue.jpg
Light_Alloy_4.4.784_RC2_by_FAFNIR.exe  proj
lpi 1                                  sh
lpi 2                                  source
man_smb_conf                           text
matrix.jpg                             touchlist
13:58:12
$cat >> unsorted
Windows XP
Windows N
Solaris
Sun OS
Linux
FreeBSD
.
^C
13:59:19
$cat unsorted
Windows XP
Windows N
Solaris
Sun OS
Linux
FreeBSD
.
13:59:23
$sort < unsorted >sorted

13:59:36
$cat sorted
.
FreeBSD
Linux
Solaris
Sun OS
Windows N
Windows XP
13:59:40
$cat > file
1
2
14:00:06
$cat >> file
3
4
14:00:26
$cat file
1
2
3
4
14:00:30
$mkdir /tmp/etccopy

14:01:07
$cp -v /etc/* /tmp/etccopy/ 2>&1 | less
14:01:59
$cp -v /etc/* /tmp/etccopy/ | less
14:02:28
$cat /etc/passwd | sort | tee sorted_passwd | less
14:03:56
$ls
backup                                 newfile
bigfile                                ogo.jpg
bin                                    pamyatka.pdf
file                                   press_any_key_to_continue.jpg
freebsd.jpg                            proj
granata.jpg                            sh
Light_Alloy_4.4.784_RC2_by_FAFNIR.exe  sorted
lpi 1                                  sorted_passwd
lpi 2                                  source
man_smb_conf                           text
matrix.jpg                             touchlist
names                                  unsorted
14:03:59
$car sorted_passwd
l3script: car: команда не найдена
14:04:09
$cat sorted_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
14:04:15
$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
прошло 113 минут
15:57:53
$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
15:59:07
$sed 's/[^a]//g' /etc/passwd
a
aa
aaa
aaaaa
a
aaaa
a
a
aaaaa
aaaa
aaaa
a
aaaaa
a
aaa
a
a
aaa
a
16:01:21
$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
16:01:38
$sed 's/[^a]//g' /etc/passwd
a
aa
aaa
aaaaa
a
aaaa
a
a
aaaaa
aaaa
aaaa
a
aaaaa
a
aaa
a
a
aaa
a
16:02:28
$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