-1

So today i was learning a bit of linux using my linux ubuntu 20.04, i was learning about autofs. I installed autofs and configured it as was shown on the video i was watching. So it was time to create a user on ubuntu device that i presume is used to connect two machines so that they can share the shared files/filesysyem as i had to also create the same user eith the same userid on my other linux device.

So i then went on to create my new user called "user1" using the 'useradd'command, but when i tried to login to this user i noticed that as my prompt im only getting the $ sign, instead of (uname)@(hostname)$, so i thought to myself maybe its because i did not set the home directory for the new user, so i then executed the following command 'chmod -s /bin/bash -m -d /home/user1/ user1' (note that i was in my main home directory when i executed this command. The main directory of which i lost all my data). So after executing this command i was then able to login to user1 and the command prompt was actually correct. But then i immediately noticed that when i logged into that user i was in the /root home directory.

When i tried to ls my main home directory i was getting nothing back, so i then momentarily exited my terminal and tried to access my files using my gui and i noticed that i had no more files in my computer, i thought maybe it was just an error i could reslove by restarting my computer, but when i restarted it i could not login as myself nor as root, when i try to login as myself i get stuck in a login loop, when i try to login as root it doesnt allow me either, i even tried password recovery and it still wont allow me to login. On the login screen when i access the tty3 it allows me to login as myself and as root but under my home directory my data seems to be losy forever.

Can someone please help me to login to my computer at least, the data i have lost can mostly be recovered but at this moment i cant even access my GUI

Lihle
  • 1
  • 1
    Why have you entered chmod -s /bin/bash ...? I'm not sure, but get a live boot usb stick, mount your rootfs, and do a chmod 755 /mnt/bin/bash. With some luck your old system should now work again. – paladin Apr 21 '22 at 15:01
  • PS mount your original rootfs to /mnt. And also do a chmod 755 /mnt/usr/bin/bash. – paladin Apr 21 '22 at 15:06
  • Okay just to edit on that, i was trying to use testdisk to recover my files, it turns out they not actually deleted, when i enter testdisk i can copy home directory with all its files and when i try to copy it to my /home directory it tells me permission denied, though im logged as root and the owner of the directory is root, but when i try to copy it to another directory it works. Yet i still cant access my gui, i think there might be a problem with the mounting of the /home directory, because when i use tty3 and type ls -l, the size of /home is 0, using testdisk the whole directory is there. – Lihle Apr 21 '22 at 18:05
  • 2
    adduser is more user friendly than useradd. The reason you were seeing only $ is because you were using the wrong shell. useradd also doesn't create a home directory unless you tell it to. Now you might have broken your system in the actions you have taken. I suggest that you reinstall and restore from backups. Try to research commands before running them so that you don't make mistakes as frequently and always have backups in case you need to start over. See: https://askubuntu.com/a/345986 and https://serverfault.com/a/267101 – Nmath Apr 21 '22 at 18:09

1 Answers1

-1

So basically i heavent solved the whole problem completely, but i have a solution which is just as good. So with the use of testdisk through tty3 i was able to enter the /home/(USER) directory and copy everything to a created directory /backups. I then went on to delete all Usernames from the /etc/passwd, /etc/shadow & /etc/group directory.

Then i created a new directory /Home/(User) where i copied all the files from /backup to, i then proceeded to create a user using "useradd" command because for some reason it wasnt allowingg me to use "adduser". After creating the user i used "usermod" to set the home directory for the new user, after that i went to /etc/passwd to set the shell to /bin/bash for the user. I then rebooted my computer and i was able to use ny computer as normal.

My only issue is that i still cant access my /home directory and it taking up about 66g of my storage space...

Lihle
  • 1