Hack Like a Pro: Linux Basics for the Aspiring Hacker, Part 8 (Managing Processes) « Null Byte :: WonderHowTo

Welcome back, my novice hackers!In my continuing effort to develop your Linux skills, I now offer you this eighth in my series forLinux Basics for the Aspiring Hacker. In this tutorial, we'll look at system processes and how to manage them.In Linux, a process is a program running in memory. Typically, your computer is running hundreds of processes simultaneously. If they're system processes, Linux folks refer to them asdaemonsordemons. You will often see the process name ending with a "d" suchhttpd, the process or daemon responsible for the http service.Step 1: See What Processes Are RunningWe can see all the processes running on your system by typing:ps auxThese switches will provide all processes (a), the user (u) ,and processes not associated with a terminal (x). This is my favorite set of switches for usingpsas it enables me to see which user initiated the process and how much in resources it's using.Note that each process listed shows us among many things.userPID (process identifier)%CPU%MEM (memory)If we just wanted to see the all the processes with limited information, we can type:ps -AYou can see all the processes running, but without such information as CPU percentage and memory percentage. Note thatairbase-ngis listed withPID 5143and the last process is thepscommand.Process numbers, or PIDs, are critical for working in Linux, as you often need the PID to manage a process. As you might have seen in some of myMetasploit tutorials, the PID often becomes critical in hacking the victim systems.Step 2: The Top CommandSimilar to thepscommand is thetopcommand, except that top shows us only the top processes. In other words, it only shows us the processes using the most resources and it's dynamic, meaning that it is gives us a real-time look at our processes. Simply type:topAs you can see, the processes are listed in the order by how much system resources they are using, and the list is constantly changing as the processes use more or less resources.Step 3: Killing ProcessesSometimes we will need to stop processes in Linux. The command we use iskill. Don't worry, it sounds more violent than it actually is. This command is particularly important if we have a process that continues to run and use system resources, even after we have tried to stop it. These processes are often referred to as "zombie" processes.We can kill a process by simply typing kill and the process ID or PID. So to kill my airbase-ng process, I can simply type:kill 5143We can see in the screenshot above that my airbase-ng process is no longer running.There are many types of "kills". The default kill (when we use the kill command without any switches) iskill 15or the termination signal. It allows the process to cleanup and gently terminate its process.Sometimes, processes still refuse to terminate even when sent the default kill command. In that case, we have to get more serious and use the absolute terminator to do the job. This iskill -9, which takes no prisoners and ends the job without allowing it to say its goodbyes and forces the kernel to terminate it immediately.Step 4: Change Process PriorityEvery process in Linux is given a priority number. As you probably guessed, this priority number determines how important the process is and where it stands in line in terms of using system resources. These priority numbers range from 0 to 127 with 0 being the highest priority and 127 being the lowest.As the root user or system admin, we can't directly determine the priority of a process—that is the job of the kernel—but we can hint to the kernel that we would like a process to run with a higher priority. We can do this through thenicecommand. Nice values range from-20to+19with the lower values indicating a higher priority.We can set a processes' nice value by using thenicecommand, the-nswitch, thevalueof the nice, and then thecommandwe want to run. So, if if we wanted to start our airbase-ng process from ourEvil Twin tutorial with the highest priority, we could type:nice -n -20 airbase-ng -a 00:09:5B:6F:64:1E --essid "Elroy" -c 11 mon0Later on, if we felt that we wanted to reduce the priority of the airbase-ng command, we couldreniceit. The renice command requires simply therenicecommand, thepriority level, and unlike the nice command, it only takes the processPID, such as:renice 15 5143We can see that by renice-ing the airbase-ng command, we have reduced its priority from -20 (highest) to 15 (relatively low).Step 5: Push a Process into the BackgroundYou probably noticed in running some ofmy hack tutorialsthat when we run a command from the shell terminal, the process will take control of that shell until it is complete. If it's an ongoing process, similar to airbase-ng, it will maintain control of that terminal until we stop it. Until that time, we can't use that shell.If we want to still use that shell, we can send that process into the background and then get control of the shell again. To start a command in the background, we simply need to end the command with the&or ampersand. So, to get airbase-ng to run in the background, we simply type:airbase-ng -a 00:09:5B:6F:64:1E --essid "Elroy" -c 11 mon0 &If we want to bring a background job to the foreground, we simply typefg. To send a foreground processes to the background, we can typeControl Zto stop it and then and using thebgcommand with the PID to send it to the background.That's It for Now...Stay tuned for more Linux basics for the aspiring hacker. If you haven't checked out the other guides yet, make sure togive them a look. If you have any questions, make sure to comment below or start a thread in theNull Byte forumfor help.Want to start making money as a white hat hacker?Jump-start your hacking career with our2020 Premium Ethical Hacking Certification Training Bundlefrom the newNull Byte Shopand get over 60 hours of training from cybersecurity professionals.Buy Now (90% off) >Other worthwhile deals to check out:97% off The Ultimate 2021 White Hat Hacker Certification Bundle99% off The 2021 All-in-One Data Scientist Mega Bundle98% off The 2021 Premium Learn To Code Certification Bundle62% off MindMaster Mind Mapping Software: Perpetual LicensePenguins walkingandpenguin triophotos via ShutterstockRelatedNews:How to Study for the White Hat Hacker Associate Certification (CWA)Hack Like a Pro:Linux Basics for the Aspiring Hacker, Part 11 (Apache Web Servers)How To:The Essential Skills to Becoming a Master HackerHack Like a Pro:Linux Basics for the Aspiring Hacker, Part 12 (Loadable Kernel Modules)Hack Like a Pro:Linux Basics for the Aspiring Hacker, Part 1 (Getting Started)Hack Like a Pro:Linux Basics for the Aspiring Hacker, Part 6 (Networking Basics)Hack Like a Pro:Linux Basics for the Aspiring Hacker, Part 25 (Inetd, the Super Daemon)How to Hack Like a Pro:Getting Started with MetasploitHack Like a Pro:Linux Basics for the Aspiring Hacker, Part 9 (Managing Environmental Variables)Hack Like a Pro:Linux Basics for the Aspiring Hacker, Part 13 (Mounting Drives & Devices)Hack Like a Pro:Windows CMD Remote Commands for the Aspiring Hacker, Part 1Hack Like a Pro:Linux Basics for the Aspiring Hacker, Part 21 (GRUB Bootloader)How To:Linux Basics for the Aspiring Hacker: Using Start-Up ScriptsHack Like a Pro:Linux Basics for the Aspiring Hacker, Part 2 (Creating Directories & Files)Hack Like a Pro:Linux Basics for the Aspiring Hacker, Part 17 (Client DNS)Hack Like a Pro:Linux Basics for the Aspiring Hacker, Part 5 (Installing New Software)How To:Linux Basics for the Aspiring Hacker: Managing Hard DrivesHack Like a Pro:Linux Basics for the Aspiring Hacker, Part 15 (Creating a Secure Tunnel to MySQL)News:What to Expect from Null Byte in 2015Hack Like a Pro:Linux Basics for the Aspiring Hacker, Part 22 (Samba)Hack Like a Pro:Linux Basics for the Aspiring Hacker, Part 10 (Manipulating Text)Hack Like a Pro:Linux Basics for the Aspiring Hacker, Part 4 (Finding Files)Goodnight Byte:HackThisSite Walkthrough, Part 6 - Legal Hacker TrainingHack Like a Pro:Hacking Samba on Ubuntu and Installing the MeterpreterGoodnight Byte:HackThisSite Walkthrough, Part 8 - Legal Hacker TrainingCommunity Byte:HackThisSite Walkthrough, Part 6 - Legal Hacker TrainingGoodnight Byte:HackThisSite Walkthrough, Part 4 - Legal Hacker TrainingCommunity Byte:HackThisSite Walkthrough, Part 1 - Legal Hacker TrainingCommunity Byte:HackThisSite Walkthrough, Part 2 - Legal Hacker TrainingGoodnight Byte:HackThisSite Walkthrough, Part 10 - Legal Hacker TrainingGoodnight Byte:HackThisSite Walkthrough, Part 9 - Legal Hacker TrainingNews:Let Me Introduce MyselfCommunity Byte:HackThisSite Walkthrough, Part 10 - Legal Hacker TrainingHow To:How Hackers Take Your Encrypted Passwords & Crack ThemCommunity Byte:HackThisSite Walkthrough, Part 9 - Legal Hacker TrainingCommunity Byte:HackThisSite Walkthrough, Part 5 - Legal Hacker Training