Showing posts with label centos. Show all posts
Showing posts with label centos. Show all posts

Tuesday, November 29, 2016

Find the UUID of your network interface or connection

Today I was looking at the /etc/sysconfig/network-scripts/ifcfg-enp0s3 file and I came across the line that says UUID. I was thinking what is UUID of a network interface? Then I started thinking about how to find UUIDs of network interfcaes. I looked on the internet but I got no solution. Then I thought of trying to find it myself using network management commands. I did find a solution.

To find the UUIDs of your network connection, run the following command.

nmcli connection show
NAME                UUID                                  TYPE            DEVICE 
virbr0              4e02750f-13d9-4662-bfc2-10f9ae1a71bd  bridge          virbr0 
Wired connection 1  09066de3-7eb7-4ee1-9059-c651b6dff7a6  802-3-ethernet  --     
enp0s3              5144084b-0537-4e4b-9f15-065431bc6d38  802-3-ethernet  --  

From the output of this command, you can find the UUID of a connection on CentOS, Fedora, RedHat(RHEL), Ubuntu, Debian operating systems.

Tested on: CentOS 7, Ubuntu 16.04 LTS

Thursday, November 24, 2016

Mount iscsi Network Devices using /etc/fstab

If you're trying to mount network devices automatically at boot on Linux and your system is not booting correctly. This post is for you.

Today I was working with iscsi. I created portals, acls, luns, targets with targetcli. But when I tried to mount it automatically through fstab file on boot, my system wasn't booting. I looked online and I found that I had to change the mount option. I did and it worked. I am going to write what mount option I used in this post.

When my system wasn't booting, my /etc/fstab configuration file looked like this,

#
# /etc/fstab
# Created by anaconda on Thu Nov 24 03:07:55 2016
#
# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
/dev/mapper/centos-root /                       xfs     defaults        0 0
UUID=0d83fc00-ee94-4741-8163-717418187f59 /boot                   xfs     defaults        0 0
/dev/mapper/centos-swap swap                    swap    defaults        0 0
UUID=f246ba49-5772-4efc-bec2-28ff76f46f79 /root/mounts/sdb xfs defaults 0 0

Here UUID=f246ba49-5772-4efc-bec2-28ff76f46f79, this is the iscsi drive I was trying to mount. The mount option was "defaults". But to get it to work, I had to change the mount option to "_netdev". What this option does it, it attempts to mount this device after all the network connection is initialized.



So my working configuration looked like this,

#
# /etc/fstab
# Created by anaconda on Thu Nov 24 03:07:55 2016
#
# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
/dev/mapper/centos-root /                       xfs     defaults        0 0
UUID=0d83fc00-ee94-4741-8163-717418187f59 /boot                   xfs     defaults        0 0
/dev/mapper/centos-swap swap                    swap    defaults        0 0
UUID=f246ba49-5772-4efc-bec2-28ff76f46f79 /root/mounts/sdb xfs _netdev  0 0



Tested on: CentOS 7

How to Open TCP and UDP ports using firewall-cmd on CentOS/RedHat/Fedora

This post is about how to open specific tcp and udp ports using the command firewall-cmd. So without further due, let's get started.



Opening TCP ports:

Let's say, I want to open the tcp ports 80 and 443 which are used by http and https protocol respectively.

To do that, run the following commands,

firewall-cmd --permanent --add-port=80/tcp
firewall-cmd --permanent --add-port=443/tcp


Opening UDP ports:

Let's say, I want to open the udp port 53, which is used by bind dns service.

To do that, run the following command,

firewall-cmd --permanent --add-port=53/udp

Reload the Configuration:

Now we have to reload firewall-cmd configurations. To do that, run the following command,

firewall-cmd --reload

Verification:

To verify that the commands worked, let's view the current opened port list,

firewall-cmd --list-ports 443/tcp 80/tcp 53/udp

Tested on: CentOS 7

View Information(Description and Required Packages) of a group using yum

In one of my earlier post, I wrote about finding available software groups on CentOS/RedHat/Fedora. But you might not know what each of these group is for, what packages it will install and stuff like that. This is the topic of this post.

Let's say I want to know more about the group "Basic Web Server". To view the information, run the following command,

yum groups info "Basic Web Server"

Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile

Environment Group: Basic Web Server
 Environment-Id: web-server-environment
 Description: Server for serving static and dynamic internet content.
 Mandatory Groups:
   +base
   +core
   +web-server
 Optional Groups:
   +backup-client
   +debugging
   +directory-client
   +guest-agents
   +hardware-monitoring
   +java-platform
   +large-systems
   +load-balancer
   +mariadb-client
   +network-file-system-client
   +performance
   +perl-web
   +php
   +postgresql-client
   +python-web
   +remote-system-management
   +web-servlet

That's it.

Tested on: CentOS 7

Install a group of packages on CentOS/RedHat/Fedora using yum

In the previous post, I wrote about how to find the available software/package groups on CentOS/RedHat/Fedora OS using yum. But how do we install a group? I will show you how to install a group of packages with yum.

Let's say we want to install a minimal graphical user interface (GUI) on our server. So the group to install for that is, "Server with GUI".

To install this group, run the following command,

yum groups install "Server with GUI"

It should work. Thank you.

Tested on: CentOS 7

View the Available Software Groups using yum on CentOS/RedHat/Fedora

To view the available groups of packages on CentOS/RedHat/Fedora, run the following command,

yum groups list

Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
Available Environment Groups:
   Minimal Install
   Compute Node
   Infrastructure Server
   File and Print Server
   Basic Web Server
   Virtualization Host
   Server with GUI
   GNOME Desktop
   KDE Plasma Workspaces
   Development and Creative Workstation
Available Groups:
   Compatibility Libraries
   Console Internet Tools
   Development Tools
   Graphical Administration Tools
   Legacy UNIX Compatibility
   Scientific Support
   Security Tools
   Smart Card Support
   System Administration Tools
   System Management
Done


You can see from the output that, theres a lot of available groups on my system such as "Server with GUI", "Basic Web Server" etc.

Tested on: CentOS 7

Remove a Group of Packages on CentOS/Fedora/RedHat using yum

I've been looking for a way to remove a group of packages I installed earlier. Then I came across this solution that I am going to share with you guys.

To remove a group using yum, run the following command,

yum groups remove "NameOfTheGroup"

I installed the group "Development Tools", then I found that I don't really need it. So to remove it, I used the following command,

yum groups remove "Development Tools"

Tested on: CentOS 7

Monday, November 14, 2016

Clear the Command History of your Terminal on Linux

You may have a lots of command in your shells history. You can display your shell commands history by running the following command,

history
    1  history
    2  lscpu
    3  history

This is the output of the history command of my Ubuntu computer. In real scenario you may have hundreds of commands on the history.

To clear the command history of your terminal on Linux, run the following command,

history -c

That's how you remove the history of your shell on Linux.

Saturday, October 15, 2016

Unlock User Account (Enable User Login) on Linux

To unlock a user account that has been locked on linux, you can use the passwd command.

The command is,

sudo passwd -u username

For example, to unlock the user 'linda', so 'linda' can login to the system again,

sudo passwd -u linda
Unlocking password for user linda.
passwd: Success

Now you can try to login as 'linda' and you will see that login is working again.

Disable User Login (Lock Password) on Linux

To lock a user account on linux, you can use the passwd command.

The command is,

sudo passwd -l username

For example, to lock the user 'linda', so 'linda' can not login to the system anymore,

sudo passwd -l linda
Locking password for user linda.
passwd: Success

Now you can try to login as 'linda' and you will see that you login is disabled.