Created
November 7, 2020 08:22
-
-
Save noize-e/21cc19126bcb988c43d4e09d50a868cb to your computer and use it in GitHub Desktop.
Functions toolbox for linux (debian distros)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# Generate password hash | |
# | |
genpwd(){ | |
echo $(tr -dc A-Za-z0-9_ < /dev/urandom | head -c 20 | xargs) | |
} | |
# Check internet connection | |
# | |
chkconn(){ | |
wget -q --spider http://google.com | |
if [ $? -eq 0 ]; then | |
echo -e "\n [+] Connected!" | |
else | |
echo -e '\n [!] No Internet access! Quitting...' | |
exit 1 | |
fi | |
} | |
szip(){ | |
zip -0 -s 3g out.zip foobar | |
split -b 2G WebForPC_Install_OS_X_El_Capitan\(2\).dmg --verbose | |
} | |
# Create new archive given a resource path | |
# | |
archive(){ | |
aname|="${1:?arg-err: archive name}" | |
rpath="${2:?arg-err: resouce path}" | |
tar -czvf ${aname}.tar.gz ${rpath} | |
} | |
# Extract archive contents | |
# | |
unarchive(){ | |
aname="${1}" | |
tar -xzvf ${aname}.tar.gz | |
} | |
copy(){ | |
# | |
# sudo apt-get install xclip | |
# | |
cat "${1}" | xclip -selection clipboard | |
} | |
# Mound read & write HFS+ journaled drive | |
# | |
mhfs(){ | |
disk="${1:?arg-err: mounted disk path}" | |
df | grep "${disk}" && \ | |
read -p "device:[/dev/sdc2] " disk | |
disk="${device:-/dev/sdc2}" | |
sudo umount ${device} && \ | |
sudo fsck.hfsplus -f ${device} && \ | |
sudo mkdir ${disk} && \ | |
sudo mount -t hfsplus -o force,rw ${device} ${disk} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment