This is an old revision of the document!
Laborator 04: Serverul web
Exerciții
Virtual Hosts
Configurare de baza
In
/etc/hosts
, adaugati 2 alias-uri, astfel incat host-urile
gsr.ro
si
www.gsr.ro
sa fie mapate pe adresa IP
127.0.0.1
Show solutionHide solution
Show solution
root@mjolnir:~# cat /etc/hosts | head -n 3
127.0.0.1 localhost
127.0.1.1 mjolnir.labs.cs.pub.ro mjolnir
127.0.0.1 gsr.ro www.gsr.ro
In configuratia server-ului Apache, adaugati un Virtual Host pentru domeniul gsr.ro
.
Aveti in vedere urmatoarele:
Fisierul de configurare al site-ului se va numi gsr.ro.conf
si se va afla in directorul /etc/apache2/sites-available
.
Virtual Host-ul va fi mapat pe portul 80.
ServerName-ul va fi gsr.ro
Adresa de mail a administatorului este admin@gsr.ro
Site-ul va servi fisiere din directorul /var/www/html/gsr.ro
Fisierele de log pentru acest site vor fi in /var/log/apache2/gsr.ro.log
si /var/log/apache2/gsr.ro.err.log
Show solutionHide solution
Show solution
root@mjolnir:~# mkdir /var/www/html/gsr.ro
root@mjolnir:~# echo "This is gsr.ro" > /var/www/html/gsr.ro/index.html
root@mjolnir:~# cat /etc/apache2/sites-available/gsr.ro.conf
<VirtualHost *:80>
ServerAdmin admin@gsr.ro
ServerName gsr.ro
DocumentRoot /var/www/html/gsr.ro
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/html/gsr.ro/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
ErrorLog /var/log/apache2/gsr.err.log
LogLevel warn
CustomLog /var/log/apache2/gsr.log combined
</VirtualHost>
Show solutionHide solution
Show solution
root@mjolnir:~# a2ensite gsr.ro
Enabling site gsr.ro.
To activate the new configuration, you need to run:
service apache2 reload
root@mjolnir:~# /etc/init.d/apache2 restart
Restarting web server: apache2[Fri Jan 27 18:29:34 2012] [warn] NameVirtualHost 172.16.7.133:8080 has no VirtualHosts
... waiting [Fri Jan 27 18:29:35 2012] [warn] NameVirtualHost 172.16.7.133:8080 has no VirtualHosts
.
Alias-uri
Pentru primul tip de alias-uri, configurati Virtual Host-ul
gsr.ro
astfel incat sa raspunda si la cereri pentru
www.gsr.ro
-
Pentru al doilea tip de alias-uri, configurati Virtual Host-ul
gsr.ro
astfel incat la accesarea adresei
http://gsr.ro/config
sa fie afisat continutul directorului
/var/www/html/gsr.ro/configfiles
.
Creati directorul /var/www/html/gsr.ro/configfiles
. In interiorul acestuia, creati fisierele file1
, file2
si file3
.
Hint: Puteti folosi ca model configuratia alias-ului doc → /usr/share/doc
din fisierul de configurare al site-ului default al Apache.
-
Show solutionHide solution
Show solution
root@mjolnir:~# mkdir /var/www/html/gsr.ro/configfiles
root@mjolnir:~# cd $_
root@mjolnir:/var/www/html/gsr.ro/configfiles# touch file1 file2 file3
root@mjolnir:/var/www/html/gsr.ro/configfiles# ls -l
total 0
-rw-r--r-- 1 root root 0 Jan 27 18:30 file1
-rw-r--r-- 1 root root 0 Jan 27 18:30 file2
-rw-r--r-- 1 root root 0 Jan 27 18:30 file3
root@mjolnir:/var/www/html/gsr.ro/configfiles# cd -
/root
root@mjolnir:~# cat /etc/apache2/sites-available/gsr.ro | tail -n 7
Alias /config "/var/www/html/gsr.ro/configfiles/"
<Directory "/var/www/html/gsr.ro/configfiles/">
Options Indexes MultiViews FollowSymLinks
AllowOverride None
</Directory>
</VirtualHost>
root@mjolnir:~# /etc/init.d/apache2 restart
Restarting web server: apache2[Fri Jan 27 18:32:57 2012] [warn] NameVirtualHost 172.16.7.133:8080 has no VirtualHosts
... waiting [Fri Jan 27 18:32:58 2012] [warn] NameVirtualHost 172.16.7.133:8080 has no VirtualHosts
.
Redirect
-
-
Pentru testare, creati directorul /var/www/html/gsr.ro/redirect
.
In interiorul acestuia, creati un fisier index.html
care sa afiseze mesajul redirect
-
Show solutionHide solution
Show solution
root@mjolnir:~# mkdir /var/www/html/gsr.ro/redirect
root@mjolnir:~# echo "redirect" > /var/www/html/gsr.ro/redirect/index.html
root@mjolnir:~# cat /etc/apache2/sites-available/gsr.ro | tail -n 3
redirect /redirect http://gsr.ro/labs
</VirtualHost>
root@mjolnir:~# /etc/init.d/apache2 restart
Restarting web server: apache2[Fri Jan 27 18:41:54 2012] [warn] NameVirtualHost 172.16.7.133:8080 has no VirtualHosts
... waiting [Fri Jan 27 18:41:55 2012] [warn] NameVirtualHost 172.16.7.133:8080 has no VirtualHosts
.
Restrictionarea accesului pe baza adresei IP
Configurati Virtual Host-ul gsr.ro
pentru a se permite accesul la acesta doar de la adresa 127.0.0.1
.
Nu uitati de directiva Order deny,allow
, care specifica ordinea in care sunt interpretate directivele Deny si Allow.
-
In Virtual Host-ul gsr.ro
, adaugati un nou ServerAlias, cu numele restricted.gsr.ro
Pe sistemul colegului, adaugati o intrare in /etc/hosts
pentru restricted.gsr.ro
, care sa se mapeze cu adresa IP a sistemului vostru.
Show solutionHide solution
Show solution
root@mjolnir:~# cat /etc/apache2/sites-available/gsr.ro.conf
<VirtualHost *:80>
ServerName gsr.ro
ServerAlias www.gsr.ro
ServerAlias restricted.gsr.ro
DocumentRoot /var/www/html/gsr.ro
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/html/gsr.ro/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order deny,allow
allow from 127.0.0.1
deny from all
</Directory>
</VirtualHost>
root@mjolnir:~# /etc/init.d/apache2 restart
Restarting web server: apache2[Fri Jan 27 19:27:55 2012] [warn] NameVirtualHost 172.16.7.133:8080 has no VirtualHosts
... waiting [Fri Jan 27 19:27:56 2012] [warn] NameVirtualHost 172.16.7.133:8080 has no VirtualHosts
.
SSL / TLS
Show solutionHide solution
Show solution
root@mjolnir:~# netstat -lntp | grep apache
tcp 0 0 172.16.7.133:8080 0.0.0.0:* LISTEN 7747/apache2
tcp6 0 0 :::80 :::* LISTEN 7747/apache2
tcp6 0 0 :::443 :::* LISTEN 7747/apache2
Show solutionHide solution
Show solution
root@mjolnir:~# ls /etc/apache2/sites-available/
default default-ssl gsr.ro sric.ro
root@mjolnir:~# a2ensite default-ssl
Enabling site default-ssl.
To activate the new configuration, you need to run:
service apache2 reload
openssl genrsa -out gsr.ro.key 2048
openssl req -new -key gsr.ro.key -out gsr.ro.csr
openssl x509 -req -days 365 -in gsr.ro.csr -signkey gsr.ro.key -out gsr.ro.crt
Show solutionHide solution
Show solution
root@mjolnir:/etc/apache2/sites-available# cat gsr.ro-ssl.conf | grep -v '^.*#' | grep -v '^$'
<IfModule mod_ssl.c>
<VirtualHost _default_:443>
ServerAdmin webmaster@localhost
ServerName gsr.ro
ServerAlias www.gsr.ro
DocumentRoot /var/www/html/gsr.ro
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/html/gsr.ro/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/ssl_access.log combined
Alias /doc/ "/usr/share/doc/"
<Directory "/usr/share/doc/">
Options Indexes MultiViews FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
Allow from 127.0.0.0/255.0.0.0 ::1/128
</Directory>
SSLEngine on
SSLCertificateFile /etc/apache2/ssl-certs/gsr.ro.crt
SSLCertificateKeyFile /etc/apache2/ssl-certs/gsr.ro.key
<FilesMatch "\.(cgi|shtml|phtml|php)$">
SSLOptions +StdEnvVars
</FilesMatch>
<Directory /usr/lib/cgi-bin>
SSLOptions +StdEnvVars
</Directory>
BrowserMatch "MSIE [2-6]" \
nokeepalive ssl-unclean-shutdown \
downgrade-1.0 force-response-1.0
BrowserMatch "MSIE [17-9]" ssl-unclean-shutdown
</VirtualHost>
</IfModule>
root@mjolnir:/etc/apache2/sites-available# a2ensite gsr.ro-ssl
Enabling site gsr.ro-ssl.
To activate the new configuration, you need to run:
service apache2 reload
root@mjolnir:/etc/apache2/sites-available# /etc/init.d/apache2 restart
Restarting web server: apache2[Fri Jan 27 21:13:02 2012] [warn] NameVirtualHost 172.16.7.133:8080 has no VirtualHosts
[Fri Jan 27 21:13:02 2012] [warn] NameVirtualHost *:443 has no VirtualHosts
[Fri Jan 27 21:13:02 2012] [warn] NameVirtualHost *:80 has no VirtualHosts
... waiting [Fri Jan 27 21:13:03 2012] [warn] NameVirtualHost 172.16.7.133:8080 has no VirtualHosts
[Fri Jan 27 21:13:03 2012] [warn] NameVirtualHost *:443 has no VirtualHosts
[Fri Jan 27 21:13:03 2012] [warn] NameVirtualHost *:80 has no VirtualHosts
.
mod_rewrite
Modulul rewrite
din Apache permite rescrierea URL-urilor din request-urile HTTP, dupa anumite reguli.
Configurati
mod_rewrite
astfel incat folosirea hostname-ului
gsr.ro
in
URL sa duca la suprascrierea acestuia cu
www.gsr.ro
root@mjolnir:/etc/apache2/sites-available# a2enmod rewrite
Enabling module rewrite.
To activate the new configuration, you need to run:
service apache2 restart
root@mjolnir:/etc/apache2/sites-available# cat gsr.ro | tail -n 7
RewriteEngine On
RewriteOptions Inherit
RewriteCond %{HTTP_HOST} !^www\.gsr\.ro [NC]
RewriteCond %{HTTP_HOST} !^$
RewriteRule ^/?(.*) http://www.gsr.ro/$1 [L,R,NE]
</VirtualHost>
RewriteEngine On
RewriteOptions Inherit
RewriteRule ^/user/([^/]+)/?(.*) /~$1 [R]
RewriteRule ^/~/([^/]+)$ /~$1/ [R]
</VirtualHost>
</solution>
/*
~~SHOWSOLUTION~~
====== Laborator 04 - Drepturi. Limitarea drepturilor. Jurnalizare ======
<note important>
Dacă un pachet nu este instalat iar un exercițiu face referire la acesta, instalați-l.
</note>
===== 1. Limitarea drepturilor utilizatorilor (3p) =====
*Comenzi/concepte/fișiere
*ulimit
*drepturi de montare in fstab
*account locking: usermod
*expirarea parolelor: chage
==== Exerciții ====
***ATENTIE** Acest set de exerciții se rezolvă pe mașina fizică și pe mașina virtuală
*[01]. Adăugați utilizatorii **guest** și **special_guest** pe mașina fizică și pe cea virtuală. (Hint: puteți folosi ''adduser'')
<solution -hidden -en><code>
root@mjolnir:~# adduser guest
[...]
root@mjolnir:~# adduser special_guest
[...]
root@heimdall:~# adduser guest
[...]
root@heimdall:~# adduser special_guest
[...]
</solution>
Show solutionHide solution
Show solution
root@heimdall:~# chage -E "2013-11-08" guest
root@heimdall:~# chage -l guest
Last password change : Nov 07, 2013
Password expires : never
Password inactive : never
Account expires : Nov 08, 2013
Minimum number of days between password change : 0
Maximum number of days between password change : 99999
Number of days of warning before password expires : 7
Show solutionHide solution
Show solution
root@heimdall:~# chage -d "2013-10-30" guest
root@heimdall:~# chage -l guest
Last password change : Oct 30, 2013
Password expires : never
Password inactive : never
Account expires : Nov 08, 2013
Minimum number of days between password change : 0
Maximum number of days between password change : 99999
Number of days of warning before password expires : 7
Show solutionHide solution
Show solution
root@heimdall:~# chage -d "2013-10-31" -M 1 special_guest
student@heimdall:~$ su special_guest
Password:
You are required to change your password immediately (password aged)
Changing password for guest.
(current) UNIX password:
Enter new UNIX password:
Retype new UNIX password:
Show solutionHide solution
Show solution
root@heimdall:~# usermod -L special_guest
student@heimdall:~$ su special_guest
Password:
su: Authentication failure
Show solutionHide solution
Show solution
root@heimdall:~# cat /etc/motd.tail
This is is a secure system. Any unauthorized access will be logged and prosecuted.
Linux heimdall 3.0.0-1-686-pae #1 SMP Sat Aug 27 16:41:03 UTC 2011 i686
The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/* /copyright.
Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
student@mjolnir:~$ ssh root@heimdall.local
This is is a secure system. Any unauthorized access will be logged and prosecuted.
Linux heimdall 3.0.0-1-686-pae #1 SMP Sat Aug 27 16:41:03 UTC 2011 i686
The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/* /copyright.
Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
Last login: Thu Oct 31 13:41:58 2013 from mjolnir-2.local
[07]. Configurați mașina virtuală astfel încât nici un utilizator să nu poată crea un fișier mai mare de 100
MB. Reporniți mașina virtuală (sau realizați un nou login) pentru ca modificările să se aplice. Testați limita fișierului folosind
dd
. (Hint:
man limits.conf
)
Show solutionHide solution
Show solution
root@heimdall:~# cat /etc/security/limits.conf | tail -n 2
* hard fsize 100000
root hard fsize 100000
[Se reporneste masina virtuala sau se efectueaza un nou login.]
student@heimdall:~$ dd if=/dev/zero of=test.dat
File size limit exceeded
student@heimdall:~$ ls -lh
total 98M
-rw-r--r-- 1 student student 98M Nov 3 13:47 test.dat
Show solutionHide solution
Show solution
root@heimdall:~# cat /etc/security/limits.conf | tail -n 2
guest hard cpu 2
guest hard maxlogins 2
2. Sudo (2p)
Exerciții
Show solutionHide solution
Show solution
root@mjolnir:~# update-alternatives --config editor
There are 4 choices for the alternative editor (providing /usr/bin/editor).
Selection Path Priority Status
------------------------------------------------------------
*0 /bin/nano 40 auto mode
1 /bin/nano 40 manual mode
2 /usr/bin/emacs23 0 manual mode
3 /usr/bin/vim.basic 30 manual mode
4 /usr/bin/vim.tiny 10 manual mode
Press enter to keep the current choice[*], or type selection number: 3
update-alternatives: using /usr/bin/vim.basic to provide /usr/bin/editor (editor) in manual mode.
Show solutionHide solution
Show solution
root@mjolnir:~# groupadd alice
root@mjolnir:~# useradd -d /home/alice -m -g alice -s /bin/bash alice
root@mjolnir:~# echo "alice:student" | chpasswd
Show solutionHide solution
Show solution
root@mjolnir:~# cat /etc/sudoers | tail -n 1
alice ALL = /usr/sbin/adduser
alice@mjolnir:~$ sudo ls
We trust you have received the usual lecture from the local System
Administrator. It usually boils down to these three things:
#1) Respect the privacy of others.
#2) Think before you type.
#3) With great power comes great responsibility.
[sudo] password for alice:
Sorry, user alice is not allowed to execute '/bin/ls' as root on mjolnir.labs.cs.pub.ro.
alice@mjolnir:~$ sudo adduser gogu
[sudo] password for alice:
Adding user `gogu' ...
Adding new group `gogu' (1004) ...
Adding new user `gogu' (1004) with group `gogu' ...
Creating home directory `/home/gogu' ...
Copying files from `/etc/skel' ...
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully
Changing the user information for gogu
Enter the new value, or press ENTER for the default
Full Name []:
Room Number []:
Work Phone []:
Home Phone []:
Other []:
Is the information correct? [Y/n]
Show solutionHide solution
Show solution
alice@mjolnir:~$ sudo adduser bob
Adding user `bob' ...
Adding new group `bob' (1005) ...
Adding new user `bob' (1005) with group `bob' ...
Creating home directory `/home/bob' ...
Copying files from `/etc/skel' ...
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully
Changing the user information for bob
Enter the new value, or press ENTER for the default
Full Name []:
Room Number []:
Work Phone []:
Home Phone []:
Other []:
Is the information correct? [Y/n]
Show solutionHide solution
Show solution
root@mjolnir:~# cat /etc/sudoers | tail -n 1
alice ALL = NOPASSWD: /usr/sbin/adduser
alice@mjolnir:~$ sudo adduser cornel
Adding user `cornel' ...
Adding new group `cornel' (1006) ...
Adding new user `cornel' (1006) with group `cornel' ...
Creating home directory `/home/cornel' ...
Copying files from `/etc/skel' ...
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully
Changing the user information for cornel
Enter the new value, or press ENTER for the default
Full Name []:
Room Number []:
Work Phone []:
Home Phone []:
Other []:
Is the information correct? [Y/n]
3. Quota (3,5p)
Exerciții
Show solutionHide solution
Show solution
root@heimdall:~# apt-get update
root@heimdall:~# apt-get install quota
Show solutionHide solution
Show solution
root@heimdall:~# mkdir /tmp/quota
Show solutionHide solution
Show solution
root@heimdall:~# dd if=/dev/zero of=disk-quota bs=1M count=25
25+0 records in
25+0 records out
26214400 bytes (26 MB) copied, 0.0859398 s, 305 MB/s
Show solutionHide solution
Show solution
root@heimdall:~# mkfs.ext3 -F disk-quota
mke2fs 1.42-WIP (02-Jul-2011)
Filesystem label=
OS type: Linux
Block size=1024 (log=0)
Fragment size=1024 (log=0)
Stride=0 blocks, Stripe width=0 blocks
6400 inodes, 25600 blocks
1280 blocks (5.00%) reserved for the super user
First data block=1
Maximum filesystem blocks=26214400
4 block groups
8192 blocks per group, 8192 fragments per group
1600 inodes per group
Superblock backups stored on blocks:
8193, 24577
Allocating group tables: done
Writing inode tables: done
Creating journal (1024 blocks): done
Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 0 mounts or
0 days, whichever comes first. Use tune2fs -c or -i to override.
Show solutionHide solution
Show solution
root@heimdall:~# file disk-quota
disk-quota: Linux rev 1.0 ext3 filesystem data, UUID=060c2a50-0def-4997-a1bf-34a2e1fcd9b5
[02].e. Adăugați o intrare corespunzătoare sistemului de fișiere nou creat în /etc/fstab. Punctul de montare va fi /tmp/quota și va trebui să activați suportul pentru cote la nivel de utilizator și la nivel de grup pentru această partiție. (Hint:
http://www.yolinux.com/TUTORIALS/LinuxTutorialQuotas.html, defaults)
Show solutionHide solution
Show solution
root@heimdall:~# cat /etc/fstab | tail -n 1
/root/disk-quota /tmp/quota ext3 defaults,usrquota,grpquota 0 0
Show solutionHide solution
Show solution
root@heimdall:~# touch /tmp/quota/myfile
root@heimdall:~# ls -l /tmp/quota/myfile
-rw-r--r-- 1 root root 0 Nov 3 14:35 /tmp/quota/myfile
Show solutionHide solution
Show solution
root@heimdall:~# mount -o loop /root/disk-quota
root@heimdall:~# mount | tail -n 1
/root/disk-quota on /tmp/quota type ext3 (rw,usrquota,grpquota)
root@heimdall:~# ls -l /tmp/quota/
total 12
drwx------ 2 root root 12288 Nov 3 14:31 lost+found
Show solutionHide solution
Show solution
root@heimdall:~# groupadd student-quota
root@heimdall:~# useradd -d /home/student-quota -m -g student-quota -s /bin/bash student-quota
root@heimdall:~# echo "student-quota:student" | chpasswd
[03].b. Rulați comanda quotacheck -F vfsv1 -vgum /tmp/quota/
pentru a inițializa automat fișierele aquota.user
și aquota.group
în /tmp/quota
. E posibil sa fie nevoie sa recreati fisierele aquota.user, respectiv aquota.group daca pasul [03].c nu functioneaza corespunzator - touch aquota.user aqouta.group si apoi schimbati permisiunile pe fisiere: chmod 600 pentru aquota.user si aquota.group.
Show solutionHide solution
Show solution
root@heimdall:~# quotacheck -vgum /tmp/quota
quotacheck: Scanning /dev/loop0 [/tmp/quota] done
quotacheck: Cannot stat old user quota file /tmp/quota/aquota.user: No such file or directory. Usage will not be substracted.
quotacheck: Cannot stat old group quota file /tmp/quota/aquota.group: No such file or directory. Usage will not be substracted.
quotacheck: Cannot stat old user quota file /tmp/quota/aquota.user: No such file or directory. Usage will not be substracted.
quotacheck: Cannot stat old group quota file /tmp/quota/aquota.group: No such file or directory. Usage will not be substracted.
quotacheck: Checked 3 directories and 0 files
quotacheck: Old file not found.
quotacheck: Old file not found.
root@heimdall:~# ls -l /tmp/quota/
total 24
-rw------- 1 root root 6144 Nov 3 14:40 aquota.group
-rw------- 1 root root 6144 Nov 3 14:40 aquota.user
drwx------ 2 root root 12288 Nov 3 14:31 lost+found
[03].c. Folosiți setquota
pentru a modifica limitele utilizatorului student-quota pentru sistemul de fișiere din /tmp/quota
astfel: soft block limit 100, hard block limit 200, soft inode 10, hard inode 15.
Show solutionHide solution
Show solution
root@heimdall:~# setquota student-quota 100 200 10 15 /tmp/quota
Show solutionHide solution
Show solution
root@heimdall:~# quotaon /tmp/quota/
Show solutionHide solution
Show solution
root@heimdall:~# quota -uv student-quota
Disk quotas for user student-quota (uid 1003):
Filesystem blocks quota limit grace files quota limit grace
/dev/loop0 0 100 200 0 10 15
student-quota@heimdall:/tmp/quota$ touch testfile
student-quota@heimdall:/tmp/quota$ ln -s testfile testfile-sl
student-quota@heimdall:/tmp/quota$ ln testfile testfile-hl
student-quota@heimdall:/tmp/quota$ ls -l
total 26
-rw------- 1 root root 7168 Nov 3 14:50 aquota.group
-rw------- 1 root root 7168 Nov 3 14:50 aquota.user
drwx------ 2 root root 12288 Nov 3 14:31 lost+found
-rw-r--r-- 2 student-quota student-quota 0 Nov 3 14:51 testfile
-rw-r--r-- 2 student-quota student-quota 0 Nov 3 14:51 testfile-hl
lrwxrwxrwx 1 student-quota student-quota 8 Nov 3 14:52 testfile-sl -> testfile
root@heimdall:~# quota -uv student-quota
Disk quotas for user student-quota (uid 1003):
Filesystem blocks quota limit grace files quota limit grace
/dev/loop0 1 100 200 3 10 15
Show solutionHide solution
Show solution
root@heimdall:~# quota -uv student-quota
Disk quotas for user student-quota (uid 1003):
Filesystem blocks quota limit grace files quota limit grace
/dev/loop0 1 100 200 3 10 15
student-quota@heimdall:/tmp/quota$ touch ana are mere
student-quota@heimdall:/tmp/quota$ ls -l
total 26
-rw-r--r-- 1 student-quota student-quota 0 Nov 3 14:55 ana
-rw------- 1 root root 7168 Nov 3 14:50 aquota.group
-rw------- 1 root root 7168 Nov 3 14:50 aquota.user
-rw-r--r-- 1 student-quota student-quota 0 Nov 3 14:55 are
drwx------ 2 root root 12288 Nov 3 14:31 lost+found
-rw-r--r-- 1 student-quota student-quota 0 Nov 3 14:55 mere
-rw-r--r-- 2 student-quota student-quota 0 Nov 3 14:51 testfile
-rw-r--r-- 2 student-quota student-quota 0 Nov 3 14:51 testfile-hl
lrwxrwxrwx 1 student-quota student-quota 8 Nov 3 14:52 testfile-sl -> testfile
root@heimdall:~# quota -uv student-quota
Disk quotas for user student-quota (uid 1003):
Filesystem blocks quota limit grace files quota limit grace
/dev/loop0 1 100 200 6 10 15
student-quota@heimdall:/tmp/quota$ touch si maria are pere
student-quota@heimdall:/tmp/quota$ ls -l
total 26
-rw-r--r-- 1 student-quota student-quota 0 Nov 3 14:55 ana
-rw------- 1 root root 7168 Nov 3 14:50 aquota.group
-rw------- 1 root root 7168 Nov 3 14:50 aquota.user
-rw-r--r-- 1 student-quota student-quota 0 Nov 3 14:56 are
drwx------ 2 root root 12288 Nov 3 14:31 lost+found
-rw-r--r-- 1 student-quota student-quota 0 Nov 3 14:56 maria
-rw-r--r-- 1 student-quota student-quota 0 Nov 3 14:55 mere
-rw-r--r-- 1 student-quota student-quota 0 Nov 3 14:56 pere
-rw-r--r-- 1 student-quota student-quota 0 Nov 3 14:56 si
-rw-r--r-- 2 student-quota student-quota 0 Nov 3 14:51 testfile
-rw-r--r-- 2 student-quota student-quota 0 Nov 3 14:51 testfile-hl
lrwxrwxrwx 1 student-quota student-quota 8 Nov 3 14:52 testfile-sl -> testfile
root@heimdall:~# quota -uv student-quota
Disk quotas for user student-quota (uid 1003):
Filesystem blocks quota limit grace files quota limit grace
/dev/loop0 1 100 200 9 10 15
student-quota@heimdall:/tmp/quota$ touch quota is getting close
loop0: warning, user file quota exceeded.
student-quota@heimdall:/tmp/quota$ ls -l
total 26
-rw-r--r-- 1 student-quota student-quota 0 Nov 3 14:55 ana
-rw------- 1 root root 7168 Nov 3 14:50 aquota.group
-rw------- 1 root root 7168 Nov 3 14:50 aquota.user
-rw-r--r-- 1 student-quota student-quota 0 Nov 3 14:56 are
-rw-r--r-- 1 student-quota student-quota 0 Nov 3 14:57 close
-rw-r--r-- 1 student-quota student-quota 0 Nov 3 14:57 getting
-rw-r--r-- 1 student-quota student-quota 0 Nov 3 14:57 is
drwx------ 2 root root 12288 Nov 3 14:31 lost+found
-rw-r--r-- 1 student-quota student-quota 0 Nov 3 14:56 maria
-rw-r--r-- 1 student-quota student-quota 0 Nov 3 14:55 mere
-rw-r--r-- 1 student-quota student-quota 0 Nov 3 14:56 pere
-rw-r--r-- 1 student-quota student-quota 0 Nov 3 14:57 quota
-rw-r--r-- 1 student-quota student-quota 0 Nov 3 14:56 si
-rw-r--r-- 2 student-quota student-quota 0 Nov 3 14:51 testfile
-rw-r--r-- 2 student-quota student-quota 0 Nov 3 14:51 testfile-hl
lrwxrwxrwx 1 student-quota student-quota 8 Nov 3 14:52 testfile-sl -> testfile
root@heimdall:~# quota -uv student-quota
Disk quotas for user student-quota (uid 1003):
Filesystem blocks quota limit grace files quota limit grace
/dev/loop0 1 100 200 13* 10 15 6days
student-quota@heimdall:/tmp/quota$ touch this was it
loop0: write failed, user file limit reached.
touch: cannot touch `it': Disk quota exceeded
root@heimdall:~# quota -uv student-quota
Disk quotas for user student-quota (uid 1003):
Filesystem blocks quota limit grace files quota limit grace
/dev/loop0 1 100 200 15* 10 15 6days
Show solutionHide solution
Show solution
student@mjolnir:~$ find /usr -name *.h > /home/student/file.h
Show solutionHide solution
Show solution
root@heimdall:~# find / -perm -4000
/sbin/mount.nfs
/usr/sbin/exim4
/usr/lib/openssh/ssh-keysign
/usr/lib/eject/dmcrypt-get-device
/usr/lib/pt_chown
/usr/lib/dbus-1.0/dbus-daemon-launch-helper
/usr/bin/passwd
/usr/bin/chfn
/usr/bin/at
/usr/bin/procmail
/usr/bin/chsh
/usr/bin/gpasswd
/usr/bin/newgrp
find: `/proc/2385/task/2385/fd/5': No such file or directory
find: `/proc/2385/task/2385/fdinfo/5': No such file or directory
find: `/proc/2385/fd/5': No such file or directory
find: `/proc/2385/fdinfo/5': No such file or directory
/bin/umount
/bin/ping
/bin/mount
/bin/ping6
/bin/su
4. Accounting (2,5p)
Comenzi/concepte/fișiere
accton
as
sa
last
lastcomm
Exerciții
Show solutionHide solution
Show solution
root@heimdall:~# accton /var/account/pacct
Show solutionHide solution
Show solution
root@heimdall:~# ac -p guest
guest 0.41
total 0.41
root@heimdall:~# ac -p
root 1.79
student 0.47
guest 0.41
total 2.67
Show solutionHide solution
Show solution
root@heimdall:~# last -n 20
root pts/2 mjolnir-2.local Thu Nov 3 15:44 still logged in
root pts/1 mjolnir-2.local Thu Nov 3 15:35 still logged in
root pts/0 mjolnir-2.local Thu Nov 3 15:32 still logged in
reboot system boot 3.0.0-1-686-pae Thu Nov 3 15:31 - 15:49 (00:17)
root pts/1 mjolnir-2.local Thu Nov 3 14:47 - 15:00 (00:12)
root pts/0 mjolnir-2.local Thu Nov 3 14:27 - down (01:04)
reboot system boot 3.0.0-1-686-pae Thu Nov 3 14:12 - 15:31 (01:19)
root pts/2 mjolnir-2.local Thu Nov 3 14:11 - crash (00:01)
guest pts/1 mjolnir-2.local Thu Nov 3 14:09 - crash (00:02)
guest tty1 Thu Nov 3 14:09 - crash (00:02)
guest tty1 Thu Nov 3 14:09 - 14:09 (00:00)
guest pts/2 mjolnir-2.local Thu Nov 3 13:59 - 14:09 (00:09)
guest pts/1 mjolnir-2.local Thu Nov 3 13:59 - 14:09 (00:10)
guest pts/1 mjolnir-2.local Thu Nov 3 13:59 - 13:59 (00:00)
guest pts/2 mjolnir-2.local Thu Nov 3 13:58 - 13:59 (00:00)
guest pts/1 mjolnir-2.local Thu Nov 3 13:58 - 13:59 (00:00)
guest tty2 Thu Nov 3 13:58 - 13:58 (00:00)
guest tty1 Thu Nov 3 13:58 - 13:58 (00:00)
guest tty1 Thu Nov 3 13:58 - 13:58 (00:00)
guest pts/3 mjolnir-2.local Thu Nov 3 13:55 - 13:55 (00:00)
wtmp begins Tue Oct 18 18:42:55 2011
Show solutionHide solution
Show solution
root@heimdall:~# sa | head -n 10
1974 994.74re 0.05cp 0avio 798k
6 0.05re 0.03cp 0avio 532k ip
2 0.11re 0.01cp 0avio 1777k apt-get
14 0.01re 0.00cp 0avio 1504k troff
6 1.75re 0.00cp 0avio 1630k vim
16 3.44re 0.00cp 0avio 953k man
2 0.00re 0.00cp 0avio 556k init
398 0.02re 0.00cp 0avio 1458k bash*
8 0.01re 0.00cp 0avio 1097k dpkg
8 0.05re 0.00cp 0avio 780k dhclient-script
*/