Linux System Administration, level 1 - NeoNovamembers.peak.org/~mountainman/writing/classnotes/LinuxSysAdmin1/...Linux System Administration, level 1 Session 8: Day to Day Administration
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Linux System Administration, level 1
Session 8:Day to Day Administration chores
Part I Process ControlPart II Using rpmPart III Archiving with tar and bzipPart IV Scheduling jobs with cron and atPart V Reading system logs
view a copy of this license, visit http://creativecommons.org/licenses/by-nc-sa/1.0/ or send a letter to Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA.
Processes & threads
● Each running executable is a process that
– Has its own Process ID (PID)
– May have multiple threads
– Has been assigned a priority by the kernel scheduler
– Is in one of several states● Running● Sleeping● Stopped● Zombie
Tools for managing processes
● ps List running processes (snapshot)
● top List running processes (continuous)
– Also gnome-system-monitor
● kill Terminate a running process
● renice Change the “nice” value of a process
● The /proc filesystem
– More information than you'll ever want to know
ps
-e Lists all processes by PID
– Gives name and PID, but not owner
-aux Lists all processes by owner
– Can be piped to grep to quickly find, for instance,● All processes with a particular owner● The PID of a process that you want to kill
top
● Lots more information than ps
– System, processor, memory and swap statistics
– Process status, cpu & memory usage, and more
● While it's running press
– P (that's a capital P) to sort by CPU usage
– k to kill a process
– q to quit
– h for help
GUI system monitors
● gnome-system-monitor
– Similar to top, but also gives nice graphs
● gkrellm
– AFAIK not part of the distro, but easily yummable
● System Monitor on panel
– Right-click on blank area of panel, choose
Add to Panel -> Utility -> System Monitor
– Watch system loads in real time
kill
● Syntax: kill -signal PID
● Get the PID from ps or top
– Can also get PID with kill -p procname
● Commonly-used signals:
TERM or 15 (default) Terminate gracefully
KILL or 9 You Die NOW!!!
● Beware! This also kills all child processes!
renice
● Changes the “nice” value of a process
– From -20 to +20
– Negative number: not nice at all (greedy)● Usually only system processes ● Only root can renice to negative numbers
– Positive number: higher = nicer● 20 = very nice; will only run when no other process wants
CPU time (everything is sleeping or waiting for I/O)
● Syntax: renice PID
Redhat Package Manager (RPM)
● Packages consist of zipped executables with scripts and headers
● Database of installed packages lives on local HD
● Most packages depend on certain other packages to also be installed
● Dependencies are listed in package header
● RPM only checks dependencies; doesn't resolve
Some RPM tasks
● Check the integrity of packages rpm -K
● Install packages rpm -ivh
● Remove packages rpm -e
● Update ("Freshen") packages rpm -Fvh
● Query packages rpm -qsomething
– See next page for a list of “somethings”
rpm -q: querying packages
-qa Produces a list of all installed packages
– Pipe to grep to find particular packages
-ql packagename List the files in a package
-qi packagename Get Info (short description) about a package
-q --whatprovides /full/path/to/filenameWhich package installs the named file on the system?
-q --whatrequires package Which packages depend on this one?
RPM security considerations
● Joe Blackhat 0wnz a router or DNS server
● You THINK you're downloading updates from RedHat or an authorized mirror, but...
● What you're REALLY downloading is a Trojan
● Now YOUR system is 0wned and you don't even know it
● ALWAYS run -K before installing/updating packages!