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.
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.
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.
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.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
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
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
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
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
Keep track of your server’s performance with these commands:
Check Disk Usage:
df -h
Check Memory Usage:
free -h
Monitor Running Processes:
top
Sometimes, you’ll need to restart or power down the server.
Reboot:
sudo reboot
Shut Down:
sudo shutdown now
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.
© 2023 All right reserved to sobiztrend.com
Leave a Reply