5 Basic Linux Commands to manage Linux based Server.

These days linux servers are popular, Everyone wants to manage their servers and perform some basic tasks on server.

Suppose Mysql server got crashed because of heavy load and their isn’t any administrator available at that time, and I need get my website up again ASAP. If we know some of basics commands, we can bring site up, without waiting for administrator. As we know Linux administrators cannot live by the GUI alone. So here are few basic commands that will help to resolve most of the issue without administrators.

1. Check Server process/load (top command):

If you want to check which process is using most of your server memory and most of your cpu speed, you can do it by using following command on your server terminal.

1
top

2. Change owner/group of files.

If you want to change any file owner/group, you can do it by using following command.

sudo chown <user>:<group> <dirname>

like :

sudo chown root:root /var/www

Above command will change owner and group of www folder to root. To change owner/group for all files/folders inside particular folder you need to put -r option as well. E.g.

sudo chown  -R root:root /var/www

Above command will change owner/group of all files/folders inside www(including www) to root .

3. Change file permission

Suppose, you have a website and you are getting “permission denied” error while uploading file, and you want to change permission of a directory to wriable by group. You can easily do it by using following command

sudo chmod 775 /var/www/html/upload

Above command will change upload directory permission to 775. It means above directory will be come writable by group

4. Restart apache,mysql, httpd, nginx, postfix services.

Suppose, your website is stopped working because apache or mysql went down, and you want to bring that up. you can do this easily by using following commands

1.Restart Apache or httpd

  • On ubuntu and upto centos 6
    • sudo /etc.init.d/apache2 restart

      or

      sudo service apache2 restart

      or

      sudo /etc.init.d/httpd restart

      or

      sudo service httpd restart
  • 2. On centos 7.x
    • systemctl restart httpd.service

Restart Mysql

  • On ubuntu and upto centos 6
    • sudo /etc.init.d/mysql restart

      or

      sudo service mysql restart

      or

      sudo /etc.init.d/mysqld restart

      or

      sudo service mysqld restart
  • 2. On centos 7.x
    • systemctl restart mysqld.service

you can follow same guidline to restart any service. you just need to find service name.

5. Check Free space on server

sometime our site get stop because of not having enough space on server, Or one partition got full. We can check that using following command

	df -h

Above comamnd will display all storage information in human readable format, that’s why I put -h option in df command.

Soon I will come with more commands and information, Stay tuned…

Leave a Reply

Your email address will not be published. Required fields are marked *

*


Skip to toolbar