Title: Important files
1 Important files
- /etc/resolv.conf
- Contains information about nameserver (DNS)
- Search list for host-name lookup
geirs_at_compaqgt cat /etc/resolv.conf nameserver
128.39.89.26 nameserver 128.39.74.16 nameserver
128.39.89.10 search iu.hio.no
2Local database for IP-addresses
- /etc/hosts
- Contains IP-addresses, names and aliases for some
hosts - This file is checked before DNS (Domain Name
Server)
geirs_at_compaqgt cat /etc/hosts hosts
This file describes a number of
hostname-to-address mappings for
the TCP/IP subsystem. It is mostly
used at boot time, when no name servers are
running. On small systems, this
file can be used instead of a
"named" name server. Syntax IP-Address
Full-Qualified-Hostname Short-Hostname 127.0.0
.1 localhost special IPv6 addresses 1
localhost ipv6-localhost
ipv6-loopback fe000 ipv6-localnet ff00
0 ipv6-mcastprefix ff021
ipv6-allnodes ff022 ipv6-allrouters ff02
3 ipv6-allhosts 128.39.74.16
cube.iu.hio.no cube 128.39.89.10
nexus.iu.hio.no nexus 128.39.89.35
compaq.iu.hio.no compaq
3DNS (Domain name server)
- DNS is a service that converts ip-addresses to
qualified hostnames (host.domain) - The service is a distributed database where each
DNS is responsible for a zone - A zone can have several DNS, primary and
secondaries - Globally there are some root servers updated by
different organizations - The configuration files for our name servers can
be found at - /iu/cube/local/iu/dns/
- /iu/cube/local/iu/dns/sz/
- /iu/cube/local/iu/dns/named.root contains the
list of root servers - /iu/cube/local/iu/dns/sz/iu.hio.no identifies
hosts with ip-adresses - In /iu/cube/local/iu/dns/sz/ the subnet files
128.39.74 etc. identifies ip-addresses with hosts
4Commands
- Finding user patterns
- last a list of the last logged in users
- finger shows information of the users on a
system - w shows logged on users and what they are doing
- who shows who is logged on
geirs_at_compaqgt last -x geirs tty1
Thu Jan 27 1723 still logged
in runlevel (to lvl 3) 2.6.4-52-default Thu Jan
27 1721 - 1928 (0207) reboot system boot
2.6.4-52-default Thu Jan 27 1721
(0207) shutdown system down 2.6.4-52-default
Thu Jan 27 1618 - 1928 (0310) runlevel (to
lvl 0) 2.6.4-52-default Thu Jan 27 1618 -
1618 (0000) geirs tty1
Thu Jan 27 0754 - down (0823) runlevel
(to lvl 3) 2.6.4-52-default Thu Jan 27 0751 -
1618 (0826) reboot system boot
2.6.4-52-default Thu Jan 27 0751
(0826) shutdown system down 2.6.4-52-default
Wed Jan 26 2340 - 1618 (1638) runlevel (to
lvl 0) 2.6.4-52-default Wed Jan 26 2339 -
2340 (0000) geirs tty1
Wed Jan 26 1848 - down (0451) runlevel
(to lvl 3) 2.6.4-52-default Wed Jan 26 1836 -
2339 (0503) reboot system boot
2.6.4-52-default Wed Jan 26 1836
(0503) shutdown system down 2.6.4-52-default
Wed Jan 26 1559 - 2339 (0740) runlevel (to
lvl 0) 2.6.4-52-default Wed Jan 26 1558 -
1559 (0000) geirs tty1
Wed Jan 26 0841 - down (0716) runlevel
(to lvl 3) 2.6.4-52-default Wed Jan 26 0811 -
1558 (0746) reboot system boot
2.6.4-52-default Wed Jan 26 0811
(0746) shutdown system down 2.6.4-52-default
Tue Jan 25 2226 - 1558 (1732) runlevel (to
lvl 0) 2.6.4-52-default Tue Jan 25 2225 -
2226 (0000) wtmp begins Tue Jan 25 222556
2005
5Commands (examples)
geirs_at_compaqgt finger Login Name
Tty Idle Login Time Where geirs
Geir Skjevling 1 230 Thu
1723 geirs_at_compaqgt finger -l Login geirs
Name Geir
Skjevling Directory /home/geirs
Shell /bin/bash On since Thu Jan 27 1723 (CET)
on tty1, idle 231 No Mail. No Plan.
geirs_at_compaqgt w 201027 up 249, 1 user,
load average 0.24, 0.07, 0.02 USER TTY
LOGIN_at_ IDLE JCPU PCPU WHAT geirs tty1
1723 246m 0.11s 0.00s /bin/sh
/usr/X11R6/bin/startx
geirs_at_compaqgt who geirs tty1 Jan 27
1723
6Commands
- Diskusage
- mount shows mounted filesystems
- df report filesystem disk space usage
- du estimate file space usage
geirs_at_compaqgt mount /dev/hda6 on / type
reiserfs (rw,acl,user_xattr) proc on /proc type
proc (rw) tmpfs on /dev/shm type tmpfs
(rw) devpts on /dev/pts type devpts
(rw,mode0620,gid5) /dev/hda1 on /windows/C type
ntfs (rw,noexec,nosuid,nodev,gid100,umask0002,nl
sutf8) /dev/hdc on /media/dvdram type subfs
(ro,nosuid,nodev,fscdfss,procuid,iocharsetutf8)
usbfs on /proc/bus/usb type usbfs (rw)
7Commands (examples)
geirs_at_compaqgt df -h Filesystem Size
Used Avail Use Mounted on /dev/hda6
37G 2.3G 34G 7 / tmpfs 506M
12K 506M 1 /dev/shm /dev/hda1
15G 6.8G 7.9G 47 /windows/C
compaq/ du -ah /home/geirs/public_html/ 4.0K
/home/geirs/public_html/test/schedule.css 4.0K
/home/geirs/public_html/test/side1.phtml 4.0K
/home/geirs/public_html/test/side2.phtml 4.0K
/home/geirs/public_html/test/side3.phtml 4.0K
/home/geirs/public_html/test/slutt.phtml 4.0K
/home/geirs/public_html/test/index.phtml 24K
/home/geirs/public_html/test 4.0K
/home/geirs/public_html/reservasjon.html 4.0K
/home/geirs/public_html/test.php 4.0K
/home/geirs/public_html/index.html 4.0K
/home/geirs/public_html/.directory 4.0K
/home/geirs/public_html/insert.phtml 4.0K
/home/geirs/public_html/sysadm.css 48K
/home/geirs/public_html/
8Commands
- CPU, processes and memory
- ps reports process status
- top live process status
- pstree shows process tree
geirs_at_compaqgt ps PID TTY TIME CMD
6239 pts/43 000000 bash 7523 pts/43
000000 ps
geirs_at_compaqgt ps PID TTY TIME CMD
6239 pts/43 000000 bash 7523 pts/43
000000 ps geirs_at_compaqgt ps aux grep
http root 5435 0.0 0.2 4948 2572 ?
Ss 0803 000 / usr/local/apache2//bin/httpd
-k start nobody 5536 0.0 0.2 5016 2636 ?
S 0803 000 /usr/local/apache2//bin/http
d -k start nobody 5537 0.0 0.2 5016 2712 ?
S 0803 000 /usr/local/apache2//bin/ht
tpd -k start nobody 5538 0.0 0.2 5016 2712
? S 0803 000 /usr/local/apache2//bin
/httpd -k start nobody 5539 0.0 0.2 5152
2716 ? S 0803 000
/usr/local/apache2//bin/httpd -k start nobody
5540 0.0 0.2 5016 2636 ? S 0803
000 /usr/local/apache2//bin/httpd -k
start nobody 6253 0.0 0.2 5016 2644 ?
S 0804 000 /usr/local/apache2//bin/httpd
-k start geirs 7548 0.0 0.0 2600 708
pts/43 S 1136 000 grep http
9searching for files
- find
- search in a directory hierarchy
- slow
geirs_at_compaq/gt find /home/ -name
web.iso /home/geirs/web.iso
- locate
- list files in databases that match a pattern
- very fast
- the database must be updated regularily (a cron
job) - files found may have been deleted
geirs_at_compaq/gt locate ntp.conf /etc/ntp.conf
10updatedb
- update a file name database
- It can be several databases
- The databases are kept up to date by running a
regular job (a cron job) - The updates normally happens daily (at nights)
and at fixed time after boot - You will normally need root permission to run
updatedb (to have access to all directories and
files on the system).
11cron
- A daemon (process) running regular tasks
- Started at boot of the machine (cron)
- cron reads /etc/crontab every minute to check if
something should be done - Special directories in /etc cron.d, cron.hourly,
cron.daily, cron.weekly andcron.monthly - cron is a tool for system administration
- can be used by all users through the command
crontab (don't confuse it with the
file/etc/crontab - Other important files/directories for cron
- If file /var/spool/cron/allow exists, you must be
listed in to use the crontab command - if it doesn't exist you must not be listed in
/var/spool/cron/deny - If neither files exists it depends on other
parameters - /var/spool/cron/tabs/ contain crontab files for
the users - Read more
- man 8 cron manual for cron deamon (process)
- man 1 crontab manual for the the command crontab
- man 5 crontab manual for the file /etc/crontab
12cron
- crontab files
- Format minute hour day_in_month month
day_in_week command - minute 0-59
- hour 0-23
- day_in_month 1-31
- month 1-12
- day_in_week 0-7 or sun mon (0 7 sunday)
- means all
- Intervals can be used, eg. 3-6 means 3,4,5 and 6
- Lists can be used, eg. 2-5,7-9
- Steps can be used, eg. /3 means every third
- 30 11 5 mycommand executes mycommand every
friday at 1130
13user cron jobs
- Register
- make a crontab file mycrontab in your user
directory - register it with crontab mycrontab
- List
- you can list it with crontab -l
- you can see it in /var/spool/cron/tabs/user
- Remove
- you can remove it with crontab -r
14System jobs and cron
- Special directories
- /etc/cron.dhourlydailyweeklymonthly
- My /etc/cron.daily contains
compaq/etc ls -l cron.daily/ total
50 drwxr-xr-x 2 root root 424 2004-09-24 2049
. drwxr-xr-x 60 root root 6024 2005-02-01 0802
.. -rwx------ 1 root root 924 2004-04-06 0532
clean_catman -rwx------ 1 root root 1761
2004-04-06 0330 clean_core -rwx------ 1 root
root 1169 2004-04-06 0532 do_mandb -rwxr-xr-x
1 root root 176 2004-04-06 0326
logrotate -rwxr-xr-x 1 root root 1875
2003-09-01 1310 suse.de-backup-rc.config -rwxr-xr
-x 1 root root 2059 2003-09-08 1550
suse.de-backup-rpmdb -rwxr-xr-x 1 root root
566 2003-10-06 1736 suse.de-check-battery -rwxr-x
r-x 1 root root 1121 2003-09-01 1310
suse.de-clean-tmp -rwxr-xr-x 1 root root 472
2003-09-01 1310 suse.de-clean-vi -rwxr-xr-x 1
root root 371 2003-09-01 1310
suse.de-cron-local -rwx------ 1 root root 1526
2004-04-06 0330 updatedb
15at - nohup
- at
- Used for batch jobs at a later stage
- at now 5 hours myjob
- Starts myjob 5 hours from now
- Restrictions to use at is given in /etc/at.deny
and/or /etc/at.allow - nohup
- Running jobs immune to hangups
- nohup my_long_job
- Running even if user is logged out