Basic Terminal Commands for Ubuntu Server Setup: A Beginner’s Guide

Ubuntu Server is one of the most popular choices for developers and system administrators due to its reliability and vast community support. Whether you’re setting up a new server for hosting a website, managing applications, or learning Linux, understanding basic terminal commands is crucial. This article walks you through essential terminal commands for setting up and managing an Ubuntu Server.

Why Use Ubuntu Server?

Ubuntu Server is lightweight, secure, and comes with regular updates. It’s ideal for deploying web servers, databases, and other critical applications. Mastering the terminal ensures you can fully harness its power and manage your server efficiently.

1. Accessing the Server

Before using any commands, you need to access the server. This is usually done via SSH (Secure Shell).

Command:
ssh username@server-ip

Replace username with your server’s user and server-ip with the IP address.

2. Update and Upgrade System Packages

Keeping your system up-to-date is crucial for security and performance.
Command:

sudo apt update && sudo apt upgrade -y
  • sudo: Runs the command with administrative privileges.
  • apt update: Refreshes the package list.
  • apt upgrade: Installs the latest versions of installed packages.
  • -y: Automatically confirms prompts.

3. Creating and Managing Users

For security, it’s best to avoid using the root account for routine tasks.
Create a New User:

sudo adduser newusername

Grant Administrative Privileges:

sudo usermod -aG sudo newusername

4. Setting Up a Firewall with UFW

Uncomplicated Firewall (UFW) simplifies managing firewall rules.
Enable UFW:

sudo ufw enable

Allow SSH Access:

 sudo ufw allow ssh

Check Firewall Status:

sudo ufw status

5. Installing Common Software

You’ll often need to install software packages.

Install Apache (Web Server):

 sudo apt install apache2 -y

Install MySQL (Database Server):

 sudo apt install mysql-server -y

Install PHP:

 sudo apt install php libapache2-mod-php php-mysql -y

6. Managing Services

You’ll need to start, stop, or check the status of services regularly.

Start a Service:

 sudo systemctl start servicename

Stop a Service:

 sudo systemctl stop servicename

Check Service Status:

 sudo systemctl status servicename

Example for Apache: sudo systemctl status apache2

7. File and Directory Management

Basic file and directory commands will help you navigate and manage your server’s file system.

List Files in a Directory:

 ls -la

Change Directory:

 cd /path/to/directory

Create a New Directory:

 mkdir new_directory

Move or Rename Files:

 mv oldfilename newfilename

Delete Files or Directories:

rm filename
rm -r directoryname # For directories

8. Monitoring System Resources

Keep track of your server’s performance with these commands:

Check Disk Usage:

 df -h

Check Memory Usage:

 free -h

Monitor Running Processes:

 top

9. Rebooting and Shutting Down

Sometimes, you’ll need to restart or power down the server.

Reboot:

 sudo reboot

Shut Down:

 sudo shutdown now

 

Conclusion

Mastering these basic terminal commands will help you confidently set up and manage your Ubuntu Server. As you grow more familiar with these commands, you can explore advanced Linux utilities to optimize server performance and security.

FAQs

Q1: How do I reset my forgotten root password in Ubuntu Server?
A1: Boot into recovery mode and use passwd command to reset the password.

Q2: Is it necessary to use UFW on Ubuntu Server?
A2: While optional, using UFW simplifies managing firewall rules and improves security.

Comments

Leave a Reply

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

Need Help ? Call Our award-winning support team 24/7 at 01-4983900

© 2023 All right reserved to sobiztrend.com