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

Содержание

Журнал

Среда (03/29/17)

/dev/pts/0
11:49:06
#ls
backup   bin  debian3       debian3.text2  file         granata.jpg                            lpi 1  man_smb_conf  names    pamyatka.pdf  press_any_key_to_continue.jpg  screenrc  temp.tar  touchlist
bigfile  cod  debian3.text  debian3.txt    freebsd.jpg  light_alloy_4.4.784_rc2_by_fafnir.exe  lpi 2  matrix.jpg    ogo.jpg  passwd        proj                           sh        text
11:49:07
#find ~ -regex '.*(\.tar|\.gz|\.tgz|\.rmp)'

11:49:16
#man find
11:50:28
#find ~ -regex '.*(\.tar|\.gz|\.tgz|\.rmp)' -regextype posix-egrep

11:50:38
#ls
backup   bin  debian3       debian3.text2  file         granata.jpg                            lpi 1  man_smb_conf  names    pamyatka.pdf  press_any_key_to_continue.jpg  screenrc  temp.tar  touchlist
bigfile  cod  debian3.text  debian3.txt    freebsd.jpg  light_alloy_4.4.784_rc2_by_fafnir.exe  lpi 2  matrix.jpg    ogo.jpg  passwd        proj                           sh        text
11:50:41
#pwd
/home/user
11:50:42
#find ~user -regex '.*(\.tar|\.gz|\.tgz|\.rmp)' -regextype posix-egrep

11:50:51
#find ~user -regex '.*(\.tar\.gz|\.tgz|\.rmp)' -regextype posix-egrep

11:51:03
#find ~user -regex '.*(\.tar|\.gz|\.tgz|\.rmp)' -regextype posix-egrep

11:51:05
#find /home/user/ -regex '.*(\.tar|\.gz|\.tgz|\.rmp)' -regextype posix-egrep
.aptitude/                             cod/                                   .l3rc                                  names/                                 sh/
backup/                                debian3                                .lesshst                               ogo.jpg                                .ssh/
.bash_history                          debian3.text                           light_alloy_4.4.784_rc2_by_fafnir.exe  pamyatka.pdf                           temp.tar
.bash_logout                           debian3.text2                          .lilalo/                               passwd                                 text/
.bash_profile                          debian3.txt                            lpi 1/                                 press_any_key_to_continue.jpg          touchlist
.bashrc                                file                                   lpi 2/                                 .profile                               .vifm/
bigfile                                freebsd.jpg                            man_smb_conf                           proj/                                  .viminfo
bin/                                   granata.jpg                            matrix.jpg                             screenrc                               .w3m/
11:51:24
#ls /home/user/
.aptitude/                             cod/                                   .l3rc                                  names/                                 sh/
backup/                                debian3                                .lesshst                               ogo.jpg                                .ssh/
.bash_history                          debian3.text                           light_alloy_4.4.784_rc2_by_fafnir.exe  pamyatka.pdf                           temp.tar
.bash_logout                           debian3.text2                          .lilalo/                               passwd                                 text/
.bash_profile                          debian3.txt                            lpi 1/                                 press_any_key_to_continue.jpg          touchlist
.bashrc                                file                                   lpi 2/                                 .profile                               .vifm/
bigfile                                freebsd.jpg                            man_smb_conf                           proj/                                  .viminfo
bin/                                   granata.jpg                            matrix.jpg                             screenrc                               .w3m/
11:51:24
#ls /home/user/
backup   bin  debian3       debian3.text2  file         granata.jpg                            lpi 1  man_smb_conf  names    pamyatka.pdf  press_any_key_to_continue.jpg  screenrc  temp.tar  touchlist
bigfile  cod  debian3.text  debian3.txt    freebsd.jpg  light_alloy_4.4.784_rc2_by_fafnir.exe  lpi 2  matrix.jpg    ogo.jpg  passwd        proj                           sh        text
11:51:36
#ls /home
ivan  petr  user
11:51:58
#find /home/user -regex '\.tar' -regextype posix-egrep

11:52:10
#find /home/user/ -regex '\.tar' -regextype posix-egrep

11:52:20
#find /home/user/ -regex '\.tar' -regextype posix-egrep

11:52:37
#find /home/user/ -regex '\.tar'

11:52:42
#find /home/user/ -regex '*\.tar'

