Looks like I froze my SUSE by editing etc/profile

Felecha

Golden Member
Sep 24, 2000
1,434
0
0
I have two hard drives, XP on #1. I created 2 partitions on #2, one for Windows storage, one for Linux so I could learn about it.

After a couple of weeks with Fedora Core 4, which I really liked but had been having some problems with, I thought I would try something else, so I got SUSE 10 and installed it over the FC4. It went very smoothly and I like SUSE at least as well as FC so far, very very nice.

But one of the applications I installed requires sourcing a config file. I've been learning about bash and its startup scripts, and learning some command line stuff. I found what looked like a very helpful tutorial on what bash does when it comes up, and I thought I would try adding the command to source that file into one of the scripts, profile or bashrc or somewhere in there. I admit I am exploring a bit.

I have learned the echo command so I thought it would be instructive to plant a line in /etc/profile like the console debug statements I often use in programming.

echo "profile" > /root/Desktop/a.txt

(I have been logging in as root so as to be able to see and do everything). Doing the echo from a terminal works like I want. And I was going to put a similar echo into the other scripts. Then I hoped that a.txt would be like a log where I could see the progress of script after script at login or at starting a shell.

Well, looks like I shouldn't have done that.

When I boot now, I get to where the splash screen should get going and I get the nice blue background but nothing appears on it, none of the welcome icons and text. I tried logging in with my ordinary user, same thing. I tried failsafe and at the console login it waited a long time and then began telling me something about bash and /usr/bin and Argument list too long and then bash and /user/bin/grep and the argument list too long.

So . . . is there any way of getting in and undoing what I did? I promise not to do it again . . .
 

Felecha

Golden Member
Sep 24, 2000
1,434
0
0
Well, some hope but more puzzlement.

I went back to FailSafe, and remembered some stuff from school - I hit Ctrl-C while it was pouring out the lines about argument list too long and it stopped at a bash prompt. I went to /etc and did

vi profile

and there in black and white was a vi editing screen. I deleted the line about echoing and saved it and as far as I know the profile file is back to what it was.

But SUSE still can't show anything on the Welcome screen. I get the first screen, and then the login screen and when I log in it just stalls as before - the nice blue background with none of the last series of icons that usually ends at the Desktop.

Interestingly, a startx command from Failsafe brings up the Desktop. So that's where I am now.

Obviously I don't know enough of what I'm doing. Luckily this is still just exploring. I dont have precious data that is at risk, although I did spend some time downloading some programs and installing them last night.

I have the SUSE install DVD. Can I reinstall from that, like you can do Windows without formatting, just reinstall the system files?

 

n0cmonkey

Elite Member
Jun 10, 2001
42,936
1
0
Don't edit /etc/profile, edit ~/.bash_profile. The /etc one should be pristine, if you're only making changes for one user.

Don't use root for every day stuff. It's a really bad idea. Don't do it.

You shouldn't have to format your /home partition, but I'd blow away the rest of it if you're going to reinstall.

If you boot into text mode, can you login fine?

Can you login to the X11 interface as a regular user? If so, no harm done. You shouldn't log in as root.
 

LokeanSon

Member
Dec 7, 2005
30
0
0
I believe if you boot from installation CD, there is a rescue option on the menu. I'd give that a shot and see what happens. I'd offer more, but I haven't had to use the rescue mode of a Suse CD since 9.1, so I just don't know what you'll get or what it will be capable of.

If that doesn't work, go through your command history and get a list of ALL the commands and the syntax you used right before this problem started. Check your .bash_history file for this info. If the rescue mode can't fix it, post the list, copying and pasting it so it is precisely the commands from the history file, and we'll see if someone here can't pinpoint what went wrong.

G/L.
 

Felecha

