in

Commands To Remove Unused Packages & Get Linux Server IP Address

Linux Tips & Tricks

Hello friends, In this article, we added 6 basic tips to Linux users. These command line codes dealing with removing the unused or unwanted packages from the Linux server, getting the IP of your Linux based PC, getting local and remote IP using Linux command lines, preview colorful terminal in output using the command line & ultimately hashtags implementation in Linux Server.

Jump To:

  • How to remove unused packages in Linux?
  • How to get local and remote server IP address?
  • How to color your Linux terminal?
  • How to implement Hashtags in Linux server?
  • How to create command line chats?
  • How to add (sum) values in a column in Linux?

How to remove unused packages in Linux:

This unused package is otherwise named as “Orphan Packages”, these are installed as the dependency of another package. This package no longer required when the original package is removed. For instance, we installed a package named as “gtprogram“. Without gtdependency, we can’t install the gtprogram.

When you tried to uninstall the gtprogram application it will remove completely but the gtdependency will exist on the pc by default. This package can be termed as an Orphan package.

yum autoremove

How to use? Copy the above code and paste in terminal

How to get a local IP address in your Linux PC:

To get you Linux pc IP address and then we suggest you use the below commands.

ifconfig | grep “inet addr:”

How to use? Copy the above code and paste in terminal

The above code will provide you with the IP address of your Linux PC. As you know “ifconfig” is mainly used to show the IP address, but it generates a lot of IP address with your PC address. To filter out your PC address and then you need to add “inet addr” with the “if config” & as a result, the IP address will appear on your Linux terminal.

Get Local IP Address
Get Local IP Address

We can create the output more custom now. For this, we need to create a filter our local IP address and remaining should be nothing. You just need to use “awk” along the above code. This code will print the second column of your IP address list.

ifconfig | grep “inet addr:” | awk ‘{print $2}’

How to use? Copy the above code and paste in terminal

awk if config
awk if config

From the above image that you will be able to customize your output IP address list and the look back IP address is 127.0.0.1 is still in the output. To remove this follow the below method.

ifconfig | grep “inet addr” | awk ‘{print $2}’ | grep -v ‘127.0.0.1’

Check this too  10+ CronJob Scheduling Task In Linux Using Terminal

How to use? Copy the above code and paste in terminal

Here “-v” with grep will print the lines which are not matched with the given arguments. The look back IP address will be the same for every Linux machines and by using “-v” along with grep will helps you to remove the unwanted IP address. On this step, we completed 90% of creating the output.

The remaining 10% can be achieved by executing the following commands. Replace the strong “addr” with “cut” following by the using of delimiter -d. The “cut” command will help you to print the first and second column. Usually, the first column and second column will not tab but by using (:). By using the “-d” will generate the output alone in the command line.

ifconfig | grep “inet addr:” | awk ‘{print $2}’ | grep -v ‘127.0.0.1’ | cut -f2 -d:

How to use? Copy the above code and paste in terminal

Print IP address alone
Print IP address alone

Ultimatlely the final output has been generated.

How to colour your Linux Terminal:

You guys will get easily bored of seeing the black & white colour terminal. So here we are going to provide the command line codes that will help you to convert your terminal from black & white to colourful terminal.

The file “.bashrc” is mainly used to handle the output of terminal. You need to edit the directory and then change the following codes inside the “.bashrc” file. This file is hidden usually in Linux and you just need the add the codes at the beginning of the codes, Simple right !!.

vi /home/$USER/.bashrc

How to use? Copy the above code and paste in terminal

Use the above command to open the terminal handler file and then add the following codes in the top of the file.

Add codes inside the .bashrc
Add codes inside the .bashrc

Then restart the Linux Server and open the terminal now, you will be able to see the terminal has been changed from black & white to colourful terminal.

Colorful Linux terminal
Colourful Linux terminal

Image Credit: Wikipedia

The files and folder are in a different colour based on the type of file. To decode the colour of the files and folder you just add the following command in the terminal.

dircolors -p

Check this too  Bash For Loop Command & Examples Ubuntu 18.04, 19.04 & Debian Distros

How to use? Copy the above code and paste in terminal