11:52:45
#find /home/user/ -regex '*\.tar'

прошло 49 минут
12:42:44
#find /home/user/ -regex '*\.tar'

12:45:51
#ls
backup   bin  debian3       debian3.text2  file         granata.jpg                            lpi 1  man_smb_conf  names    pamyatka.pdf  press_any_key_to_continue.jpg  screenrc  temp.tar  touchlist
bigfile  cod  debian3.text  debian3.txt    freebsd.jpg  light_alloy_4.4.784_rc2_by_fafnir.exe  lpi 2  matrix.jpg    ogo.jpg  passwd        proj                           sh        text
12:45:52
#find /home/user/ -regex '*\.tar'

12:46:02
#pwd
/home/user
12:46:06
#man find
12:52:26
#man find
12:52:56
#find /home/user/ -regextype posix-grep -regex '*\.tar'
find: Unknown regular expression type `posix-grep'; valid types are `findutils-default', `awk', `egrep', `ed', `emacs', `gnu-awk', `grep', `posix-awk', `posix-basic', `posix-egrep', `posix-extended', `posix-minimal-basic', `sed'.
12:53:00
#find /home/user/ -regextype posix-egrep -regex '*\.tar'

12:53:08
#find /home/user/ -regextype posix-egrep -regex '.*\.tar'
/home/user/temp.tar
12:53:12
#a=1

12:53:35
#env
SHELL=/bin/bash
TERM=xterm
HISTSIZE=2000
SSH_CLIENT=192.168.16.187 49228 22
L3_PARENT_TTY=/dev/pts/0
L3_TAMPERED_EDITORS= vi vim pico nano
SSH_TTY=/dev/pts/0
USER=root
HISTFILESIZE=2000
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
MAIL=/var/mail/root
L3_SESSION_ID=31383263589649259-1490769712
PWD=/home/user
LANG=ru_RU.UTF-8
12:53:36
#echo $a
1
12:53:51
#bash
root@debian3:/home/user# echo $a
root@debian3:/home/user# pstree
init─┬─acpid
     ├─cron
     ├─exim4
     ├─6*[getty]
     ├─2*[l3-agent]
     ├─rsyslogd───3*[{rsyslogd}]
     ├─sshd───sshd───bash───script───script───l3script───bash───pstree
     └─udevd
root@debian3:/home/user# pstree -h
init─┬─acpid
     ├─cron
     ├─exim4
     ├─6*[getty]
     ├─2*[l3-agent]
     ├─rsyslogd───3*[{rsyslogd}]
     ├─sshd───sshd───bash───script───script───l3script───bash───pstree
     └─udevd
root@debian3:/home/user# exit
12:57:51
#echo $a
1
12:57:57
#pstree -h
init─┬─acpid
     ├─cron
     ├─exim4
     ├─6*[getty]
     ├─2*[l3-agent]
     ├─rsyslogd───3*[{rsyslogd}]
     ├─sshd───sshd───bash───script───script───l3script───pstree
     └─udevd
12:58:03
#export a

12:58:11
#bash
root@debian3:/home/user# echo $a
1
root@debian3:/home/user# exit
12:59:02
#set
BASH=/usr/local/bin/l3script
BASHOPTS=checkwinsize:cmdhist:expand_aliases:extquote:force_fignore:hostcomplete:interactive_comments:progcomp:promptvars:sourcepath
BASH_ALIASES=()
BASH_ARGC=()
BASH_ARGV=()
BASH_CMDS=()
BASH_LINENO=()
BASH_SOURCE=()
BASH_VERSINFO=([0]="4" [1]="2" [2]="37" [3]="1" [4]="release" [5]="x86_64-pc-linux-gnu")
BASH_VERSION='4.2.37(1)-release'
...
MACHTYPE=x86_64-pc-linux-gnu
MAIL=/var/mail/root
MAILCHECK=60
OLDPWD=/home
OPTERR=1
OPTIND=1
OSTYPE=linux-gnu
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
PIPESTATUS=([0]="0")
PPID=14495
12:59:06
#env
SHELL=/bin/bash
TERM=xterm
HISTSIZE=2000
SSH_CLIENT=192.168.16.187 49228 22
L3_PARENT_TTY=/dev/pts/0
OLDPWD=/home
L3_TAMPERED_EDITORS= vi vim pico nano
SSH_TTY=/dev/pts/0
USER=root
HISTFILESIZE=2000
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
MAIL=/var/mail/root
L3_SESSION_ID=31383263589649259-1490769712
a=1
PWD=/home/user
LANG=ru_RU.UTF-8
12:59:10
#export
declare -x HISTFILESIZE="2000"
declare -x HISTSIZE="2000"
declare -x HOME="/root"
declare -x L3_HOME="/root/.lilalo/"
declare -x L3_PARENT_TTY="/dev/pts/0"
declare -x L3_SESSION_ID="31383263589649259-1490769712"
declare -x L3_TAMPERED_EDITORS=" vi vim pico nano"
declare -x LANG="ru_RU.UTF-8"
declare -x LANGUAGE="ru_UA:ru"
declare -x LOGNAME="root"
declare -x MAIL="/var/mail/root"
declare -x OLDPWD="/home"
declare -x PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
12:59:38
#man set
13:00:17
#help set
set: set [-abefhkmnptuvxBCHP] [-o option-name] [--] [arg ...]
    Set or unset values of shell options and positional parameters.
    Change the value of shell attributes and positional parameters, or
    display the names and values of shell variables.
    Options:
      -a  Mark variables which are modified or created for export.
      -b  Notify of job termination immediately.
      -e  Exit immediately if a command exits with a non-zero status.
      -f  Disable file name generation (globbing).
      -h  Remember the location of commands as they are looked up.
...
          are unset.
      -   Assign any remaining arguments to the positional parameters.
          The -x and -v options are turned off.
    Using + rather than - causes these flags to be turned off.  The
    flags can also be used upon invocation of the shell.  The current
    set of flags may be found in $-.  The remaining n ARGs are positional
    parameters and are assigned, in order, to $1, $2, .. $n.  If no
    ARGs are given, all shell variables are printed.
    Exit Status:
    Returns success unless an invalid option is given.
13:01:34
#help
GNU bash, version 4.2.37(1)-release (x86_64-pc-linux-gnu)
These shell commands are defined internally.  Type `help' to see this list.
Type `help name' to find out more about the function `name'.
Use `info bash' to find out more about the shell in general.
Use `man -k' or `info' to find out more about commands not in this list.
A star (*) next to a name means that the command is disabled.
 job_spec [&]                                                                                             history [-c] [-d offset] [n] or history -anrw [filename] or history -ps arg [arg...]
 (( expression ))                                                                                         if COMMANDS; then COMMANDS; [ elif COMMANDS; then COMMANDS; ]... [ else COMMANDS; ] fi
 . filename [arguments]                                                                                   jobs [-lnprs] [jobspec ...] or jobs -x command [args]
 :                                                                                                        kill [-s sigspec | -n signum | -sigspec] pid | jobspec ... or kill -l [sigspec]
...
 export [-fn] [name[=value] ...] or export -p                                                             typeset [-aAfFgilrtux] [-p] name[=value] ...
 false                                                                                                    ulimit [-SHacdefilmnpqrstuvx] [limit]
 fc [-e ename] [-lnr] [first] [last] or fc -s [pat=rep] [command]                                         umask [-p] [-S] [mode]
 fg [job_spec]                                                                                            unalias [-a] name [name ...]
 for NAME [in WORDS ... ] ; do COMMANDS; done                                                             unset [-f] [-v] [name ...]
 for (( exp1; exp2; exp3 )); do COMMANDS; done                                                            until COMMANDS; do COMMANDS; done
 function name { COMMANDS ; } or name () { COMMANDS ; }                                                   variables - Names and meanings of some shell variables
 getopts optstring name [arg]                                                                             wait [id]
 hash [-lr] [-p pathname] [-dt] [name ...]                                                                while COMMANDS; do COMMANDS; done
 help [-dms] [pattern ...]                                                                                { COMMANDS ; }