Golden Member
Sep 24, 2000
1,434
0
0
Can I ask what has been a big curious question? I've heard consistently - DONT use root! I don't know the full why. I have thought it either had to do with security, like if I'm root someone can take control and get complete access, or it was to keep people from messing with things they don't know about. I don't worry about making messes (hah! I've already complained about my messes, haven't I?). And there's no one else here who would get in as root while I'm out for coffee.

When I have tried being a user it looks like I can't see any other files in File Manager. I get to see my Home folder and that's all. That's a real pain. I've been installing things that I need to be able to get at the files for. And do chmods for getting them running, too.

[edited later - doh! I haven't learned the File manager enough yet, that's all. Found the button-tab along the side of the window that opens into the full File System.]

And I know I can use su or sudo for things I need to do like chmod.

Anyway I keep feeling like it's similar to my early days when people said STAY OUT OF THE REGISTRY. Nowadays I do programming that makes registry changes and all that and I feel like OK, yes you can screw the whole thing, but since I know what I need to know there, no need for fear any more. So far I've felt like that about root.

I would love to learn more about why it matters.

And I just reinstalled the whole SUSE and it's been fine for now. I have a luxurious new Athlon 3800+ and the install takes less time than fooling with other things and I have no precious data to worry about at this point. Learning by doing (and messing up . . .)

And where is .bash_profile? I haven't found it yet in SUSE. FC4 had one in the user's home folder.

 

TonyRic

Golden Member
Nov 4, 1999
1,972
0
71
The reason to not use root is because it is generally bad practice. It becomes a bad habit and must be avoided. You should always use a regular user account and become root by using 'su -' or using sudo to execute commands as root. It will minimize the potential for totally screwing your system. If you do not care about any of this, then that is your business. But, it is definately not best practice.

.bash_profile is located in your home directory. '~' refers to your home directory. Therefore 'vi ~/.bash_profile' will edit .bash_profile in your home directory.

NOTE: the dot "." in the filename. That makes the fine "invisible" to a standard directory listing. You will see it if you run 'ls -a"

reinstalling a *nix OS is typically the worst "kill the fly with the sledgehammer" approach to fixing problems. You could have booted into the failsafe choice or off of the install CD. You could have mounted the drive and fixed the problem from there.
 

Felecha

Golden Member
Sep 24, 2000
1,434
0
0
There is no .bash_profile anywhere on the Linux installation that I can find. I have learned about hidden files that start with '.', and it's just not there. I had one course in school where we used RedHat 6, and I had RH9 at home some time ago and FC4 just recently for a couple of weeks. They all had .bash_profile in the home directory. I wondered if this was something different about SUSE 10.

I did manage to get in with Failsafe as I mentioned above, and as far as I know I edited my mistake back to OK. Still didn't fix the problem, so that's when I gave up and just full reinstalled. I could pursue that puzzle for a long time and there are other things I am eager to get to working with. I once spent 6 full days at work on a problem (that one could NOT be ignored, it HAD to be solved) and that was a sobering experience. Here I just wanted to get on, even though if someone had offered me 10 bucks to explain what was going on there I would probably have paid it, I really would like to know more about the boot process and bash starting itself up.

Anyway, there is no .bash_profile so there is something interesting right in front of me.

Thanks all

 

LokeanSon

Member
Dec 7, 2005
30
0
0
You're a programmer... I do a little coding myself. Let's say you write this great program, foobar, and you've done it as root. Now you want to have your friends try it out. But they either don't have root access, OR, they follow the golden rule and don't run as root. Well unbeknownst to you, because you're still learning this stuff and don't have all the subtleties down yet, you went and wrote your program to access something that requires root privileges. You're still new on the system, so it won't be obvious to you what you did and could prove to be downright painful to figure out what the problem is. I've done stuff like this myself writing stuff for Windows and accessing portions of the registry.

Anyway, that's one thing. Another is what you've already done. Root is the key to the kingdom. It isn't *JUST* administrator access, it's access to every last thing on the system with no safeguards, especially when you're messing around at the command line with commands you don't understand.

