Linux System Administration – Part 2

In this post, we are continuing with the commands that are used for Linux system administration.

How to change the hostname

1) [For RedHat and Centos] Using a text editor open the file /etc/sysconfig/network and Modify the HOSTNAME= value to  match your server’s new name

Sample entry after editing:

 

2) Run the below command:

This will change the hostname until next reboot. The change won’t be visible immediately in your current terminal. Start a new terminal to see the new hostname.

3) For internal networking, change the host that is associated with the main IP address for your server at /etc/hosts file

4) Also change the hostname at /etc/hostname

5) Finally, restart networking or your computer to apply the changes.

Example :

How to view network connections

The “netstat” command can be used for viewing the network connections. Using this command, it is possible to look for the ports your server is listening on and the programs behind those ports.

How to update local host aliases

In order to update the local host aliases, edit the file /etc/hosts. This has to be done by the user with root privilege. Also sudo can be used to update this file.

Format of each line :

IP_address <tab> your_domain <tab> alias

Example :

 

How to shutdown

In order to properly shutdown a Linux machine, the command “shutdown” can be used. If many users are logged in, this command can be used with options as in the example given below :

where +2 indicates that the system will shutdown in 2 minutes.

To shutdown immediately :

How to monitor user information

There are various Linux commands available for monitoring user information. Some of them are “who”, “w”, “users”, “groups”, “id” and “last”. The command “set” displays all the environment variables in the current user’s environment.

 

 

Scroll to Top