Here are general steps on how to use the Command Line Interface (CLI) on your VPS:
1. Secure Shell (SSH) Access: The first step to accessing your VPS through command line is to establish a Secure Shell (SSH) connection with your server. This can usually be done through a Terminal if you’re using MacOS or a program like PuTTY for Windows users.
For MacOS and Linux users: – Open Terminal – Type the command: ssh root@your_server_ip. Replace “your_server_ip” with your actual server’s IP address. – It will prompt you for a password, enter the root password for your VPS. For windows users: – Open PuTTY and fill in the hostname or IP address field with your server’s IP address – Make sure the port is set to 22 (default for SSH). – Click open and a terminal window will appear prompting for username: input “root”, and for the password, enter your root password.1. Using Commands: The commands you use in the CLI depend on the type of VPS you have, it could either be Windows-based or Linux-based. Here are few examples:
– `pwd`: shows you the full path of your current directory. – `ls`: lists all files and folders in the current directory. – `cd [folder name]`: changes the current directory to the specified folder. – `mkdir [folder name]`: creates a new directory with the specified name. – `rm [file name]`: removes or deletes the specified file.1. Start/Stop/Restart Services: You can control various server services through command line. Here are examples for apache.
– To Start service, `service apache2 start`. – To Stop service, `service apache2 stop`. – To Restart service, `service apache2 restart`.1. Update and Upgrade System: On a VPS, keeping the system and software up to date is crucial for security and compatibility reasons.
- You can use `sudo apt-get update` to update system and `sudo apt-get upgrade` to install those updates for Debian/Ubuntu based systems.
- For RHEL/CentOS based systems use `sudo yum -y update`
1. Install Software: Different software can also be installed directly from the command line.
- On Debian/Ubuntu based systems `sudo apt-get install [name of the software]`
- On RHEL/CentOS based systems use `sudo yum install [name of the software]`
1. Exit: To end the session, just type `exit` in the CLI.
Remember to always double-check your commands before pressing enter. Mistypes can cause a lot of trouble. Also note, most of the time you will need to use ‘sudo’ prefix to have administrative privileges to perform certain tasks.