13:02:32
#help emacs
l3script: help: no help topics match `emacs'.  Try `help help' or `man -k emacs' or `info emacs'.
13:02:37
#help set
set: set [-abefhkmnptuvxBCHP] [-o option-name] [--] [arg ...]
    Set or unset values of shell options and positional parameters.
    Change the value of shell attributes and positional parameters, or
    display the names and values of shell variables.
    Options:
      -a  Mark variables which are modified or created for export.
      -b  Notify of job termination immediately.
      -e  Exit immediately if a command exits with a non-zero status.
      -f  Disable file name generation (globbing).
      -h  Remember the location of commands as they are looked up.
...
          are unset.
      -   Assign any remaining arguments to the positional parameters.
          The -x and -v options are turned off.
    Using + rather than - causes these flags to be turned off.  The
    flags can also be used upon invocation of the shell.  The current
    set of flags may be found in $-.  The remaining n ARGs are positional
    parameters and are assigned, in order, to $1, $2, .. $n.  If no
    ARGs are given, all shell variables are printed.
    Exit Status:
    Returns success unless an invalid option is given.
13:02:40
#help set | grep emacs
              emacs        use an emacs-style line editing interface
13:02:46
#help set | grep vim

13:02:49
#help env
l3script: help: no help topics match `env'.  Try `help help' or `man -k env' or `info env'.
13:03:01
#env --help
Использование: env [КÐ-] [ИМЯ=ЗНАЧЕНИЕ]… [КОМАНДА [АРГ]…]
Присваивает каждому ИМЕНИ соответствующее ЗНАЧЕНИЕ и запускает КОМАНДУ в этом
окружении.
  -i, --ignore-environment   начать с пустым окружением
  -0, --null                 завершать каждую выводимую строку 0-м байтом,
                             a не символом новой строки
  -u, --unset=ИМЯ            удалить переменную с ИМЕНЕМ из окружения
      --help     показать эту справку и выйти
      --version  показать информацию о версии и выйти
