Skip to main content

The Unix Tip of the Day

Hi ALL

it's Been  long time since last unix/linux tips , so today we will learn to use ps / grep / awk / xargs / kill in one long command .. .

ps :    prints information about selected processes. Use options to specify which processes to select and what information to print about them .

grep :  The grep command searches the input text files (standard input
default) for lines matching a pattern.  Normally, each line found is
copied to the standard output.  grep supports the Basic Regular
Expression syntax (see regexp(5)).  The -E option (egrep) supports
Extended Regular Expression (ERE) syntax (see regexp(5)).  The -F
option (fgrep) searches for fixed strings using the fast Boyer-Moore
string searching algorithm.  The -E and -F options treat newlines
embedded in the pattern as alternation characters.  A null expression
or string matches every line.

awk :   awk scans each input file for lines that match any of a set of
patterns specified literally in program or in one or more files
specified as -f progfile.  With each pattern there can be an
associated action that is to be performed when a line in a file
matches the pattern.  Each line is matched against the pattern portion
of every pattern-action statement, and the associated action is
performed for each matched pattern.  The file name - means the
standard input.  Any file of the form var=value is treated as an
assignment, not a filename.  An assignment is evaluated at the time it
would have been opened if it were a filename, unless the -v option is
used.

An input line is made up of fields separated by white space, or by
regular expression FS.  The fields are denoted $1, $2, ...; $0 refers
to the entire line.

xargs :   xargs combines the fixed initial-arguments with arguments read from
standard input to execute the specified command one or more times.
The number of arguments read for each command invocation and the
manner in which they are combined are determined by the options
specified.

kill :   The kill command sends a signal to each process specified by a pid
process identifier.  The default signal is SIGTERM, which normally
terminates processes that do not trap or ignore the signal.


now , it's time to run some examples :

>ps    # that is what we have running on the Back Ground ..


>ps | grep sleep    # here we filter from the general output the rows with the word sleep



>ps | grep sleep | awk '{print $2}'      # here we cut the second string form every row , which is the PID



> ps | grep sleep | awk '{print $2}' | xargs -i kill -9 {}   # here we kill the process we filtered on by one by using xargs and the stoping the process with signal 9 by using kill .



and here is the final status :





Comments

Popular posts from this blog

ESP32-C6 Wi-Fi Logger with Browser GPS + Heat Map Dashboard

This project is an ESP-IDF firmware for the Seeed Studio XIAO ESP32-C6 that turns the board into a self-hosted, secure Wi-Fi scanning logger. It creates its own access point, serves a responsive HTTPS web UI, logs nearby Wi-Fi access points, optionally tags rows with GPS coordinates (provided by the client browser), and exposes battery status from the on-board LiPo input. The end result is a pocket Wi-Fi “survey” tool: scan, track, export logs as CSV, and generate a heat map view to visualize RSSI vs location. Project overview and feature set: :contentReference[oaicite:1]{index=1} What it does AP + Station mode so the device can serve the dashboard while scanning nearby Wi-Fi networks. HTTPS web interface using a bundled certificate/key for local secure access. Single scan and continuous tracking modes. CSV export for analysis and archiving. Persistent logging to SPIFFS at /spiffs/logs.csv . Battery monitoring via ADC with voltage/percentage/status sh...

learn how to sniff wireless passwords with pirni

The thing about the iPod Touch and the iPhone is that they are great portable hacking devices. To the naked eye the iPod Touch/iPhone looks like nothing more than an ordinary mp3 player/cellphone however that is just an understatement to its full potential. Once your Ipod Touch/iPhone is jailbroken you have access to your whole file system meaning that applications generally associated with laptop/desktop hacking can be ported and used on the iPod Touch/iPhone. This opens up a whole lot of possibilities for network sniffing, port scanning and much much more! In this tutorial we are going to take a look at one of these programs called Pirni. What is Pirni? Pirni is an application that was ported to The Ipod Touch/iPhone to be used as a native network sniffer. Pirni is so useful because it gets past the iPod Touch’s/iPhone’s wifi hardware limitation of not being able to be set into promiscious mode (a mode that allows a network device to intercept and read each network packet that arrive...

how to run a GUI application throw SSH using X11

soo all we need is first to install the ssh server on the server - machine we like to control so - 1. sudo su 2. apt-get install openssh-server . . now back to our machine using the ssh : 1. ssh -V -X username@the-server-ip 2. enter the password and that is it now we can run any GUI application that install on the server using his CPU cycles yahhhh great !! for example lets run WireShark : 3. gksudo wireshark & now all that if we runing tow Linux machines !! but what windows users that like to run a linux app??! !! soo we need it tow applications 1. putty you can get it here : http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html 2.Xming you can get it here : http://sourceforge.net/projects/xming/ ok so first we need to install Xming , and after that we going to use butty but we need to cheak Enable X11 forwarding in connection -- > SSH -- > X11 >> Enable x11 forwarding . and that is it free to run any linux application on windows using SSH . have fun ...