b8c4c21f

C STIME TTY TIME CMD


[methody@localhost methody]$ ps -f UID PID PPID C STIME TTY TIME CMD methody 3590 1850 0 13:58 tty3 00:00:00 -bash methody 3624 3590 0 14:01 tty3 00:00:00 ps -f
Пример 5.1. Просмотр таблицы собственных процессов
Закрыть окно

[methody@localhost methody]$ cat > loop while true; do true; done ^D [methody@localhost methody]$ sh loop ^C [methody@localhost methody]$
Пример 5.2. Создание бесконечно выполняющегося сценария
Закрыть окно

[methody@localhost methody]$ sh loop& [1] 3634 [methody@localhost methody]$ ps -f UID PID PPID C STIME TTY TIME CMD methody 3590 1850 0 13:58 tty3 00:00:00 -bash methody 3634 3590 99 14:03 tty3 00:00:02 sh loop methody 3635 3590 0 14:03 tty3 00:00:00 ps -f
Пример 5.3. Запуск фонового процесса
Закрыть окно

[methody@localhost methody]$ bash loop& [2] 3639 [methody@localhost methody]$ top 14:06:50 up 3:41, 5 users, load average: 1,31, 0,76, 0,42 4 processes: 1 sleeping, 3 running, 0 zombie, 0 stopped CPU states: 99,4% user, 0,5% system, 0,0% nice, 0,0% iowait, 0,0% idle Mem: 514604k av, 310620k used, 203984k free, 0k shrd, 47996k buff 117560k active, 148388k inactive Swap: 1048280k av, 0k used, 1048280k free 184340k cached PID USER PRI NI SIZE RSS SHARE STAT %CPU %MEM TIME COMMAND 3639 methody 20 0 1260 1260 1044 R 50,3 0,2 0:12 bash 3634 methody 18 0 980 980 844 R 49,1 0,1 3:06 sh 3641 methody 9 0 1060 1060 872 R 0,1 0,2 0:00 top 3590 methody 9 0 1652 1652 1264 S 0,0 0,3 0:00 bash
Пример 5.4. Разделение времени между процессами
Закрыть окно

[methody@localhost methody]$ fg bash loop ^C
Пример 5.5. Перевод фонового процесса в активное состояние с помощью команды fg (foreground)
Закрыть окно

[methody@localhost methody]$ sh loop ^Z [1]+ Stopped sh loop [methody@localhost methody]$ bg [1]+ sh loop & [methody@localhost methody]$ fg sh loop ^C [methody@localhost methody]$
Пример 5.6. Перевод процесса в фон с помощью "^Z" и bg
Закрыть окно

[methody@localhost methody]$ sh sh-2.05b$ sh loop & bash loop & [1] 3652 [2] 3653 sh-2.05b$ ps -fH UID PID PPID C STIME TTY TIME CMD methody 3590 1850 0 13:58 tty3 00:00:00 -bash methody 3634 3590 87 14:03 tty3 00:14:18 sh loop methody 3651 3590 0 14:19 tty3 00:00:00 sh methody 3652 3651 34 14:19 tty3 00:00:01 sh loop methody 3653 3651 35 14:19 tty3 00:00:01 bash loop methody 3654 3651 0 14:19 tty3 00:00:00 ps -fH


Пример 5.7. Запуск множества фоновых процессов
Закрыть окно

sh-2.05b$ kill 3634 [1]+ Terminated sh loop sh-2.05b$ ps -fH UID PID PPID C STIME TTY TIME CMD methody 3590 1850 0 13:58 tty3 00:00:00 -bash methody 3651 3590 0 14:19 tty3 00:00:00 sh methody 3652 3651 34 14:19 tty3 00:01:10 sh loop methody 3653 3651 34 14:19 tty3 00:01:10 bash loop methody 3658 3651 0 14:23 tty3 00:00:00 ps -fH
Пример 5.8. Принудительное завершение процесса с помощью kill
Закрыть окно

