Ubuntu is one of the most popular operating systems for server management, known for its simplicity, stability, and extensive support. Whether you’re new to server management or an experienced admin, understanding key Ubuntu commands is crucial. Here are common commands and straightforward explanations on how to use them effectively. These are some commands i commonly used in managing my own web server.
1. Update and Upgrade Your Server
sudo apt update
: This checks the repositories and updates the list of available software packages.sudo apt upgrade
: This command upgrades the installed packages on your system to their latest versions.
Regularly running these commands helps maintain your server’s security and stability.
2. Managing Users
sudo adduser username
: Adds a new user to your server, prompting you to set a password and additional details.sudo passwd username
: Allows you to change or set the password for an existing user.
Managing users effectively is critical for server security and proper access control.
3. Managing File Permissions
sudo chown user:group file
: Changes the ownership of a file or directory.sudo chmod 755 file
: Sets permissions (read, write, execute) for owner, group, and others. This ensures proper access management.
Correct file permissions and ownership are vital for maintaining security and functionality.
4. Managing System Services
sudo systemctl status servicename
: Checks the current status of a service (e.g., nginx, apache2, mysql).sudo systemctl start servicename
: Starts a service.sudo systemctl stop servicename
: Stops a service.sudo systemctl restart servicename
: Restarts a service to apply new settings.
Knowing how to manage services helps you maintain optimal server performance.
Are you familiar of those commands? Check also more command on managing full web server:
EASY Guide to Setting Up and Managing an Unmanaged Ubuntu Web Server with NGINX, PHP, and SSL
5. Firewall Management
sudo ufw allow 80,443/tcp
: Allows HTTP and HTTPS traffic through your firewall.
Proper firewall configuration enhances your server’s security by controlling network access.
6. Disk and Resource Monitoring
df -h
: Displays available disk space in an easy-to-read format.du -sh /path
: Shows the total disk space used by a specific directory.top
orhtop
: Provides a live overview of resource usage (CPU, memory, processes).ps aux | grep processname
: Checks running processes and their details.
Monitoring your server helps detect issues early and manage resources effectively.
7. File and Directory Management
ls -lh
: Lists files with human-readable sizes.rm file
orrm -r dir
: Removes files or directories safely.
Efficient file management prevents clutter and maintains system order.
8. Installing and Removing Packages
sudo apt install packagename
: Installs new software packages.sudo apt remove packagename
: Removes unnecessary packages from your server.
Managing packages allows you to customize your server to suit your needs.
9. Remote Server Access and File Transfer
ssh user@server_ip
: Securely accesses your server remotely via SSH.scp file user@server_ip:/path
: Securely transfers files to your remote server.
Remote access and file transfers are essential for managing your server remotely and efficiently.
10. Scheduled Tasks
crontab -e
: Opens the cron jobs scheduler, allowing you to automate regular tasks.
Automating tasks with cron saves time and ensures consistency in routine maintenance.
Mastering these Ubuntu commands will empower you to manage your server effectively, maintain security, and optimize its performance. Incorporate these commands into your regular server management routine to keep your hosting environment running smoothly.