| /l3/users/4-9-2017/NT-Ladm/debian2.net.nt/root :1 :2 :3 :4 :5 |
|
|
#./shell.sh bash
./shell.sh: line 7: unexpected EOF while looking for matching `"' ./shell.sh: line 11: ошибка синтаксиса: неожиданный конец файла |
|
#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
|
|
#./shell.sh bash
Changing shell bash for user...hell Changing shell bash for ivan...hell Changing shell bash for petr...hell |
|
#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
|
|
#./shell.sh bash
Changing shell bash for user... usermod: изменения не внесены Changing shell bash for ivan... usermod: изменения не внесены Changing shell bash for petr... usermod: изменения не внесены ^C |
|
#./shell.sh zsh
Changing shell zsh for user... Changing shell zsh for ivan... Changing shell zsh for petr... |
|
#./shell.sh bash
Changing shell bash for user... Changing shell bash for ivan... Changing shell bash for petr... |
|
#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
|
|
#./shell.sh zsh
./shell.sh: line 3: 1:-bash: команда не найдена Changing shell for user... Changing shell for ivan... Changing shell for petr... |
|
#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
|
|
#./shell.sh zsh
Changing shell zsh for user... Changing shell zsh for ivan... Changing shell zsh for petr... |
|
#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 |
|
#./shell.sh
Changing shell bash for user... Changing shell bash for ivan... Changing shell bash for petr... |
|
#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 |
|
#t=25
|
|
#echo $t
25 |
|
#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
|
|
#echo $t
25 |
|
#export t
|
|
#bash
root@debian2:/usr/share/man# echo $t 25 root@debian2:/usr/share/man# exit exit |
|
#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 |
|
#echo $?
0 |
|
#test 5 -eq 5
|
|
#echo $?
0 |
|
#test 5 -eq 6
|
|
#echo $?
1 |
|
#ping -c100 8.8.8.8&> report.txt &
[1] 14136 |
|
#jobs
[1]+ Running ping -c100 8.8.8.8 &>report.txt & |
|
#kill %1
[1]+ Завершено ping -c100 8.8.8.8 &>report.txt |
|
#jobs
|
|
#ping -c100 8.8.8.8&> report.txt
^Z [1]+ Stopped ping -c100 8.8.8.8 &>report.txt |
|
#jobs
[1]+ Stopped ping -c100 8.8.8.8 &>report.txt |
|
#bg
[1]+ ping -c100 8.8.8.8 &>report.txt & |
|
#bg %1
l3script: bg: job 1 already in background |
|
#test -x shell.sh; echo $?
0 [1]+ Done ping -c100 8.8.8.8 &>report.txt |
|
#test -x passwd
|
|
#echo $?
1 |
|
#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.
|
|
#l='ls'
|
|
#$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 |
|
#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.
|
|
#cd /etc/init.d/
|
|
#vi cron
|
|
# 30 [ -r /etc/default/cron ] && . /etc/default/cron
|
|
#vi proc.sh
|
|
#chmod u+x proc.sh
|
|
#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) |
|
#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 |
|
#./proc.sh
./proc.sh: line 5: [: пропущен `]' |
|
#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 |
|
#./proc.sh
^C |
|
#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 Параметры терминала |