GNU Linux Survival Guide - labcabrera/lab-insurance GitHub Wiki
Display all |
|
Create |
|
Change password |
|
Display user groups |
|
Add to group |
|
Logged Users |
|
chmod (-R) 400 ${resource}
Octal | Binary | File mode |
---|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Alternative usage: chmod (+|-) (w|r|x) ${resource}
Change file owner |
|
Symbolic link creation |
|
Folder size |
|
Text replace |
|
File system disk space |
|
File monitoring |
|
Mount |
|
Umount |
|
Mount SSH |
|
Safe delete |
|
Find by name |
|
Find by name and execute action |
|
Find by content (grep) |
|
Find by content (find) |
|
Count occurrences |
|
Format | Compress | Extract |
---|---|---|
gzip/bzip2 |
|
|
zip |
|
|
7z |
|
|
Delete old files |
|
Find duplicates |
|
Process list |
|
Memory usage |
|
Process resources |
|
Force release memory |
|
Disk transfer rate |
|
Display environment |
|
Process monitor |
|
Install package from deb archive |
|
List installed packages |
|
User manual search |
|
Determine distro and kernel |
|
Search program folder |
|
RPM to DEB |
|
Network interfaces |
|
Open ports |
|
Route table |
|
DNS configuration |
|
SSH file copy |
|
SSH tunneling |
|
TCP Traceroute |
|
Port scan |
|
Silent port scan |
|
IP range scan |
|
OS detection |
|
#!/bin/bash # execute using ". ./set-proxy (enable|disable)" case "$1" in enable) export http_proxy="http://{user}:{password}@{host}:{port}" // (1) export https_proxy=$http_proxy export HTTP_PROXY=$http_proxy export HTTPS_PROXY=$http_proxy ;; disable) unset http_proxy unset https_proxy unset HTTP_PROXY unset HTTPS_PROXY ;; *) echo "Usage . $0 (enable|disable)" exit 1 esac
-
user:password
is not mandatory on anonymous proxy.
JSON pretty print file |
|
JSON pretty print curl |
|
Eclipse cleanup |
|
Red color bash prompt
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;31m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
Update |
|
Local commit |
|
List branches |
|
Create local branch |
|
Switch branch |
|
Override local changes |
|
Initialize local repo |
|
Create patch |
|
Apply patch |
|
Export master |
|
Determine URL |
|
Determine URL (broken ref) |
|
Create tag |
|
Push tag |
|
Merge and push (fast-fwd) |
|
Recursive folder pull |
|
git flow init -d git flow feature start foo git commit ... git flow feature finish foo git flow release start 0.1.0 git commit ... git flow release finish 0.1.0 git flow release publish 0.1.0
Install image |
|
Run image |
|
Run image |
|
Stop container |
|
Stop all containers |
|
Display all images |
|
Display running containers |
|
Display all containers |
|
Docker compose start |
|
Open container bash console |
|
Remove image |
|
Remove images |
|
Cleanup images |
|
Remove all containers |
|
Push private server |
|
Export and import |
|
docker run -i -t --name {name} -h {hostName} -p 1234:1234 -p 5678:5678 -v ${source}/${target ${imageName}:${imageVersion}
-i |
interactive |
--name |
container name |
-h |
container host name |
-t |
allocate a pseudo-TTY |
-v |
volumes |
Docker using proxy
#!/bin/bash # Check root user if [ "$EUID" -ne 0 ] ; then echo "Please run as root" exit 1 fi CONFIG_FILE=/etc/systemd/system/docker.service.d/http-proxy.conf USERNAME=***** PASSWORD=***** if [ ! -f $CONFIG_FILE ] ; then echo "[Service]" > $CONFIG_FILE echo "Environment=\"HTTP_PROXY=http://$USERNAME:$PASSWORD@host:80\"" >> $CONFIG_FILE echo "Environment=\"HTTPS_PROXY=http://$USERNAME:$PASSWORD@host:80\"" >> $CONFIG_FILE echo "Created file $CONFIG_FILE" cat $CONFIG_FILE fi echo "Restarting docker service" systemctl daemon-reload systemctl restart docker
#!/bin/bash CONFIG_FILE=/etc/systemd/system/docker.service.d/http-proxy.conf if [ -f $CONFIG_FILE ] ; then echo "Moving file $CONFIG_FILE" cat $CONFIG_FILE mv $CONFIG_FILE $CONFIG_FILE.exclude fi systemctl daemon-reload systemctl restart docker
Execute SQL |
|
Backup |
|
Restore / execute script |
|
Exit |
|
Exit !save |
|
Exit and save |
|
Undo |
|
Delete curred line |
|
Insert new line |
|
Search |
|
Search backward |
|
Replace first |
|
Globally (all) on current line |
|
Between two lines |
|
Every ocurrence in file |
|
#!/bin/bash # Use this command to query media type: # xdg-mime query filetype ${file} DEFAULT_TEXT_EDITOR=code.desktop xdg-mime default firefox.desktop text/xml xdg-mime default ${DEFAULT_TEXT_EDITOR} text/plain xdg-mime default ${DEFAULT_TEXT_EDITOR} application/xml xdg-mime default ${DEFAULT_TEXT_EDITOR} application/json xdg-mime default ${DEFAULT_TEXT_EDITOR} text/x-java xdg-mime default ${DEFAULT_TEXT_EDITOR} application/x-shellscript xdg-mime default ${DEFAULT_TEXT_EDITOR} text/x-python xdg-mime default ${DEFAULT_TEXT_EDITOR} text/markdown echo "Default applications:" cat ~/.local/share/applications/mimeapps.list
Option 1: edit ~/.netrc with following format:
machine ${host} login ${username} password ${password}
Option 2:
#!/usr/bin/expect spawn scp ${source} user@host:${target} expect "*password:" send "changeit\r" interact
#!/usr/bin/env bash echo "PostGree backup helper" DATABASE='performance' SCHEMA_NAME='public' SYS_USER='postgres' HOST='localhost' USER='performance' FILE='dump-performance-postgresql' read -p "Options: (C)reate; (R)estore: " OPTION if [ $OPTION = "C" ] then echo "Creating backup" rm $FILE pg_dump $DATABASE -h $HOST -U $USER -W > $FILE elif [ $OPTION = "R" ] then echo "Restoring backup" echo "DROP SCHEMA public CASCADE;" psql $DATABASE -h $HOST -U $SYS_USER -c 'DROP SCHEMA public CASCADE;' echo "CREATE SCHEMA public AUTHORIZATION performance;" psql $DATABASE -h $HOST -U $SYS_USER -c 'CREATE SCHEMA public AUTHORIZATION performance;' psql $DATABASE -h $HOST -U $USER -W < $FILE rm -r /KISS/performance/local else echo "Invalid option" fi