Skip to content

Instantly share code, notes, and snippets.

@codler
Last active October 12, 2020 10:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save codler/948b8d3f28057d807defb728c73c683c to your computer and use it in GitHub Desktop.
Save codler/948b8d3f28057d807defb728c73c683c to your computer and use it in GitHub Desktop.

New OS

sudo apt update
sudo apt full-upgrade

Check most used disk usage by folder

sudo du -a / 2>/dev/null | sort -n -r | head -n 20

Save space

sudo apt clean
uname -r
dpkg --list 'linux-image-*'
sudo apt purge linux-image-4.19.0-11-amd64-unsigned linux-image-4.19.0-9-amd64 linux-image-4.19.0-9-amd64-unsigned linux-image-amd64

systemctl

sudo systemctl enable mongod  # Autostart on boot
sudo systemctl start mongod
sudo systemctl stop mongod
sudo systemctl restart mongod
sudo systemctl status mongod
sudo systemctl deamon-reload  # Run after edit x.service

Mongodb

sudo nano /etc/mongod.conf
sudo nano /lib/systemd/system/mongod.service

sudo mongodump --db admin --out /var/backups/mongobackups/`date +"%m-%d-%y"` --authenticationDatabase "admin" -u "admin" -p
sudo mongorestore --db admin --drop ./admin/ --authenticationDatabase "admin" -u "admin"

journalctl

sudo journalctl -u mongod -n 20

Serivce for systemctl

sudo nano /lib/systemd/system/hello_env.service

Service file

[Unit]
Description=hello_env.js - making your environment variables rad
Documentation=https://example.com
After=network.target

[Service]
Environment=NODE_PORT=3002
Type=simple
User=codler
WorkingDirectory=/home/codler/project
ExecStart=npm run server
Restart=on-failure

[Install]
WantedBy=multi-user.target

Jenkins

sudo visudo
# at end of file
jenkins ALL=(ALL) NOPASSWD: ALL
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment