Linux User Creation: Difference between revisions

From Chorke Wiki
Jump to navigation Jump to search
 
(17 intermediate revisions by the same user not shown)
Line 1: Line 1:
==Users » System==
==System » User==
===Users » System » With Home ===
===System » User » Homeless===
----
----
<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
cat << EXE | sudo bash
cat << EXE | sudo bash
CHORKE_SYS_USERS='activemq artemis hadoop spark keycloak minikube minio wildfly'
for SSH_USER in \${CHORKE_SYS_USERS};do
  if ! id -g \${SSH_USER} &>/dev/null;then addgroup --quiet --system \${SSH_USER};fi
  if ! id -u \${SSH_USER} &>/dev/null;then
    adduser --quiet --system --ingroup \${SSH_USER} --home /nonexistent --shell /usr/sbin/nologin --disabled-password \${SSH_USER}
  fi
done
echo && cat /etc/passwd|awk -F : '\$3 >= 120 && \$3 < 900 {printf("%-6s » %s\n", \$3, \$1)}'|sort -h
echo && cat /etc/group |awk -F : '\$3 >= 120 && \$3 < 900 {printf("%-6s » %s\n", \$3, \$1)}'|sort -h && echo
EXE
</syntaxhighlight>
===System » User » Resident===
----
<syntaxhighlight lang="bash">
cat << EXE | sudo bash
mkdir -p /home/system/
CHORKE_SYS_USERS='academia agronomy assembla aviation commando crafting'
CHORKE_SYS_USERS='academia agronomy assembla aviation commando crafting'
for SSH_USER in \${CHORKE_SYS_USERS};do
for SSH_USER in \${CHORKE_SYS_USERS};do
   if ! id -g \${SSH_USER} &>/dev/null;then addgroup --quiet --system \${SSH_USER};fi
   if ! id -g \${SSH_USER} &>/dev/null;then addgroup --quiet --system \${SSH_USER};fi
   if ! id -u \${SSH_USER} &>/dev/null;then
   if ! id -u \${SSH_USER} &>/dev/null;then
     adduser --quiet --system --home /home/\${SSH_USER} --shell /bin/bash \${SSH_USER}
     adduser --quiet --system --ingroup \${SSH_USER} --home /home/system/\${SSH_USER} --shell /bin/bash --disabled-password \${SSH_USER}
    mkdir /home/\${SSH_USER}/.ssh && touch /home/\${SSH_USER}/.ssh/authorized_keys
     chage -m 99999 -M 99999 -E -1 -I -1  \${SSH_USER}
     touch /home/\${SSH_USER}/.ssh/config


     chown -R \${SSH_USER}:\${SSH_USER} /home/\${SSH_USER}/.ssh
     mkdir /home/system/\${SSH_USER}/.ssh
     chage -m 99999 -M 99999 -E -1 -I -1  \${SSH_USER}
    touch /home/system/\${SSH_USER}/.ssh/config
     chmod 600 /home/\${SSH_USER}/.ssh/authorized_keys
    touch /home/system/\${SSH_USER}/.ssh/authorized_keys
     chmod 600 /home/\${SSH_USER}/.ssh/config
 
     chmod 700 /home/\${SSH_USER}/.ssh
     chown -R \${SSH_USER}:\${SSH_USER} /home/system/\${SSH_USER}/
     chmod 600 /home/system/\${SSH_USER}/.ssh/authorized_keys
     chmod 600 /home/system/\${SSH_USER}/.ssh/config
     chmod 700 /home/system/\${SSH_USER}/.ssh
   fi
   fi
done
done


