Hi there, this is my first post in these forums and I'm embarrassed to show you these photos. I bought this cactus about 3 years ago and it was in a small terra cotta pot. I bought it at an outdoor market where it was sitting in the sun. I put it in my office window and within a couple of months the surface facing the window went brown and dry. I probably under-watered it plus it obviously got too much sun. I moved it to a different window that got a lot less sun and it sat there for 2.5 years, pinched down as you can see and put on more height but much narrower. So, probably not enough sun. At that time it was in a common space and I would guess it got watered too much.
After being alone in the office since late February, I finally took it home two weeks ago. I noticed it was leaning slightly. I gave it a good watering when I got home, then a week later I repotted it into a slightly wider, twice as deep pot with moistened soil and put it on a windowsill where it gets 3-4 hours of morning sun, not too intense, with bright diffuse light the rest of the day. The lean has since increased, maybe because I didn't pack it in well enough, but the plant stem is firm to the soil line.
I'm wondering if there is any way to give this cactus back its health, and what kind it is. I would be very grateful if anybody can identify it and give me any advice.
Best wishes and thank you all for your generosity in posting so much useful information on this forum!