How to install a package forcefully in Linux

Install a package forcefully in Linux

Before installing a package forcefully, first understand a situation where we need this force option.
Let me corrupt one command and show you how to install it's package forcefully.
First check the package of the command we are going to corrupt. Let say mount command.

# which mount
# rpm -qf /bin/mount


[root@linuxelearn Packages]# which mount
/bin/mount
[root@linuxelearn Packages]# rpm -qf /bin/mount
util-linux-ng-2.17.2-6.el6.x86_64
[root@linuxelearn Packages]#


Okey, so we know the package of mount let's copy other commands content over mount command. Let copy date commands contents over mount command.

#cp /bin/date /bin/mount


[root@linuxelearn Packages]# cp /bin/date /bin/mount
cp: overwrite `/bin/mount'? y
[root@linuxelearn Packages]#


Now when you run mount command it will show Date, that means it is corrupted.

[root@linuxelearn Packages]# mount
Tue Mar 14 22:59:43 IST 2017
[root@linuxelearn Packages]# date
Tue Mar 14 22:59:49 IST 2017
[root@linuxelearn Packages]#


So to fix the mount command we need to reinstall it's package, let's install the package and check whether mount command is fixed or not. Move to the folder where you kept the package and install it.

#rpm -ivh util-linux-ng...


[root@linuxelearn Packages]# rpm -ivh util-linux-ng-2.17.2-6.el6.x86_64.rpm
warning: util-linux-ng-2.17.2-6.el6.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID fd431d51: NOKEY
Preparing...                ########################################### [100%]
            package util-linux-ng-2.17.2-6.el6.x86_64 is already installed
[root@linuxelearn Packages]#


It says the package already install, check by using mount command whether it is working fine.

[root@linuxelearn Packages]# mount
Tue Mar 14 23:03:41 IST 2017
[root@linuxelearn Packages]#


opps...! It isn't fixed yet, now in such to force the installation to be done, the syntax is

#rpm -ivh <package name> -- force
#rpm -ivh util-linux-ng...


[root@linuxelearn Packages]# rpm -ivh util-linux-ng-2.17.2-6.el6.x86_64.rpm --force
warning: util-linux-ng-2.17.2-6.el6.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID fd431d51: NOKEY
Preparing...                ########################################### [100%]
   1:util-linux-ng          ########################################### [100%]
[root@linuxelearn Packages]#


Okay then we have not only installed package successfully but we have also fixed the command. Congratulations.

Now we run the mount command check output.


[root@linuxelearn Packages]# mount
/dev/sda2 on / type ext4 (rw)
oproc on /proc type proc (rw)
sysfs on /sys type sysfs (rw)
devpts on /dev/pts type devpts (rw,gid=5,mode=620)
tmpfs on /dev/shm type tmpfs (rw,rootcontext="system_u:object_r:tmpfs_t:s0")
/dev/sda1 on /boot type ext4 (rw)
none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
sunrpc on /var/lib/nfs/rpc_pipefs type rpc_pipefs (rw)
gvfs-fuse-daemon on /root/.gvfs type fuse.gvfs-fuse-daemon (rw,nosuid,nodev)
/dev/sr0 on /media/RHEL_6.0 x86_64 Disc 1 type iso9660 (ro,nosuid,nodev,uhelper=udisks,uid=0,gid=0,iocharset=utf8,mode=0400,dmode=0500)
/dev/sdb on /media/XIAOMI type iso9660 (ro,nosuid,nodev,uhelper=udisks,uid=0,gid=0,iocharset=utf8,mode=0400,dmode=0500)
[root@linuxelearn Packages]#


This is step by step solution of install package forcefully.


I Hope You Enjoyed reading This articule…..

How to manage installed services in Linux.

manage installed services in Linux.

Services in linux are programs or called daemon's that once started run continuously in the background and are ready for input or monitor changes in your computer and respond to them. For example the Apache server has a daemon called httpd ( The d is for daemon ) that listens on port 80 your computer and when it receives a request for a page it sends the appropriate data back to the client machine.

Many services are required to run all the time however many can be safely turned of for both security reasons as running unnecessary services opens more doors into your computer, but also for performance reasons. It may not make much difference but your computer should boot slightly faster with less services it has to start on boot.
One of the techniques in every Linux administrators toolbox to improve security of a box is to turn off unneeded services.

Chkconfig and service Commands

There are 2 commands used to control services:
  • Service – This controls the starting and stopping of services during a session, these setting are not saved. If you start Apache this way but it is not set to start on boot using the above method then it will continue to run but on next boot will not start automatically.
  • Chkconfig – This controls which services are set to start on boot, by their nature these setting are saved and are applied at next boot. Changing these settings will not start the services immediately; it will just flag them to be strated from the next boot.

The command use for maintaining a service is

#service <name of the service> Status                     ---        To check the status of the service
#service <name of the service> start                        ---        To start the service
#service <name of the service> stop             ---        To stop a service
#service <name of the service> reload                     ---        To reload the service
#service <name of the service> restart                    ---        To restart the service
#service - - status-all                                      ---        To see all the service status

To command use for service availability is

#chkconfig – list                                             ---        To check the availability of service
#chkconfig <service> on                               ---        To make the service available after restart
#chkconfig <service> off                              ---        To make the service unavailable after restart

Now we will see how to use the above commands:

Check the status of ftp service “vsftpd”
To check the status of the above service

#service vsftpd status


[root@linuxelearn Desktop]# service vsftpd status
vsftpd is stopped
[root@linuxelearn Desktop]#


Start Ftp services
To start the ftp service, the command is
#service vsftpd start


[root@linuxelearn Desktop]# service vsftpd start
Starting vsftpd for vsftpd:                                [  OK  ]
[root@linuxelearn Desktop]# service vsftpd status
vsftpd (pid 3261) is running...
[root@linuxelearn Desktop]#


Reload the ftp services, may be required after doing some change in config file.
To reload the service, the command is
#service vsftpd reload


[root@linuxelearn Desktop]# service vsftpd reload
Shutting down vsftpd:                                      [  OK  ]
Starting vsftpd for vsftpd:                                [  OK  ]
[root@linuxelearn Desktop]#


To restart the ftp or any service, required when reload does not work
To restart the ftp services, the command will be

#service vsftpd restart


[root@linuxelearn Desktop]# service vsftpd restart
Shutting down vsftpd:                                      [  OK  ]
Starting vsftpd for vsftpd:                                [  OK  ]
[root@linuxelearn Desktop]#


Check the status of the all service availability using chkconfig command.
To check the status of all service availability, use

#chkconfig –list


[root@linuxelearn Desktop]# chkconfig --list
NetworkManager        0:off    1:off    2:on     3:on     4:on     5:on     6:off
abrtd                0:off    1:off    2:off    3:on     4:off    5:on     6:off
acpid               0:off    1:off    2:on     3:on     4:on     5:on     6:off
atd                   0:off    1:off    2:off    3:on     4:on     5:on     6:off
auditd              0:off    1:off    2:on     3:on     4:on     5:on     6:off
autofs              0:off    1:off    2:off    3:on     4:on     5:on     6:off
avahi-daemon              0:off    1:off    2:off    3:on     4:on     5:on     6:off
bluetooth         0:off    1:off    2:off    3:on     4:on     5:on     6:off
certmonger     0:off    1:off    2:off    3:off    4:off    5:off    6:off
cgconfig          0:off    1:off    2:off    3:off    4:off    5:off    6:off
cgred               0:off    1:off    2:off    3:off    4:off    5:off    6:off
cpuspeed         0:off    1:on     2:on     3:on     4:on     5:on     6:off
crond               0:off    1:off    2:on     3:on     4:on     5:on     6:off
cups                 0:off    1:off    2:on     3:on     4:on     5:on     6:off
dnsmasq          0:off    1:off    2:off    3:off    4:off    5:off    6:off
firstboot          0:off    1:off    2:off    3:off    4:off    5:off    6:off
haldaemon      0:off    1:off    2:off    3:on     4:on     5:on     6:off
httpd               0:off    1:off    2:off    3:off    4:off    5:off    6:off
ip6tables          0:off    1:off    2:on     3:on     4:on     5:on     6:off
iptables            0:off    1:off    2:on     3:on     4:on     5:on     6:off
irqbalance        0:off    1:off    2:off    3:on     4:on     5:on     6:off
kdump             0:off    1:off    2:off    3:off    4:off    5:off    6:off
lvm2-monitor              0:off    1:on     2:on     3:on     4:on     5:on     6:off
mdmonitor                  0:off    1:off    2:on     3:on     4:on     5:on     6:off
messagebus                 0:off    1:off    2:on     3:on     4:on     5:on     6:off
microcode_ctl             0:off    1:off    2:on     3:on     4:on     5:on     6:off
nagios              0:off    1:off    2:on     3:on     4:on     5:on     6:off
netconsole       0:off    1:off    2:off    3:off    4:off    5:off    6:off
netfs                0:off    1:off    2:off    3:on     4:on     5:on     6:off
network           0:off    1:off    2:on     3:on     4:on     5:on     6:off
nfs                   0:off    1:off    2:off    3:off    4:off    5:off    6:off
nfslock            0:off    1:off    2:off    3:on     4:on     5:on     6:off
nscd                 0:off    1:off    2:off    3:off    4:off    5:off    6:off
nslcd                0:off    1:off    2:off    3:off    4:off    5:off    6:off
ntpd                 0:off    1:off    2:off    3:off    4:off    5:off    6:off
ntpdate            0:off    1:off    2:off    3:off    4:off    5:off    6:off
oddjobd          0:off    1:off    2:off    3:off    4:off    5:off    6:off
portreserve      0:off    1:off    2:on     3:on     4:on     5:on     6:off
postfix             0:off    1:off    2:on     3:on     4:on     5:on     6:off
psacct              0:off    1:off    2:off    3:off    4:off    5:off    6:off
rdisc                0:off    1:off    2:off    3:off    4:off    5:off    6:off
restorecond    0:off    1:off    2:off    3:off    4:off    5:off    6:off
rhnsd               0:off    1:off    2:on     3:on     4:on     5:on     6:off
rpcbind            0:off    1:off    2:on     3:on     4:on     5:on     6:off
rpcgssd            0:off    1:off    2:off    3:on     4:on     5:on     6:off
rpcidmapd      0:off    1:off    2:off    3:on     4:on     5:on     6:off
rpcsvcgssd       0:off    1:off    2:off    3:off    4:off    5:off    6:off
rsyslog             0:off    1:off    2:on     3:on     4:on     5:on     6:off
saslauthd         0:off    1:off    2:off    3:off    4:off    5:off    6:off
smartd             0:off    1:off    2:off    3:off    4:off    5:off    6:off
snmpd             0:off    1:off    2:off    3:off    4:off    5:off    6:off
snmptrapd      0:off    1:off    2:off    3:off    4:off    5:off    6:off
sshd                 0:off    1:off    2:on     3:on     4:on     5:on     6:off
sssd                 0:off    1:off    2:off    3:off    4:off    5:off    6:off
sysstat             0:off    1:on     2:on     3:on     4:on     5:on     6:off
udev-post        0:off    1:on     2:on     3:on     4:on     5:on     6:off
vsftpd              0:off    1:off    2:off    3:off    4:off    5:off    6:off
wpa_supplicant           0:off    1:off    2:off    3:off    4:off    5:off    6:off
ypbind             0:off    1:off    2:off    3:off    4:off    5:off    6:off
[root@linuxelearn Desktop]#


Note: where 0 1 2 3 4 5 6 are the run levels in Linux, The output shows that on which run level the service is available even after reboot.

Check the status of a particular service, say “vsftpd”
To check the status of a vsftpd service, the command is

#chkconfig –list <name of the service>
#chkconfig –list vsftpd


[root@linuxelearn Desktop]# chkconfig --list vsftpd
vsftpd              0:off    1:off    2:off    3:off    4:off    5:off    6:off
[root@linuxelearn Desktop]#


Make the service availability on for vsftpd.
To make the service availability on for vsftpd service,

#chkconfig vsftpd on


[root@linuxelearn Desktop]# chkconfig vsftpd on
[root@linuxelearn Desktop]# chkconfig --list vsftpd
vsftpd              0:off    1:off    2:on     3:on     4:on     5:on     6:off
[root@linuxelearn Desktop]#


Make the service availability off for vsftpd
To make the service availability off the command is

#chkconfig vsftpd off


[root@linuxelearn Desktop]# chkconfig vsftpd off
[root@linuxelearn Desktop]# chkconfig --list vsftpd
vsftpd              0:off    1:off    2:off    3:off    4:off    5:off    6:off
[root@linuxelearn Desktop]#


Make the service vsftpd availability on only runlevel 5
To make the service availability on, on a particular runlevel, the syntax is

#chkconfig –level <1-6> <service> <on/off>
#chkconfig – level 5 vsftpd on


[root@linuxelearn Desktop]# chkconfig --level 5 vsftpd on
[root@linuxelearn Desktop]# chkconfig --list vsftpd
vsftpd              0:off    1:off    2:off    3:off    4:off    5:on     6:off
[root@linuxelearn Desktop]#


The same can be done for making service unavailable in a particular run level.

I hope you enjoyed reading this article….


How to Create a user with root permission in Linux.

Create a user with root permission in Linux.

On every Linux system, the root account is a special user that has administrative rights. Logging in as root (or executing commandswith root privileges) is necessary for many tasks. Into this article we will learn how to create a user with root privileges or grant root permissions to an existing user by setting User and Group IDs and we will also learn how to delete a root permission granted user.
Actually this is not a good idea to give all the permissions of root to a non-root user, so use the sudo command on the production servers to run commands as super user, instead of using the non root user with root permission.


Warning : Giving a non-root user all the permissions of root is very dangerous, because the non-root user will be able to do literally anything that could cause a big trouble if account is hijacked.


How to Create a new user account with Root Privileges or Permissions.

Lets First step is we have to add a new user into the system and grand him all root permission.
Use the following commands to create the new user raj and give him the same privileges as root and set a new password :

        # useradd -ou 0 -g 0 raj
        # passwd raj


[root@linuxelearn ~]# useradd -ou 0 -g 0 raj

[root@linuxelearn ~]# passwd raj
Changing password for user raj
New password:
BAD PASSWORD: it is based on a dictionary word
Retype new password:
passwd: all authentication tokens updated successfully.
[root@linuxelearn ~]#


Now we have just created the user raj, with UID 0 and GID 0, so that user in the same group and has the same permissions as root. Using this raj user you can perform all root commands without any warning and error.

How to give Root Permission to an existing user in Linux.

Perhaps you already have another normal user use that user in my case I have normal user named as sam and you would like to give root permissions to this normal user.
Frist check details of sam user. It will show following output.

# grep sam /etc/passwd


[root@linuxelearn ~]# grep sam /etc/passwd
sam:x:506:506::/home/sam:/bin/sh


Now edit /etc/passwd file and give root permissions to the user sam by changing User and Group IDs to UID 0 and GID 0 :

Then check detail info it will show following output.

#  grep sam /etc/passwd


[root@linuxelearn ~]# grep sam /etc/passwd
sam:x:0:0::/home/sam:/bin/sh


How to delete a user account with UID 0 or root permission granted user.

You can't delete second root user with another UID 0 using userdel command.

# userdel sam


[root@linuxelearn ~]# userdel sam
userdel: user sam is currently used by process 1


It will show above massage.

To delete user sam with UID 0, open /etc/passwd file and change sam user UID.
For example,


[root@linuxelearn ~]# grep sam /etc/passwd
sam:x:0:0::/home/sam:/bin/sh


Sam user UID is 0 change it into as following:


[root@linuxelearn ~]# grep sam /etc/passwd
sam:x:601:0::/home/sam:/bin/sh


Now, you'll be able to delete user sam with userdel command :

# userdel sam

[root@linuxelearn ~]#userdel sam
[root@linuxelearn ~]#



I hope you enjoyed reading this post....