Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 

readme.md

on ubuntu server

add user

sudo adduser new_user
usermod -aG sudo new_user

use the root user

sudo bash
#or
su root

manage sudo users

Sudoers allows particular users to run various commands as the root user, without needing the root password.

sudo bash
cd
visudo

add user to a group

usermod -aG groupname username

remove user from group

gpasswd --delete username groupname

change the ownership of a directory to the root user

ls -alh
sudo chown -R root /var/log/forever

change the ownership of a directory to the current user

ls -alh
sudo chown -R $USER /var/log/forever

change the group of a directory to the current user

#show the groups the username belongs to
whoami
groups username
sudo chgrp username file.txt

nginx

sudo apt-get install nginx
sudo service nginx start
sudo vim /etc/nginx/sites-available/default
ll /var/www/html/
#assign the www dir to <current logged user> instead of root
sudo chown -R $USER:$USER /var/www

node

curl -sL https://deb.nodesource.com/setup_14.x | sudo -E bash -
sudo apt-get install -y nodejs

log

ll /var/log/
sudo tail -f /var/log/auth.log

github / bitbucket ssh keys

cd /home/ubuntu/.ssh
ssh-keygen
cat id_rsa.pub
# add key to github / bitbucket
git remote -v
git remote add origin [email protected]:zsimo/api.git

Install unattended upgrades

sudo apt install unattended-upgrades
# View conf file
cat /etc/apt/apt.conf.d/50unattended-upgrades

scan for open ports

sudo apt install nmap
nmap YOUR_SERVER_IP_ADDRESS
# services list associated to ports
less /etc/services

ufw (uncomplicated firewall)

sudo ufw enable
ufw allow ssh
sudo ufw status verbose

ufw allow http
ufw deny http
ufw reject http
systemctl start firewalld
systemctl stop firewalld
systemctl disable firewalld
# remove port
sudo ufw status numbered
sudo ufw delete <number>

firewall centos firewall-cmd

see os version

cat /etc/issue

see dependencies

ldd /bin/bash

show processes

ps aux

show directories list by size

du --max-depth=1 -hx
lsblk

search for a string in the current directory and all subdirectories

grep -r "not_found" ./

list all files order by modification date desc

ls -ltr

list the biggest files in a given

du -ah /path/to/directory | sort -rh | head -n 20

see filesystem usage where the directory is located

df -h /path/to/directory

create file of a given size

sudo dd if=/dev/zero of=./10Gfile02 bs=1G count=10

show memory usage

free -h

show memory usage

sudo ncdu

remove all files and directories in the current directory

rm -rf ./*