You are on page 1of 2

Command Line Wizardy

Hey Welcome to more fun with commands and I will teach you slowly how to become a command line ninja. If
you are making the transition from windows then please check out my other posts on Linux commands and if
you are here to make progress you are in the right place so let's get cracking and discover some commands
and concepts.
Piping and Redirection
A pipe is a form of redirection that is used in Linux and other Unix-like operating systems to send
the output of one program to another program for further processing.
ps -aux

The above commands displays information about processes their status and resource useage

If you run the command as it is you will not be able to read everything! this is where the pipe
comes in handy

( ps -aux running without pipe )



To make the command easier to read we pipe ( | ) the command with the more command

ps -aux | more

Alternative you can use less

ps -aux | less



Using Grep in Pipes

We will run the ps -aux command to show us all the processes running on the system. But this
time we will pipe the output of the command using the grep utility. Which we can use to find
specific information



For instance in the above example we run the command ps -aux and we use grep to only show
instances of where the word bash occurs.



So you can use grep to find a specfic word from command results


Redirection

We use piping to chain commands together we can also use command line redirection to redirect
results of a command to a location. This could be a text file, or a special file such as a device file.



Again in the above example we are running the command ps -aux and redirecting the results of the
command into a text file called test.txt

To view the contents of the test.txt

You might also like