1 / 20

Files and processes, what where, and why?

Files and processes, what where, and why?. Files are the building blocks. Used for storing stuff (files) Used for pointing to other files (symlinks, directories) Used for representing physical devices (/dev/hda, /dev/lp0, /dev/usb/mouse0)

leal
Télécharger la présentation

Files and processes, what where, and why?

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Files and processes, what where, and why?

  2. Files are the building blocks • Used for storing stuff (files) • Used for pointing to other files (symlinks, directories) • Used for representing physical devices (/dev/hda, /dev/lp0, /dev/usb/mouse0) • Used for representing internal kernel info (/proc/10826, /proc/sys/net/ipv4) • Used for processes to interact (sockets, FIFOs, etc)

  3. Processes are running programs • They can be spawned, suspended, resumed, or killed. • Ps command lists them. • Each process is also represented as a set of files in /proc

  4. We'll learn about files.. • Where are they? • How do we find out information about them? • Why are they useful? • What types of files are common? • What are some interesting files?

  5. We'll learn about processes • How do we tell which ones are running? • How do we string them together to perform nifty tricks? • How do we send them signals, to kill them, suspend them, etc? • What tricks can we perform to find out more about what a process is doing?

  6. Where the files at, dog? • Filesystem standards: FSSTD • Paths • Your path is the place in the tree something fits. • Example: /home/ucf/lruppert • Navigation • Cd command changes where you are. • Pwd command tells you where you are.

  7. Looking at files • Ls -l shows all. • Hidden files start with a period. Ls -a includes them in the listing. • Ls by itself for quick displays of files. • For text files, more 'filename' works pretty well. • You can find files with the locate command. • RTFM!

  8. Why files? • Treating everything as a file provides one unified way to communicate with everything. • It gives us one concept to learn instead of many. • It's an easy way to find the resources at your disposal, since everything fits in one big tree that represents your world.

  9. What are some kinds of file? • 'flat' files, like /etc/passwd • Database hash files like /etc/aliases.db • Directories like /etc • Device files like /dev/lp0 • Links and symbolic links, like /etc/rc.d/* or /etc/timezone • Kernel data like /proc/cpuinfo • Process listings in /proc/ • Weird stuff like sockets like /tmp/.X0-socket

  10. Some cool files to poke at • /etc/passwd – Lists system accounts • /proc/cpuinfo – Shows the chip • /proc/pci – Shows the devices plugged into a reasonably modern system. • /var/log/messages – System errors and various chatty things programs make note of.

  11. Processes are running programs • The ps command shows what's running. • Ps -ef shows everything • Ps -fp shows one process • Parent processes can be seen. • RTFM. • Listings for each process in /proc/

  12. How do we string them together? • The pipe symbol | is your friend. • Redirecting output: < and > • Appending stuff: >> • Examples: • Ps -ef | more • Ls -l | grep goat • Cat /var/log/messages | grep postfix | grep reject | sort | more • RTFM

  13. Deciding who lives or dies • Each process has a process ID • Signals have names and numbers: • HUP – Hangup signal • KILL – Kill with extreme prejudice • STOP – Suspends a process • CONT – Resumes a suspended process • TERM – The default when you issue a kill command.

  14. The kill command is your remote control • kill pid • kill -HUP pid • kill -9 pid • kill -STOP pid • kill -CONT pid • kill -INT pid • killall pattern • RTFM

  15. The top command is your friend • Top lists the top resource pigs on your system at the time. It's useful for finding out why your machine is so slow.

  16. Processes beget processes • Init process starts sshd • Sshd starts login • Login spawns a shell • Apache spawns perl, which runs neomail. • It's another big happy Unix tree.

  17. Eavesdropping for the perverse • You can eavesdrop on processes with the strace command, if there's no other way to find out why they're being evil. • strace -p processid • strace command line

  18. Conclusion. • Everything in Unix is trees of files. Understand files, and processes, and you understand Unix. • Everything in action is a process. Understand processes and you understand the system in action. • Files are physical reality, processes are spiritual.

  19. Homework. • Look at processes on your system. Start processes, stop them, kill them, eavesdrop on them. • Look around your filesystem. Examine files, and get a feel for the structure and design of the tree. • Look at the kernel files in /proc • Learn a couple of the following and run them in strings to have effects on things: cat, sort, uniq, grep, more, tee • Read chapters 2, 3, 4, and 9 from rute.

  20. Questions?

More Related