Debian/Ubuntu server commands every VPS owner should know

Debian/Ubuntu server commands every VPS owner should know
Terminal console on Linux Ubuntu.

In this short guide, we’ll show you around 100 linux commands that are easy to use but are very powerful for receiving information and being in control of your server. I’ll show you the command, and explain what it does, you can follow along by trying these commands how as you go through the list.

System Information

• uname -a, Show your system or kernel info
• hostnamectl, Shows hostname and your OS info
• uptime, How long the server has been running for
• lsb_release -a, Shows your linux distro info
• cat /etc/os-release, Shows your OS release details
• lscpu, CPU info
• lspci, Lists PCI devices
• lsusb, Lists USB devices
• free -h, RAM usage
• df -h, Disk usage by mounted filesystems
• du -sh <directory>, Shows a total size of a directory

User and Group Management

• whoami, Shows the current user
• id, Shows user/group IDs
• adduser <user>, Add a new user
• usermod -aG sudo <user>, Give a user sudo permissions
• passwd <user>, Change user’s password
• deluser <user>, Delete a user
• groups, Show groups of the current user
• groupadd <group>, Create a new group
• gpasswd -a <user> <group>, Add a user to a group
• last, Show the login history
• w, Show who is logged in and what they’re up to

File and Directory Management

• ls -l, List files with details
• ls -a, List all files including hidden files
• cd <directory>, Change directory
• pwd, Print working directory
• mkdir <directoryname>, Create a new directory
• rmdir <directoryname>, Delete an empty directory
• rm -rf <directory>, Remove a directory and it’s contents
• cp <file1> <file2>, Copy a file
• mv <file1> <file2>, Move or rename a file
• touch <file.txt>, Create an empty file
• nano <file.txt>, Edit a file in nano editor
• cat <file.txt>, Show contents 
• less <file.txt>, View file with scrolling
• head -n 20 <file.txt>, Show first 20 lines of a file
• tail -f /var/log/syslog, Stream the log file
• find / -name “<name>.<file-type>”, Search for files by name and file type.

Networking

• ip, Shows IP addresses hooked to server
• ifconfig, Show network interfaces (requires net-tools package)
• ping <website>, Check connectivity
• traceroute <website>, Show route packets will take
• nslookup <website>, DNS lookup
• dig <website>, A more detailed DNS lookup
• netstat -tulnp, Show listening ports (requires net-tools package)
• ss -tulnp, Show sockets or ports
• curl <URL>, Fetch a URL’s content
• wget <URL>, Download a file
• scp file user@server:/directory, Copy file over SSH
• rsync -av file user@server:/directory, Sync files
• ftp <server>, Connect to FTP
• telnet host <port>, Test connection to a port

Package Management

• apt update, Refreshes package lists
• apt upgrade, Upgrade your installed packages
• apt full-upgrade, Upgrade including dependencies
• apt install <package>, Install a package
• apt remove <package>, Remove a package
• apt purge <package>, Remove package and their config files
• apt autoremove, Remove unused dependencies
• apt dpkg -i <file.deb>, Install a .deb package
• dpkg -l, List installed packages

Permissions

• chmod 755 <file>, Change file permissions
• chown <user>:<group> <file>, Change ownership of a file
• chgrp <group> <file>, Change group ownership
• umask 022, Default permission mask
• stat <file>, Show file permissions and details
• ls -l, Check permissions of files

Extras

• alias ll=’ls -la’, Create a command shortcut
• history, Show command history
• !<number>, Run command number <number> from history
• clear, Clear the terminal screen
• echo “Hello”, Print a text
• date, Show date and time
• cal, Show the calendar
• shutdown -h now, Shutdown the system
• reboot, Restart the system
• timedatectl, Show or set your timezone
• cron -e, Edit cron jobs