2. Grundwissen für die tägliche Arbeit eines Sysadmin
Manuals, Files, Prozesse, Geräte, grep, awk, find, ps
=========================================================
|
| next | back | 2. Grundwissen | WS 2013/14 - 1 |
Manuals
-------
Kommando man:
man(1) man(1)
NAME
man - format and display the on-line manual pages
manpath - determine user's search path for man pages
SYNOPSIS
man [-adfhktwW] [-m system] [-p string] [-C config_file]
[-M path] [-P pager] [-S section_list] [section] name ...
DESCRIPTION
man formats and displays the on-line manual pages.
OPTIONS
-M path
Specify the list of directories to seach for man
pages. default list is found by consulting
/usr/lib/man.config. MANPATH
-P pager
Specify which pager to use.
By default, man uses /usr/bin/less
PAGER
-S section_list
List is a colon separated list of manual sections to
search. This option overrides the MANSECT environment
variable.
|
| next | back | 2. Grundwissen | WS 2013/14 - 2 |
-a By default, man will exit after displaying the first
manual page it finds. Using this option forces man
to display all the manual pages that match name,, not
just the first.
-f Equivalent to whatis..
-k Equivalent to apropos..
ENVIRONMENT
MANPATH
If MANPATH is set, its value is used as the path to
search for manual pages.
MANROFFSEQ
If MANROFFSEQ is set, its value is used to determine
the set of preprocessors run before running nroff or
troff. By default, pages are passed through the
table preprocessor before nroff.
MANSECT
If MANSECT is set, its value is used to determine
which manual sections to search.
PAGER If PAGER is set, its value is used as the name of the
program to use to display the man page.
SEE ALSO
apropos(1), whatis(1), less(1), groff(1).
Konfigurationsfiles:
Solaris: /usr/share/man/man.cf
SuSE: /etc/manpath.config
|
| next | back | 2. Grundwissen | WS 2013/14 - 3 |
Manualabschnitte:
1 Ausführbare Programme oder Shellbefehle
1b, 1c, 1f, 1m, 1s
2 Systemaufrufe (Kernelfunktionen)
3 Bibliotheksaufrufe (Funktionen in System-Bibliotheken)
3c, 3lib, 3xfn, ....
4 Spezielle Dateien (gewöhnlich in /dev)
5 Dateiformate und Konventionen, z. B. /etc/passwd
6 Spiele
7 Makropakete und Konventionen, z. B. man(7), groff(7)
8 Systemadministrationsbefehle (in der Regel nur für root)
9 Kernelroutinen [Nicht Standard]
n neu [veraltet]
l lokal [veraltet]
p öffentlich [veraltet]
o alt [veraltet]
Manpath für User:
MANPATH=/usr/man:/usr/local/man:/usr/openwin/man:/home/unixsoft/bell/Man
Manpath für Administrator:
MANPATH=/usr/share/man:/usr/openwin/share/man:/usr/dt/share/man:\
/usr/demo/SOUND/man:/usr/demo/link_audit/man:/usr/java1.2/man:\
/usr/apache/man:/usr/perl5/man:/usr/j2se/man:/opt/SUNWconn/ge/man:\
/opt/SUNWconn/man:/opt/SUNWrtvc/man:/opt/sfw/man:/opt/sfw/mysql/man:\
/opt/sfw/kde/man:/opt/SUNWut/Solaris_JRE_1.2.2_12/man:/opt/SUNWut/man:\
/opt/SUNWut/share/man:/opt/SUNWconn/man:/usr/local/man:\
/usr/local/share/man
|
| next | back | 2. Grundwissen | WS 2013/14 - 4 |
Beispiele:
man man
man manpath (nur bei Linux)
man -k manpath - apropos manpath
whatis man
man write
man -a write
man 2 write
man -s 3c reboot
man reboot
Erzeugen der Datenbasis für apropos oder whatis:
/usr/lib/make-whatis oder catman -w
Weitere Informationsquellen:
/usr/share
/usr/doc
/opt/csw/share, /opt/csw/doc
/opt/sfw/share, /opt/sfw/info
/usr/share/doc
/usr/share/doc/packages
|
| next | back | 2. Grundwissen | WS 2013/14 - 5 |
Files
-----
Filetypen: ls-Kennung
reguläre Files - keine
Fileverzeichnisse - d
Special Files - c,b
Geräte, Speicher, Netzwerk
Links - l
harte Links, symbolische Links
named Pipes - p
sockets - s
door-Files - D (nur bei Solaris)
Fileprotection:
Klassen: user, group, other
Arten: File: ausführen, lesen, schreiben
Directory: durchsuchen, lesen, schreiben
1 4 2
|
| next | back | 2. Grundwissen | WS 2013/14 - 6 |
Besonderheiten bei der Fileprotection:
t - Sticky Bit:
File: save text mode
Directory: löschen von Files nur durch Eigentümer
spezieller Schutz für /tmp /usr/spool/mail
rwxrwxrwt
s - SUID Bit: Setze UID für Prozess bei Ausführung
Eigentümer rws--x--x
s - GUID Bit:
File: Setze GID für Prozess bei Ausführung
Directory: Übername der GID für neue Files im Directory,
rekursiv
l - GUID Bit: erzwingt File Locking beim Lesen und Schreiben
(Solaris, Tru64, nicht bei Linux)
S - ???
Eigentümer neuer Files:
UID - EUID des Prozesses
GID - EGID des Prozesses (System V)
GID der Directory (BSD)
Zugriffsrechte neuer Files:
Spezifikation bei open unter Berücksichtigung von umask
|
| next | back | 2. Grundwissen | WS 2013/14 - 7 |
Geräte
-------
Verzeichnis /dev /devices
Prozesse
--------
Attribute von Prozessen:
PID - Prozessnummer
PPID - Prozessnummer des Elternprozesses
Nice Number - vom Sysadmin steuerbare Prozesspriorität
TTY - Terminal des Prozesses (eventuell nicht vorhanden)
RUID - real UID
EUID - effektiver UID
RGID - real GID
EGID - effektiver GID
Lebenszyklus eines Prozesses:
fork, exec, exit (wait)
login:
init -----> init
fork |
| exec
getty (mingetty, ttymon )
| exec
login
| exec
sh ----> sh
fork |
| exec
|
ls
|
| next | back | 2. Grundwissen | WS 2013/14 - 8 |
Arten von Prozessen
-------------------
Interaktive Prozesse - durch Nutzer gestartet
(auch im Hintergrund)
Prozess-Steuerung:
& - Hintergrundprozess
^Z - anhalten des Vordergrundprozesses
jobs - anzeigen der Hintergrundprozesse
%n - bezeichnet Hintergrundprozess n
suspend - Vordergrundprozeß anhalten, Hintergrundprozeß in
den Vordergrund
fg %n - Hintergrundprozess n in Vordergrund
bg - Restart eines Hintergrundprozesses
Batch-Prozesse: durch Batch-Systeme gestartet
z.B.: NQS - Network Queuing System
Dämone: Prozesse durch Unix-System beim boot gestartet
z.B.: portmap, inetd, nfsd, automountd, cron, lpd, ...
|
| next | back | 2. Grundwissen | WS 2013/14 - 9 |
Kommandos --------- |
| next | back | 2. Grundwissen | WS 2013/14 - 10 |
Prozesse auflisten lassen - ps
--------------------------------
AIX:
ps [-A] [-a] [-d] [-e] [-f] [-k] [-l] [-F Format] [-G Glist]
[-g Glist] [-p Plist] [-t Tlist] [-U Ulist] [-u Ulist]
ps [a] [c] [e] [ew] [eww] [g] [n] [U] [w] [x] [l|s|u|v]
[t Tty] [ ProcessNumber ]
Beispiel: ps -efal
Linux:
ps -ANadefjlFLmwV [-<option> <wert>] ...
aTgrxXZjlsuvScefhnwHmL [-<option> <wert>] ...
Beispiel: ps -efa
ps aux
Solaris:
ps [ -aAcdefjlL ] [ -g grplist ] [ -n namelist ]
[[ -o format ] ... ] [ -p proclist ]
[ -s sidlist ] [ -t term ] [ -u uidlist ]
[ -U uidlist ] [ -G gidlist ]
Beispiel: ps -efa
ps -efaL # mit allen Threads
BSD Compatible Syntax
ps [aAeghjlLmsSTuvwx] [oO specifier][==header],... [tty]
[process_number]
Beispiel: ps -efa
ps aux
|
| next | back | 2. Grundwissen | WS 2013/14 - 11 |
Auslastung des Rechners - top/prstat
------------------------------------
Linux:
top -hv | -bcHiSs -d delay -n limit -u|U user -p pid[,pid] -w [cols]
-h - help
-b - batch (für Scripte)
-u - Nutzer spezifisch
-p - für spezielle Prozesse
Solaris:
top ..
prstat [-acHJLmRrtTv] [-d u | d] [-C psrsetlist] [-h lgrplist]
[-j projlist] [-k tasklist] [-n ntop[,nbottom]]
[-p pidlist] [-P cpulist] [-s key | -S key ]
[-u euidlist] [-U uidlist] [-z zoneidlist] [-Z]
[interval [count]]
-L - LWL-Prozesse
|
| next | back | 2. Grundwissen | WS 2013/14 - 12 |
Fileverzeichnisse anschauen - ls
--------------------------------
AIX:
ls [-AadiLNRrs] [-F | -p] [-b | -q] [-C | -m]
[[{-c | -u} [-l ] [-t]] | [[-g | -n | -l | -o | -e] [-t]]]
[ File ... ] [ Directory ... ]
ls -f [ -d ] [ -i ] [ -s ] [ -C | -m | -x ]
[ Directory ... ]
Linux:
ls [OPTION]... [FILE]...
Solaris:
/usr/bin/ls [ -aAbcCdfFgilLmnopqrRstux1 ] [ file... ]
/usr/xpg4/bin/ls [ -aAbcCdfFgilLmnopqrRstux1 ] [ file... ]
Beispiele:
ls -lF # Kennzeichen des Filetypes
ls -lisa # alles mit Erstellungszeit
ls -lisac # alles mit change-Time !!
ls -lisact # alles mit change-Time und nach Zeit sortiert
ls -ld # nur Directories
ls -i # mit I-Node-Nummer
|
| next | back | 2. Grundwissen | WS 2013/14 - 13 |
Ändern der Zugriffsrechte - chmod
---------------------------------
Absolute Modes
/bin/chmod [ -fRcv ] mode filename ...
/usr/bin/chmod [ -fRcv ] mode filename ...
/usr/5bin/chmod [ -fRcv ] mode filename ...
-R rekursiv absteigend
-f leise
-c verbose bei Aktionen
-v verbose - geschwätzig
mode
400 Read by owner.
200 Write by owner.
100 Execute (search in directory) by owner.
040 Read by group.
020 Write by group.
010 Execute (search) by group.
004 Read by others.
002 Write by others.
001 Execute (search) by others.
4000 Set user ID on execution.
2000 Set group ID on execution.
1000 Sticky bit.
|
| next | back | 2. Grundwissen | WS 2013/14 - 14 |
Symbolic Modes
/bin/chmod [ -fRcv ] <who><op><permission> filename ...
/usr/bin/chmod [ -fRcv ] <who><op><permission> filename ...
/usr/5bin/chmod [ -fRcv ] <who><op><permission> filename ...
who is a combination of:
u User's permissions.
g Group permissions.
o Others.
a All, or ugo.
op is one of:
+ To add the permission.
- To remove the permission.
= To assign the permission explicitly
permission is any combination of:
r Read.
w Write.
x Execute.
X Give execute permission if the file is a direc-
tory or if there is execute permissions
s Set owner or group ID.
t Set the sticky bit
l Filelocking
|
| next | back | 2. Grundwissen | WS 2013/14 - 15 |
AIX:
chmod [-fR] [[u][g][o] | [a]]{{-|+|=} [r][w][x][X][s][t]}
{ File ... | Directory ... }
chmod [ -R ] [ -f ] PermissionCode { File ... | Directory ... }
Linux:
chmod [OPTION]... MODE[,MODE]... FILE...
chmod [OPTION]... OCTAL-MODE FILE...
chmod [OPTION]... --reference=RFILE FILE...
OPTION - -c, -f, -v, -R
Solaris:
chmod [ -fR ] <absolute-mode> file...
chmod [ -fR ] <symbolic-mode-list> file...
Beispiele:
chmod a=r lead
chmod og+rX *
|
| next | back | 2. Grundwissen | WS 2013/14 - 16 |
Minimale Zugriffsrechte:
Kommando Zugriffsrechte
File Directory
cd ./Test/a2 - x
ls ./Test/a1 - r
ls -lisa ./Test/a - rx
ls ./Test/a2/t2 - x
cat ./Test/a2/t2 r x
cat >> ./Test/a2/t2 w x
cat > ./Test/a3/t3 - wx
rm ./Test/a3/t3 - wx
./Test/a2/x.bin x x
./Test/a/x.scr rx x
|
| next | back | 2. Grundwissen | WS 2013/14 - 17 |
Ändern des Eigentümers und der Gruppe - chown, chgrp
----------------------------------------------------
Nur für SU!!!
Linux:
/bin/chown [ -chfRv] owner[:group] filename ...
-f Do not report errors.
-R Recursively descend into directories setting the owner-
ship of all files in each directory encountered. When
symbolic links are encountered, their ownership is
changed, but they are not traversed.
-h If the file is a symbolic link, change the owner of
the symbolic link. Without this option, the owner of
the file referenced by the symbolic link is changed.
AIX:
chown [-f] [-R] [-h] Owner[:Group] { File ... | Directory ... }
Solaris:
chown [ -fhR ] owner[:group] filename ...
chown -R [-H|-L|-P] owner[:group] filename ...
Beispiele:
chown bell xxx
chown bell:root xxx
chown -R bell:unixsoft dir
|
| next | back | 2. Grundwissen | WS 2013/14 - 18 |
Solaris:
chgrp [ -fhR ] group filename...
chgrp -R [-f] [-H|-L|-P] groupe filename
Beispiele:
chgrp mi96 ./*
chgrp -R mi96 ./*
|
| next | back | 2. Grundwissen | WS 2013/14 - 19 |
Files anschauen
---------------
more
more [-cdflsu] [-lines] [+linenumber] [+/pattern]
[ filename ... ]
less
less -?
less -V
less [-[+]aBcCdeEfgGiImMnNqQrsSuUVwX]
[-b bufs] [-h lines] [-j line] [-k keyfile]
[-{oO} logfile] [-p pattern] [-P prompt] [-t tag]
[-T tagsfile] [-x tab] [-y lines] [-[z] lines]
[+[+]cmd] [filename]...
head
head [ -n ] [ filename...]
tail
tail +|-number [ lbc ] [ f ] [ filename ]
tail +|-number [ l ] [ rf ] [ filename ]
file
file [ -f ffile ] [ -cL ] [ -m mfile ] filename...
Beispiele:
more /etc/passwd
head -1 /etc/passwd
file /*
tail /var/adm/messages
|
| next | back | 2. Grundwissen | WS 2013/14 - 20 |
File suchen
-----------
find pathname [!]primary {operator primary} [action]
primary
-atime n Zugriffszeit | +n - mehr als
-mtime n Modifikationszeit | -n - weniger als
-size n n Blöcke lang | n - genau
-newer file Files neuer als <file>
-type t Filetype (f,d,c,b,p,l,s)
-name file Filename
-perm p Zugriffsrechte | p - genau
-user owner Eigentümer | -4000 - SUID
-group grp Gruppe | -2000 - GUID
-nouser Eigentümer nicht in Passwd
-nogroup Gruppe nicht in Group
-xdev Suchen innerhalb eines Filesystems
operator
-o oder
-a und
! nicht
action
-print Filename ausgeben
-ls ls -lisa <filename>
-exec cmd Kommando ausführen {} - Filename \; - Ende
-ok cmd Kommando ausführen mit Bestätigung
Beispiele:
find /usr/bin -perm -4000 -a -user root -ls
find /etc -mtime -2 -print
find /usr3 -name core -print -exec rm {} \;
find /usr3 -name \*.c -print
|
| next | back | 2. Grundwissen | WS 2013/14 - 21 |
File suchen(2):
linux
locate [-d path | --database=path] [-e | --existing]
[-i | --ignore-case ] [--version] [--help] pattern...
-d Datenbasis
-e nur existierende werden angezeigt (Datenbasis)
-i Groß- und Kleinschreibung ignorieren
updatedb muß vorher laufen!!
Beispiele:
locate pcmcia
locate -i yast
Bearbeiten/Filtern:
sed [ -n ] [ -e script ] [ -f sfilename ] [ filename ]...
awk [ -f program-file ] [ -Fc ] [ program ]
[ variable=value ... ] [ filename...]
Beispiel:
BSD
kill -15 `ps -aux | awk '$1=="mueller" {print $2} '`
System V
kill -15 `ps -efa | awk '$1=="bell" {print $2 }'`
|
| next | back | 2. Grundwissen | WS 2013/14 - 22 |
Kommunikation mit Nutzern
-------------------------
mail:
/bin/mail [-deHinNUv] [-f [filename | +folder]] [-T file]
[-u user]
/usr/ucb/Mail [-dFinUv] [-h number] [-r address] [-s subject]
recipient ...
/usr/bin/mailx [-BdFintUv~] [-b bcc] [-c cc] [-s subject]
recipient
/usr/bin/mail [-BDFintv~] [-s subject] [-a attachment ]
[-c cc-addr] [-b bcc-addr] [-r from-addr]
[-h hops] [-A account] to-addr
get-mail-list: Erzeugen einer Mail-Liste aus /etc/group
#!/bin/sh
echo get-mail-list for $1
number=`grep $1:: /etc/group | awk -F: '{ print $3 }' `
grep :$number: /etc/netpasswd/passwd | \
awk -F: ' { print $1 } ' | sort > $1
send-mail: Senden einer Mail mit Hilfe einer Mail-Liste
#!/bin/sh
if [ $# != 3 ]
then
echo "usage:" $0 "<mail-list> <subject> <mail>"
exit 1
fi
echo send mail $1 to $3
echo mail to `cat $3`
/usr/bin/mailx -s "$2" `cat $3` < $1
|
| next | back | 2. Grundwissen | WS 2013/14 - 23 |
mit Datenschutz:
#!/bin/sh
if [ $# != 3 ]
then
echo "usage:" $0 "<mail-list> <subject> <mail>"
exit 1
fi
echo send mail $1 to $3
for i in `cat $3`
do
echo mail to $i
/usr/bin/mailx -s "$2" $i < $1
done
Weitere Kommunikationsmöglichkeiten:
write bell ttyp0 (local user)
write bell@bellus (remote)
(writesrv muss aktiviert sein)
talk bell@bellus (remote)
|
| next | back | 2. Grundwissen | WS 2013/14 - 24 |
Hardware anschauen:
AIX: lscfg -v
Solaris: dmesg
prtconf
prtdiag
sysdef
getdev
devinfo -i /dev/rdsk/c1t0d0s0
devattr -v /dev/rdsk/c1t0d0s0
psrinfo - Prozessorinformationen
cfgadm -al
dpcli
mpathadm
Linux: lspci - pci-bus
hwinfo - Hardware-Informationen
( cardctl - PCMCIA-Karten)
( scsi_info - SCSI-Geräte)
( ide_info)
lsdev
getsysinfo
Software Anschauen:
Solaris: pkginfo
Linux: rpm -qa
|
| back | 2. Grundwissen | WS 2013/14 - 25 |