davidgrenier
Posts: 1
Joined: Sat Mar 23, 2013 3:54 pm

/etc/profile startx vs raspi-config

Sat Mar 23, 2013 3:59 pm

Following some guide I had added startx at the end of /etc/profile to start x automatically.

Now though I had noticed I had a large number of instances of xinit, sh and startx in the task manager and thouth that should be a problem.

After reading you could simpli start lxde through raspi-config, I removed the startx entry at the end of /etc/profile and switched on the raspi-config, reboot. Problem solved.

Why is that? Everything was so slow as a consequence and almost all memory was chugged up in those instances.

Second question, I had manually enabled auto login for the pi login through some other recipe. Was that required in the case where I had enabled lxde to start automatically through raspi-config?

Thanks,

David

DBryant
Posts: 281
Joined: Sat Feb 02, 2013 12:41 pm
Location: Berkshire, UK

Re: /etc/profile startx vs raspi-config

Mon Mar 25, 2013 9:56 am

For bash shells, you will see in the man-page
When bash is invoked as an interactive login shell, or as a non-interactive shell with the --login option, it first reads and executes commands from the file /etc/profile, if that file exists. After reading that file, it looks for ~/.bash_profile, ~/.bash_login, and ~/.profile, in that order, and reads and executes commands from the first one that exists and is readable. The --noprofile option may be used when the shell is started to inhibit this behavior.
Unfortunately you'll tend to find that implementation from distro to distro is a little hazier that might be supposed.

So /etc/profile is for any shell you might invoke as a user, and you might well have more than a single shell within a single login session. So putting startx in /etc/profile means you will have multiple instances of the graphical environment running (as you have seen).

In general you wouldn't put startx in /etc/profile or any of the user facing files i.e. those starting ~ in the above quotation, and particularly so on small systems where resource like RAM are low. They are scenarios where multiple screens are required but even then they are fairly (ever?) implemented by additions to /etc/profile

Usually startx would be started in one of the rc files; those are invoked once on system start-up, so there is only one copy executed. All shells you might then invoke during your work flow are then executed within that single graphical instance. If you look at what raspi-config does when you enable 'auto graphical' then it simple adds an invocation of the ligthtdm script to runlevel 2 (2 being the default level to which the OS boots). Disabling simply removes that link; and the OS is delivered without that link.

raspi-config does is right, your other source (aka some guide) is leading you in the wrong direction. It's often hard to gauge what is an authoritative source for advice but these specific platform forums are perhaps a better place to start than more generic sites since they are more likely to evolve to meet the demands of the hardware, a wide(r) local knowledge base etc and they are moderated too.
Second question, I had manually enabled auto login for the pi login through some other recipe.
Login is not the same as automatically starting the graphical environment. If you enable startx without auto-login it will present you with a username/password dialogue for you to fill in. So yes, you would have to enable auto-login in addition. How you implement it, via 'some recipe' or another guide is open to choice.

HTH

chris57100
Posts: 522
Joined: Wed Sep 12, 2012 7:23 pm
Location: Thionville
Contact: Website

Re: /etc/profile startx vs raspi-config

Thu Mar 28, 2013 12:42 pm

You can install nodm to start X on boot without updating any profile file.
You can also start X with a dedicated user other than root or pi (check /etc/default/nodm)
Raspberry Pi Home Server : http://www.pihomeserver.fr
Software and electronic tutorials : Samba, Airplay, CUPS, Time machine, Nginx, Owncloud, rTorrent, Wordpress, etc.
Full Wi-Fi hotspot installation on a RPi 3 including a captive portal and freeradius management: https://github.com/pihomeserver/Kupiki-Hotspot-Script

Joe Schmoe
Posts: 4277
Joined: Sun Jan 15, 2012 1:11 pm

Re: /etc/profile startx vs raspi-config

Thu Mar 28, 2013 1:39 pm

Short summary: There are lots of correct ways to do this, but putting it in /etc/profile isn't one of them.

BTW, per the thread Subject, what does this have to do with "raspi-config"? Is your idea that you could just use the config program to make it run X on startup? If so, any reason not to do it that way?
And some folks need to stop being fanboys and see the forest behind the trees.

(One of the best lines I've seen on this board lately)

Return to “Beginners”