8 Commands Before Creating A New CentOS Server

Arnish Gupta
3 min readApr 24, 2020

--

CentOS is a very popular operating system for servers. It is a lightweight, open-source and easy for install libraries and packages. It is based on the linux platform so the commands are similar as per linux. yum is the keyword to use packages for install, remove and update. Here we will learn some commands that should be executed for the new server.

Hello Everyone, I am using the centos server for the last 5 years so I found some commands as per my experience. Let’s look at these commands:

  1. Update the current packages:
yum update -y 

This command will update all the current packages with the latest version. The last parameter -y is for giving permission, otherwise, it asks for permission with yes or no.

2. Set Time-Zone:

timedatectl set-timezone Asia/Kolkata

You have to set the timezone accordingly to your preference. We have set Asia/Kolkata the above command. you can find your zone with the following command:

timedatectl list-timezones

you can check the date of the system with the date command.

3. Change SSH Port: SSH is to use port numbers between 1024 and 32,767.

1. vi /etc/ssh/sshd_config
2. Find #Port 22 -> Port <Port Number>
3. check status <service sshd status> then restart <service sshd restart>

You can use port with ssh command is like

ssh -i "<file.pem>" <username>@<server ip/host> -p <Port Number>

4. Access/Revoke SSH Key: All the public key for access the server is written in the following file:

vi ~/.ssh/authorized_keys

you can add or remove from here. you can get the public key from the PEM file from the following command:

ssh-keygen -y
# it asks you to enter the file with proper path
i.e. ~/Document/staging.pem

Remember that the PEM file has 400 permission you can give like this:

chmod 400 <PEM File Name>

5. Install Helpful Packages Wget and Zip: wget command downloads the external file link to the local machine. zip command helpful to compress the file. You can install these packages with theses commands:

yum install wget -y
yum install zip -y

6. Check RAM Usage:

free -m

Output:

7. Check Disk Details:

df -h

Output:

8. Check Running Packages:

ps -ef | grep <package-name>

Output:

The First root means this package runs with this user and the second 7850 is the process id. if you want to stop this process you can do like this:

kill -9 <process-id>
(i.e) kill -9 7850

I hope it will help you. There is one more article to make smart terminal shortcut HERE.

Thank you for reading.

--

--

No responses yet