Saturday, May 27, 2023

Linux Command Line Hackery Series - Part 5



Welcome back to the Linux Command Line Hackery series, this is Part-V of the series. Today we are going to learn how to monitor and control processes on our Linux box, so wrap your sleeves up and let's get started.

Command:    ps
Syntax:           ps [options]
Description:  ps displays information about the currently running processes. Some of the common flags of ps are described briefly below
Flags: 
  -A or -e -> select all processes
  -a -> select all processes except both session leaders and processes not associated with a terminal.
  T -> select all processes associated with current terminal
  -u <username or id> -> select all processes of a given user or userlist

Open up a terminal and type ps:

ps

what you'll see is a list of processes currently running in your terminal. One important thing to notice in the output is what's called as PID which stands for process ID. It is the number that uniquely identifies a process. Just keep that PID concept in mind we'll use it soon.

OK I know that's not really what you want to see rather you want to see all the processes that are currently running on your box. Don't worry we have flags to rescue, in order to see all the processes you can use the -e flag like this:

ps -e

Boom! you get a long list of processes currently running on your machine (don't stare at me like that, you asked and I gave you that). If you want to see processes of a particular user you can type the following command in your terminal:

ps -u bob

here "bob" is a username. This command will list all processes of the user with effective user name of bob.

You can do a full-format listing of the processes using the -f flag like this:

ps -fu bob

But the output of the ps command is a snapshot not really a live preview of what is going on in your box. I know your next question is going to be something like this, Isn't there a command in Linux that gives me a live updating information of the processes? Yes, there is a command called top that we'll learn about next.

Command:    top
Syntax:           top [options]
Description:  top gives a dynamic real-time view of a running system. That is, it gives the up-to-date information about all the processes running on your Linux box (sounds fun!). Besides giving information about current processes and threads top also provides a brief system summary.

To start top just type this command:

top

and you'll get a nice and cute looking ugly display :). Well what the heck is going on here you might ask, right? What you get is information about what is going on with your computer. To see what more can you do with top just type <h> within the program window and you'll be given list of options that you can play with.

OK looking at what processes are going on in your box is cool but what if you want to terminate (or close) a process, is there a command line utility for that? Yes, there is and that's what we are going to look at next.

Command:   kill
Syntax:          kill [options] <pid> [...]
Description:  kill is used to send a signal to process which by default is a TERM signal meaning kill by default sends a signal of termination to process (Cruel guy). To list the available signals we can use the -l or -L flag of the kill command.


To simply terminate a process we provide kill command a PID (process ID) and it will send the TERM signal to the process. So to kill a process first we'll list the running processes and then we'll keep the PID of the process in mind that we want to terminate. After that we'll issue the kill command with the PID that we just found.

ps -ax
kill 1153

the above command will send a TERM signal to the process whose PID is 1153, as simple as that.

We can also use our already learned skills to refine the output of ps command. Say we have a xterm terminal running on our box and we want to terminate it. By using ps command all alone we'll get a long listing of all processes running on our box. But we can limit the output of ps command to just those processes that we're interested in by piping ps command with the grep command like this:

ps -ax | grep xterm

wow! that's amazing, we're able to pull out only those results from the ps command that contained xterm in them. Isn't that a cool trick? But what is that vertical bar ( ) doing in the middle, you may be thinking, right? Remember we learned about the input and output re-directors previously, the vertical bar (pipe in geeky terms) is another re-director whose task is to redirect the output of one command as input to another command. Here the pipe redirects the output of ps -ax command as input to grep command and of-course from the previous article you know that grep is used to search for a PATTERN in the given input. That means the above command searches for the xterm word in the output of ps -ax command and then displays just those lines of ps -ax command which contain xterm. Now get that PID and kill that process.

That's it for today, try these commands up on your own box and remember practice is gonna make you master the Linux command line. :)

Related articles


  1. Pentest Tools
  2. Hacking Tools Online
  3. Best Hacking Tools 2020
  4. Pentest Tools Url Fuzzer
  5. Hack App
  6. Best Pentesting Tools 2018
  7. Hackers Toolbox
  8. Hacking Tools
  9. Pentest Tools Android
  10. Hacking Tools Usb
  11. Hack Tools For Mac
  12. Pentest Tools Review
  13. Pentest Tools Subdomain
  14. Pentest Tools Windows
  15. Hacker Tools 2019
  16. Pentest Tools For Ubuntu
  17. Ethical Hacker Tools
  18. Hack Tool Apk No Root
  19. Best Hacking Tools 2019
  20. Hacking Tools For Windows Free Download
  21. Free Pentest Tools For Windows
  22. Easy Hack Tools
  23. Hacker Tools Mac
  24. Hacking Tools Software
  25. Hacker Tools Hardware
  26. Beginner Hacker Tools
  27. Wifi Hacker Tools For Windows
  28. Kik Hack Tools
  29. Hack Rom Tools
  30. Hacker Tools Hardware
  31. Hacker Tool Kit
  32. What Are Hacking Tools
  33. Pentest Tools List
  34. Hacking Tools Hardware
  35. Hak5 Tools
  36. Pentest Tools Github
  37. Hak5 Tools
  38. Nsa Hack Tools
  39. Pentest Tools Tcp Port Scanner
  40. Pentest Tools Github
  41. Hacking Tools For Kali Linux
  42. Pentest Recon Tools
  43. Pentest Tools Apk
  44. Termux Hacking Tools 2019
  45. Hacking Tools Online
  46. Hacker Tools Hardware
  47. Hack Rom Tools
  48. Hacker Tools List
  49. Best Pentesting Tools 2018
  50. New Hack Tools
  51. Pentest Box Tools Download
  52. Hack Apps
  53. Hacker Tools Free
  54. Tools 4 Hack
  55. Hacker Hardware Tools
  56. Hacker Tools 2019
  57. Hacker Tools For Windows
  58. Pentest Tools Windows
  59. Pentest Tools Kali Linux
  60. Hacking Tools Windows
  61. Termux Hacking Tools 2019
  62. Hacker Security Tools
  63. Hacker Tools Apk Download
  64. Pentest Tools Open Source
  65. Pentest Tools Framework
  66. Hacking Tools For Windows Free Download
  67. Hack Apps
  68. Install Pentest Tools Ubuntu
  69. Pentest Tools Windows
  70. Hacker Search Tools
  71. Pentest Tools Subdomain
  72. Hacker Tools For Pc
  73. Hacker Tools
  74. Tools 4 Hack
  75. Hacking Tools Usb
  76. Hacking Tools Online
  77. Hackers Toolbox
  78. Black Hat Hacker Tools
  79. Hacking Tools Name
  80. Hack Tools Mac
  81. Hacking Tools Mac
  82. Ethical Hacker Tools
  83. Hacker Tools Online
  84. Pentest Tools Windows
  85. Hacker Tools Mac
  86. Blackhat Hacker Tools
  87. Black Hat Hacker Tools
  88. Pentest Automation Tools
  89. Hacking Tools Github
  90. Hack Tools For Pc
  91. Pentest Tools Linux
  92. Hacks And Tools
  93. Hacking Tools Free Download
  94. Ethical Hacker Tools
  95. Top Pentest Tools
  96. Hacker Tools Apk
  97. Computer Hacker
  98. Tools 4 Hack

No comments:

Post a Comment