sh-2.05b$ exit [methody@localhost methody]$ ps -fH UID PID PPID C STIME TTY TIME CMD methody 3590 1850 0 15:17 tty3 00:00:00 -bash methody 3663 3590 0 15:23 tty3 00:00:00 ps -fH methody 3652 1 42 15:22 tty3 00:00:38 bash loop methody 3653 1 42 15:22 tty3 00:00:40 sh loop [methody@localhost methody]$ kill -HUP 3652 3653 [methody@localhost methody]$ ps PID TTY TIME CMD 3590 tty3 00:00:00 bash 3664 tty3 00:00:00 ps
Пример 5.9. Завершение процесса естественным путем с помощью сигнала "Hang Up"
Закрыть окно

[methody@localhost methody]$ date > tmpfile [methody@localhost methody]$ cat tmpfile Срд Сен 22 14:52:03 MSD 2004 [methody@localhost methody]$ chmod -r tmpfile [methody@localhost methody]$ cat tmpfile cat: tmpfile: Permission denied [methody@localhost methody]$ date -u > tmpfile [methody@localhost methody]$ chmod +r tmpfile; chmod -w tmpfile [methody@localhost methody]$ cal > tmpfile -bash: tmpfile: Permission denied [methody@localhost methody]$ cat tmpfile Срд Сен 22 10:52:35 UTC 2004 [methody@localhost methody]$ rm tmpfile rm: удалить защищенный от записи обычный файл `tmpfile'? y
Пример 5.10. Что можно и что нельзя делать с файлом, доступ к которому ограничен
Закрыть окно

[methody@localhost methody]$ cat > script echo 'Hello, Methody!' ^D [methody@localhost methody]$ ./script -bash: ./script: Permission denied [methody@localhost methody]$ sh script Hello, Methody! [methody@localhost methody]$ chmod +x script [methody@localhost methody]$ ./script Hello, Methody!
Пример 5.11. Создание простейшего исполняемого сценария
Закрыть окно

[methody@localhost methody]$ cat > to.sort #!/bin/ sort some unsorted lines [methody@localhost methody]$ sort to.sort #!/bin/sort lines some unsorted [methody@localhost methody]$ chmod +x to.sort [methody@localhost methody]$ ./to.sort #!/bin/sort lines some unsorted
Пример 5.12. Создание sort-сценария
Закрыть окно

[methody@localhost methody]$ mkdir dir [methody@localhost methody]$ date > dir/smallfile [methody@localhost methody]$ /bin/ls dir smallfile [methody@localhost methody]$ cd dir [methody@localhost dir]$ pwd /home/methody/dir [methody@localhost dir]$ cd [methody@localhost methody]$ pwd /home/methody [methody@localhost methody]$ cat dir/ smallfile Срд Сен 22 13:15:20 MSD 2004
Пример 5.13. Доступ к каталогу на чтение и использование
Закрыть окно

[methody@localhost methody]$ chmod -x dir [methody@localhost methody]$ ls dir ls: dir/smallfile: Permission denied [methody@localhost methody]$ alias ls alias ls='ls --color=auto' [methody@localhost methody]$ /bin/ls dir smallfile [methody@localhost methody]$ cd dir -bash: cd: dir: Permission denied [methody@localhost methody]$ cat dir/smallfile cat: dir/smallfile: Permission denied
Пример 5.14. Доступ к каталогу на чтение без использования
Закрыть окно

[methody@localhost methody]$ chmod +x dir; chmod -r dir [methody@localhost methody]$ /bin/ls dir /bin/ls: dir: Permission denied [methody@localhost methody]$ cat dir/smallfile Срд Сен 22 13:15:20 MSD 2004 [methody@localhost methody]$ cd dir [methody@localhost dir]$ /bin/ls ls: .: Permission denied [methody@localhost dir]$ cd [methody@localhost methody]$
Пример 5.15. Доступ к каталогу на использование без чтения
Закрыть окно

[methody@localhost methody]$ rm - rf dir rm: невозможно открыть каталог `dir': Permission denied [methody@localhost methody]$ chmod -R +rwx dir [methody@localhost methody]$ rm -rf dir
Пример 5.16. Рекурсивное удаление каталога
Закрыть окно
Содержание раздела