Uncategorized Archives - The Linux GURUS https://thelinuxgurus.com/category/uncategorized/ Learn Linux & DevOPS from THE LINUX GURUS Tue, 14 Jul 2020 14:57:58 +0000 en-US hourly 1 https://i0.wp.com/thelinuxgurus.com/wp-content/uploads/2020/01/cropped-thelinuxgurus_transparent_name.png?fit=32%2C32&ssl=1 Uncategorized Archives - The Linux GURUS https://thelinuxgurus.com/category/uncategorized/ 32 32 148921671 Install & learn to use TCPDUMP with examples https://thelinuxgurus.com/install-learn-to-use-tcpdump-with-examples/ https://thelinuxgurus.com/install-learn-to-use-tcpdump-with-examples/#respond Tue, 14 Jul 2020 14:57:58 +0000 https://thelinuxgurus.com/?p=1177 Monitoring is one of the crucial tasks of a SysAdmin & it’s useful in identifying any issues with our systems or networks. Once an issue...

The post Install & learn to use TCPDUMP with examples appeared first on The Linux GURUS.

]]>
Monitoring is one of the crucial tasks of a SysAdmin & it’s useful in identifying any issues with our systems or networks. Once an issue has been identified, we can then resolve it. In this article, we are going to discuss one such tool, basically, it’s a command-line utility called TCPDUMP Command.

Tcpdump command is a network packet analyzing tool that allows us to monitor our network traffic. Using it, we can check the TCP\IP & other network packets being transmitted over the network interfaces attached to our servers.

Recommended Read: Examples on how to use PS COMMAND in Linux

Also Read: Top Linux commands to monitor NETWORK

Tcpdump command uses libpcap library to capture the network packets. We can check the network packets in real-time or we can also save it to a file, which we can check later. To use the tcpdump command, we should use it with root user or with a user with sudo privileges.

Here, we will be discussing how we can install & use TCPDUMP with examples. So let’s start,


Install TCPDUMP command in Linux

In most cases, we already should have tcpdump installed on most of the Linux distributions, but if it’s not then you can use one of the following commands to install it your system.

CentOS/RHEL 6 & 7

$ sudo yum install tcpdump

Fedora/CentOS/RHEL 8

$ dnf install tcpdump

Ubuntu/Debian/Linux Mint

$ apt-get install tcpdump

Now let’s learn how we can use it to monitor our network traffic.


TCPDUMP command examples

Check network traffic from all network interface

To get the network packets from all network interfaces, run the following command,

$ tcpdump -i any


Check network traffic from only a single network interface

To get the network packets from a single interface, use

$ tcpdump -i enp0s3


Getting captured network packets to a file

To write all the captured packets to a file, use the ‘-w’ option,

$ tcpdump -i eth1 -w packets_file


Reading a network packets file

To read an already created, old tcpdump file, use the following command,

$ tcpdump -r packets_file


Check packets for a protocol or port number

To check all the packets used based on the protocol, run the following command

$ tcpdump ssh

To get packets for a single port ot for a range of ports, use

$ tcpdump port 80

$ tcpdump portrange 20-200

We can also use ‘src’ & ‘dst’ options to get packets for ports based on source & destination.

We can also combine two conditions (example mentioned below) with AND (and , && ), OR ( or. || ) & EXCEPT (not , ! ). This helps when we have analyzed network packets based on some conditions.


Getting more packets information with readable timestamps

To get more information regarding the packets along with the readable timestamp, use

$ tcpdump -ttttnnvvS


Capture network packets of a network range

To get the packets for a network, execute the following command from the terminal

$ tcpdump net 10.10.1.0/24


Check network packets for a single IP address

To capture network packets for a single IP address, whether source or destination or both, use the following command,

$ tcpdump host 10.10.1.12

To get packets based on source or destination of an IP address, use

$ tcpdump src 10.10.1.12

$ tcpdump dst 10.10.1.12


Using AND

We can use ‘and’ or symbol ‘&&’ to combine two conditions or mote with tcpdump. An example would be,

$ tcpdump src 10.10.1.12 && port 22 -w ssh_packets


Using OR

OR will check the command tcpdump -i eth0 src port not 22ainst one the mentioned conditions in the command, like

$ tcpdump src 10.10.1.12 or dst 10.10.1.30 && port 22 -w ssh_packets

$ tcpdump port 443 or 80 -w http_packets


Using EXCEPT

EXCEPT will be used when we want to leave out something to fulfill a condition, like

$ tcpdump -i enp0s3 src port not 22

This will monitor all the traffic on eth0 but will not capture port 22.


Using Help

These were only some examples that we can use with tcpdump command. There are plenty of other options that we can use with tcpdump command, & like with other Linux commands, we can refer to help to check all the options,

$ tcpdump –help

Please feel free to send in any queries or suggestions using the comment box below.

If you think we have helped you or just want to support us, please consider these:-

Connect to us: Facebook | Twitter | Linkedin

TheLinuxGURUS are thankful for your continued support.