ls -alh /home/*/.ssh/* && echo
echo && ls -alh /home/system/*/.ssh/*
cat /etc/passwd|awk -F : '\$3 >= 120 && \$3 <= 999 {printf("%-6s » %s\n", \$3, \$1)}'|sort -h && echo
echo && cat /etc/passwd|awk -F : '\$3 >= 120 && \$3 < 900 {printf("%-6s » %s\n", \$3, \$1)}'|sort -h
cat /etc/group |awk -F : '\$3 >= 120 && \$3 <= 999 {printf("%-6s » %s\n", \$3, \$1)}'|sort -h
echo && cat /etc/group |awk -F : '\$3 >= 120 && \$3 < 900 {printf("%-6s » %s\n", \$3, \$1)}'|sort -h && echo
EXE
EXE
</syntaxhighlight>
</syntaxhighlight>


===Users » General » With Home===
==Common » User==
===Common » User » Resident===
----
----
<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
cat << EXE | sudo bash
cat << EXE | sudo bash
CHORKE_EXT_USER='argo.cd drone.ci tool.tech shahed.hossain raiyan.shahed'
mkdir -p /home/common/
CHORKE_EXT_USER='argo.cd drone.ci tool.tech raiyan.shahed shahed.hossain'
for SSH_USER in \${CHORKE_EXT_USER};do
for SSH_USER in \${CHORKE_EXT_USER};do
   if ! id -u \${SSH_USER} &>/dev/null;then
   if ! id -u \${SSH_USER} &>/dev/null;then
     useradd --create-home --home-dir /home/\${SSH_USER} --shell /bin/bash \${SSH_USER}
     useradd --create-home --home-dir /home/common/\${SSH_USER} --shell /bin/bash \${SSH_USER}
     mkdir /home/\${SSH_USER}/.ssh && touch /home/\${SSH_USER}/.ssh/authorized_keys
    chage -m 99999 -M 99999 -E -1 -I -1  \${SSH_USER}
     touch /home/\${SSH_USER}/.ssh/config
 
     mkdir /home/common/\${SSH_USER}/.ssh
    touch /home/common/\${SSH_USER}/.ssh/config
     touch /home/common/\${SSH_USER}/.ssh/authorized_keys


     chown -R \${SSH_USER}:\${SSH_USER} /home/\${SSH_USER}/.ssh
     chown -R \${SSH_USER}:\${SSH_USER} /home/common/\${SSH_USER}/
    chage -m 99999 -M 99999 -E -1 -I -1  \${SSH_USER}
     chmod 600 /home/common/\${SSH_USER}/.ssh/authorized_keys
     chmod 600 /home/\${SSH_USER}/.ssh/authorized_keys
     chmod 600 /home/common/\${SSH_USER}/.ssh/config
     chmod 600 /home/\${SSH_USER}/.ssh/config
     chmod 700 /home/common/\${SSH_USER}/.ssh
     chmod 700 /home/\${SSH_USER}/.ssh
   fi
   fi
done
done


ls -alh /home/*/.ssh/* && echo
echo && ls -alh /home/common/*/.ssh/*
cat /etc/passwd|awk -F : '\$3 >= 1000 {printf("%-6s » %s\n", \$3, \$1)}'|sort -h && echo
echo && cat /etc/passwd|awk -F : '\$3 >= 1000 && \$3 < 65500 {printf("%-6s » %s\n", \$3, \$1)}'|sort -h
cat /etc/group |awk -F : '\$3 >= 1000 {printf("%-6s » %s\n", \$3, \$1)}'|sort -h
echo && cat /etc/group |awk -F : '\$3 >= 1000 && \$3 < 65500 {printf("%-6s » %s\n", \$3, \$1)}'|sort -h && echo
EXE
EXE
</syntaxhighlight>
</syntaxhighlight>
Line 132: Line 156:
  useradd -m -d /home/chorke -s /bin/bash chorke
  useradd -m -d /home/chorke -s /bin/bash chorke
  useradd -m -d /home/chorke -s /bin/bash chorke
  useradd -m -d /home/chorke -s /bin/bash chorke
|-
| colspan="3" |
----
|-
| valign="top" colspan="3" |
<syntaxhighlight lang="bash">
adduser --quiet --system --ingroup chorke --no-create-home    --shell /usr/sbin/nologin --disabled-password chorke
adduser --quiet --system --ingroup chorke --home /nonexistent --shell /usr/sbin/nologin --disabled-password chorke
</syntaxhighlight>


|}
|}
Line 142: Line 176:
* [https://unix.stackexchange.com/questions/533663/ Linux » Get users with UID >= 1000]
* [https://unix.stackexchange.com/questions/533663/ Linux » Get users with UID >= 1000]
* [https://manpages.debian.org/bookworm/adduser/adduser.conf.5.en.html Linux » Add User]
* [https://manpages.debian.org/bookworm/adduser/adduser.conf.5.en.html Linux » Add User]
| valign="top" |
| valign="top" |
|-
| colspan="3" |
----
|-
| valign="top" |
* [[Ubuntu/Raspberry Pi]]
* [[Ubuntu Upgrade]]
* [[ActiveMQ]]
* [[Minikube]]
* [[Keycloak]]
* [[Hadoop]]
* [[Jenkins]]
* [[WildFly]]
* [[Spark]]
* [[MinIO]]


| valign="top" |
| valign="top" |

Latest revision as of 17:24, 12 December 2024

System » User

System » User » Homeless


cat << EXE | sudo bash
CHORKE_SYS_USERS='activemq artemis hadoop spark keycloak minikube minio wildfly'
for SSH_USER in \${CHORKE_SYS_USERS};do
  if ! id -g \${SSH_USER} &>/dev/null;then addgroup --quiet --system \${SSH_USER};fi
  if ! id -u \${SSH_USER} &>/dev/null;then
    adduser --quiet --system --ingroup \${SSH_USER} --home /nonexistent --shell /usr/sbin/nologin --disabled-password \${SSH_USER}
  fi
done

echo && cat /etc/passwd|awk -F : '\$3 >= 120 && \$3 < 900 {printf("%-6s » %s\n", \$3, \$1)}'|sort -h
echo && cat /etc/group |awk -F : '\$3 >= 120 && \$3 < 900 {printf("%-6s » %s\n", \$3, \$1)}'|sort -h && echo
EXE

System » User » Resident


cat << EXE | sudo bash
mkdir -p /home/system/
CHORKE_SYS_USERS='academia agronomy assembla aviation commando crafting'
for SSH_USER in \${CHORKE_SYS_USERS};do
  if ! id -g \${SSH_USER} &>/dev/null;then addgroup --quiet --system \${SSH_USER};fi
  if ! id -u \${SSH_USER} &>/dev/null;then
    adduser --quiet --system --ingroup \${SSH_USER} --home /home/system/\${SSH_USER} --shell /bin/bash --disabled-password \${SSH_USER}
    chage -m 99999 -M 99999 -E -1 -I -1  \${SSH_USER}

    mkdir /home/system/\${SSH_USER}/.ssh
    touch /home/system/\${SSH_USER}/.ssh/config
    touch /home/system/\${SSH_USER}/.ssh/authorized_keys

    chown -R \${SSH_USER}:\${SSH_USER} /home/system/\${SSH_USER}/
    chmod 600 /home/system/\${SSH_USER}/.ssh/authorized_keys
    chmod 600 /home/system/\${SSH_USER}/.ssh/config
    chmod 700 /home/system/\${SSH_USER}/.ssh
  fi
done

echo && ls -alh /home/system/*/.ssh/*
echo && cat /etc/passwd|awk -F : '\$3 >= 120 && \$3 < 900 {printf("%-6s » %s\n", \$3, \$1)}'|sort -h
echo && cat /etc/group |awk -F : '\$3 >= 120 && \$3 < 900 {printf("%-6s » %s\n", \$3, \$1)}'|sort -h && echo
EXE

Common » User

Common » User » Resident


cat << EXE | sudo bash
mkdir -p /home/common/
CHORKE_EXT_USER='argo.cd drone.ci tool.tech raiyan.shahed shahed.hossain'
for SSH_USER in \${CHORKE_EXT_USER};do
  if ! id -u \${SSH_USER} &>/dev/null;then
    useradd --create-home --home-dir /home/common/\${SSH_USER} --shell /bin/bash \${SSH_USER}
    chage -m 99999 -M 99999 -E -1 -I -1  \${SSH_USER}

    mkdir /home/common/\${SSH_USER}/.ssh
    touch /home/common/\${SSH_USER}/.ssh/config
    touch /home/common/\${SSH_USER}/.ssh/authorized_keys

    chown -R \${SSH_USER}:\${SSH_USER} /home/common/\${SSH_USER}/
    chmod 600 /home/common/\${SSH_USER}/.ssh/authorized_keys
    chmod 600 /home/common/\${SSH_USER}/.ssh/config
    chmod 700 /home/common/\${SSH_USER}/.ssh
  fi
done

echo && ls -alh /home/common/*/.ssh/*
echo && cat /etc/passwd|awk -F : '\$3 >= 1000 && \$3 < 65500 {printf("%-6s » %s\n", \$3, \$1)}'|sort -h
echo && cat /etc/group |awk -F : '\$3 >= 1000 && \$3 < 65500 {printf("%-6s » %s\n", \$3, \$1)}'|sort -h && echo
EXE

Playground

apt list --installed|grep linux-image
systemd-analyze blame
dpkg -l | grep "gnome-shell-extension"

systemctl list-dependencies graphical.target
cat /proc/acpi/wakeup
sudo apt list --installed|grep desktop-icons
sudo dpkg-query -l|grep desktop-icons
sudo apt install gnome-shell-extension-manager
apt info gnome-shell-extension-manager -a

cat <<-'EXE'|sudo bash
umount /var/snap/firefox/common/host-hunspell
snap remove firefox
EXE
cat <<-'EXE'|sudo bash
snap disable remmina
snap remove --purge remmina
EXE
systemctl list-dependencies --type=service --state=running
systemctl list-dependencies --type=service --state=active
systemctl list-dependencies docker.service
systemctl list-dependencies --all

cat /etc/passwd
cat /etc/group
cat /etc/passwd|\
awk -F : '$3 >= 1000 {printf("%-6s » %s\n", $3, $1)}'|sort -h
useradd -m -d /home/chorke -s /bin/bash chorke
useradd -m -d /home/chorke -s /bin/bash chorke

adduser --quiet --system --ingroup chorke --no-create-home    --shell /usr/sbin/nologin --disabled-password chorke
adduser --quiet --system --ingroup chorke --home /nonexistent --shell /usr/sbin/nologin --disabled-password chorke

References