-
-
Notifications
You must be signed in to change notification settings - Fork 617
/
bash_aliases
executable file
·323 lines (283 loc) · 16 KB
/
bash_aliases
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
# This is my current / up-to-date list of bash aliases.
# This is the exact same file that is on all of my hosts - synced using Synthing.
# Rename shared/config/bash_aliases.env.example and use it as a starter
# SOURCE ENVIRONMENTAL VARIABLES FOR BASH_ALIASES
if [[ -f "$HOME/docker/shared/config/bash_aliases.env" ]]; then
source $HOME/docker/shared/config/bash_aliases.env
fi
# CHANGE TO CUSTOM BASH PROMPT
username="AnandSHB" # or use $USER
export PS1='[\e[0;32m\u\e[0m@\e[0;33m\H\e[0m: \e[0;36m\w\e[0m]\$ '
# DOCKER - All Docker commands start with "d" AND Docker Compose commands start with "dc"
alias dstop='sudo docker stop $(sudo docker ps -a -q)' # usage: dstop container_name
alias dstopall='sudo docker stop $(sudo docker ps -aq)' # stop all containers
alias drm='sudo docker rm $(sudo docker ps -a -q)' # usage: drm container_name
alias dprunevol='sudo docker volume prune' # remove unused volumes
alias dprunesys='sudo docker system prune -a' # remove unsed docker data
alias ddelimages='sudo docker rmi $(sudo docker images -q)' # remove unused docker images
alias derase='dstopcont ; drmcont ; ddelimages ; dvolprune ; dsysprune' # WARNING: removes everything!
alias dprune='ddelimages ; dprunevol ; dprunesys' # remove unused data, volumes, and images (perfect for safe clean up)
alias dexec='sudo docker exec -ti' # usage: dexec container_name (to access container terminal)
alias dps='sudo docker ps -a' # running docker processes
alias dpss='sudo docker ps -a --format "table {{.Names}}\t{{.State}}\t{{.Status}}\t{{.Image}}" | (sed -u 1q; sort)' # running docker processes as nicer table
alias ddf='sudo docker system df' # docker data usage (/var/lib/docker)
alias dlogs='sudo docker logs -tf --tail="50" ' # usage: dlogs container_name
alias dlogsize='sudo du -ch $(sudo docker inspect --format='{{.LogPath}}' $(sudo docker ps -qa)) | sort -h' # see the size of docker containers
alias dips="sudo docker ps -q | xargs -n 1 sudo docker inspect -f '{{.Name}}%tab%{{range .NetworkSettings.Networks}}{{.IPAddress}}%tab%{{end}}' | sed 's#%tab%#\t#g' | sed 's#/##g' | sort | column -t -N NAME,IP\(s\) -o $'\t'"
alias dp600='sudo chown -R root:root $HOME/docker/secrets ; sudo chmod -R 600 $HOME/docker/secrets ; sudo chown -R root:root $HOME/docker/.env ; sudo chmod -R 600 $HOME/docker/.env' # re-lock permissions
alias dp777='sudo chown -R $USER:$USER $HOME/docker/secrets ; sudo chmod -R 777 $HOME/docker/secrets ; sudo chown -R $USER:$USER $HOME/docker/.env ; sudo chmod -R 777 $HOME/docker/.env' # open permissions for editing
# DOCKER COMPOSE TRAEFIK 2 - All docker-compose commands start with "dc"
case $HOSTNAME in
ds918) # synology at this point uses an old version of docker. Therefore, 'docker-compose' instead of 'docker compose'
alias dcrun='sudo docker-compose -f $HOME/docker/docker-compose-$HOSTNAME.yml' # /volume1/docker symlinked to /var/services/homes/user/docker
;;
*)
alias dcrun='sudo docker compose --profile all -f $HOME/docker/docker-compose-$HOSTNAME.yml'
;;
esac
alias dclogs='dcrun logs -tf --tail="50" ' # usage: dclogs container_name
alias dcup='dcrun up -d --build --remove-orphans' # up the stack
alias dcdown='dcrun down --remove-orphans' # down the stack
alias dcrec='dcrun up -d --force-recreate --remove-orphans' # usage: dcrec container_name
alias dcstop='dcrun stop' # usage: dcstop container_name
alias dcrestart='dcrun restart ' # usage: dcrestart container_name
alias dcstart='dcrun start ' # usage: dcstart container_name
alias dcpull='dcrun pull' # usage: dcpull to pull all new images or dcpull container_name
alias traefiklogs='tail -f $HOME/docker/logs/$HOSTNAME/traefik/traefik.log' # tail traefik logs
# Manage "core" services as defined by profiles in docker compose
alias startcore='sudo docker compose --profile core -f $HOME/docker/docker-compose-$HOSTNAME.yml start'
alias createcore='sudo docker compose --profile core -f $HOME/docker/docker-compose-$HOSTNAME.yml up -d --build --remove-orphans'
alias stopcore='sudo docker compose --profile core -f $HOME/docker/docker-compose-$HOSTNAME.yml stop'
# Manage "media" services as defined by profiles in docker compose
alias stopmedia='sudo docker compose --profile media -f $HOME/docker/docker-compose-$HOSTNAME.yml stop'
alias createmedia='sudo docker compose --profile media -f $HOME/docker/docker-compose-$HOSTNAME.yml up -d --build --remove-orphans'
alias startmedia='sudo docker compose --profile media -f $HOME/docker/docker-compose-$HOSTNAME.yml start'
# Manage "diwkiads" services as defined by profiles in docker compose
alias stopdownloads='sudo docker compose --profile downloads -f $HOME/docker/docker-compose-$HOSTNAME.yml stop'
alias createdownloads='sudo docker compose --profile downloads -f $HOME/docker/docker-compose-$HOSTNAME.yml up -d --build --remove-orphans'
alias startdownloads='sudo docker compose --profile downloads -f $HOME/docker/docker-compose-$HOSTNAME.yml start'
# Manage Starr apps as defined by profiles in docker compose
alias stoparrs='sudo docker compose --profile arrs -f $HOME/docker/docker-compose-$HOSTNAME.yml stop'
alias startarrs='sudo docker compose --profile arrs -f $HOME/docker/docker-compose-$HOSTNAME.yml start'
alias createarrs='sudo docker compose --profile arrs -f $HOME/docker/docker-compose-$HOSTNAME.yml up -d --build --remove-orphans'
# Manage "dbs" (database) services as defined by profiles in docker compose
alias stopdbs='sudo docker compose --profile dbs -f $HOME/docker/docker-compose-$HOSTNAME.yml stop'
alias createdbs='sudo docker compose --profile dbs -f $HOME/docker/docker-compose-$HOSTNAME.yml up -d --build --remove-orphans'
alias startdbs='sudo docker compose --profile dbs -f $HOME/docker/docker-compose-$HOSTNAME.yml start'
# CROWDSEC
alias cscli='dcrun exec -t crowdsec cscli'
alias csdecisions='cscli decisions list'
alias csalerts='cscli alerts list'
alias csinspect='cscli alerts inspect -d'
alias cshubs='cscli hub list'
alias csparsers='cscli parsers list'
alias cscollections='cscli collections list'
alias cshubupdate='cscli hub update'
alias cshubupgrade='cscli hub update'
alias csmetrics='cscli metrics'
alias csmachines='cscli machines list'
alias csbouncers='cscli bouncers list'
alias csfbstatus='sudo systemctl status crowdsec-firewall-bouncer.service'
alias csfbstart='sudo systemctl start crowdsec-firewall-bouncer.service'
alias csfbstop='sudo systemctl stop crowdsec-firewall-bouncer.service'
alias csfbrestart='sudo systemctl restart crowdsec-firewall-bouncer.service'
alias tailkern='sudo tail -f /var/log/kern.log'
alias tailauth='sudo tail -f /var/log/auth.log'
alias tailcsfb='sudo tail -f /var/log/crowdsec-firewall-bouncer.log'
alias csbrestart='dcrec2 traefik-bouncer ; csfbrestart'
# WEB STACK
alias webrs='dcrec php7 redis nginx'
# DOCKER TRAEFIK 1 SWARM
alias dslogs='sudo docker service logs -tf --tail="50"'
alias dsps='sudo docker stack ps zstack'
alias dsse='sudo docker stack services zstack'
alias dsls='sudo docker stack ls'
alias dsrm='sudo docker stack rm'
alias dsup='sudo docker stack deploy --compose-file $HOME/docker/docker-compose-swarm.yml zstack'
alias dshelp='echo "dslogs dsps dsse dsls dsrm dsup"'
# COMPRESSION
alias untargz='tar --same-owner -zxvf'
alias untarbz='tar --same-owner -xjvf'
alias lstargz='tar -ztvf'
alias lstarbz='tar -jtvf'
alias targz='tar -zcvf'
alias tarbz='tar -cjvf'
# NAVIGATION
alias cd..='cd ..'
alias ..='cd ..'
alias ...='cd ../..'
alias .3='cd ../../..'
alias .4='cd ../../../..'
alias .5='cd ../../../../..'
# SYNC AND COPY
alias scp='scp -r'
alias rsynce='sudo rsync -avzh --progress --force --delete --exclude-from $HOME/docker/shared/config/rsync-exclude'
alias rsyncne='sudo rsync -avzh --progress --force --delete'
alias cpn='cp --verbose' # native copy
alias cp='sudo rsync -avzh --info=progress2' # copy files with rsync
alias mv='sudo rsync -avzh --info=progress2 --remove-source-files' # move files with rsync
alias mvn='mv --verbose' # native move
# SEARCH AND FIND
alias gh='history|grep' # search bash history
alias findr='sudo find / -name'
alias grep='grep --color=auto'
alias egrep='egrep --color=auto'
alias fgrep='fgrep --color=auto'
# TRASH - trash-cli
alias rm='trash-put'
alias rmv='rm -rv'
alias tempty='trash-empty ; sudo trash-empty ; sudo -H trash-empty'
alias tlist='trash-list'
alias srmt='sudo trash-put'
# FILE SIZE AND STORAGE
alias fdisk='sudo fdisk -l'
alias uuid='sudo vol_id -u'
alias ls='ls -F --color=auto --group-directories-first'
alias ll='ls -alh --color=auto --group-directories-first'
alias lt='ls --human-readable --color=auto --size -1 -S --classify' # file size sorted
alias lsr='ls --color=auto -t -1' # recently modified
alias mnt='mount | grep -E ^/dev | column -t' # show mounted drives
alias dirsize='sudo du -hx --max-depth=1'
alias dirusage='du -ch | grep total' # Grabs the disk usage in the current directory
alias diskusage='df -hl --total | grep total' # Gets the total disk usage on your machine
alias partusage='df -hlT --exclude-type=tmpfs --exclude-type=devtmpfs' # Shows the individual partition usages without the temporary memory values
alias usage10='du -hsx * | sort -rh | head -10' # Gives you what is using the most space. Both directories and files. Varies on current directory
# BASH ALIASES
alias baupdate='. ~/.bashrc'
alias baedit='nano $HOME/.bash_aliases'
alias bacopy='sudo cp $HOME/.bash_aliases* /root/'
alias baget='curl -s https://raw.githubusercontent.com/htpcBeginner/docker-traefik/master/shared/config/bash_aliases -o /$HOME/.bash_aliases >/dev/null 2>&1'
# GIT AND SITE MANAGEMENT
alias gcpush='echo "Usage: gcpush ../commits/date.txt" ; cd $HOME/docker ; bash scripts/github/doccheck.sh' # To push my files to docker-traefik repo
alias gpush='cd $HOME/docker ; git push'
alias ggraph='git log --all --decorate --oneline --graph'
# MAIL SERVER TESTING
alias nullsend='sudo echo 1 > /var/spool/nullmailer/trigger'
alias tmail1='echo -e "### `date +'\''%Y-%m-%d %H:%M'\''` ### \n\n This is a mail server test using tmail1 alias." | mail -s "tmail1 from $HOSTNAME" info@$PRIMARY_DOMAIN -aFrom:$HOSTNAME@$PRIMARY_DOMAIN'
alias tmail2='echo -e "### `date +'\''%Y-%m-%d %H:%M'\''` ### \n\n This is a mail server test using tmail2 alias. It needs and email id after the tmail2 command." | mail -s "tmail2 from $HOSTNAME"'
# UFW FIREWALL
alias ufwenable='sudo ufw enable'
alias ufwdisable='sudo ufw disable'
alias ufwallow='sudo ufw allow'
alias ufwlimit='sudo ufw limit'
alias ufwlist='sudo ufw status numbered'
alias ufwdelete='sudo ufw delete'
alias ufwreload='sudo ufw reload'
# SYSTEMD START, STOP AND RESTART
alias ctlreload='sudo systemctl daemon-reload'
alias ctlstart='sudo systemctl start'
alias ctlstop='sudo systemctl stop'
alias ctlrestart='sudo systemctl restart'
alias ctlstatus='sudo systemctl status'
alias ctlenable='sudo systemctl enable'
alias ctldisable='sudo systemctl disable'
alias ctlactive='sudo systemctl is-active'
alias shellstart='ctlstart shellinabox'
alias shellstop='ctlstop shellinabox'
alias shellrestart='ctlrestart shellinabox'
alias shellstatus='ctlstatus shellinabox'
alias sshstart='ctlstart ssh'
alias sshstop='ctlstop ssh'
alias sshrestart='ctlrestart ssh'
alias sshstatus='ctlstatus ssh'
alias ufwstart='ctlstart ufw'
alias ufwstop='ctlstop ufw'
alias ufwrestart='ctlrestart ufw'
alias ufwstatus='ctlstatus ufw'
alias webminstart='ctlstart webmin'
alias webminstop='ctlstop webmin'
alias webminrestart='ctlrestart webmin'
alias webminstatus='ctlstatus webmin'
alias sambastart='ctlstart smbd'
alias sambastop='ctlstop smbd'
alias sambarestart='ctlrestart smbd'
alias sambastatus='ctlstatus smbd'
alias nfsstart='ctlstart nfs-kernel-server'
alias nfsstop='ctlstop nfs-kernel-server'
alias nfsrestart='ctlrestart nfs-kernel-server'
alias nfsstatus='ctlstatus nfs-kernel-server'
alias nfsreload='sudo exportfs -a'
# INSTALLATION AND UPGRADE
alias update='sudo apt-get update'
alias upgrade='sudo apt-get update && sudo apt-get upgrade'
alias install='sudo apt-get install'
alias finstall='sudo apt-get -f install'
alias rinstall='sudo apt-get -f install --reinstall'
alias uninstall='sudo apt-get remove'
alias search='sudo apt-cache search'
alias addkey='sudo apt-key adv --recv-keys --keyserver keyserver.ubuntu.com'
# CLEANING
alias clean='sudo apt-get clean && sudo apt-get autoclean'
alias remove='sudo apt-get remove && sudo apt-get autoremove'
alias purge='sudo apt-get purge'
alias deborphan='sudo deborphan | xargs sudo apt-get -y remove --purge'
alias cleanall='clean && remove && deborphan && purge'
# SHUTDOWN AND RESTART
alias shutdown='sudo shutdown -h now'
alias reboot='sudo reboot'
# NETWORKING
alias portsused='sudo netstat -tulpn | grep LISTEN'
alias showports='netstat -lnptu'
alias showlistening='lsof -i -n | egrep "COMMAND|LISTEN"'
alias ping='ping -c 5'
alias ipe='curl ipinfo.io/ip' # external ip
alias ipi='ipconfig getifaddr en0' # internal ip
alias header='curl -I' # get web server headers
# SYNOLOGY DSM COMMANDS
alias servicelist='sudo synoservicecfg --list' # does not work in DSM 7
alias servicestatus='sudo synosystemctl status'
alias servicestop='sudo synosystemctl stop'
alias servicehstop='sudo synoservicecfg --hard-stop' # does not work in DSM 7
alias servicestart='sudo synosystemctl start'
alias servicehstart='sudo synoservicecfg --hard-start' # does not work in DSM 7
alias servicerestart='sudo synosystemctl restart'
alias restartdocker='sudo synosystemctl restart pkgctl-Docker'
# MISCELLANEOUS
alias wget='wget -c'
alias nano='sudo nano -iSw$'
alias scxterm='bash $HOME/docker/scripts/xterm.sh'
# SYSTEM MONITORING
alias meminfo='free -m -l -t' # memory usage
alias psmem='ps auxf | sort -nr -k 4' # get top process eating memory
alias psmem10='ps auxf | sort -nr -k 4 | head -10' # get top process eating memory
alias pscpu='ps auxf | sort -nr -k 3' # get top process eating cpu
alias pscpu10='ps auxf | sort -nr -k 3 | head -10' # get top process eating cpu
alias cpuinfo='lscpu' # Get server cpu info
alias gpumeminfo='grep -i --color memory /var/log/Xorg.0.log' # get GPU ram on desktop / laptop
alias free='free -h'
# RCLONE
alias rcdlogs='tail -f $HOME/docker/logs/cloudserver/rclone-drive.log'
alias rcclogs='tail -f $HOME/docker/logs/cloudserver/rclone-crypt.log'
alias rcupmedia='bash $HOME/docker/scripts/cloudserver/upload-media-now.sh'
alias rcupmedialogs='tail -f $HOME/docker/logs/cloudserver/upload-media-now.log'
alias rcupdump='bash $HOME/docker/scripts/cloudserver/upload-dump.sh'
alias rcupdumplogs='tail -f $HOME/docker/logs/cloudserver/upload-dump.log'
alias rcrestart='sudo bash $HOME/docker/scripts/rclone-restart.sh'
alias rcstop='sudo bash $HOME/docker/scripts/rclone-stop.sh'
alias rcstart='sudo bash $HOME/docker/scripts/rclone-start.sh'
alias rcstatus='sudo bash $HOME/docker/scripts/rclone-status.sh'
alias rcps="ps -ef | grep '/usr/bin/rclone sync\|/usr/bin/rclone copy\|/usr/bin/rclone move'" # see running rclone copy sync or move
alias rcupdate="sudo -v ; curl https://rclone.org/install.sh | sudo bash" # update rclone
alias rcpurge="kill -SIGHUP $(pidof rclone)" # purge rclone cache
alias rcforget="rclone rc vfs/forget" # rclone forget via remote control
# YT-DLP
alias ytupdate='yt-dlp -U'
alias ytlist='yt-dlp --list-formats'
alias ytdump='yt-dlp --dump-json'
alias ytdv='yt-dlp --config-location $HOME/docker/appdata/yt-dlp/yt-dlp-video.conf'
alias ytdvc='yt-dlp --cookies "$HOME/docker/appdata/yt-dlp/cookies.txt" --config-location $HOME/docker/appdata/yt-dlp/yt-dlp-video.conf'
alias ytda='yt-dlp --config-location $HOME/docker/appdata/yt-dlp/yt-dlp-audio.conf'
alias ytdac='yt-dlp --cookies "$HOME/docker/appdata/yt-dlp/cookies.txt" --config-location $HOME/docker/appdata/yt-dlp/yt-dlp-audio.conf'
# Auto-Traefik
alias sshagent='eval "$(ssh-agent -s)" ; ssh-add $HOME/auto-traefik/.git/auto_traefik_github'
alias atpush='sshagent ; git add -A ; git commit -m "updates" ; git push'
# PiHole
alias pidis='bash $HOME/server/scripts/pihole-disable.sh'
alias pien='bash $HOME/server/scripts/pihole-enable.sh'
alias pi10='bash $HOME/server/scripts/pihole-10.sh'
alias piup='bash $HOME/server/scripts/pihole-update.sh'
alias rpi3up='bash $HOME/server/scripts/rpi3-update.sh'
alias rpi0up='bash $HOME/server/scripts/rpi0-update.sh'
# VNC
alias vnc1='vncserver -geometry 1270x720 -depth 24'
alias vnckill1='vncserver -kill :1'