Bash utilities for Kali and other Debian-based systems. Built for helpdesk and junior security work on a machine you already administer: create a local user, install a script as a command, and apply package updates.
Authorized use. These scripts change accounts and files on the machine where you run them. Use them only on systems you administer.
- Create a local account with
zshas the login shell, with or withoutsudo - Install a script file as a command in
/usr/bin - Optional root-only command (
chmod 700, ownerroot) - Reject command names that contain
/or.., so the write cannot leave/usr/bin - Refuse to replace a command that is already installed
- Stop
newuser,stc, andupdatemykaliunless they are run as root - Run
apt updateandapt full-upgrade -yfrom one command
- A Debian-based system with
apt(developed on Kali Linux) zsh(sudo apt install zsh).newuserwill not continue without it, because it sets that shell on the new account- Root, or a user who can
sudo.installallnowcallssudoitself. The other three commands must be started as root
git clone https://github.com/avitwil/MyBashScripts.git
cd MyBashScripts
./installallnowinstallallnow copies these commands into /usr/bin:
| Command | Source | What it does |
|---|---|---|
newuser |
newuser |
Create a user and optionally add them to the sudo group |
stc |
scripttocommand.sh |
Install a script file as a command |
updatemykali |
updatemykali |
apt update and apt full-upgrade -y |
You can also run a script from the checkout without installing it, for example sudo ./newuser.
newuser checks the effective user id, checks that zsh is on PATH, then asks for a username and a y or n sudo answer. It creates the account with adduser, sets the shell with usermod -s /usr/bin/zsh, and on y adds the account to the sudo group. It finishes by printing the matching /etc/passwd and /etc/group lines.
stc (scripttocommand.sh) checks root, checks that the source file exists, and rejects a command name that contains / or ... It writes the file to /usr/bin/<name> and sets mode 755. A third argument of sudo changes that to mode 700 and owner root. An existing path under /usr/bin is left untouched.
updatemykali checks root, then runs apt update and apt full-upgrade -y. It takes no arguments and does not ask for confirmation.
installallnow finds newuser, scripttocommand.sh, and updatemykali next to itself, copies them to /usr/bin (scripttocommand.sh becomes stc), and sets each one mode 700 and owner root. If a copy fails, it stops instead of printing success.
Examples below are from a local lab run. Paths are /tmp and a fictional account named acmehelp. User ids in the newuser transcript come from that lab machine.
./newuser
./scripttocommand.sh /tmp/acme-hello.sh acmehello
./updatemykaliEach command prints this and exits 1:
This script must be run as root (use sudo).
sudo newuserThe script prompts for the username and for sudo access. adduser then asks for a password (not echoed) and the usual name and phone fields. Answer y to put the account in the sudo group, or n to leave it as a normal user.
Lab run, answer n, full name ACME Helpdesk:
User creation script by Avi Twil. Please wait...
Enter new user name: acmehelp
Do you want this user to have "sudo" privileges? [y/n]: n
info: Adding user `acmehelp' ...
info: Selecting UID/GID from range 1000 to 59999 ...
info: Adding new group `acmehelp' (1001) ...
info: Adding new user `acmehelp' (1001) with group `acmehelp (1001)' ...
info: Creating home directory `/home/acmehelp' ...
info: Copying files from `/etc/skel' ...
New password:
Retype new password:
passwd: password updated successfully
Changing the user information for acmehelp
Enter the new value, or press ENTER for the default
Full Name []: ACME Helpdesk
Room Number []:
Work Phone []:
Home Phone []:
Other []:
Is the information correct? [Y/n] Y
info: Adding new user `acmehelp' to supplemental / extra groups `users' ...
info: Adding user `acmehelp' to group `users' ...
acmehelp in passwd file
-------------------------------
acmehelp:x:1001:1001:ACME Helpdesk,,,:/home/acmehelp:/usr/bin/zsh
-------------------------------
acmehelp in group file
-------------------------------
users:x:100:acmehelp
acmehelp:x:1001:
-------------------------------
User creation complete
adduser's info: lines vary by distribution. The prompts and the passwd line are the part to check: the shell should be /usr/bin/zsh.
sudo stc /tmp/acme-hello.sh acmehello
sudo stc /tmp/acme-hello.sh acmehello sudo- First argument: path to the script file.
- Second argument: command name. It must not contain
/or... - Third argument:
sudofor a root-only command. Omit it for mode755.
Missing arguments, a missing file, a name that would escape /usr/bin, and a name that is already taken all exit 1:
$ sudo stc
missing script file path
correct format : sudo stc [script] [command] [sudo/nothing]
sudo stc /tmp/acme-hello.sh command
or
sudo stc /tmp/acme-hello.sh command sudo
$ sudo stc /tmp/no-such-acme.sh acmehello
file /tmp/no-such-acme.sh does not exist
correct format : sudo stc [script] [command] [sudo/nothing]
sudo stc /tmp/acme-hello.sh command
or
sudo stc /tmp/acme-hello.sh command sudo
$ sudo stc /tmp/acme-hello.sh ../acmehello
invalid command name
$ sudo stc /tmp/acme-hello.sh bash
command bash already exists
try another command name
A successful install prints one line, and the new command runs from PATH:
$ sudo stc /tmp/acme-hello.sh acmehello
command acmehello created successfully
$ acmehello
ACME lab command is installed
/tmp/acme-hello.sh in that run was a two-line script:
#!/bin/bash
echo "ACME lab command is installed"Passing sudo as the third argument prints the same success line, then sets mode 700 and owner root.
sudo updatemykaliRuns apt update, then apt full-upgrade -y, and exits with apt's status. There is no extra prompt. Without root it exits 1 with the message shown above.
./installallnowInstalling commands by Avi Twil...
Installing "newuser" command...
Installing "stc" command...
Installing "updatemykali" command...
Installation complete
--------------------------------------------------------------------------------------------------------
newuser -- create a new user
stc [script file] [command name] [sudo/nothing] -- install a script as a command
updatemykali -- run apt update and full-upgrade; no input needed
--------------------------------------------------------------------------------------------------------
Enjoy
After that, newuser, stc, and updatemykali are on the default PATH.
Terminal captures from the lab runs above.
MIT. See LICENSE.




