Jun 11, 2024

Ubuntu/Linux Commands

 Check ubuntu version

  • lsb_release -a
Checking date
  • date
  • date + "%d/%b/%y-%R:%S"
  • vim date-time.sh
Repository
  • /etc/apt/sources.list
Installation
  • apt-get install mysql
or
  • wget https://dev.mysql.com/get/mysql-apt-config_0.8.12-1_all.deb
  • dpkg -i mysql-apt-config_0.8.12-1_all.deb


Restart service
  • systemctl restart mysql
Check installed app
  • apt --list
or
  • dpkg --list
Running Process 
  • ps
  • ps aux
  • ps aux | grep ssh
  • ps aux —sort=-pcpu,+pmem
  • ps -o pid,uname,comm -C <process>
  • top
  • htop
Kill Running Process
  • kill pid <number pid>
Network Monitor
  • nmon
File or folder directory
  • ls
  • ll
  • cd ../
  • cd /etc/
  • cd
Copy File
  • cp info.php info.php.0
Read File
  • cat /etc/source.cnf
Disk Usage
  • df
  • df -T
  • df -m
  • df -h
  • df -i
Check Memory Usage
  • free
  • free -h
  • watch free
  • watch -d free
Check IP Address
  • ip a
Shutdown
  • systemctl poweroff
Restart
  • reboot
Start/Stop Apps Service
  • systemctl stop nginx
  • systemctl start nginx
  • systemctl reload nginx
  • systemctl restart nginx
  • service nginx reload
  • service nginx restart
Web Server Information
  • curl -i http://localhost
Remove File/Folder
  • rm /etc/apt/...
  • rm -rf /etc/apt.....
Firewall
  • ufw allow http
  • ufw status
Nginx (Install)

Nginx
  • nginx -t

Nginx (Restrict IP Access)

Configure SSL
  • mkdir /etc/nginx/ssl/
  • openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /etc/nginx/ssl/nginx.key -out /etc/nginx/ssl/nginx.crt
  • add-apt-repository ppa:certbot/certbot
  • apt install python-certbot-nginx
  • certbot --nginx -d ......................
  • certbot renew --dry-run
  • letsencrypt
  • disable ipv6 on DBS Server

Wapiti (Web Vulnerability Scanner)
  • apt install wapiti
  • wapiti http://facebook.com -n 10 -b folder
Fail2Ban (Security Tools)
  • Block IP Ranges
Repository
  • /etc/apt/source.list

------------
lxd init --auto