Basic Commands for Working with a Linux VPS Server
1 мин. чтения
🔄 Rebooting and Shutting Down the Server #
sudo reboot — reboot the server
sudo shutdown -h now — shut down the server immediately
sudo shutdown -r +5 — reboot in 5 minutes
sudo poweroff — power off the server
📂 File System Navigation #
pwd — show current directory
ls — list files and folders in the current directory
ls -la — list all files including hidden, with details
cd /path/to/folder — change to specified directory
cd .. — go up one directory level
cd ~ or cd — go to the user’s home directory
🗂️ Working with Files and Folders #
cp source destination — copy a file or folder
mv source destination — move or rename a file/folder
rm file — delete a file
rm -r folder — delete a folder recursively
mkdir folder_name — create a new folder
touch file_name — create an empty file
cat file — display file contents in the terminal
nano file — open file in nano text editor
⚙️ Managing Processes and Services #
🧠 Viewing and managing processes: #
top — show active processes in real time
htop — improved top (if installed)
ps aux — list all processes with details
kill PID — terminate a process by ID
kill -9 PID — force kill a process
🔧 Managing systemd services: #
sudo systemctl start service_name — start a service
sudo systemctl stop service_name — stop a service
sudo systemctl restart service_name — restart a service
sudo systemctl status service_name — check service status
sudo systemctl enable service_name — enable service autostart at OS boot
sudo systemctl disable service_name — disable service autostart
sudo journalctl -u service_name — view service logs
sudo journalctl -u service_name -f — view service logs in real time
💾 Disk and Memory Information #
df -h — show disk usage in human-readable format
du -sh /path/to/folder — size of specified folder
free -h — show RAM usage
vmstat — show memory and process statistics
🌐 Network and Connections #
ip a — show all network interfaces
ping google.com — check website availability
netstat -tulnp — show all listening ports and processes
ss -tulw — modern alternative to netstat
curl ifconfig.me — show server external IP address
ssh user@ip_address — connect to another server via SSH
👥 User Management #
whoami — show current user
adduser username — create a new user
passwd username — change user password
usermod -aG sudo username — add user to sudo group
deluser username — delete a user
📦 Package Management (Debian/Ubuntu) #
sudo apt update — update package list
sudo apt upgrade — upgrade installed packages
sudo apt install package_name — install a package
sudo apt remove package_name — remove a package
sudo apt autoremove — remove unused packages
🛠️ Additional Useful Commands #
history — show command history
clear — clear terminal screen
who — show who is currently logged in
uptime — show server uptime
date — show current date and time
chmod +x file — make a file executable
scp file user@host:/path/ — copy a file to a remote server
🔒 Security Tips #
- Never run commands as
rootunless necessary. Usesudo. - Regularly update the system and installed packages.
- Use SSH keys instead of passwords for server access.
- Create backups of important data.