Solved User management.

Looking to delete user but i want to delete all what this user installed using sudo/pip etc.
rmuser does not do that.
Im not sure if i was dreaming or ive seen somewhere you can delete directory and its done.
How do you deal with removing user ?
 
Check the sudo or pkg lines and manually remove the installed packages:
grep sudo /home/user/.history
Dont have .history file.

If something is installed with sudo(8) then it's not that user that installed it, it was root.


pw userdel -r <username>
rmuser <username>

I usually prefer pw(8), as it give you more control.
Thank You.
So in this way i can just do this if i want my system to be more like a fresh install ?
pw userdel -r <username>
pkg delete -af
rm -rf /usr/local/*
but all the rc.conf edited files where i did with sudo/root will stay and i just need to comment out like nvidia , rstudio , etc. as there will be no modules left to load.
 
At that point, it's probably faster and more reliable to just reinstall.
Not really , i thought about it as i used to do this with Arch Linux as it takes 10 min to reinstall but FreeBSD is new for me so it takes a bit longer for me to do stuff ( plus so many restarts as i used to follow how to and my system takes few mins to reboot ) so i would prefer to remove user/pkges and then install few things and create a snapshot ( as im learning and FreeBSD is a new thing for me specially snapshots and zfs )
 
Why would you delete everything in /usr/local. There is all programs you have installed yourself on the system installed, as well as config files for those programs. It has nothing to do with the users files. The strong separation between the operating system, user programs (witch are not installed by the user, but programs not used the operating system), and the actual user(s) is one of the things that makes the system so easy to understand and use.
Delete the user with
pw userdel -r <username>
Then remove all the users local files under either /home/username or /usr/home/username
That should do it. There will be some log files and other small things left in /var (log files) . But they are there for a reason and should not be removed.
 
There is no way to undo things done with a tool like sudo - even with a full history (which you never will have by default): If a shell was opened by f.e. sudo su - the history is that of root, and is mixed by different people.
It is as simple as that: Untrusted persons shouldn't get the possibility to do things as root. If so, you're lost afterwards. To get a clean system the only way is to install from scratch again (or deinstall all ports/packages, reset all files from the base system to its defaults, remove all databases, webspaces etc. - but for "remove all db, htdocs" you already need to know what that person has done, so again: impossible).
 

Then: ls -lha /home/user

It won't remove user changes to /etc but it's a good way to start:

 
Why would you delete everything in /usr/local. There is all programs you have installed yourself on the system installed, as well as config files for those programs. It has nothing to do with the users files. The strong separation between the operating system, user programs (witch are not installed by the user, but programs not used the operating system), and the actual user(s) is one of the things that makes the system so easy to understand and use.
Delete the user with
pw userdel -r <username>
Then remove all the users local files under either /home/username or /usr/home/username
That should do it. There will be some log files and other small things left in /var (log files) . But they are there for a reason and should not be removed.
I think i found what im looking for just need to do a bit more of research.

Im experimenting atm so instead of re-install OS i just want to get back to post install OS just in case so i can go ahead and do more harm/good what ever im intended to do to experiment with my setup.
I dont want to re-install OS every time i do something silly - so finding a command to revert the system is always good choise and time efficient also snapshots as i didnt made any of them at the start.
 
If you want a system, let's say, secure. The most sensible thing is to make a recipe of the packages you install and the extra configuration. Reinstallation will be a matter of minutes. It's what I always do with any *nix installation. In your case you risk having hidden settings from the user you deleted.
 
If you want a system, let's say, secure. The most sensible thing is to make a recipe of the packages you install and the extra configuration. Reinstallation will be a matter of minutes. It's what I always do with any *nix installation. In your case you risk having hidden settings from the user you deleted.
you mean something like pkg prime-origins > origins.txt and something like this to config files ?
 
Something like this, where the commands take you to a usable system. Not a complete list:

Code:
pkg install xorg-minimal drm-kmod xf86-video-intel lightdm ligthdm-greeter lxde-meta firefox
sysrc lightdm_enable="YES"
sysrc dbus_enable="YES"
echo "proc /proc procfs  rw 0 0" >> /etc/fstab
mount /proc
pw groupmod video -m my-user
kldload i915kms
# [firewall config]
service dbus start
service lightdm start

Simpler to your head than a list of packages after a few years.
 
Last edited by a moderator:
Back
Top