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

Содержание

Журнал

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

/dev/pts/2
13:06:46
#./shell.sh bash
./shell.sh: line 7: unexpected EOF while looking for matching `"'
./shell.sh: line 11: ошибка синтаксиса: неожиданный конец файла
13:06:49
#vi shell.sh
--- /tmp/l3-saved-11890.13402.1905	2017-09-06 14:06:59.875199020 +0300
+++ shell.sh	2017-09-06 14:07:22.567176715 +0300
@@ -4,7 +4,7 @@
 #echo $users
 for user in $users
   do 
-   echo "Changing shell $shell for $user...hell 
+   echo "Changing shell $shell for $user...hell" 
    usermod -s /bin/$shell $user
    sleep 2
   done
13:07:22
#./shell.sh bash
Changing shell bash for user...hell
Changing shell bash for ivan...hell
Changing shell bash for petr...hell
13:07:37
#vi shell.sh
--- /tmp/l3-saved-11890.6737.29850	2017-09-06 14:07:52.823193523 +0300
+++ shell.sh	2017-09-06 14:08:13.995251722 +0300
@@ -4,7 +4,7 @@
 #echo $users
 for user in $users
   do 
-   echo "Changing shell $shell for $user...hell" 
+   echo "Changing shell $shell for $user..." 
    usermod -s /bin/$shell $user
    sleep 2
   done
13:08:14
#./shell.sh bash
Changing shell bash for user...
usermod: изменения не внесены
Changing shell bash for ivan...
usermod: изменения не внесены
Changing shell bash for petr...
usermod: изменения не внесены
^C
13:08:21
#./shell.sh zsh
Changing shell zsh for user...
Changing shell zsh for ivan...
Changing shell zsh for petr...
13:08:33
#./shell.sh bash
Changing shell bash for user...
Changing shell bash for ivan...
Changing shell bash for petr...
13:08:48
#vi shell.sh
--- /tmp/l3-saved-11890.15505.23671	2017-09-06 14:10:34.915200828 +0300
+++ shell.sh	2017-09-06 14:12:45.315201178 +0300
@@ -1,6 +1,6 @@
 #!/bin/bash
 users=$(awk -F: '$3>=1000 && $3!=65534{print $1}' /etc/passwd | tr "\n" " ")
-shell=$1
+shell=$(1:-bash)
 #echo $users
 for user in $users
   do 
13:12:45
#./shell.sh zsh
./shell.sh: line 3: 1:-bash: команда не найдена
Changing shell  for user...
Changing shell  for ivan...
Changing shell  for petr...
13:12:56
#vi shell.sh
--- /tmp/l3-saved-11890.11694.9798	2017-09-06 14:13:05.715198523 +0300
+++ shell.sh	2017-09-06 14:13:39.671190393 +0300
@@ -1,6 +1,6 @@
 #!/bin/bash
 users=$(awk -F: '$3>=1000 && $3!=65534{print $1}' /etc/passwd | tr "\n" " ")
-shell=$(1:-bash)
+shell=${1:-bash}
 #echo $users
 for user in $users
   do 
13:13:39
#./shell.sh zsh
Changing shell zsh for user...
Changing shell zsh for ivan...
Changing shell zsh for petr...
13:13:48
#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/zsh
sshd:x:102:65534::/var/run/sshd:/usr/sbin/nologin
ivan:x:1001:1001::/home/ivan:/bin/zsh
petr:x:1002:1002::/home/petr:/bin/zsh
13:14:00
#./shell.sh
Changing shell bash for user...
Changing shell bash for ivan...
Changing shell bash for petr...
13:14:17
#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
13:14:19
#t=25

13:23:43
#echo $t
25
13:23:50
#bash
root@debian2:/usr/share/man# pstree
init─┬─acpid
     ├─cron
     ├─exim4
     ├─6*[getty]
     ├─2*[l3-agent]
     ├─rsyslogd───3*[{rsyslogd}]
     ├─2*[script───l3script]
     ├─sshd─┬─sshd───bash───script───script───l3script───bash───pstree
     │      └─sshd───sshd───bash───script───script───l3script
     └─udevd
root@debian2:/usr/share/man# echo $t
root@debian2:/usr/share/man# exit
exit
13:25:03
#echo $t
25
13:25:06
#export t

13:26:12
#bash
root@debian2:/usr/share/man# echo $t
25
root@debian2:/usr/share/man# exit
exit
13:27:00
#env
SHELL=/bin/bash
TERM=xterm
HISTSIZE=2000
SSH_CLIENT=192.168.16.176 49158 22
L3_PARENT_TTY=/dev/pts/2
OLDPWD=/root
L3_TAMPERED_EDITORS= vi vim pico nano
SSH_TTY=/dev/pts/2
USER=root
HISTFILESIZE=2000
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
MAIL=/var/mail/root
L3_SESSION_ID=2642526237808327667-1504677564
PWD=/usr/share/man
LANG=ru_RU.UTF-8
13:27:22
#echo $?
0
13:30:14
#test 5 -eq 5

13:38:46
#echo $?
0
13:38:51
#test 5 -eq 6

13:38:55
#echo $?
1
13:38:56
#ping -c100 8.8.8.8&> report.txt &
[1] 14136
13:45:59
#jobs
[1]+  Running                 ping -c100 8.8.8.8 &>report.txt &
13:46:24
#kill %1
[1]+  Завершено      ping -c100 8.8.8.8 &>report.txt
13:47:03
#jobs

13:47:11
#ping -c100 8.8.8.8&> report.txt
^Z
[1]+  Stopped                 ping -c100 8.8.8.8 &>report.txt
13:48:04
#jobs
[1]+  Stopped                 ping -c100 8.8.8.8 &>report.txt
13:48:09
#bg
[1]+ ping -c100 8.8.8.8 &>report.txt &
13:48:20
#bg %1
l3script: bg: job 1 already in background
13:48:36
#test -x shell.sh; echo $?
0
[1]+  Done                    ping -c100 8.8.8.8 &>report.txt
13:52:58
#test -x passwd

13:53:21
#echo $?
1
13:53:31
#help test
test: test [expr]
    Evaluate conditional expression.
    Exits with a status of 0 (true) or 1 (false) depending on
    the evaluation of EXPR.  Expressions may be unary or binary.  Unary
    expressions are often used to examine the status of a file.  There
    are string operators and numeric comparison operators as well.
    The behavior of test depends on the number of arguments.  Read the
    bash manual page for the complete specification.
    File operators:
      -a FILE        True if file exists.
...
      arg1 OP arg2   Arithmetic tests.  OP is one of -eq, -ne,
                     -lt, -le, -gt, or -ge.
    Arithmetic binary operators return true if ARG1 is equal, not-equal,
    less-than, less-than-or-equal, greater-than, or greater-than-or-equal
    than ARG2.
    See the bash manual page bash(1) for the handling of parameters (i.e.
    missing parameters).
    Exit Status:
    Returns success if EXPR evaluates to true; fails if EXPR evaluates to
    false or an invalid argument is given.
13:54:24
#l='ls'

13:55:32
#$l
cs  da  de  es  fi  fr  gl  hu  id  it  ja  ko  man1  man2  man3  man4  man5  man6  man7  man8  nl  pl  pt  pt_BR  report.txt  ru  shell.sh  sl  sv  tr  zh_CN  zh_TW
13:55:35
#help [
[: [ arg... ]
    Evaluate conditional expression.
    This is a synonym for the "test" builtin, but the last argument must
    be a literal `]', to match the opening `['.
[[ ... ]]: [[ expression ]]
    Execute conditional command.
    Returns a status of 0 or 1 depending on the evaluation of the conditional
    expression EXPRESSION.  Expressions are composed of the same primaries used
    by the `test' builtin, and may be combined using the following operators:
      ( EXPRESSION )    Returns the value of EXPRESSION
      ! EXPRESSION              True if EXPRESSION is false; else false
      EXPR1 && EXPR2    True if both EXPR1 and EXPR2 are true; else false
      EXPR1 || EXPR2    True if either EXPR1 or EXPR2 is true; else false
    When the `==' and `!=' operators are used, the string to the right of
    the operator is used as a pattern and pattern matching is performed.
    When the `=~' operator is used, the string to the right of the operator
    is matched as a regular expression.
    The && and || operators do not evaluate EXPR2 if EXPR1 is sufficient to
    determine the expression's value.
    Exit Status:
    0 or 1 depending on value of EXPRESSION.
13:59:33
#cd /etc/init.d/

14:02:44
#vi cron
14:07:04
# 30 [ -r /etc/default/cron ] && . /etc/default/cron

14:07:23
#vi proc.sh
14:07:50
#~
  2 i=1
  3
  4 while [ $i -lt 1000000]
  5  do
  6   echo $i > /dev/pts/2
  8   clear > /dev/pts/2
  9 2 i=$[$i+1]
 10  done
~
~
...
~
~
~
~
~
~
~
~
~
"proc.sh" [Новый] 10L, 108C записано
14:12:35
#chmod u+x proc.sh

14:12:51
#who
root     pts/2        2017-09-06 08:59 (192.168.16.176)
user     pts/6        2017-09-06 09:01 (192.168.16.176)
14:12:58
#vi proc.sh
--- /tmp/l3-saved-11890.23650.16498	2017-09-06 15:13:26.659189430 +0300
+++ proc.sh	2017-09-06 15:14:07.495196491 +0300
@@ -5,6 +5,6 @@
 while [ $i -lt 1000000]
  do
   echo $i > /dev/pts/2
-  clear > /dev/pts/2
+  clear > /dev/pts/6
   i=$[$i+1]
  done
14:14:07
#./proc.sh
./proc.sh: line 5: [: пропущен `]'
14:14:24
#vi proc.sh
--- /tmp/l3-saved-11890.32206.6955	2017-09-06 15:14:31.419145632 +0300
+++ proc.sh	2017-09-06 15:16:39.783191451 +0300
@@ -2,9 +2,9 @@
 
 i=1
 
-while [ $i -lt 1000000]
+while [ $i -lt 100000 ]
  do
-  echo $i > /dev/pts/2
+  echo $i > /dev/pts/6
   clear > /dev/pts/6
   i=$[$i+1]
  done
14:16:39
#./proc.sh
^C
14:20:17
#stty -a
speed 38400 baud; rows 48; columns 173; 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
Параметры терминала
14:22:46