rfhpc8317% cat /etc/defaultdomain
im-unix
rfhpc8317% cat /etc/release
Solaris 8 10/00 s28x_u2wos_11 INTEL
Copyright 2000 Sun Microsystems, Inc. All Rights Reserved.
Assembled 28 August 2000
rfhpc8317% cat /etc/release /etc/defaultdomain
Solaris 8 10/00 s28x_u2wos_11 INTEL
Copyright 2000 Sun Microsystems, Inc. All Rights Reserved.
Assembled 28 August 2000
im-unix
rfhpc8317% more /etc/defaultdomain im-unix /etc/defaultdomain (END)
rfhpc8317% head /etc/services #ident "@(#)services 1.27 00/11/06 SMI" /* SVr4.0 1.8 */ # # # Copyright (c) 1999-2000 by Sun Microsystems, Inc. # All rights reserved. # # Network services, Internet style # tcpmux 1/tcp echo 7/tcp rfhpc8317% head -1 /etc/services #ident "@(#)services 1.27 00/11/06 SMI" /* SVr4.0 1.8 */
rfhpc8317% tail /etc/services
www-ldap-gw 1760/tcp # HTTP to LDAP gateway
www-ldap-gw 1760/udp # HTTP to LDAP gateway
listen 2766/tcp # System V listener port
nfsd 2049/udp nfs # NFS server daemon (clts)
nfsd 2049/tcp nfs # NFS server daemon (cots)
eklogin 2105/tcp # Kerberos encrypted rlogin
lockd 4045/udp # NFS lock daemon/manager
lockd 4045/tcp
dtspc 6112/tcp # CDE subprocess control
fs 7100/tcp # Font server
rfhpc8317% tail -2 /etc/services
dtspc 6112/tcp # CDE subprocess control
fs 7100/tcp # Font server
rfhpc8317% tail -n -2 /etc/services
dtspc 6112/tcp # CDE subprocess control
fs 7100/tcp # Font server
rfhpc8317% tail -n +2 /etc/release
Copyright 2000 Sun Microsystems, Inc. All Rights Reserved.
Assembled 28 August 2000
rfhpc8317% tail -n +3 /etc/release
Assembled 28 August 2000
rfhpc8317% tail -f /vardata/logs/apache/access
[ID 702911 user.notice] 193.145.101.10 - - [17/Mar/2005:11:44:43 +0100] \"GET /~oracle/sqlplus/ch9.html HTTP/1.0\" 200 228998
[ID 702911 user.notice] 81.169.145.11 - - [17/Mar/2005:11:44:46 +0100] \"GET /%7Efeyrer/SA/02-login.html HTTP/1.1\" 200 937
rfhpc8317% wc /etc/release
3 17 183 /etc/release
rfhpc8317% wc -l /etc/release
3 /etc/release
rfhpc8317% tail -5 /etc/services | wc -l
5
rfhpc8317% od -cx /etc/defaultdomain
0000000 i m - u n i x \n
6d69 752d 696e 0a78
0000010
rfhpc8317% file /bin/ls /bin/ls: ELF 32-bit LSB executable 80386 Version 1, dynamically linked, stripped rfhpc8317% file /etc/passwd /etc/passwd: ascii text rfhpc8317% file /sbin/rc0 /sbin/rc0: executable /sbin/sh script
rfhpc8317% head -1 /etc/passwd root:x:0:1:Super-User:/root:/sbin/sh rfhpc8317% head -1 /etc/passwd | cut -f5 -d: Super-User rfhpc8317% ls -l /etc | head -3 total 457 lrwxrwxrwx 1 root root 14 Jan 3 2001 TIMEZONE -> ./default/init drwxr-xr-x 2 adm adm 512 Jan 3 2001 acct rfhpc8317% ls -l /etc | tail -n +2 | head -3 lrwxrwxrwx 1 root root 14 Jan 3 2001 TIMEZONE -> ./default/init drwxr-xr-x 2 adm adm 512 Jan 3 2001 acct lrwxrwxrwx 1 root root 14 Jan 3 2001 aliases -> ./mail/aliases rfhpc8317% ls -l /etc | tail -n +2 | head -3 | cut -c55- TIMEZONE -> ./default/init acct aliases -> ./mail/aliases
rfhpc8133% ls Muttrc ldapsearchprefs.conf mime.types a2ps-site.cfg ldaptemplates.conf pine.conf a2ps.cfg lynx.cfg rc.d ... rfhpc8133% ls -l total 578 -rw-r--r-- 1 root wheel 77042 Dec 25 2000 Muttrc -r--r--r-- 1 root wheel 2512 Dec 24 2000 a2ps-site.cfg -r--r--r-- 1 root wheel 12878 Dec 24 2000 a2ps.cfg -r--r--r-- 1 root wheel 77 Dec 24 2000 esd.conf ... drwxr-xr-x 2 root wheel 512 Jan 2 2001 rc.d ... rfhpc8133% ls -F Muttrc ldapsearchprefs.conf mime.types a2ps-site.cfg ldaptemplates.conf pine.conf a2ps.cfg lynx.cfg rc.d/ ... rfhpc8133% ls -a . ldapfriendly mime.types .. ldapsearchprefs.conf pine.conf Muttrc ldaptemplates.conf rc.d ... rfhpc8133% ls -aF ./ ldapfriendly mime.types ../ ldapsearchprefs.conf pine.conf Muttrc ldaptemplates.conf rc.d/ ... rfhpc8133% ls -l /etc/passwd -rw-r--r-- 1 root sys 1543 Mar 13 2002 /etc/passwd rfhpc8133% ls -l /etc total 462 lrwxrwxrwx 1 root root 14 Oct 10 2001 TIMEZONE -> ./default/init drwxr-xr-x 2 adm adm 512 Oct 11 2001 acct lrwxrwxrwx 1 root root 14 Oct 10 2001 aliases -> ./mail/aliases drwxr-xr-x 2 root sys 512 Oct 10 2001 ami -rwxr--r-- 1 root sys 604 Oct 11 2001 asppp.cf ... rfhpc8133% ls -ld /etc drwxr-xr-x 40 root sys 3584 Feb 11 11:52 /etc
sunsauer% cp /etc/passwd passwd-kopie sunsauer% cp /etc/passwd . sunsauer% ls -l total 16 -rw-r--r-- 1 feyrer bedienst 1543 Mar 26 12:04 passwd sunsauer% cp -pr /usr/include . sunsauer% ls -l total 48 drwxr-xr-x 28 feyrer bedienst 14018 Feb 4 17:20 include -rw-r--r-- 1 feyrer bedienst 1543 Mar 26 12:04 passwd sunsauer% ls -d include/*/. include/Mrm/. include/kerberosv5/. include/sys/. include/X11/. include/net/. include/tnf/. include/Xm/. include/netinet/. include/uil/. ...Achtung beim kopieren von ganzen Dateibäumen mit Symlinks. Besser tar o.ä. verwenden!
sunsauer% ls -F include/ passwd sunsauer% mv passwd passwd.BAK sunsauer% ls -F include/ passwd.BAK sunsauer% mv passwd.BAK include sunsauer% ls -F include/ sunsauer% mv include/passwd.BAK . sunsauer% ls -F include/ passwd.BAK
sunsauer% ls -F include/ passwd.BAK sunsauer% rm passwd.BAK sunsauer% rm include rm: include is a directory sunsauer% rm -fr include sunsauer% ls -F sunsauer%
Zusammenhang zwischen Inode-Nummer und Verzeichnissen:
rfhpc8317% mkdir /usr/tmp/feyrer
rfhpc8317% cd /usr/tmp/feyrer/
rfhpc8317% od -cx .
0000000 < H 002 \0 \f \0 001 \0 . \0 \0 \0 231 \b \0 \0
483c 0002 000c 0001 002e 0000 0899 0000
0000020 364 001 002 \0 . . \0 \0 \0 \0 \0 \0 \0 \0 \0 \0
01f4 0002 2e2e 0000 0000 0000 0000 0000
0000040 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0
0000 0000 0000 0000 0000 0000 0000 0000
*
0001000
rfhpc8317%
rfhpc8317% cp /etc/group bla
rfhpc8317% od -cx .
0000000 < H 002 \0 \f \0 001 \0 . \0 \0 \0 231 \b \0 \0
483c 0002 000c 0001 002e 0000 0899 0000
0000020 \f \0 002 \0 . . \0 \0 = H 002 \0 350 001 003 \0
000c 0002 2e2e 0000 483d 0002 01e8 0003
0000040 b l a \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0
6c62 0061 0000 0000 0000 0000 0000 0000
0000060 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0
0000 0000 0000 0000 0000 0000 0000 0000
*
0001000
rfhpc8317%
rfhpc8317% ls -lai bla
149565 -rw-r--r-- 1 feyrer bedienst 290 Mar 18 13:15 bla
rfhpc8317% printf %x\\n 149565
2483d
Liste von Verzeichnis-Attributen laut dirent(3) bzw. <dirent.h> Header File:
typedef struct dirent {
ino_t d_ino; /* Inode-Nummer */
off_t d_off; /* Offset nächster Eintrag */
unsigned short d_reclen; /* Länge des Namens */
char d_name[1]; /* Dateiname */
} dirent_t;
Vollständige Liste von Datei-Attributen laut stat(2) Manpage:
struct stat {
mode_t st_mode; /* File mode (see mknod(2)) */
ino_t st_ino; /* Inode number */
dev_t st_dev; /* ID of device containing */
/* a directory entry for this file */
dev_t st_rdev; /* ID of device */
/* This entry is defined only for */
/* char special or block special files */
nlink_t st_nlink; /* Number of links */
uid_t st_uid; /* User ID of the file's owner */
gid_t st_gid; /* Group ID of the file's group */
off_t st_size; /* File size in bytes */
time_t st_atime; /* Time of last access */
time_t st_mtime; /* Time of last data modification */
time_t st_ctime; /* Time of last file status change */
/* Times measured in seconds since */
/* 00:00:00 UTC, Jan. 1, 1970 */
long st_blksize; /* Preferred I/O block size */
blkcnt_t st_blocks; /* Number of 512 byte blocks allocated*/
};
sunsauer% cp /etc/group bla sunsauer% ls -li total 16 4150014 -rw-r--r-- 1 feyrer bedienst 278 Mar 26 12:14 bla sunsauer% ln bla bang sunsauer% ls -li total 32 4150014 -rw-r--r-- 2 feyrer bedienst 278 Mar 26 12:14 bang 4150014 -rw-r--r-- 2 feyrer bedienst 278 Mar 26 12:14 bla sunsauer% rm bla sunsauer% head -1 bang root::0:root
sunsauer% cp /etc/group bla sunsauer% ls -li total 16 4150014 -rw-r--r-- 1 feyrer bedienst 278 Mar 26 12:16 bla sunsauer% ln -s bla blub sunsauer% ls -li total 32 4043432 lrwxrwxrwx 1 feyrer bedienst 3 Mar 26 12:16 blub -> bla 4150014 -rw-r--r-- 1 feyrer bedienst 278 Mar 26 12:16 bla sunsauer% ls -liL total 32 4150014 -rw-r--r-- 1 feyrer bedienst 278 Mar 26 12:16 blub 4150014 -rw-r--r-- 1 feyrer bedienst 278 Mar 26 12:16 bla sunsauer% rm bla sunsauer% head -1 blub bang: No such file or directory
Mehr Infos dazu: hier(7), Linux Filesystem Hierarchy Standard
rfhpc8317% pwd /net/rfhs8012/home3/bedienst/feyrer
rfhpc8317% pwd
/net/rfhs8012/home3/bedienst/feyrer
rfhpc8317% ls -ld work
drwx------ 17 feyrer bedienst 512 Oct 6 06:30 work
rfhpc8317% cd work
rfhpc8317% pwd
/net/rfhs8012/home3/bedienst/feyrer/work
rfhpc8317% cd ..
rfhpc8317% pwd
/net/rfhs8012/home3/bedienst/feyrer
rfhpc8317% cd /etc
rfhpc8317% pwd
/etc
rfhpc8317% cd .
rfhpc8317% pwd
/etc
rfhpc8317% cd
rfhpc8317% pwd
/net/rfhs8012/home3/bedienst/feyrer
rfhpc8317% cd -
rfhpc8317% pwd
/etc
rfhpc8317% pwd
/etc
rfhpc8317% cd / &
[1] 10992
[1] Done cd /
rfhpc8317% pwd
/etc
$ mkdir test $ mkdir test/subdir $ mkdir test/subdir/very/very/deeply/nested/subdir mkdir: test/subdir/very/very/deeply/nested/subdir: No such file or directory $ mkdir -p test/subdir/very/very/deeply/nested/subdir $ ls -l test/subdir total 2 drwxr-xr-x 3 feyrer wheel 512 Jul 29 16:27 very $ find test -type d test test/subdir test/subdir/very test/subdir/very/very test/subdir/very/very/deeply test/subdir/very/very/deeply/nested test/subdir/very/very/deeply/nested/subdir $
$ rmdir test rmdir: test: Directory not empty $ rm -fr test/* $ ls -la test total 4 drwxr-xr-x 2 feyrer wheel 512 Jul 29 16:22 . drwxrwxrwt 6 root wheel 512 Jul 29 16:22 .. $ rmdir test $Das Verzeichnis muß leer sein um mit "rmdir" gelöscht werden zu können. Alternative: "rm -fr".
rfhpc8317% ls -l /etc/syslog.conf -rw-r--r-- 1 root sys 1001 Apr 15 2003 /etc/syslog.conf rfhpc8317% du /etc/syslog.conf 2 /etc/syslog.conf rfhpc8317% du -k /etc/syslog.conf 1 /etc/syslog.conf rfhpc8317% du -k /etc 5 /etc/cron.d 50 /etc/default 3 /etc/dfs 8 /etc/dhcp 225 /etc/fs/hsfs ... 180 /etc/dt 7 /etc/sshd 3247 /etc rfhpc8317% du -sk /etc 3247 /etc
rfhpc8130% id uid=102(feyrer) gid=200(bedienst) groups=200(bedienst),0(wheel) rfhpc8130% whoami feyrer rfhpc8130% echo $USER feyrer rfhpc8130% groups bedienst wheel
chown user file chown user:group fileNur als root moeglich - Quotas!
chgrp group file
chmod [ugo][+-=][rwx] chmod 700
chmod go-rwx meine_dateien chmod go-rw,go+x $HOME/public_html chmod -w wichtig chmod 700 meine_dateien chmod 711 $HOME/public_html chmod 444 wichtig
rwx = 4+2+1 = 7 r-x = 4 +1 = 5 rw- = 4+2 = 6 r-- = 4 = 4
| Binaries: | rwxr-xr-x | (755) |
| Dateien: | rw-r--r-- | (644) |
| Teamwork: | rwxrwxr-x/rw-rw-r-- | (775/664) |
| Paranoia: | rwx------ | (700) |
Default-Permissions: rw-rw-rw- = 666
Bits ausmaskieren: & 000010010 = 022 = umask
------------------------
Bei neuen Dateien: rw-r--r-- = 644
rfhpc8133% umask 22 rfhpc8133% touch x rfhpc8133% ls -l x -rw-r--r-- 1 feyrer bedienst 0 Oct 9 17:38 x rfhpc8133% umask 66 rfhpc8133% touch y rfhpc8133% ls -l y -rw------- 1 feyrer bedienst 0 Oct 9 17:39 y rfhpc8133% umask 6 rfhpc8133% touch z rfhpc8133% ls -l z -rw-rw---- 1 feyrer bedienst 0 Oct 9 17:39 z
rfhpc8133% mkdir test rfhpc8133% mkdir test/dir rfhpc8133% ls -l test total 20 drwxr-xr-x 2 feyrer bedienst 512 Oct 9 17:06 dir rfhpc8133% chmod ugo=x test rfhpc8133% ls -lad test d--x--x--x 3 feyrer bedienst 512 Oct 9 17:06 test rfhpc8133% ls -la test ls: test: Permission denied rfhpc8133% cd test rfhpc8133% ls ls: .: Permission denied rfhpc8133% cd dir rfhpc8133% ls -la total 4 drwxr-xr-x 2 feyrer bedienst 512 Oct 9 17:06 . d--x--x--x 3 feyrer bedienst 512 Oct 9 17:06 ..
rfhpc8133% pwd /tmp_mnt/rfhs8012/root/home3/bedienst/feyrer/test rfhpc8133% cd .. rfhpc8133% rm -fr test rm: test: Permission denied rfhpc8133% cd test rfhpc8133% rmdir dir rmdir: dir: Permission denied rfhpc8133% pwd /tmp_mnt/rfhs8012/root/home3/bedienst/feyrer/test rfhpc8133% ls -lad . d--x--x--x 3 feyrer bedienst 512 Oct 9 17:06 . rfhpc8133% chmod u+w . rfhpc8133% rmdir dir rfhpc8133% pwd /tmp_mnt/rfhs8012/root/home3/bedienst/feyrer/test rfhpc8133% cd .. rfhpc8133% rmdir test rfhpc8133%
-r-x--s--x 1 root mail 66256 Dec 13 2002 /usr/bin/mail -r-xr-sr-x 1 root sys 59700 Nov 4 2002 /usr/bin/netstat -r-sr-sr-x 1 root sys 22168 Nov 4 2002 /usr/bin/passwd -r-xr-sr-x 1 root tty 11612 Nov 4 2002 /usr/bin/write -r-xr-sr-x 1 root games 22596 Sep 19 2005 /usr/games/tetris
rfhpc8133% cat ~mea33856/test/fubar #!/bin/sh id rfhpc8133% ls -la ~mea33856/test/fubar -rwsr-sr-x 1 mea33856 users 14 Apr 15 12:47 /home2/student/mea33856/test/fubar rfhpc8133% id (NetBSD) uid=102(feyrer) gid=200(bedienst) groups=200(bedienst),0(wheel),304(soft),308(vhb-nn),311(admin),306(nds),303(tr) rfhpc8133% ~mea33856/test/fubar (NetBSD) uid=102(feyrer) gid=200(bedienst) groups=200(bedienst),0(wheel),304(soft),308(vhb-nn),311(admin),306(nds),303(tr) rfhpc8133% ssh darwin id (SuSE Linux) uid=102(feyrer) gid=200(bedienst) groups=200(bedienst),304(soft),308(vhb-nn),311(admin),306(nds),303(tr) rfhpc8133% ssh darwin ~mea33856/test/fubar (SuSE Linux) uid=102(feyrer) gid=200(bedienst) groups=200(bedienst),304(soft),308(vhb-nn),311(admin),306(nds),303(tr) rfhpc8133% ssh delphi id (Solaris) uid=102(feyrer) gid=200(bedienst) rfhpc8133% ssh delphi ~mea33856/test/fubar (Solaris) uid=102(feyrer) gid=200(bedienst) euid=33856(mea33856) egid=100(student) rfhpc8133% cat ~mea33856/test/blub.c #includeAbhilfe bei NetBSD ist die SETUIDSCRIPTS Kernel Option, siehe options(4).#include int main (int argc, char ** argv) { printf("uid: %d \t gid: %d \t euid: %d \t egid: %d\n", getuid(), getgid(), geteuid(), getegid()); exit(0); } rfhpc8133% ls -la ~mea33856/test/blub -rwsr-sr-x 1 mea33856 users 6333 Apr 15 12:57 /home2/student/mea33856/test/blub rfhpc8133% ~mea33856/test/blub uid: 102 gid: 200 euid: 33856 egid: 100
+-------+-------+-------+-------+
| s s s | r w x | r w x | r w x |
| e e t | | | |
| t t i | | | |
| u g c | | | |
| i i k | | | |
| d d y | | | |
+-------+-------+-------+-------+
User Group Other
(Owner)
Auf alten Unix-Systemen wurden Programme beim start gleichzeitig in den Swapspace kopiert und nach Ende von dort entfernt. das Sticky-Bit bewirkte dass das Programm nicht entfernt wurde um die Startzeit zu senken.
Auf modernen systemen mit Paging ohne Bedeutung.
Nur Besitzer einer Datei darf diese loeschen, bei Verzeichnissen wie /tmp mit mode 777. Dient zum Schutz vor überschreiben und Manipulation von Daten sowie Symlink Attacks.
Beispiel:
rfhpc8317% ls -lad /tmp drwxrwxrwt 7 root sys 305 Mar 22 14:18 /tmp
% grep '^root' /etc/passwd root:*:0:0:Charlie &,,,:/root:/bin/sh % grep '^ro*t' /etc/passwd root:*:0:0:Charlie &,,,:/root:/bin/sh % grep ^ro*t /etc/passwd % % ls -l /usr/bin | grep -v root total 25236 -rwxr-xr-x 1 bin bin 18964 Dec 16 1999 apm ---s--x--x 1 uucp uucp 74776 Mar 29 2001 cu -rwxr-xr-x 1 bin bin 172 Oct 13 1999 lp_1251 -r-xr-xr-x 1 bin bin 2554 Dec 5 1999 mailp ... % cd $HOME/public_html ; grep -hi "<title>" *.html <TITLE></TITLE> <TITLE>Test-From</TITLE> <TITLE>How to find Hubert's Office <TITLE>Hubert Feyrer</TITLE> <title>Übungen zur Security-Vorlesung</title> ...
rfhpc8320% echo bla Blaa blaaafasel bla Blaa blaaafasel rfhpc8320% echo bla Blaa blaaafasel | sed 's/bla/BLA/' BLA Blaa blaaafasel rfhpc8320% echo bla Blaa blaaafasel | sed 's/bla/BLA/g' BLA Blaa BLAaafasel rfhpc8320% echo bla Blaa blaaafasel | sed 's/bla/BLA/gi' BLA BLAa BLAaafasel rfhpc8320% echo bla Blaa blaaafasel | sed 's/bla*/BLA/gi' BLA BLA BLAfasel rfhpc8320% echo bla Blaa blaaafasel | sed 's/bl\(a*\)/BL_\1_/gi' BL_a_ BL_aa_ BL_aaa_fasel
rfhpc8320% xclock &
[1] 29586
rfhpc8320% ps -ef | grep xclock
feyrer 29586 29394 1 13:35:15 pts/15 0:00 xclock
rfhpc8320% ps -ef | grep xclock | awk '{ print $2; }'
29586
rfhpc8320% ps -ef | grep xclock | awk '{ print $2; }' | sed 's/^/kill/'
kill 29586
rfhpc8320% ps -ef | grep xclock | awk '{ print $2; }' | sed 's/^/kill/' | sh
[1] + Terminated xclock
$ test -e /etc $ echo $? 0 $ test -e /etc/passwd $ echo $? 0 $ test -e /foobar $ echo $? 1
$ test -f /etc/passwd $ echo $? 0 $ test -f /etc $ echo $? 1 $ test -f /etc/gibtsnet $ echo $? 1
$ test -d /etc $ echo $? 0 $ test -d /etc/passwd $ echo $? 1 $ test -d /foobar $ echo $? 1
$ test ! -d /etc $ echo $? 1 $ test ! -d /foobar $ echo $? 0
$ test s1 = s2 $ echo $? 1 $ test s = s $ echo $? 0
$ test s1 != s2 $ echo $? 0 $ test s != s $ echo $? 1
$ test 2 -gt 1 $ echo $? 0 $ test 2 -gt 3 $ echo $? 1 $ test 2 -gt 2 $ echo $? 1
$ test 2 -le 1 $ echo $? 1 $ test 2 -le 3 $ echo $? 0 $ test 2 -le 2 $ echo $? 0
Der "test" Befehl ist dasselbe wie der "[" Befehl, um bei Shell-Scripten die lesbarkeit zu erhöhen:
$ ls -li /bin/test /bin/[ 10848 -r-xr-xr-x 2 root wheel 46252 Apr 4 12:51 /bin/[ 10848 -r-xr-xr-x 2 root wheel 46252 Apr 4 12:51 /bin/testIn vielen Shells ist der test/[ Befehl auch intern implementiert, um Geschwindigkeit zu sparen.
find . -name filename
find . -name 'glob pattern'
find . -name '*.c'
find . -print
find . -ls
find . -type d -print
find . -newer /file
find . -exec 'rm {} ;'
find /usr -user root -ls
find /usr -inum 123
echo test.html bla.html | xargs ls -la find . -type f -name '*.html' -print | xargs grep -i '<title>' find /usr/include -type f -print | xargs grep ' fork.*(.*).*;' find $HOME -type d -print | xargs echo rm -fr