2021-10-09 03:20:23 +03:00
2021-08-30 04:26:02 +03:00
ref
2021-09-24 00:04:22 +03:00
2021-10-02 01:30:20 +03:00
2021-09-25 01:33:15 +03:00
2021-10-09 03:20:23 +03:00
2021-10-03 21:06:00 +03:00
2021-09-25 00:40:40 +03:00
2021-08-29 03:32:56 +03:00
ref
2021-09-15 21:38:08 +03:00
2021-09-26 20:22:56 +03:00
2021-10-09 03:15:02 +03:00

BashConfig

Content

Project description

Bash config files

Prompt

SSH

Create ssh key on local device

  1. ssh-keygen
  2. Save to ~/.ssh
  3. Enter passphrase
  4. Copy content of ~/.ssh/id_rsa.pub key to remote ~/.ssh/authorized_keys


Add aliases for ssh to ~/.ssh/config:

Host host_name
   HostName ip
   Port 22
   User root
   IdentityFile ~/.ssh/id_rsa


Using aliases:

ssh host_name
sftp host_name

White and black lists

add white list to /etc/hosts.allow:

sshd: 10.83.33.77/32, 10.63.152.9/32, 10.12.100.11/28, 10.82.192.0/28

add black list to /etc/hosts.deny:

sshd: ALL

Tips

Bash

Command Description
Alt + . Esc + . Last object
Ctrl + r Search by bash_history
Ctrl + l Clear, like command clear
rm -rf ~/BashConfig; git clone https://github.com/TheK4n/BashConfig && cp BashConfig/.bash* ~; rm -rf ~/BashConfig && . ~/.bashrc

$RANDOM - Return random 0-32767
/command - Without using alias
df -h / - Size

Vim

Command Description
Ctrl + [ Analog Esc
d -> Ctrl + End Delete from cursor to end of file
u Undo
Ctrl + r Redo
22G Go to line 22

Autostart

  • create /etc/systemd/system/<service>.service
sudo vim /etc/systemd/system/<service>.service
sudo systemctl daemon-reload
sudo systemctl start <service>.service
sudo systemctl status <service>.service
sudo systemctl enable <service>.service

Cron

crontab -e

0 0 1 1 * command.sh - Every year in 1 January 00:00:00
*/1 * * * * command.sh - Every minute
0 */3 * * 2,5 command.sh - One time per 3 hours in Tue and Fri
0 0,12 1 */2 * command.sh - At minute 0 past hour 0 and 12 on day-of-month 1 in every 2nd month

Description
Languages
Shell 79.6%
Lua 18.2%
Python 1.4%
Ruby 0.7%