find ./ -name '\*.sh'
find ./ -type f \\( -name '\*.sh.\*' -o -name '\*.sh' \\)
-size 1k 1M 1w(byte)
-mtime
-atime
-perm
-exec {} \;
grep -irln ./ --color -e 'hello\*'
grep -irlE ./ -e 'hell'
grep -irnE ./ -e 'Example\*|unannotated\*' --color
grep -v '#' abc.yaml #exclude all lines with # symbols
du -sh .
du -sh *
df -h
cat abc.txt | wc
cat abc.txt | wc -l
cat abc.txt | wc -c // run the characters
cat abc.txt | wc -L // longest line
cat -n abc.txt #catting with lines
vim +15 abc.txt // opening vim on 15lines
tail -f abc.txt
head -n 10 abc.txt
sed '/^$/d'
sed 's/parttime/fulltime/1' abc.txt => first occurence in line
sed 's/parttime/fulltime/2' abc.txt => 2nd occurence in line
sed -n 1p abc.txt #show only the 1st line
sed 's/parttime/fulltime/1w abcd.txt' abc.txt => substitude and write it into abcd.txt
sed '11 s/parttime/fulltime/' abc.txt => replace only on 11line
sed '11 s/parttime/[fulltime]/2' abc.txt => replace only on 11line 2nd occurnce
sed '1,5 s/parttime/fulltime/' abc.txt => replace between 1,5 lines
sed 's|//.\*||' abc.txt # all comments replacements
sed '$d' abc.txt # delete last line
sed '1s/.*/enabled: true/; 2s/:.*/: false/' fiat.yml # ".*" anything
sed -i 's/LoadBalancer/NodePort/;s/31380/30080/' file.yaml #multiple replcemnet
ssh-keygen
ssh-copy-id user@ip
ssh user@ip -L 8080:localhost:8080 # Port forwarding with ssh tunnel with no reverse proxy or ssl
ssh -T git@github.com #check the git ssh connections
/etc/sudoers or visudo
user ALL=(ALL) NOPASSWD: ALL
%user_grp ALL=(ALL) NOPASSWD: ALL
netstat -tupln # listing all listening ports with there application name if sudo is used
nslookup google.com # resoloving the dns name to addrs
telnet google 80 # checking whether google is listening with port 80
:set ai
:set ru
:set nu
:set ts=2 #tabstop
:set tw=2 #tabwidth
:set et
:le 3 #left indent with 3space
gg #top
GA #bottom
:m 1 #move current line up by 1
PS1="\033[01;34m~> \[\033[00m\]"
PS1="'${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;35m\]\w\$\[\033[00m\] '"
\033[01;34m
while read line
do
echo $line
done
for line in $(cat file.txt)
do
echo $line
done
cat > file.txt <<-EOF
line1
line2
line3
line4
line5
EOF
cat file.csv | tr '\n' '\t'
- paste is usefull when we want to merge the line of a file. Into a single line or based on delimeter
- paste with a filename is similar as that of cat cmd
paste file1.txt # cat file1.txt
- Checking for the bin file is present or not within the system
#!/bin/bash
CMD=$(which htpasswd 2>/dev/null)
check_config() {
if [ -z $CMD ]; then
printf "Exiting: htpasswd is missing.\n"
exit 1
fi
}
check_config
exit $?