The output of the above code is very large and it will take a huge time consumption to get the end. And so we suggest you use the following command will show the lesser output.

dircolors -p | less

How to use? Copy the above code and paste in terminal

Decolour less command line
Decolour less command line

How to implement Hashtags in Linux Server:

The usage of Hashtags here is mainly for searching. Searching a keyword with # will make the process very very simple as possible. This method is already used in the famous social websites like Facebook & Twitter. Only pro guys will know that it is possible to use the Hashtags in the Linux terminal.

Most of the languages consider it as the # as the comment. In Linux, the Hashtags are used in the configuration files. For finding through the Hashtags you just need to run a sample command initially and then to find it later using the Hashtags.

As a sample, we create the hashtags for the previous command and execute it. Then we will able to find the value of the hashtags that have been stored previously.

ifconfig | grep “inet addr:” | awk ‘{print $2}’ | grep -v ‘127.0.0.1’ | cut -f2 -d: #mypcip

How to use? Copy the above code and paste in terminal

The above code is tagged with “mypcip” hashtag. In the terminal, just enter the hashtag name with “#” the value of the hashtag will appear on the terminal otherwise you just the enter the following command to view the hashtag value and the command is “reverse-i-serach

Implement Hashtags in command line
Implement Hashtags in the command line

How to create command line chat in Linux:

We can create command line chat box using the terminal in the Linux. Everyone knows that the most famous messaging or chat applications are “Whatsapp, Fb Messenger & phone messaging app”. This Linux terminal chat box can be able to chat with your friends using their IP address. This chat is faster than any other messaging applications.

The Linux chat can be achieved through the NC method. The term NC means “Net Cat” method. This method is one of the most powerful methods and so it is compared to many other important things in Linux commands. The usage of NC methods are :

  • Debug tool
  • Diagnosing tool
  • Investigation tool
  • Reading tool
  • Writing tool
  • Reverse DNS checking tool
  • and more
Check this too  DF Command in Linux: DF Command to Check Disk Space in Linux

This NC method will work on the port and so it is mainly used to monitor the backdoors, port configurations and port incoming and outgoing bandwidth reference details. To create an instance chat application just follow the code in the terminal.

nc -l -vv -p 24322

How to use? Copy the above code and paste in terminal

Explanation of Switches and Commands:

  • -v : Verbose
  • -vv : More verbose (multiply for verbose)
  • -p : Local port address
Command Line Chat Linux
Command Line Chat Linux

You can terminate the chat session by clicking the “ctrl + cotherwise execute the command “one-to-one” service.

How to Add (Sum) two values in the command line:

The following command will help you to add the two values in the column. The output of the function will appear in the terminal too. The command for adding the two values is :

ls -l

How to use? Copy the above code and paste in terminal

Adding two values in column
Adding two values in column

To Print Particular Column Value:

The above code will print the output value in the numerical form, For printing the particular column value you must need to do some extra work and they are:

ls -l | awk ‘{print $5}’

How to use? Copy the above code and paste in terminal

Adding particular column value
Adding particular column value

The above code will list the value of column 5 and nothing else. $5 represents the column number & “awk” used for filter purpose. Now again use the “awk” code to print the sum of the 5th column values and the following code will do that function.

Adding the Particular column values
Adding the Particular column values

That’s it, friends. We are working very very hard to provide a good articles for improving your knowledge on the Linux platform and the above 6 tips will enhance your Linux skill. If you have any queries and then feel free to comment us and we will reply soon.

  • Article Length
  • Content Explanation
  • Image Explanantion
  • Content Clarity
4.7

Summary

In this article, we wrote some important, basic tips and tricks in Linux. Try this and enhance your Linux skills.

Leave a Reply

Your email address will not be published. Required fields are marked *

Written by Rachel

I'm Rachel, From Arizona. Am playing the "Content Management" Role in Tec Robust. I started working in TR from Jan 2019. Big Marvel Fan.

Contact me:
tecrobust [@] gmail.com
Sub: Message to Rachel

Basic Linux Commands

Basic Linux Commands & Codes for Beginners[Ubuntu & Mint & More]

Best Linux Apps

Install Google Chrome on Ubuntu Unity 18.04.1 LTS