Search Commands
Search Results
Python Commands
Environment
python3 -m venv venv
Create a new virtual environment.
python3 -m venv myproject_env
source venv/bin/activate
Activate virtual environment (Linux/Mac).
source venv/bin/activate
pip install -r requirements.txt
Install dependencies from requirements file.
pip install -r requirements.txt
pip freeze > requirements.txt
Export current dependencies to requirements file.
pip freeze > requirements.txt
python -m http.server 8000
Start simple HTTP server on port 8000.
python -m http.server 8080
Django
django-admin startproject myproject
Create a new Django project.
django-admin startproject webapp
python manage.py runserver
Start Django development server.
python manage.py runserver 0.0.0.0:8000
python manage.py makemigrations
Create database migrations.
python manage.py makemigrations
python manage.py migrate
Apply database migrations.
python manage.py migrate
python manage.py createsuperuser
Create Django admin superuser.
python manage.py createsuperuser
Flask
flask run
Start Flask development server.
flask run --host=0.0.0.0 --port=5000
flask db init
Initialize Flask-Migrate database.
flask db init
flask db migrate -m "message"
Create new database migration.
flask db migrate -m "Add user table"
flask db upgrade
Apply database migrations.
flask db upgrade
NGINX Commands
Configuration
nginx -t
Test NGINX configuration for syntax errors.
nginx -t
nginx -s reload
Reload NGINX configuration without stopping.
nginx -s reload
nginx -s stop
Stop NGINX server.
nginx -s stop
nginx -s quit
Gracefully shutdown NGINX.
nginx -s quit
Logs
tail -f /var/log/nginx/access.log
Follow NGINX access log in real-time.
tail -f /var/log/nginx/access.log
tail -f /var/log/nginx/error.log
Follow NGINX error log in real-time.
tail -f /var/log/nginx/error.log
nginx -V
Show NGINX version and compile-time options.
nginx -V
Portainer Commands
Installation
docker volume create portainer_data
Create volume for Portainer data persistence.
docker volume create portainer_data
docker run -d -p 8000:8000 -p 9443:9443 --name portainer --restart=always -v /var/run/docker.sock:/var/run/docker.sock -v portainer_data:/data portainer/portainer-ce:latest
Run Portainer CE with SSL on port 9443.
docker run -d -p 9443:9443 --name portainer --restart=always -v /var/run/docker.sock:/var/run/docker.sock -v portainer_data:/data portainer/portainer-ce:latest
Management
docker logs portainer
View Portainer container logs.
docker logs -f portainer
docker restart portainer
Restart Portainer container.
docker restart portainer
docker stop portainer && docker rm portainer
Stop and remove Portainer container.
docker stop portainer && docker rm portainer
Linux Server Commands
System Info
htop
Interactive process and system monitor.
htop
df -h
Show disk space usage in human-readable format.
df -h
free -h
Display memory usage in human-readable format.
free -h
uptime
Show system uptime and load average.
uptime
lscpu
Display CPU architecture information.
lscpu
Services
systemctl status <service>
Check status of a systemd service.
systemctl status nginx
systemctl start <service>
Start a systemd service.
systemctl start nginx
systemctl stop <service>
Stop a systemd service.
systemctl stop nginx
systemctl restart <service>
Restart a systemd service.
systemctl restart nginx
systemctl enable <service>
Enable service to start at boot.
systemctl enable nginx
Network
netstat -tulpn
Show listening ports and associated processes.
netstat -tulpn | grep :80
ss -tulpn
Modern replacement for netstat to show sockets.
ss -tulpn | grep :443
iptables -L
List all iptables firewall rules.
iptables -L -n
ufw status
Show UFW firewall status and rules.
ufw status verbose
ping -c 4 <host>
Test network connectivity to a host.
ping -c 4 google.com
curl -I <url>
Check HTTP headers and response status.
curl -I https://example.com
Security & Users
sudo -i
Switch to root user with environment.
sudo -i
sudo su - <username>
Switch to another user account.
sudo su - www-data
passwd <username>
Change password for a user.
passwd john
useradd -m -s /bin/bash <username>
Create new user with home directory.
useradd -m -s /bin/bash developer
usermod -aG sudo <username>
Add user to sudo group.
usermod -aG sudo developer
chmod 755 <file/directory>
Set file/directory permissions.
chmod 755 /var/www/html
chown -R <user>:<group> <directory>
Change ownership of files/directories.
chown -R www-data:www-data /var/www
Process Management
ps aux
List all running processes.
ps aux | grep nginx
kill -9 <pid>
Force kill a process by PID.
kill -9 1234
killall <process_name>
Kill all processes by name.
killall nginx
nohup <command> &
Run command in background, immune to hangups.
nohup python3 app.py &
screen -S <session_name>
Create a new screen session.
screen -S myapp
tmux new-session -s <session_name>
Create a new tmux session.
tmux new-session -s development
Logs & Monitoring
journalctl -u <service> -f
Follow systemd service logs in real-time.
journalctl -u nginx -f
tail -f /var/log/syslog
Follow system log in real-time.
tail -f /var/log/syslog
dmesg | tail
Show recent kernel messages.
dmesg | tail -20
who
Show who is currently logged in.
who
last
Show last logged in users.
last -10
SSH & Remote Commands
SSH Basics
ssh user@hostname
Connect to remote server via SSH.
ssh root@192.168.1.100
ssh -p <port> user@hostname
Connect to SSH on custom port.
ssh -p 2222 user@server.com
ssh-keygen -t rsa -b 4096
Generate SSH key pair for authentication.
ssh-keygen -t rsa -b 4096 -C 'user@email.com'
ssh-copy-id user@hostname
Copy SSH public key to remote server.
ssh-copy-id admin@server.com
scp <file> user@hostname:<path>
Secure copy files to remote server.
scp app.zip user@server:/home/user/
rsync -avz <source> user@hostname:<dest>
Synchronize files/directories to remote server.
rsync -avz ./website/ user@server:/var/www/
SSH Key Management
ssh-add ~/.ssh/keyname
Add SSH private key to authentication agent.
ssh-add ~/.ssh/id_rsa
ssh-agent bash
Start SSH agent for managing private keys.
eval $(ssh-agent -s)
chmod 600 ~/.ssh/id_rsa
Set correct permissions for SSH private key.
chmod 600 ~/.ssh/id_rsa
ssh-add -l
List SSH keys currently loaded in agent.
ssh-add -l
SSH Security
sudo nano /etc/ssh/sshd_config
Edit SSH server configuration.
sudo nano /etc/ssh/sshd_config
sudo systemctl restart sshd
Restart SSH service after config changes.
sudo systemctl restart sshd
ssh -i <keyfile> user@hostname
Connect using specific private key file.
ssh -i ~/.ssh/server_key user@server.com
ssh -L <local_port>:localhost:<remote_port> user@hostname
Create SSH tunnel for port forwarding.
ssh -L 8080:localhost:80 user@server.com
ssh -v user@hostname
Connect with verbose output for debugging SSH issues.
ssh -v user@server.com
sudo ufw allow OpenSSH
Allow SSH through UFW firewall.
sudo ufw allow OpenSSH
sudo fail2ban-client status sshd
Check fail2ban SSH protection status.
sudo fail2ban-client status sshd
sshd -T
Display active SSH server configuration.
sudo sshd -T | grep Port
Remote Sessions
tmux new -s session_name
Create new tmux session for persistent remote work.
tmux new -s development
screen -S session_name
Start screen session for detached remote work.
screen -S server_maintenance
sftp user@hostname
Connect to remote server using SFTP for file transfer.
sftp admin@server.com
ssh user@host 'bash -s' < local_script.sh
Execute local script on remote server via SSH.
ssh user@server 'bash -s' < deploy.sh
Advanced Tunneling
ssh -R <remote_port>:localhost:<local_port> user@hostname
Create reverse SSH tunnel from remote to local.
ssh -R 8080:localhost:3000 user@server.com
ssh -D <local_port> user@hostname
Create SOCKS proxy tunnel through SSH.
ssh -D 1080 user@server.com
ssh -N -f -L <local_port>:localhost:<remote_port> user@hostname
Create background SSH tunnel without shell.
ssh -N -f -L 5432:localhost:5432 user@db-server.com
Package Management Commands
APT (Ubuntu/Debian)
sudo apt update
Update package repository information.
sudo apt update
sudo apt upgrade
Upgrade all installed packages.
sudo apt upgrade -y
sudo apt install <package>
Install a package.
sudo apt install nginx
sudo apt remove <package>
Remove a package.
sudo apt remove apache2
apt search <keyword>
Search for packages by keyword.
apt search python3
sudo apt autoremove
Remove unused packages and dependencies.
sudo apt autoremove
sudo apt list --upgradable
Show available package updates.
sudo apt list --upgradable
sudo apt purge <package>
Remove package and its configuration files.
sudo apt purge apache2
sudo apt show <package>
Display detailed package information.
sudo apt show nginx
sudo apt-cache policy <package>
Show package version and repository source.
sudo apt-cache policy docker.io
sudo dpkg -i <file>.deb
Install .deb package file directly.
sudo dpkg -i package.deb
sudo dpkg -r <package>
Remove package using dpkg.
sudo dpkg -r old-package
YUM/DNF (RedHat/CentOS)
sudo yum update
Update all packages (CentOS 7 and older).
sudo yum update -y
sudo dnf update
Update all packages (CentOS 8+/Fedora).
sudo dnf update -y
sudo yum install <package>
Install package with YUM.
sudo yum install nginx
sudo dnf install <package>
Install package with DNF.
sudo dnf install nginx
sudo yum remove <package>
Remove package with YUM.
sudo yum remove httpd
sudo dnf remove <package>
Remove package with DNF.
sudo dnf remove httpd
sudo dnf list installed
List all installed packages.
sudo dnf list installed | grep nginx
sudo dnf info <package>
Display detailed package information.
sudo dnf info nginx
Snap/Flatpak
sudo snap install <package>
Install application using Snap.
sudo snap install code --classic
sudo snap remove <package>
Remove Snap application.
sudo snap remove code
snap list
List installed Snap applications.
snap list
flatpak install <package>
Install application using Flatpak.
flatpak install flathub org.gimp.GIMP
flatpak remove <package>
Remove Flatpak application.
flatpak remove org.gimp.GIMP
flatpak list
List installed Flatpak applications.
flatpak list
Shell Commands
Navigation
pwd
Print the current working directory.
pwd
ls
List files and directories in the current directory.
ls -lah
cd <directory>
Change to the specified directory.
cd /usr/local/bin
cd ..
Move up one directory level.
cd ..
cd -
Switch to the previous directory.
cd -
Directories
mkdir <directory>
Create a new directory.
mkdir project
rmdir <directory>
Remove an empty directory.
rmdir old_folder
rm -r <directory>
Remove a directory and its contents recursively.
rm -r build
mv <source> <destination>
Move or rename files/directories.
mv old_folder new_folder
du -sh <directory>
Show disk usage of a directory in human-readable format.
du -sh logs/
Files
touch <file>
Create an empty file or update its timestamp.
touch README.md
rm <file>
Remove a file.
rm temp.txt
cp <source> <destination>
Copy files or directories.
cp -r src/ backup/src/
cat <file>
Display the contents of a file.
cat notes.txt
head <file>
Show the first lines of a file.
head -n 10 logfile.log
tail <file>
Show the last lines of a file.
tail -f logfile.log
Search & Display
find <path> -name "<pattern>"
Search directories for files matching a pattern.
find . -name "*.log"
grep -R "<text>" <directory>
Recursively search files for a text pattern.
grep -R "TODO" src/
tree
Display directory structure as a tree.
tree -L 2
locate <filename>
Quickly find file paths by name (requires updated database).
locate config.yaml
which <command>
Show the full path of a command binary.
which python3
File Operations
nano <file>
Edit file in terminal text editor.
nano config.txt
chmod <mode> <file>
Change file permissions.
chmod 755 script.sh
chown <user>:<group> <file>
Change file ownership.
chown user:group file.txt
Archives
tar -czvf <archive.tar.gz> <folder>
Create compressed tar archive.
tar -czvf backup.tar.gz documents/
tar -xzvf <archive.tar.gz>
Extract compressed tar archive.
tar -xzvf backup.tar.gz
zip -r <archive.zip> <folder>
Create ZIP archive.
zip -r project.zip project/
unzip <archive.zip>
Extract ZIP archive.
unzip project.zip
Terminal Helpers
clear
Clear terminal screen.
clear
history
Show command history.
history | tail -10
Text Processing
grep "<text>" <file>
Search for text pattern in file.
grep "error" logfile.txt
wc -l <file>
Count lines in file.
wc -l data.txt
sort <file> | uniq
Sort file and remove duplicate lines.
sort names.txt | uniq
Processes
ps aux | grep <process>
Find running processes by name.
ps aux | grep nginx
top
Display running processes and system resources.
top
htop
Interactive process viewer (if installed).
htop
Docker Commands
Container
docker ps
List running containers.
docker ps -a
docker stop <container_id>
Stop a running container.
docker stop my_container
docker run -d --name <name> <image>
Run a new container in detached mode.
docker run -d --name webserver nginx
docker exec -it <container_id> /bin/bash
Open an interactive shell inside a running container.
docker exec -it my_container /bin/bash
docker logs <container_id>
View logs of a container.
docker logs my_container
docker restart <container_id>
Restart a running container.
docker restart my_container
docker rm <container_id>
Remove a stopped container.
docker rm my_container
docker stop $(docker ps -q)
Stop all running containers.
docker stop $(docker ps -q)
Images
docker images
List available Docker images.
docker images --all
docker rmi <image_id>
Remove a Docker image.
docker rmi ubuntu:latest
docker pull <image>
Download an image from a registry.
docker pull node:14
docker tag <source_image> <target_image>
Tag an image with a new name.
docker tag ubuntu:latest myrepo/ubuntu:v1
docker build -t <name> .
Build a Docker image from Dockerfile in current directory.
docker build -t myapp:latest .
Networks
docker network ls
List Docker networks.
docker network ls
docker network create <network_name>
Create a new Docker network.
docker network create frontend_net
docker network inspect <network>
Show detailed information about a network.
docker network inspect bridge
docker network connect <network> <container>
Connect a container to a network.
docker network connect frontend_net webapp
docker network disconnect <network> <container>
Disconnect a container from a network.
docker network disconnect frontend_net webapp
Volumes
docker volume ls
List Docker volumes.
docker volume ls
docker volume create <volume_name>
Create a new Docker volume.
docker volume create data_volume
Debug
docker inspect <resource>
Show detailed information about containers, images, volumes or networks.
docker inspect my_container
docker stats
Display live resource usage statistics of running containers.
docker stats --no-stream
docker top <container_id>
Display running processes inside a container.
docker top my_container
Cleanup
docker system prune -a
Remove all unused containers, networks, images and build cache.
docker system prune -a --force
docker image prune
Remove dangling and unused images.
docker image prune -a
docker volume prune
Remove unused volumes.
docker volume prune --force
Registry
docker login
Log in to a Docker registry.
docker login docker.io
docker logout
Log out from a Docker registry.
docker logout docker.io
Context
docker context ls
List available Docker contexts.
docker context ls
docker context use <context>
Switch to a different Docker context.
docker context use remote-docker
Compose
docker-compose build
Build or rebuild services defined in docker-compose.yml
docker-compose build --no-cache
docker-compose up
Create and start containers in detached mode
docker-compose up -d
docker-compose down
Stop and remove containers, networks, volumes
docker-compose down -v
docker-compose logs
View output from containers
docker-compose logs -f web
docker-compose ps
List running compose services
docker-compose ps
docker-compose exec
Execute a command in a running container
docker-compose exec web bash
docker-compose restart
Restart services
docker-compose restart nginx
docker-compose config
Validate and view the compose file
docker-compose config
docker-compose pull
Pull service images
docker-compose pull
docker-compose pause/unpause
Pause or unpause services
docker-compose pause redis
docker-compose stop
Stop running services without removing containers
docker-compose stop web
docker-compose rm
Remove stopped service containers
docker-compose rm -f
docker-compose up -d --build
Build images and start services in detached mode
docker-compose up -d --build --force-recreate
Git Commands
Basics
git init
Initialize a new Git repository.
git init my_project
git clone <repo_url>
Clone a remote repository.
git clone https://github.com/user/repo.git
git status
Show the current status of the working directory.
git status
git add <file>
Add changes to the staging area.
git add README.md
git commit -m "message"
Commit staged changes with a message.
git commit -m "Initial commit"
Staging
git restore --staged <file>
Remove file from staging area.
git restore --staged README.md
git restore <file>
Discard changes in working directory.
git restore config.js
git reset <file>
Remove file from staging area (legacy).
git reset HEAD file.txt
Branching
git branch
List all branches.
git branch --all
git checkout <branch_name>
Switch to a different branch.
git checkout develop
git checkout -b <branch_name>
Create and switch to a new branch.
git checkout -b feature/new-feature
git merge <branch_name>
Merge a branch into the current branch.
git merge feature/new-feature
git branch -d <branch_name>
Delete a branch.
git branch -d feature/old-feature
git switch <branch>
Switch to a different branch (modern alternative to checkout).
git switch develop
git stash
Temporarily save uncommitted changes.
git stash push -m "work in progress"
git stash pop
Restore and remove most recent stashed changes.
git stash pop
Remote
git remote -v
Show remote repositories.
git remote -v
git push origin <branch_name>
Push changes to a remote repository.
git push origin main
git pull origin <branch_name>
Pull changes from a remote repository.
git pull origin main
git fetch
Fetch changes from remote without merging.
git fetch origin
git branch -u origin/<branch>
Set upstream tracking for current branch.
git branch -u origin/main
git fetch --prune
Fetch changes and remove stale remote branches.
git fetch --prune origin
Analysis
git show <commit>
Display details and changes of a specific commit.
git show abc123
git blame <file>
Show who last modified each line of a file.
git blame src/main.js
git tag
List all tags in the repository.
git tag --sort=-version:refname
git tag <name>
Create a new tag at current commit.
git tag v1.0.0
History
git log
Show commit history.
git log --oneline
git diff
Show changes between commits or working directory.
git diff HEAD~1
git reset <commit>
Reset to a specific commit.
git reset --hard HEAD~1
git revert <commit>
Revert a specific commit.
git revert abc123
Kubernetes Commands
Pods
kubectl get pods
List all pods in the current namespace.
kubectl get pods -o wide
kubectl describe pod <pod-name>
Show detailed information about a specific pod.
kubectl describe pod my-app-pod
kubectl logs <pod-name>
View logs from a specific pod.
kubectl logs -f my-app-pod
kubectl exec -it <pod-name> -- /bin/bash
Execute commands inside a running pod.
kubectl exec -it my-app-pod -- /bin/bash
Services
kubectl get services
List all services in the current namespace.
kubectl get svc -o wide
kubectl expose deployment <deployment-name> --port=80
Create a service to expose a deployment.
kubectl expose deployment nginx --port=80 --type=LoadBalancer
Deployments
kubectl get deployments
List all deployments in the current namespace.
kubectl get deployments -o wide
kubectl scale deployment <deployment-name> --replicas=3
Scale a deployment to a specified number of replicas.
kubectl scale deployment nginx --replicas=5
kubectl rollout restart deployment/<deployment-name>
Restart a deployment by triggering a rollout.
kubectl rollout restart deployment/nginx