LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 07-07-2018, 09:19 AM   #1
cuintilo
LQ Newbie
 
Registered: Jun 2018
Distribution: Debian stretch
Posts: 14

Rep: Reputation: 0
Added stuff into profile.d-folder, couldn't login afterwards


Hello, everyone.

Recently I started using gnu/linux, specifically newest release of Debian (stretch).

Some days ago I started to learn about scripting, though for what I've seen it's synonymous with using system to it's fullest potential...

Anyway, I'm reading couple tutorial ebooks at the moment and ran into stuff I don't understand.

I tried to add a simple script displaying a message upon login, but when I tried to login (into GUI, mind you) it wouldn't let me - screen just reverted back into giving my user password after entering it.

What I did was I added simple "greeting.sh"-file into profile.d folder, which had just an echo statement in it.

Does more experienced user have an explanation for this behavior? Also some tips for good (free) ebooks about scripting and system in general would be appreciated, I'm not sure if my current reading is doing the trick efficiently enough.

Cheers, and thank you!
 
Old 07-07-2018, 10:30 AM   #2
keefaz
LQ Guru
 
Registered: Mar 2004
Distribution: Slackware
Posts: 6,552

Rep: Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872
If you login with gui, it's preferable to use startup scripts folowing your Desktop environment practices
scripts in /etc/profile.d are meant essentially to set environment (env variables, maybe functions as well)

For greeting in console login, there is /etc/issue configuration file as well

A simple echo "something" in script shouldn't produce what you describe though, there must be an error somewhere
 
1 members found this post helpful.
Old 07-07-2018, 10:35 AM   #3
hazel
LQ Guru
 
Registered: Mar 2016
Location: Harrow, UK
Distribution: LFS, AntiX, Slackware
Posts: 7,583
Blog Entries: 19

Rep: Reputation: 4454Reputation: 4454Reputation: 4454Reputation: 4454Reputation: 4454Reputation: 4454Reputation: 4454Reputation: 4454Reputation: 4454Reputation: 4454Reputation: 4454
You didn't put an exit command at the end of your script, did you? These scripts are "sourced" (i.e. run inside your login shell, not as a separate command), so "exit" will log you out again.
 
1 members found this post helpful.
Old 07-07-2018, 11:25 AM   #4
cuintilo
LQ Newbie
 
Registered: Jun 2018
Distribution: Debian stretch
Posts: 14

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by keefaz View Post
If you login with gui, it's preferable to use startup scripts folowing your Desktop environment practices
scripts in /etc/profile.d are meant essentially to set environment (env variables, maybe functions as well)

For greeting in console login, there is /etc/issue configuration file as well

A simple echo "something" in script shouldn't produce what you describe though, there must be an error somewhere
Ok, thank you for information!

Quote:
Originally Posted by hazel View Post
You didn't put an exit command at the end of your script, did you? These scripts are "sourced" (i.e. run inside your login shell, not as a separate command), so "exit" will log you out again.
That actually might be it, not 100% certain though, stupid me didn't save that script anywhere when I removed it from profile.d so that I could log in with gui again. Another thing that occurred to me is that I maybe forgot to add #! at the beginning. Could that produce something like this on its own? I find it somewhat confusing that sometimes when I've written something into file it doesn't seem to matter whether for example "!#/bin/bash" is there and file can be executed properly. Is this some kind of automation by something by any chance? I'm currently using emacs as my text editor with hardly any modification of my own, so there might be some kind of newbie mechanic in use?
 
Old 07-07-2018, 11:31 AM   #5
keefaz
LQ Guru
 
Registered: Mar 2004
Distribution: Slackware
Posts: 6,552

Rep: Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872
It's "#!/bin/bash" (note position of # and !), called "shebang"

Its role is to ensure that bash will interpret this script, say if you start the script from csh shell, the script will stay a bash script thanks to the bash shebang on first line
 
1 members found this post helpful.
Old 07-07-2018, 11:38 AM   #6
cuintilo
LQ Newbie
 
Registered: Jun 2018
Distribution: Debian stretch
Posts: 14

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by keefaz View Post
It's "#!/bin/bash" (note position of # and !), called "shebang"

Its role is to ensure that bash will interpret this script, say if you start the script from csh shell, the script will stay a bash script thanks to the bash shebang on first line
So if I have a (bash) thing that's missing it it would be running properly in a bash and any other environment that recognizes notation and anything else would produce errors that produce some sort of message/termination?

Last edited by cuintilo; 07-07-2018 at 11:40 AM.
 
Old 07-07-2018, 11:43 AM   #7
keefaz
LQ Guru
 
Registered: Mar 2004
Distribution: Slackware
Posts: 6,552

Rep: Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872
Yes if started from a bash shell, a bash script doesn't need the shebang
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Ok to copy and rename Chromium profile folder to use as Chrome profile? linustalman Linux - Software 4 01-10-2017 08:54 AM
[SOLVED] PATH From ~/.profile is only added when logging in remotely linux_walt Linux - Newbie 7 01-04-2015 10:53 AM
When I open Google Chrome 13 Beta, it says that my profile couldn't be opened correct theif519 Linux - Newbie 2 07-11-2011 09:29 AM
[SOLVED] Perform some tasks when a new file is added in the folder abubakar-malik Linux - Newbie 18 02-24-2011 04:17 AM
bash profile stuff gauge73 Linux - Newbie 7 01-05-2004 01:54 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 03:08 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration