LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 03-12-2013, 12:55 PM   #1
Didier Spaier
LQ Addict
 
Registered: Nov 2008
Location: Paris, France
Distribution: Slint64-15.0
Posts: 11,077

Rep: Reputation: Disabled
nano tip: set a variable in the boot command line to be used later


Seen this in the Current (pre-release) ChangeLog for x86 (32-bit):
Code:
a/syslinux-4.06-i486-1.txz:  Upgraded.
       Actually, dropping back from 5.01, which has a bug that prevents extra
       options given at the boot prompt from being passed to the kernel.
       We'll look at this again when 5.02 comes out.
Slackware's installer make use of this feature and this reminds me that I could share a little tip.

In addition to passing options to the kernel (and possibly modules) it is possible to set a shell variable in the command line and use its value after booting. You can even quote it. For instance if I write following boot command line:
Code:
Linux didier="dumb bunny"
once logged in after booting I get this:

root@slackware:/ echo $didier
dumb bunny
root@slackware:/


I just tried that inside Slackware's installer, I'll check that it works on an installed system.

PS sorry for the missing code tags, there seems to be a bug in the parser used by this forum.

Last edited by Didier Spaier; 03-12-2013 at 02:58 PM. Reason: s/it's/its/ Oh, well...
 
Old 03-12-2013, 02:08 PM   #2
David the H.
Bash Guru
 
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Arch + Xfce
Posts: 6,852

Rep: Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037
I'd suggest using the /etc/environment file instead, if you need truly global variables.

But actually, I wouldn't use either of these for trivial settings. When you do this, the value becomes available literally everywhere in the system. All processes inherit it. Just use your /etc/profile or similar shell startup script, the way they're intended.
 
Old 03-12-2013, 02:24 PM   #3
Didier Spaier
LQ Addict
 
Registered: Nov 2008
Location: Paris, France
Distribution: Slint64-15.0
Posts: 11,077

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by David the H. View Post
When you do this, the value becomes available literally everywhere in the system.
That's exactly what makes that so handy in some circumstances. For instance if append LANG=fr or kbd=fr.map to the boot command line of Slackware's installer, I can gather the values directly afterwards, no need to even parse /proc/cmdline.
 
1 members found this post helpful.
  


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
A tip regarding Exiv2 on the command line SilversleevesX Linux - General 0 09-12-2012 06:37 AM
TIP: Reducing PDF file size from the command line with GhostScript (gs) ShellyCat Linux - Newbie 3 07-12-2012 04:11 AM
[SOLVED] Get a variable from a user on command line, in the middle of a line mikejreading Linux - Software 4 11-22-2010 09:06 PM
LXer: Tip: Easily Enable Syntax Highlighting in Nano Editor LXer Syndicated Linux News 0 09-23-2008 10:10 PM
set a line in a file as a variable tpreitano Linux - General 5 08-24-2005 11:53 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 08:31 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