Last active
February 22, 2025 16:31
-
-
Save vistajess/1daed2c2ea6779fac827a199d6911c6f to your computer and use it in GitHub Desktop.
Ubuntu cheat sheet
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Ubuntu CLI Cheat Sheet π | |
## π File & Directory Management | |
```bash | |
ls -la # List all files, including hidden ones | |
pwd # Show current directory | |
cd /path/to/dir # Change directory | |
mkdir folder_name # Create a new folder | |
rm -rf folder_name # Remove a folder and its contents | |
cp file1 file2 # Copy a file | |
cp -r dir1 dir2 # Copy a directory | |
mv file1 file2 # Move or rename a file | |
find /path -name "filename" # Find a file by name | |
locate filename # Find file (faster but needs `sudo updatedb`) | |
## π File Operations | |
cat file.txt # Show file contents | |
less file.txt # View large files page by page | |
nano file.txt # Edit file in Nano | |
vim file.txt # Edit file in Vim | |
echo "text" > file.txt # Create a file with text | |
echo "text" >> file.txt # Append text to a file | |
touch file.txt # Create an empty file | |
wc -l file.txt # Count lines in a file | |
## π Process & Resource Management | |
ps aux # Show all running processes | |
top # Monitor system processes | |
kill PID # Kill a process by ID | |
kill -9 PID # Force kill a process | |
pkill -9 processname # Kill a process by name | |
## π₯ Kill Process on a Port | |
sudo lsof -i :PORT # Find process using a port | |
sudo fuser -k PORT/tcp # Kill process using a port | |
sudo netstat -tulnp | grep :PORT # Find process (alternative) | |
sudo kill -9 $(sudo lsof -t -i :PORT) # Kill process directly | |
## π Network Commands | |
ifconfig or ip a # Show network interfaces | |
ping example.com # Ping a website | |
wget URL # Download a file | |
curl -O URL # Download with curl | |
netstat -tulnp # List active network connections | |
ss -tulnp # Modern alternative to netstat | |
traceroute example.com # Trace the route packets take | |
host example.com # Get DNS information | |
## π User Management | |
whoami # Show current user | |
id username # Show user ID and group | |
sudo adduser username # Add a new user | |
sudo userdel -r username # Delete a user | |
passwd # Change user password | |
who # Show logged-in users | |
sudo visudo # Edit sudoers file | |
## π¦ Package Management | |
sudo apt update # Refresh package list | |
sudo apt upgrade # Upgrade installed packages | |
sudo apt install package # Install a package | |
sudo apt remove package # Remove a package | |
dpkg -l | grep package # Check if a package is installed | |
apt-cache search keyword # Search for a package | |
## π System Control | |
uname -a # Show system information | |
df -h # Check disk usage | |
du -sh folder/ # Check folder size | |
history # Show command history | |
sudo reboot # Restart the system | |
sudo shutdown -h now # Shutdown immediately | |
uptime # Show system uptime | |
## πΎ File Permissions | |
chmod 777 file # Full permissions for everyone | |
chmod +x script.sh # Make a script executable | |
chown user:group file # Change file ownership |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment