Web Server

Nginx port to subfolder reverse proxy

server {
    listen 80;

    index index.html index.htm index.nginx-debian.html index.php;


    location ~/app2(.*)$ {
        proxy_set_header X-Real-IP  $remote_addr;
        proxy_set_header X-Forwarded-For $remote_addr;
        proxy_set_header Host $host;

Basic netstat Command

netstat [OPTIONS]
       Default : Displays  a  list of open sockets

    --route , -r
       Display  the kernel routing tables.

   --groups , -g
       Display multicast group membership information for IPv4 and IPv6.

   --interfaces, -i
       Display a table of all network interfaces.

   --masquerade , -M
       Display a list of masqueraded connections.

   --statistics , -s
       Display summary statistics for each protocol.

Netstat command


Show numerical addresses

netstat -n

Show only tcp connections

netstat -t

Show only udp connections

netstat -u

Show only listening sockets

netstat -l

Show name and PID of programs

netstat -p

Show network statistics

netstat -s

Show kernel routing table

netstat -r

Show listening ports, process, port numbers

netstat -pln

Show listening ports, process, port numbers for TCP

netstat -plnt

chown and chmod Command basics


# chown owner-user file 
# chown owner-user:owner-group file

Listing files with owner and group

# ls -la

Changing owner and owner group

# chown praison file.txt
# chown praison:praison file.txt

Change the owner for a folder

# chown praison:praison /folder

Change the owner for all subfiles of the folder

# chown -R praison:praison /folder


# chmod options permissions file name

Change permission for a single file

# chmod 644 filename

Change permission for all files under a directory

# chmod -R 755 directory

Make your file executable

# sudo chmod +x filename

Basic PS Linux commands

Display all processes

$ ps ax
$ ps -ef
$ ps aux
$ ps -ef -f

Display process by a user

$ ps -f -u www-data

Display process by process ID or name

$ ps ax | grep apache
$ ps -ef | grep apache
$ ps -C apache2
$ ps -f  -p 3150,7298,6544

Sort process by CPU or memory usage

$ ps aux --sort=-pcpu | head -5

Display elapsed time of a process

$ ps -e -o pid,comm,etime

Realtime process viewer

$ watch -n 1 'ps -e -o pid,uname,cmd,pmem,pcpu --sort=-pmem,-pcpu | head -15'
Web Server


Check syntax of Nginx’s configuration files

nginx -t -c /etc/nginx/nginx.conf

Debug Command

$ service nginx configtest

Apache Server Port number Check

netstat -ntpl |grep httpd