The post Install & learn to use TCPDUMP with examples appeared first on The Linux GURUS.

]]>
https://thelinuxgurus.com/install-learn-to-use-tcpdump-with-examples/feed/ 0 1177
Simple guide to install MongoDB on Ubuntu 18.04 https://thelinuxgurus.com/simple-guide-to-install-mongodb-on-ubuntu-18-04/ https://thelinuxgurus.com/simple-guide-to-install-mongodb-on-ubuntu-18-04/#respond Fri, 24 Jan 2020 07:04:22 +0000 https://thelinuxgurus.com/?p=1037 MongoDB is a free & open-source No-SQL database, it uses JSON like document format to store data in the database which is unlike the SQL...

The post Simple guide to install MongoDB on Ubuntu 18.04 appeared first on The Linux GURUS.

]]>
MongoDB is a free & open-source No-SQL database, it uses JSON like document format to store data in the database which is unlike the SQL database, where data is stored in a row & column-based format.

MongoDB is very fast & has great performance when compared to the SQL database. MongoDB databases are very easy to scale & they also address various shortcomings that other SQL databased present. MongoDB is completely ideal for the types of DB required to handle the data that we have today i.e. big data, IoT, online gaming, etc.

Recommended Read: Scheduling CRON Jobs with Crontab for Beginners

Also Read: Ultimate guide to install PYTHON from source

In this tutorial, we will learn to install MongoDB on Ubuntu 18.04. There are two methods with which we can install MongoDB on Ubuntu 18.04,

1- Install using apt manager,

2- Install using tar packages.


1- Install MongoDB on Ubuntu 18.04 using apt

We need to first make sure that “gnupg” package is installed on the system or not, cause we will receive an error while importing the public keys for mongodb if it’s not installed. Install it with the following command,

$ sudo apt-get install gnupg

Next, we will import the public keys for MongoDB,

$ wget -qO – https://www.mongodb.org/static/pgp/server-4.2.asc | sudo apt-key add –

Next, we will create the list file for MongoDB with the following command,

$ echo “deb [ arch=amd64 ] https://repo.mongodb.org/apt/ubuntu bionic/mongodb-org/4.2 multiverse” | sudo tee /etc/apt/sources.list.d/mongodb-org-4.2.list

Now reload the repositories for packages,

$ sudo apt-get update

Now to install MongoDB on Ubuntu 18.04, execute

$ sudo apt-get install -y mongodb-org

Or to install a specific version, use

$ sudo apt-get install -y mongodb-org=4.2.2 mongodb-org-server=4.2.2 mongodb-org-shell=4.2.2 mongodb-org-mongos=4.2.2 mongodb-org-tools=4.2.2


2- Install MongoDB on Ubuntu 18.04 using tar packages

Before we can download & install mongodb using tar packages. We must have some packages installed on our servers,

$ sudo apt-get install libcurl4 openssl

We will create a directory for keeping the mongodb packages,

$ mkdir -p /data/mongodb

Next, we have to download the package using the following command,

$ wget https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-ubuntu1804-4.2.2.tgz

Next, we need to extract the file to the created directory,

$ tar -xvzf mongodb-linux-x86_64-ubuntu1804-4.2.2.tgz -C /data/mongodb

Next, we will create symbolic links to the binaries directory,

$ sudo ln -s /data/mongodb/bin/* /usr/local/bin/

Now, we need to create a data directory & log directory as well,

$ sudo mkdir -p /var/lib/mongo

$ sudo mkdir -p /var/log/mongo

Next, we have change ownership of these folders to mongod,

$ sudo chown -R mongod:mongod /var/lib/mongo

$ sudo chown -R mongod:mongod /var/log/mongo

Note: When installing using apt package manager, all these folders are created by the system only with required permissions.


Starting & connecting MongoDB

Once we have installed mongodb, we can start the database with the following command,

$ sudo systemctl start mongod

Also, we can use the following command to start db,

$ mongod –dbpath /var/lib/mongo –logpath /var/log/mongodb/mongod.log –fork

Now to connect to the database,

$ mongo


Connecting database from remote systems

By default, we can only connect the database from the localhost & to be able to connect the database from other systems, we need to make configuration in mongodb configuration file,

$ sudo vi /etc/mongod.conf

& look for “net.bindIp”, then change it the following

net.bindIp 0.0.0.0

You can also change & mention a single remote IP address if you only need to connect from a single remote system. After making the changes, you need to restart the database to implement the changes made,

$ sudo systemctl stop mongod

$ sudo systemctl start mongod

Note:- If running database through CLI, we can mention the parameter “–bind_ip” followed by ‘0.0.0.0’ for connecting from all remote IPs or we can also mention a single IP address.

That’s it guys, we now end this tutorial on how to install MongoDB on 18.04. Please do send us your questions, queries & suggestions using the comment box below.

If you think we have helped you or just want to support us, please consider these:-

Connect to us: Facebook | Twitter | Linkedin

TheLinuxGURUS are thankful for your continued support.

The post Simple guide to install MongoDB on Ubuntu 18.04 appeared first on The Linux GURUS.

]]>
https://thelinuxgurus.com/simple-guide-to-install-mongodb-on-ubuntu-18-04/feed/ 0 1037