Posts Under Category: SSH

Yum command is one of the most used and important command on a Linux system. Here is how you can see the history of Yum command on a Linux server.
read more

If you want to know the version of yum installed on your Linux server, here is how you can find.
read more

The main user / administrator of a Linux server is root. Here is how you can create a new user on your CentOS server / VPS.

Login to your server as root as run following command to create a new user named ravi.

/usr/sbin/adduser ravi

Now set password for new user ravi

passwd ravi

Screenshot

add-new-user

Done!!

read more

Let’s say we want to search for text lophost in file /var/log/messages
We can do this using command grep. Login to your server via SSH and run following command

grep lophost /var/log/messages

read more

On a Linux server you can rename a file using mv command.
Let say you want to rename file-one.txt to file-two.txt
Use following command for this.

mv file-one.txt file-two.txt

Another example. Suppose we want to rename ravi.txt to lophost.txt located in /var

mv /var/ravi.txt /var/lophost.txt

read more

You should open only limited ports for incoming and outgoing traffic on a server. You can use firewall like CSF firewall to open only trusted ports on a server.

If you want to check all open/listening ports that your server is using, run below command via SSH:

netstat -an

OR

netstat -tulp

OR

netstat -tulpn

The command will print a list of all open ports, protocol using the port, local address and foreign address (IP).

Our Recommended VPS Hosting

Using below commands you can start, stop and restart MySQL from SSH.
Login to your server as root via SSH, and run following commands.

Start MySQL

service mysql start

OR

/etc/init.d/mysql start

Stop MySQL

service mysql stop

OR

/etc/init.d/mysql stop

Restart MySQL

service mysql restart

OR

/etc/init.d/mysql restart

Status of MySQL

If you want to know the status of MySQL on your server, run below command.

service mysql status

read more

Use following command to know the hostname of your server.

hostname

You should run above command in SSH as root user.

Our Recommended VPS Hosting

If for some reason you do not want to update your server kernel but want to update other packages running on CentOS, here is how you can do.

Update can be done using yum command and to exclude kernel from update we need to add exclude command.
Login to your server as root via SSH and run following command:

yum -y --exclude=kernel\* update

OR

yum -y -x 'kernel*' update

Above command will update all packages but will leave kernel update on a CentOS server.

Our Recommended VPS Hosting

If you want to copy a file / folder from one server to another, you can use wget or scp command. In this tutorial I will show how to use scp command to copy files / folder from one server to another.

Let us suppose

Server One IP is: 1.1.1.1
Server Two IP is: 2.2.2.2

How to copy a file

Suppose you want to copy a file from server one to server two.
Location of file on server one is: /home/filename.txt

Login to server two via SSH and run following command

scp [email protected]:/home/filename.txt /home/

This will copy filename.txt file from server one to server two and save in /home directory.

How to copy a folder / directory

Suppose you want to copy a complete folder from server one to server two.
Let’s say you want to copy /backup folder from server one to server two.

Login to server two via SSH and run following command

scp -r [email protected]:/backup /foldername

This will copy /backup directory from server one to server two and save in /foldername directory.

Our Recommended VPS Hosting