-
Notifications
You must be signed in to change notification settings - Fork 5
Shell
Lowy Shin edited this page Dec 20, 2023
·
44 revisions
- URL Encoding
str=`tail giipAgent.log`
echo "original string"
echo $str
encode=$(echo $str | jq -Rr '@uri')
echo "URL Encoded..."
echo $encode
-
Performance check
-
Repository management
-
Kill all process fixed name
ps aux | grep <processname> | grep -v grep | awk '{ print "kill -9", $2 }' | sh
- https://qiita.com/masarufuruya/items/409679c1006980ef1b60
-
split - separate the file
split -d -b 99M -a 3 orgfile.log split_file
-
options
- -d : change sub-string to number
- -b : split each bytes
- -a n : split number of n
-
Check word contains the file(word exists)
strTxt=`cat ../gitrst.txt`
if [[ $strTxt == *"file changed"* ]]; then
echo "File changed!!!"
fi
- check file size
sFileName="<filename>"
if [ -s $sFileName ]; then
echo "File size is not zero."
fi
- file exists
sFileName="<filename>"
if [ -e $sFileName ]; then
echo "File exist."
fi
- date
- Various converting datetime string : https://talklowykr.blogspot.com/2020/06/shell-date-command-examples-linux-bash.html
dtnow=`date +%Y%m%d`
dtprev=`date -d "1 day ago" +%Y%m%d`
echo "Today:${dtnow}, Yesterday:${dtprev}"
-
du
- Show directory status
-
du -b /data | sort -n | grep -v test >du-data.txt
- -b : show usage by byte
- sort -n : sort by number(big size directory is below)
- /data : target directory
-
ls -lt
- show files sorting date
-
mv
-
for i in `find /orgpath -mtime +15 -type f`; do mv $i /targetpath; done
- The files over 15 days from /orgpath to /targetpath
-
-
if you can not work cp and mv force on shell scripts, then use it
\cp -f origin.txt target.txt
\mv -f origin.txt target.txt
- ignore alias command recent version of linux.
-
diff FileA FileB
- compare with FileA and FileB.
-
fdisk
-
fdisk -l
- list physical devices and format status
-
fdisk /dev/sdb
- partitioning
/dev/sdb
- p : Check status selected partition
- g : gpt mode change
- n : Create new partition
- w : Save changed
- partitioning
-
mkfs.ext4 /dev/sdb1
- format partition of
sdb1
- format partition of
mkdir -p /data2
mount /dev/sdb1 /data2
-
-
get current directory name
- name only :
basename ``pwd``
- full path :
pwd
- name only :
- git pull and changed target file, then execute it
git pull origin master >../${svrname}-gitsyncstat.txt
strTxt=`cat ../${svrname}-gitsyncstat.txt`
if [[ $strTxt == *"lwcmd.sh"* ]]; then
# execute all fw rule
sh sh/lwcmd.sh
rm -rf lwcmd.sh
fi
-
Various if condition process
It can be changed /
to |
when error on shell
#before
sed -e "s/PermitRootLogin yes/PermitRootLogin no/g" /etc/ssh/sshd_config>/etc/ssh/sshd_config_bak
#after
sed -e "s|PermitRootLogin yes|PermitRootLogin no"|g" /etc/ssh/sshd_config>/etc/ssh/sshd_config_bak
- using one method without MID, SUBSTR, LEFT, RIGHT
lwStr="giipasp.azurewebsites.net"
echo ${lwStr:0:2}
# -> gi
echo ${lwStr:4}
# -> .net
echo ${lwStr:0:-4}
# -> giipasp.azurewebsites
echo ${lwStr%.*}
# -> giipasp.azurewebsites
echo ${lwStr%%.*}
# -> giipasp
echo ${lwStr#*.}
# -> azurewebsites.net
echo ${lwStr##*.}
# -> net
- Make sure create user by
adduser
and connect test before this process!!
sshblockroot.sh
cp /etc/ssh/sshd_config /etc/ssh/sshd_config.bak
sed -e "s/PermitRootLogin yes/PermitRootLogin no/g" /etc/ssh/sshd_config>/etc/ssh/sshd_config_bak
sed -e "s/#PermitRootLogin/PermitRootLogin/g" /etc/ssh/sshd_config_bak>/etc/ssh/sshd_config
rm -f /etc/ssh/sshd_config_bak
service sshd restart
https://talklowykr.blogspot.com/2020/01/linux-root.html#more
- add sudoer to user
usermod -aG wheel mylogin
- check user group
cat /etc/group | grep mylogin
- check sudoers file open wheel
cat /etc/sudoers | grep wheel
notice : delete comment when commented
-
handling curl status
-
Trim string
-
Get PID
mypid=`echo $$`
echo "$mypid"
- jq
- Change Linux Time
### backup org localtime
cp /etc/localtime /etc/localtime.org
### Change to JST
ln -sf /usr/share/zoneinfo/Asia/Tokyo /etc/localtime
- vi hot key : https://prev.net-newbie.com/linux/commands/vi.html
by shell
cp /etc/DIR_COLORS ~/.dircolors
vi ~/.dircolors
``
Find and change color code `~/.dircolors`
```vim
DIR 01;36 # directory
LINK 36;01 # symbolic link
httpd -t -D DUMP_CONFIG 2>/dev/null | grep '# In' | awk '{print $4}' # 設定ファイル一覧
httpd -t -D DUMP_CONFIG 2>/dev/null | grep -v '#' # 設定ファイル内容
httpd -V # コンパイル時の設定
httpd -S -D SSL # 実行時の設定
httpd -l # 静的モジュール一覧
httpd -M # ロード済みモジュール一覧
rpm -qi httpd # パッケージ情報
rpm -q --changelog httpd # パッケージ更新履歴
-
Test if a Website Is Available - bash shell
- check web site and mail with response http code
- 【簡単】Webサイトの差分チェック+LINE通知をシェルスクリプトでやる
- KB wiki is multi-lingual writing. If you want translate to your language, use google translate!
- Go to giip service Page : http://giipweb.littleworld.net
- Documentation : https://github.com/LowyShin/giip/wiki
- Sample automation scripts : https://github.com/LowyShin/giip/tree/gh-pages/giipscripts
See more : https://github.com/LowyShin/giip/wiki
- Token exchanges : https://tokenjar.io/GIIP
- Token exchanges manual : https://www.slideshare.net/LowyShin/giipentokenjario-giip-token-trade-manual-20190416-141149519
- GIIP Token Etherscan : https://etherscan.io/token/0x33be026eff080859eb9dfff6029232b094732c52
If you want get GIIP, contact us any time!
- LowyWorkEnv : https://github.com/LowyShin/Lowyworkenv/wiki
- CLoud RDBMS比較
- MachineLearning
- SQL Server
- ORACLE
- MySQL
- mariadh
- Redis with MySQL
- Mongodb
- Apache-Drill
- A5MK2-MultiDBMSTool
- BI
- Referrals
- Juliaの自動微分パッケージ Zygote の紹介
- color code table
- Canva - free Online Design tool
- vscode
- git(github)
- GoogleSheet
- UiPath(RPA)
- WinAutomation(official)
- Excel
- VNC
- VPN
- Note Tool
- Blog
- google news alert
- Online PDF to JPG
- LoadTest " putty
- Shell/bash
- crontab
- PowerShell
- Windows(DOS) batch
- Wscript/wsf
- AWS
- Azure
- File Sync(rsync, scp...)
- KnownPort(wikipedia)
- CentOS(Linux)
- Windows10
- Android