Просто «-» -- синоним для «-i». Если не задана КОМАНДА, печатает получившееся
окружение.
Об ошибках в env сообщайте по адресу bug-coreutils@gnu.org.
Домашняя страница GNU coreutils: <http://www.gnu.org/software/coreutils/>
Справка по работе с программами GNU: <http://www.gnu.org/gethelp/>
Об ошибках в переводе сообщений «env» сообщайте по адресу <gnu@mx.ru>
Полная документация доступна по команде: info coreutils 'env invocation'
13:03:09
#env
SHELL=/bin/bash
TERM=xterm
HISTSIZE=2000
SSH_CLIENT=192.168.16.187 49228 22
L3_PARENT_TTY=/dev/pts/0
OLDPWD=/home
L3_TAMPERED_EDITORS= vi vim pico nano
SSH_TTY=/dev/pts/0
USER=root
HISTFILESIZE=2000
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
MAIL=/var/mail/root
L3_SESSION_ID=31383263589649259-1490769712
a=1
PWD=/home/user
LANG=ru_RU.UTF-8
13:04:27
#env
SHELL=/bin/bash
TERM=xterm
HISTSIZE=2000
SSH_CLIENT=192.168.16.187 49228 22
L3_PARENT_TTY=/dev/pts/0
OLDPWD=/home
L3_TAMPERED_EDITORS= vi vim pico nano
SSH_TTY=/dev/pts/0
USER=root
HISTFILESIZE=2000
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
MAIL=/var/mail/root
L3_SESSION_ID=31383263589649259-1490769712
a=1
PWD=/home/user
LANG=ru_RU.UTF-8
13:05:01
#export
declare -x HISTFILESIZE="2000"
declare -x HISTSIZE="2000"
declare -x HOME="/root"
declare -x L3_HOME="/root/.lilalo/"
declare -x L3_PARENT_TTY="/dev/pts/0"
declare -x L3_SESSION_ID="31383263589649259-1490769712"
declare -x L3_TAMPERED_EDITORS=" vi vim pico nano"
declare -x LANG="ru_RU.UTF-8"
declare -x LANGUAGE="ru_UA:ru"
declare -x LOGNAME="root"
declare -x MAIL="/var/mail/root"
declare -x OLDPWD="/home"
declare -x PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
13:05:18
#export
declare -x HISTFILESIZE="2000"
declare -x HISTSIZE="2000"
declare -x HOME="/root"
declare -x L3_HOME="/root/.lilalo/"
declare -x L3_PARENT_TTY="/dev/pts/0"
declare -x L3_SESSION_ID="31383263589649259-1490769712"
declare -x L3_TAMPERED_EDITORS=" vi vim pico nano"
declare -x LANG="ru_RU.UTF-8"
declare -x LANGUAGE="ru_UA:ru"
declare -x LOGNAME="root"
declare -x MAIL="/var/mail/root"
declare -x OLDPWD="/home"
declare -x PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
13:05:35
#env
SHELL=/bin/bash
TERM=xterm
HISTSIZE=2000
SSH_CLIENT=192.168.16.187 49228 22
L3_PARENT_TTY=/dev/pts/0
OLDPWD=/home
L3_TAMPERED_EDITORS= vi vim pico nano
SSH_TTY=/dev/pts/0
USER=root
HISTFILESIZE=2000
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
MAIL=/var/mail/root
L3_SESSION_ID=31383263589649259-1490769712
a=1
PWD=/home/user
LANG=ru_RU.UTF-8
13:05:47
#help export
export: export [-fn] [name[=value] ...] or export -p
    Set export attribute for shell variables.
    Marks each NAME for automatic export to the environment of subsequently
    executed commands.  If VALUE is supplied, assign VALUE before exporting.
    Options:
      -f        refer to shell functions
      -n        remove the export property from each NAME
      -p        display a list of all exported variables and functions
    An argument of `--' disables further option processing.
    Exit Status:
    Returns success unless an invalid option is given or NAME is invalid.
13:05:55
#export -p
declare -x HISTFILESIZE="2000"
declare -x HISTSIZE="2000"
declare -x HOME="/root"
declare -x L3_HOME="/root/.lilalo/"
declare -x L3_PARENT_TTY="/dev/pts/0"
declare -x L3_SESSION_ID="31383263589649259-1490769712"
declare -x L3_TAMPERED_EDITORS=" vi vim pico nano"
declare -x LANG="ru_RU.UTF-8"
declare -x LANGUAGE="ru_UA:ru"
declare -x LOGNAME="root"
declare -x MAIL="/var/mail/root"
declare -x OLDPWD="/home"
declare -x PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
13:06:04
#echo $Ps1

13:14:32
#echo $Ps1

13:14:34
#echo $PS1

13:14:37
#mkdir scripts

13:16:50
#cd scripts/

13:16:53
#vi shell.sh
--- /dev/null	2017-03-27 13:30:21.879999998 +0300
+++ shell.sh	2017-03-29 14:24:05.343932263 +0300
@@ -0,0 +1,4 @@
+#!/bin/bash
+
+users=`awk -F: '$3>=1000&&$3==65534{print $1}' | tr "\n" " "`
+echo $users
13:24:05
#chmod u+x shell.sh

13:24:19
#pwd
/home/user/scripts
13:24:56
#/home/user/scripts/shell.sh
^C
13:28:57
#./shell.sh
nobody
13:28:59
#vi shell.sh
--- /tmp/l3-saved-14496.7784.20248	2017-03-29 14:29:14.703920862 +0300
+++ shell.sh	2017-03-29 14:32:01.007924913 +0300
@@ -1,4 +1,4 @@
 #!/bin/bash
 
-users=`awk -F: '$3>=1000&&$3==65534{print $1}' /etc/passwd | tr "\n" " "`
+users=`awk -F: '$3>=1000&&$3!=65534{print $1}' /etc/passwd | tr "\n" " "`
 echo $users
13:32:01
#vi shell.sh
13:32:16
#vim .vimrc
--- /dev/null	2017-03-27 13:30:21.879999998 +0300
+++ .vimrc	2017-03-29 14:32:49.463918874 +0300
@@ -0,0 +1,2 @@
+set syntax=on
+set nnoremap <F7> :!%:p<Enter>
13:32:49
#vim .vimrc
13:32:55
#~
#!/bin/bash
users=`awk -F: '$3>=1000&&$3!=65534{print $1}' /etc/passwd | tr "\n" " "`
echo $users
"shell.sh" 4L, 99C
13:33:08
#~
shell.sh
13:33:09
#ls -lah
итого 16K
drwxr-xr-x  2 root root 4,0K Мар 29 14:33 .
drwxr-xr-x 17 user user 4,0K Мар 29 14:16 ..
-rwxr--r--  1 root root   99 Мар 29 14:32 shell.sh
-rw-r--r--  1 root root   45 Мар 29 14:32 .vimrc
13:33:11
#useradd -m anna

13:33:23