This problem is magnified on distributions like Suse. Suse isn't meant to be used for hacking around at the same level as a slak or a gentoo. It has programs that want to be in charge of your configuration files and those programs often
follow their own rules, which often aren't as easy to find documentation for. This means if you pull open any old man page or site for a given service and try to play with what it's talking about, you can seriously hose your system due to doing things that aren't the "Suse way". Suse is meant as a functional, easy to use desktop OS, where most configuration is done through the tools they provide. Bypassing it at the command line through root is asking for trouble.

If you're going to use a distribution like Suse, focus on learning its tools FIRST, before you even think about playing around in root at the command line. Learn how to do things like fix the system should it break, using it's tools. Ahem. Then once you have those tools down, you'll be able to play a lot more freely. But definetly do NOT run as root all the time. Set yourself up a user account, and run as a user. That's how it's meant to be done.

Another thing to remember, running Linux as root all the time removes major security advantages of Linux. You are not nearly as secure if you run as root all the time.
 

LokeanSon

Member
Dec 7, 2005
30
0
0
Just went through the Suse install CD, because I remembered there being an automated type repair. For future reference...

If you have a problem you can't fix, boot your install CD, act like you're going to reinstall... When you get to the screen for installation mode, it will list 2 things, full install and update. There will be a button that says "Other". Click that button, and choose the "repair installation" option. When I used it under 9.x, it fixed a kernel update gone bad, pretty much by itself.
 

Felecha

Golden Member
Sep 24, 2000
1,434
0
0
Thanks. That helps a lot.

And ... any idea where .bash_profile is or what the story is on that in SUSE?
 

Felecha

Golden Member
Sep 24, 2000
1,434
0
0
And actually right now I have to be more into other things with Linux. I am starting a new job the first of the year where they use Java, which I used to do a good bit of, but I've been off in .Net for 2 years. The new folks work in Windows and RedHat and SUSE. So I wanted to plunge back into Linux and mess around and fix things if I broke them. But I also wanted to work in Linux with the Linux version of NetBeans. Right now I'm spending more time working IN Linux, not so much time for working ON Linux.

I must say that as a desktop OS SUSE is far beyond the RH 6.2 I first learned on. Back then the big attraction for us in school was it was not Windows. It was surely more difficult to work in than Windows. SUSE 10 is very very nice!

And NetBeans 4.1 is much nicer than the NetBeans I used 2 years ago, too
 

sourceninja

Diamond Member
Mar 8, 2005
8,805
65
91
Quick lesson on why not to run as root.

First backup your whole system. Because this will most likely destroy it.

Login as a user and type rm -rf / and press enter.

