From 78ef8d0a88a73b4ed37cb6f7bda07d07837f33dc Mon Sep 17 00:00:00 2001 From: "kebler.net" Date: Mon, 24 Oct 2022 18:13:58 -0700 Subject: [PATCH] add functions osinfo adduserid () fsudo () to basic --- function/01-basic | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/function/01-basic b/function/01-basic index 1500df6..6ca8d66 100644 --- a/function/01-basic +++ b/function/01-basic @@ -86,4 +86,25 @@ editor() { ${EDITOR} $1; } add-repo-key () { gpg --keyserver keyserver.ubuntu.com --recv-key $1 gpg -a --export $1 | sudo apt-key add - -} \ No newline at end of file +} + +osinfo () { + echo kernel: $(uname -r) + echo machine: $(arch) + cat /etc/os-release + cat /etc/upstream-release/lsb-release +} + +# adduserid name id# +# add a suer with specific id number +adduserid () { +sudo groupadd -g $2 $1 +sudo useradd -d ${/home/$1} -s /bin/bash -u $2 -g $1 $1 +} + +fsudo () # run a function as sudo +{ + [[ "$(type -t $1)" == "function" ]] && + ARGS="$@" && sudo bash -c "$(declare -f $1); $ARGS" +} +alias ssudo="ssudo " \ No newline at end of file