41 - Programs Processes and Scripts: Processes Commands in Linux
41 - Programs Processes and Scripts: Processes Commands in Linux
Michel Bisson
Types of processes - Programs - Daemons (detach themselves from the process that launched it)
Commands to display the processes ASCIIPrograms pscauxOt|less c=Commands only without parametersa=all started from tty u=process owner (user) x=All Processes not started from tty Ot=Order of process types |less=show scrollable output psfChttpd Shows all the httpd processes pscaux|grephttpd """"" pscauxf|less Shows processes with hierarchy tree pstreep|less (processes hierarchy tree with PID) pseo%p%P%U%n%a Custom list -> PID-PPID,User-Nice-Cmd+Args pseo%p%u%n%y%x%c%asortuser|less Custom list -> PID-User-Nice-tty-Time-Command-CmdArgs pseopid,ppid,user,nice,comm,argssortuser|less Custom list -> PID-PPID-User-Nice-Command-CmdArgs pseopid,user,bsdstart,comm,args|less Custom list ->PID-User-StartTime-Command-CmdArgs pidofprocessname Gives a list of PID's for this process top Curent processes with refreshes. Type 'h' for help screen watchn1pscaux Refreshes every second aliaswps="watchn1'pscaux|grepxxxx'" X-Programs kpm is standard kpstree (Good) ksysguard from SuSE CD (Good) gtopand procman from the gnome packages
Ending processes ASCIIPrograms kill<ProzessNummer> (Default is 15 SIGTERM) kill9 <ProzessNummer> killall<Prozessname> (Defaultis15 SIGTERM) killall9<Prozessname> killl Lists the kill messages options When a process dies it sends a SIGHUP to all of its children XPrograms kpmandksysguardpakages are standard (Good) ktopon CD only with older Distributions as 8.1 xzapon CD only with older Distributions as 8.1 qps on CD
41_Processes.odt - 1
Michel Bisson
Show lots of info about the system processes and kernel setup etc. procinfo[afn1] f refreshes (default every 5 sec) a shows all info possible n1 refreshes every sec Starting a program with another Nice value: nice[npriority]ProgramName Note 1: nice needs a first '' before the priority. or n eg.nice12prgm(starts prgm with nice value of 12) or nicen12 prgm(does the same) Note 2 : Default nice values: - Starting program without nice: 0 - Starting program with nice: +10 To show all the modules or library modules (.so) a program uses: lddProgramName Changing the NICE priority for an already running process: renicepriorityPID priority is : 20 to 19. Note:Userscannotassignanewpriorityhigherthatthecurrentone Sarting a new process after the last background process has finished wait$!;NewProcess WheresomePIDofrunningprocessesappear ListthePID'softherunningprocessname ListthePID'softherunningprocessname
Role of /proc directory : Stores a directory per process ps Status column Description DUninterruptible sleep RRunnable (On the running queue) SSleeping TTraced or Stopped ZZombie ....dead but not completely taken out of system yet. WNo Resident Pages reserved. X Dead process(should never be seen) BSD format extra status <Niced to Higher priority as 0 (-1 to -20) NNiced to lower priority as 0(1 to 19) LPages locked in to memory (Custom IO -Realtime system) sSession leader lMultithreaded +Foreground process
41_Processes.odt - 2
Michel Bisson
ToKillallprocessesthatuseamountedfilesystemtofreeitupbeforeunmountingit:
fuserkmmountpoint
Bash Jobs
Command&
%[+n]orfg fg%jobNr or %jobNr or jobsx Programname bg bg%jobNo. or %jobNo.& <Ctrl>Z %[+n]& jobs or
Start an active job in background Shows also job number in square brackets and PID Activatesthelastjobinbackground[+]andputitinforeground. Activatesajobandputsitintheforeground
Activatesthelastjobandputitinbackground. ActivatesastoppedjobandkeepsitintheBackground Sends foreground job as stopped in background bg[+n] Resumes the last stopped job as running in the background Listallthejobsofthisshell Theresultwillbeshownasfollows: (xisthejobnumber) [x]+ Thelastjobstartedinthebackground [x] Thejobstartedinthebackgroundbeforethelastone.
41_Processes.odt - 3