10 Key IP Commands on CentOS 7 & RedHat 7

 How To, Linux  Comments Off on 10 Key IP Commands on CentOS 7 & RedHat 7
Sep 232018
 

Getting a good handle on IP commands will prove useful if you’re managing a Linux box.

Although ifconfig was deprecated and replaced with ip several years ago, some folks sill use ifconfig.

But it’s good to be aware of the basic ip commands when you’re managing a Linux server.

Here are a bunch of IP commands that were tested on my CentOS 7 box. They should work on a RedHat 7 system too.

1. How to Display IP Addresses

To see the IP addresses on your system and various interfaces, use the ip addr command.

[thomaspc@localhost ~]$ ip addr
1: lo:  mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: enp0s25:  mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether 00:25:64:d4:d7:ca brd ff:ff:ff:ff:ff:ff
    inet 10.0.1.50/24 brd 10.0.1.255 scope global noprefixroute dynamic enp0s25
       valid_lft 57035sec preferred_lft 57035sec
    inet6 fe80::e64d:5dda:2def:dfbe/64 scope link noprefixroute 
       valid_lft forever preferred_lft forever
3: virbr0:  mtu 1500 qdisc noqueue state UP group default qlen 1000
    link/ether 52:54:00:13:72:5b brd ff:ff:ff:ff:ff:ff
    inet 192.168.122.1/24 brd 192.168.122.255 scope global virbr0
       valid_lft forever preferred_lft forever
4: virbr0-nic:  mtu 1500 qdisc pfifo_fast master virbr0 state DOWN group default qlen 1000
    link/ether 52:54:00:13:72:5b brd ff:ff:ff:ff:ff:ff
7: vnet0:  mtu 1500 qdisc pfifo_fast master virbr0 state UNKNOWN group default qlen 1000
    link/ether fe:54:00:ed:b0:ce brd ff:ff:ff:ff:ff:ff
    inet6 fe80::fc54:ff:feed:b0ce/64 scope link 
       valid_lft forever preferred_lft forever

Let’s next examine how to check for information only on a particular interface.

2. Display Information for a Specific Interface

The below command will display information only on a particular interface.

[thomaspc@localhost ~]$ ip addr show dev enp0s25
2: enp0s25:  mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether 00:25:64:d4:d7:ca brd ff:ff:ff:ff:ff:ff
    inet 10.0.1.50/24 brd 10.0.1.255 scope global noprefixroute dynamic enp0s25
       valid_lft 56947sec preferred_lft 56947sec
    inet6 fe80::e64d:5dda:2def:dfbe/64 scope link noprefixroute 
       valid_lft forever preferred_lft forever
3. Show Various Network Interfaces

The ip link command provides information on the state of different network interfaces.

[thomaspc@localhost ~]$ ip link
1: lo:  mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: enp0s25:  mtu 1500 qdisc pfifo_fast state UP mode DEFAULT group default qlen 1000
    link/ether 00:25:64:d4:d7:ca brd ff:ff:ff:ff:ff:ff
3: virbr0:  mtu 1500 qdisc noqueue state UP mode DEFAULT group default qlen 1000
    link/ether 52:54:00:13:72:5b brd ff:ff:ff:ff:ff:ff
4: virbr0-nic:  mtu 1500 qdisc pfifo_fast master virbr0 state DOWN mode DEFAULT group default qlen 1000
    link/ether 52:54:00:13:72:5b brd ff:ff:ff:ff:ff:ff
7: vnet0:  mtu 1500 qdisc pfifo_fast master virbr0 state UNKNOWN mode DEFAULT group default qlen 1000
    link/ether fe:54:00:ed:b0:ce brd ff:ff:ff:ff:ff:ff

The ip link command can also be used to get an interface online or offline.

4. How to Add an IP Address

The below command will show you how to add an IP address using the ip addr command.

[thomaspc@localhost ~]$ ip addr add 192.168.0.77/24 dev enp0s25

The above command adds address 192.168.0.77 with netmask 24 to device enp0s25

5. How to Delete an IP Address

With the ip addr del command, deleting an IP address is simple.

[thomaspc@localhost ~]$ ip addr del 192.168.0.77/24 dev enp0s25
6. How to bring a Network Interface Up?

Learning how to bring a network interface up is essential for a Linux system administrator.

[thomaspc@localhost ~]$ sudo ip link set em1 up

The above command will bring enp0s25 online.

7. How to bring a Network Interface Down?

There might be occasions when you need to bring a network interface down on our CentOS 7 system.

For such situations, go with the following command.

[thomaspc@localhost ~]$ sudo ip link set enp0s25 down

The above command will take enp0s25offline.

You can check if the interface enp0s25 has been taken offline via the following command:

[thomaspc@localhost ~]$ ip addr show enp0s25
enp0s25:  mtu 1500 qdisc pfifo_fast state DOWN group default qlen 1000
    link/ether 00:25:64:d4:d7:ca brd ff:ff:ff:ff:ff:ff
    inet 10.0.1.50/24 brd 10.0.1.255 scope global noprefixroute dynamic enp0s25
       valid_lft 79017sec preferred_lft 79017sec

As you see from the above output, the network interface enp0s25 is indeed down.

8. How to Check the Routing Table?

You can use ip route show to check the routing table (previously, you were likely using the route command.

[thomaspc@localhost ~]$ ip route show
default via 10.0.1.1 dev enp0s25 proto dhcp metric 100 
10.0.1.0/24 dev enp0s25 proto kernel scope link src 10.0.1.50 metric 100 
192.168.122.0/24 dev virbr0 proto kernel scope link src 192.168.122.1
9. How to Add a Route?

Now, let’s look at how to add an entry to the routing table.

[thomaspc@localhost ~]$ ip route add 192.168.3.0/24 dev enp0s25
10. How to Delete a Route?

To delete an entry from the routing table, run the below command.

[thomaspc@localhost ~]$ ip route del 192.168.3.0/24 dev enp0s25
 Posted by at 2:19 pm

How to Install KeePassX on CentOS 7

 Linux, Security  Comments Off on How to Install KeePassX on CentOS 7
Sep 232018
 

KeepassxEven if you’re an Einstein, there’s no way you can remember all the user names and passwords for your Hotmail, Netflix, Gmail, multiple Bank accounts, Credit Card accounts, Dropbox and other sundry login details.

People without a password manager tend to write the user names and passwords on a piece of paper (not good because you can easily lose it) or, worse, use the same set of user names and passwords for multiple accounts (more dangerous because if one of your accounts is compromised the others will soon be too).

The biggest plus of a password manager is that you no longer have to remember multiple user names and passwords but just one master password that provides you with access to all the other user names and passwords.

If you’re not using a password manager, get one immediately. There are several password managers but a lot of them charge a monthly fee.

Since there are open source password managers of high quality, there’s no need to sign up for a fee-based service.

My personal favorite is KeePassX.

KeePassX Password Manager

KeePassX is a decent password manager for Linux and has been around for more than a decade.

I’ve used KeePassX on various flavors of Linux for a few years now and like that it’s free, local (i.e., not cloud-based), and comes with a secure password generator.

The latest version is KeePassX 2.0.2-1 on Ubuntu/Linux Mint repositories but the version for CentOS 7 or CentOS 6 is 0.4.4. The official KeePassX version is newer, 2.0.3.

Default security setting for the KeePassX database on version 0.4.4 of my CentOS 7 machine is AES (Rijndael) 256-bit encryption.

KeePassX has URL open (ctrl u) and auto-fill (ctrl v) capabilities but I must caution that once in a while the auto-fill does not work.

KeePassX also features Groups to let you keep all your user names and passwords for a certain category (say different e-mail accounts) into Groups. So you can have one group for E-mail, another for Entertainment (Netflix, Amazon Videos, etc.), a third for your bank and credit card accounts and so on.

Installing KeePassX

Installing KeePassX on CentOS 7 or CentOS 6 is a no-brainer.

[thomaspc@localhost ~]$ sudo yum install keepassx
[sudo] password for thomaspc: 
Loaded plugins: fastestmirror, langpacks, product-id, search-disabled-repos, subscription-manager
Loading mirror speeds from cached hostfile
epel/x86_64/metalink                                                                                                                                     |  14 kB  00:00:00     
 * base: mirror.datto.com
 * epel: mirror.umd.edu
 * extras: centos2.zswap.net
 * updates: mirror.atlanticmetro.net
base                                                                                                                                                     | 3.6 kB  00:00:00     
epel                                                                                                                                                     | 3.2 kB  00:00:00     
extras                                                                                                                                                   | 3.4 kB  00:00:00     
updates                                                                                                                                                  | 3.4 kB  00:00:00     
(1/2): epel/x86_64/updateinfo                                                                                                                            | 944 kB  00:00:00     
(2/2): epel/x86_64/primary                                                                                                                               | 3.6 MB  00:00:00     
epel                                                                                                                                                                12686/12686
Resolving Dependencies
--> Running transaction check
---> Package keepassx.x86_64 0:0.4.4-1.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================================================================================================================
 Package                                    Arch                                     Version                                       Repository                              Size
================================================================================================================================================================================
Installing:
 keepassx                                   x86_64                                   0.4.4-1.el7                                   epel                                   807 k

Transaction Summary
================================================================================================================================================================================
Install  1 Package

Total download size: 807 k
Installed size: 2.8 M
Is this ok [y/d/N]: y
Downloading packages:
keepassx-0.4.4-1.el7.x86_64.rpm                                                                                                                          | 807 kB  00:00:00     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : keepassx-0.4.4-1.el7.x86_64                                                                                                                                  1/1 
  Verifying  : keepassx-0.4.4-1.el7.x86_64                                                                                                                                  1/1 

Installed:
  keepassx.x86_64 0:0.4.4-1.el7                                                                                                                                                 

Complete!
Advantages & Disadvantages

Since every individual has unique needs, it’s hard to speak for everyone.

In my case, I prefer a password manager that’s local. So KeePassX is a plus for me.

But others may want a cloud-based password manager that they can access from any device anywhere.

KeePassX will not please such people because it lacks a cloud version. But you can keep a copy of the encrypted KeePassX database on Dropbox or similar online storage service and access the KeePassX database that way.

Overall, I’ve found KeePassX to be a reliable Password Manager on my CentOS 7 and Linux Mint 18 systems.

You can read more about KeePassX on the password manager’s web site KeePassX.org.

 Posted by at 2:17 pm

6 Ways to Check if a Package is Installed on a Linux Mint or Ubuntu PC

 How To, Linux  Comments Off on 6 Ways to Check if a Package is Installed on a Linux Mint or Ubuntu PC
Sep 102018
 

This morning I was checking via the command line to see if MySQL Server was installed on my Linux Mint 18 (Sarah) system and fumbled around a bit about how to do it.

Presumably, there are many other Linux users who wish to install a package and unsure how to check it on the command line.

So I decided to do this blog post on the various ways to check if a particular package is installed on a Linux Mint or Ubuntu system.

For each unique method, I will illustrate with two examples (the first example for a package not installed and the second for a package that’s already installed).

1. apt-cache policy Method

Not Installed

$ apt-cache policy mysql-server
N: Unable to locate package mysql-server

apt-cache policy is a quick way to determine if a particular package is installed on a Ubuntu or Linux Mint system.

Already Installed

$ apt-cache policy grsync
grsync:
  Installed: 1.2.5-1
  Candidate: 1.2.5-1
  Version table:
 *** 1.2.5-1 500
        500 http://archive.ubuntu.com/ubuntu xenial/universe amd64 Packages
        100 /var/lib/dpkg/status
2. dpkg -l Method

Not Installed

$ dpkg -l | grep mysql-server

Since mysql-server is not on my system, I did not get any output when I ran the dpkg -l | grep mysql-server command.

Already Installed

$ dpkg -l | grep grsync
ii  grsync        1.2.5-1       amd64        GTK+ frontend for rsync
3. dpkg-query Method

Let’s now consider the dpkg-query way to see if a specific package is installed on Ubuntu or Linux Mint.

Not Installed

$ dpkg-query -s mysql-server
dpkg-query: package 'mysql-server' is not installed and no information is available
Use dpkg --info (= dpkg-deb --info) to examine archive files,
and dpkg --contents (= dpkg-deb --contents) to list their contents.

The above example clearly demonstrates that mysql-server is not installed on my Linux Mint 18 PC.

Already Installed

$ dpkg-query -s grsync
Package: grsync
Status: install ok installed
.....output truncated
4. dpkg -s Method

dpkg -s package_name is another quick way to determine if a package is installed on an Ubuntu system.

Not Installed

$ dpkg -s mysql-server | grep Status
dpkg-query: package 'mysql-server' is not installed and no information is available
Use dpkg --info (= dpkg-deb --info) to examine archive files,
and dpkg --contents (= dpkg-deb --contents) to list their contents.

Already Installed

$ dpkg -s cherrytree | grep Status
Status: install ok installed
5. apt list Method

Not Installed

$ apt list mysql-server
Listing... Done
mysql-server/xenial-updates,xenial-updates,xenial-security,xenial-security 5.7.23-0ubuntu0.16.04.1 all

Already Installed

$ apt list firefox
Listing... Done
firefox/sarah,now 61.0.1+linuxmint1+sylvia amd64 [installed]
N: There is 1 additional version. Please use the '-a' switch to see it
6. dpkg -l | grep package Method

Not Installed

$ dpkg -l | grep mysql-server

Since mysql-server is not installed on my Linux desktop, the above example did not produce any output.

Already Installed

$ dpkg -l | grep firefox
ii  firefox                     61.0.1+linuxmint1+sylvia            amd64        Safe and easy web browser from Mozilla
ii  firefox-locale-en           61.0.1+linuxmint1+sylvia            amd64        English language pack for Firefox
 Posted by at 1:25 pm

How to Create a File on Linux

 Linux  Comments Off on How to Create a File on Linux
Aug 132018
 

As I say often, there are many ways to skin a Linux cat.

Here are a few ways to create a new file on a Linux system.

I have tested the following commands on CentOS 7 and Linux Mint 18.

Creating a New File

1. Touch method

$ touch file_name

Example:

$ touch jennifer

$ ls
Interview-Questions       Favorite-Beer.txt             REdHat-Release-Dates.odt               Ubuntu-Tips
jennifer

2. Echo method

$ echo -n > New_file

Example:

$ echo -n > sammy
$ ls
Desktop  Documents  Downloads  Music  Pictures  Public  sammy  Templates  Videos  VirtualBox VMs

3. Echo method with some content in file

$ echo jack and jill went up the hill > new_file

Example:

$ echo jack and jill went up the hill > donald_trump
$ ls
Desktop  Documents  donald_trump  Downloads  Music  Pictures  Public  sammy  Templates  Videos  VirtualBox VMs
$ ls
Desktop  Documents  donald_trump  Downloads  Music  Pictures  Public  sammy  Templates  Videos  VirtualBox VMs
$ cat donald_trump
jack and jill went up the hill

4. Quickie Method

$ > New_File

$ > Hillary_clinton
$ ls
$        Documents     Downloads        Music     Public  Templates  VirtualBox VMs
Desktop  donald_trump  Hillary_clinton  Pictures  sammy   Videos

5. Via Nano Text Editor

$ nano new_file

Once new_file is opened, hit ctr-o (i.e., the alphabet o and NOT zero).

You can also create a new file via the Vim text editor:

6. Use the Vim Text Editor

$ vi new_file

To save your new_file, hit Esc, then type :wq the file will then be saved and you will exit vim.

 Posted by at 2:36 pm

Linux Mint 19 Won’t Support Minimal Install Option

 Linux  Comments Off on Linux Mint 19 Won’t Support Minimal Install Option
Apr 302018
 

The bigwigs at Linux Mint have spoken.

The nice minimal install option available in the new Ubuntu 18.04 LTS distro will NOT be offered with the upcoming Linux Mint 19 aka Tara.

With Ubuntu 18.04’s minimal install, you only get the Firefox browser and a few basic utilities, not the fancy stuff like LibreOffice, etc.

Linux Mint did not provide any reason why such a cool feature as minimal install would not be made available in the next major version of the popular distribution.

Well, you can’t really question the wisdom of the Delphic oracles. Can you?

Although based on Ubuntu 18.04 LTS, Linux Mint 19 will likely differ from its parent in another important way too.

Linux Mint developers are considering retaining support for home directory encryption, a feature stripped in the Ubuntu 18.04 installer. But a final decision has yet to be made in this matter.

No Minimal Install Support with Linux Mint 19 aka Tara

Tara – Other Features

Besides leveraging the various improvements in its upstream parent Ubuntu 18.04 LTS, the love-child (Tara) should also feature improvements in Mint tools, with the focus on Update Manager, Software Manager and Welcome Screen. Continue reading »

 Posted by at 3:03 pm

Ubuntu 18.04 LTS – My First Impressions

 Linux  Comments Off on Ubuntu 18.04 LTS – My First Impressions
Apr 262018
 

Ubuntu 18.04 LTS aka Bionic Beaver is out today (April 26, 2018) and you can download it here.

After downloading it, go to the folder and do a shasum check to ensure your download’s integrity.

Here’s how to do the shasum check:

$ sha256sum bionic-desktop-amd64.iso
adf9c1cbb2529cb06a67bbb16af881d8d918078e7e155a897ac30a9e0cf2bafa  bionic-desktop-amd64.iso

Since this is a LTS (long term support) version, users of Desktop, Server and Core editions will get support in terms of security and other updates for the next five years, i.e., until April 2023.

I’m not a stranger to Ubuntu 18.04 LTS since I had already downloaded beta 2 (desktop version) a few days back on a Dell Optiplex 780 PC and launched it via Virtualbox.

Here are my first impressions of the official release of Ubuntu 18.04 LTS, which hews close to beta 2. Continue reading »

 Posted by at 7:43 pm