List all processes with process ID that use a port

List open files # List open files is usefull for many things including: lsof -i :80 // list open files that use the port 80 A.K.A processes that use the port 80 lsof /folder // list open files (processes orginating) in folder lsof -p 1080 // list open files used by process id in this […]

■ ■ □ ■ ■ ■ □ □ ■

Create alias in ubuntu server

Add aliases in bash_aliases sudo nano  ~/.bash_aliases alias declaration format: alias commandname=’command you will alias’ ex: alias taillog=’tail -f var/log/error.log’   to activate defined aliases run source ~/.bashrc

■ ■ □ ■ ■ ■ □ □ ■

Installing PostgreSQL

First step: sudo apt-get update sudo apt-get install postgresql postgresql-contrib Second step: logging in  sudo -u postgres psql Creating user $ sudo -u postgres createuser <username> Creating Database $ sudo -u postgres createdb <dbname> Giving the user a password $ sudo -u postgres psql psql=# ALTER USER <username> with encrypted password ‘<password>’; Granting privileges on database psql=# […]

■ ■ □ ■ ■ ■ □ □ ■

Resize SWAP

//Make all swap off sudo swapoff -a //Resize sudo dd if=/dev/zero of=/swapfile bs=1M count=1024 //Swapfile usable sudo mkswap /swapfile //Swapon again sudo swapon /swapfile

■ ■ □ ■ ■ ■ □ □ ■

Delete files with 0 bites

find . -name ‘file*’ -size 0 -print0 | xargs -0 rm

■ ■ □ ■ ■ ■ □ □ ■

Create SWAP on LINUX SERVER

free -m mkdir -p /var/_swap_ cd /var/_swap_ #Here, 1M * 2000 ~= 2GB of swap memory dd if=/dev/zero of=swapfile bs=1M count=2000 mkswap swapfile swapon swapfile chmod 600 swapfile echo “/var/_swap_/swapfile none swap sw 0 0” >> /etc/fstab #cat /proc/meminfo free -m

■ ■ □ ■ ■ ■ □ □ ■