Then try it as root.
then reboot (well if it hasn't already crashed).

People shouldn't run as admin on windows either, but they do because sofware programers came from the 98 mindset and didn't write their software to work without being able to access the whole system. This opens up a lot of security problems in windows. For example. I have a web browser on windows and linux. On windows I run as admin, so if my web browser has a security hole, guess what it can be used to screw up my whole system. On linux I run as a user. My browser has a security hole. The only thing I can have access too is what My user has access too (which is basically just the /home folder and maybe read/exe on a few other directories.) If I was running as root it could install a root kit, or screw up etc, or whatever it was designed to do.

So running as a normal user with the least amount of privleges you can have to make life livable is best. This will protect you from secuirty holes in your software, idiot actions on yourself, and keep you compatable with those in the linux world (that way you wont start writing games that require you to run them as root).

as for .bash_profile. If you dont have one, just make it. Its not required to be there, but it will get used if it is.
 

n0cmonkey

Elite Member
Jun 10, 2001
42,936
1
0
Originally posted by: TonyRic
.bash_profile is located in your home directory. '~' refers to your home directory.

~ refers to the root of the home (ie. /home). ~/ refers to your home directory. You can access someone else's home directory with the ~USERNAME shortcut.
 

Felecha

Golden Member
Sep 24, 2000
1,434
0
0
OK, that's what I wondered. thanks for all the root perspectives. Very enlightening.

With practice I've found it's rather easy to get to root when I need so that's not a worry any more.

I found a tutorial a few days back that talked about the progress of bash stuff at login and at the start of a new shell. It was interesting and I wish I could remember the google string I used for finding it.

So bash will look for a .bash_profile and run it if there is one and shrug and pass on by if there is not?
 

n0cmonkey

Elite Member
Jun 10, 2001
42,936
1
0
Originally posted by: Felecha
OK, that's what I wondered. thanks for all the root perspectives. Very enlightening.

With practice I've found it's rather easy to get to root when I need so that's not a worry any more.

I found a tutorial a few days back that talked about the progress of bash stuff at login and at the start of a new shell. It was interesting and I wish I could remember the google string I used for finding it.

So bash will look for a .bash_profile and run it if there is one and shrug and pass on by if there is not?

It should look for ~/.bash_profile and use it if it exists. If not, it should use the one in /etc.
 

drag

Elite Member
Jul 4, 2002
8,708
0
0
In Debian they keep the files you want to be installed with your users in a /etc/skel directory (for skeleton, I guess).

There is a bash_profile in there... Maybe Fedora has something similar.
There is also sample files in /usr/share/doc/adduser/
(also for other programs, such as vim and such that are handy.)

Try going:
locate bash_profile

maybe you have to do a updatedb first though.

In my links in my sig there is the linux documentation project. They have 2 bash scripting guides, a beginners and advanced one, and several smaller bash howtos. Such as how to customize your bash prompt and things like that.
 
sale-70-410-exam    | Exam-200-125-pdf    | we-sale-70-410-exam    | hot-sale-70-410-exam    | Latest-exam-700-603-Dumps    | Dumps-98-363-exams-date    | Certs-200-125-date    | Dumps-300-075-exams-date    | hot-sale-book-C8010-726-book    | Hot-Sale-200-310-Exam    | Exam-Description-200-310-dumps?    | hot-sale-book-200-125-book    | Latest-Updated-300-209-Exam    | Dumps-210-260-exams-date    | Download-200-125-Exam-PDF    | Exam-Description-300-101-dumps    | Certs-300-101-date    | Hot-Sale-300-075-Exam    | Latest-exam-200-125-Dumps    | Exam-Description-200-125-dumps    | Latest-Updated-300-075-Exam    | hot-sale-book-210-260-book    | Dumps-200-901-exams-date    | Certs-200-901-date    | Latest-exam-1Z0-062-Dumps    | Hot-Sale-1Z0-062-Exam    | Certs-CSSLP-date    | 100%-Pass-70-383-Exams    | Latest-JN0-360-real-exam-questions    | 100%-Pass-4A0-100-Real-Exam-Questions    | Dumps-300-135-exams-date    | Passed-200-105-Tech-Exams    | Latest-Updated-200-310-Exam    | Download-300-070-Exam-PDF    | Hot-Sale-JN0-360-Exam    | 100%-Pass-JN0-360-Exams    | 100%-Pass-JN0-360-Real-Exam-Questions    | Dumps-JN0-360-exams-date    | Exam-Description-1Z0-876-dumps    | Latest-exam-1Z0-876-Dumps    | Dumps-HPE0-Y53-exams-date    | 2017-Latest-HPE0-Y53-Exam    | 100%-Pass-HPE0-Y53-Real-Exam-Questions    | Pass-4A0-100-Exam    | Latest-4A0-100-Questions    | Dumps-98-365-exams-date    | 2017-Latest-98-365-Exam    | 100%-Pass-VCS-254-Exams    | 2017-Latest-VCS-273-Exam    | Dumps-200-355-exams-date    | 2017-Latest-300-320-Exam    | Pass-300-101-Exam    | 100%-Pass-300-115-Exams    |
http://www.portvapes.co.uk/    | http://www.portvapes.co.uk/    |