RHEL Subscriptions


To be able to use YUM on an RHEL server you need to register it with the RedHat servers.
NB: You can do this with a Developer account, which is free!
First register the system
# subscription-manager register --auto-attach
that enter your username and password.
or add --username=<username> --password=<password> onto the end of the above command
 
Next attach a subscription
# subscription-manager list --available | awk '/Pool/ { system ("subscription-manager attach --pool="$3) }'
or
# subscription-manager attach --auto
Once you are done, you can remove the subscription and server from their systems.
To remove a system from a RHEL subscription you first have to run,
# subscription-manager list --consumed
to get the serial number. Then pass that serial number to the remove command
# subscription-manager remove --serial=XXXXXXX
OR
you can run this command, which does both
# subscription-manager list --consumed | awk '/Serial:/ { system ("subscription-manager remove --serial="$2) }'

Shell Redirect

Discard the output
Sometimes you will need to execute a command, but you don’t want the output displayed on the screen. In such cases, you can discard the output by redirecting it to the file /dev/null −

$ command > /dev/null

Here command is the name of the command you want to execute. The file /dev/null is a special file that automatically discards all its input.
To discard both output of a command and its error output, use standard redirection to redirect STDERR to STDOUT −

$ command > /dev/null 2>&1

Here 2 represents STDERR and 1 represents STDOUT. You can display a message on to STDERR by redirecting STDOUT into STDERR as follows −

$ echo message 1>&2

Setgid

When set on a directory,
Setting the setgid permission on a directory (e.g. “chmod g+s”) it causes new files and subdirectories created within it to inherit its group ID, rather than the primary group ID of the user who created the file (the owner ID is never affected, only the group ID).

Setting up SSH to use key pairs

If you SSH to the same server a lot and don’t want to type the password each time you can configure SSH so you don’t have to.

First login to your terminal as normal and run

$ ssh-keygen

This will ask you the name of the key pair file you want to use.
It will suggest ~/.ssh/id_rsa
It will also create an id_rsa.pub file.

Next you need to “copy” that file to the server you want to connect to, you do by using the ssh-copy-id command.

$ ssh-copy-id user@hostname

You will be prompted for your password one last time, but from that point on you should be able to connect without using your password.

NOTE: If you want to do the same thing to another host, all you need to do is use the ssh-copy-id command again and replace the hostname with the new hostname.