Linux/Bash Commands

Linux/Bash

User Actions

# Add user
sudo adduser pgsql

# Check user
whoami

# change user
sudo su - pgsql

Installed apps

#List of Installed Packages
sudo apt list --installed 

find / -name "filename" #find a file by name

SSH

# Access remote PC
sudo ssh username@ip-address

# Example
sudo ssh root@163.127.38.97


# Clone folders to remote via SSH
scp -r /path/to/local/dir user@remotehost:/path/to/remote/dir

System services

# List All System Services
‌systemctl -at service 

# Check status of an application
sudo systemctl status {app}.service
sudo systemctl status mysql.service

#List all system startup programs
systemctl -t service --state=active   

# Enable
sudo systemctl enable {service}
sudo systemctl enable confluence.service

# Disable
sudo systemctl disable {service}
sudo systemctl disable nginx.service

System DNS flush


sudo systemd-resolve --flush-caches

System ports

sudo netstat -peanut
sudo netstat -lp

#App use the port number
netstat -tulpn | grep :6379

#Get the PID of the process
ps -u my_account -o pid,rss,command | grep redis
# then kill
sudo kill -9 the_pid