LinuxQuestions.org
Visit Jeremy's Blog.
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 01-26-2009, 03:38 PM   #1
arunlfc
LQ Newbie
 
Registered: Jan 2009
Posts: 21

Rep: Reputation: 15
Confusion with configuration files


Hello.
I'm completely new to linux.
Linux configuration files are text files with a lot of strange characters.
I really wonder how people (the linux pros) can understand that stuff and be able to edit those configurations and do a lot of fun stuff.
My questions are:
1. Is it some kind of scripting language like html that linux uses??
2. Do i have to learn all those syntax to be able to understand what's in those files, and if i do, will i be learning something that is specific only to linux or is this type of syntax and language used elsewhere than in configuration files for linux?
 
Old 01-26-2009, 03:53 PM   #2
agrestic
Member
 
Registered: Jan 2009
Location: atlanta, ga, usa
Distribution: sabayon 5, slack64, Lenny, LFS 6.4 user # 20665
Posts: 61

Rep: Reputation: 16
The config files that end with .sh, and whose first line of code is:
#!/bin/bash
are written in the bash scripting language. Some of these files don't end with .sh; they're just a name, like S10networking.
You can learn Bash here. Bash doesn't work on windows; idk about other OS's.
Files that end in .cpp, .c and .h are written in a variant of C.
Those that end in .py are written in python.
As far as programming goes, many find it easier to learn python first, then C; both languages are used on Linux, windows, etc. There are more (Perl, Tcl/Tk) but i know nothing about those.
 
Old 01-26-2009, 03:55 PM   #3
Hiko
Member
 
Registered: Oct 2007
Location: Penn Valley, CA.
Distribution: Arch, Ubuntu, Fedora, Mint
Posts: 52

Rep: Reputation: 16
Aloha,
1. No. Configuartion files in linux are text files that can be edited in any text editor.
2. Yes you will need to learn and understand what the options in the files are and what they are used for and how they apply to the system you are using. For the most part this is only Linux specific but it can be helpful with other systems that are similiar, BSD, Solaris, et al.

Also, I have not seen to many "special" characters in configuartion files. Although what you mean by special may not be what I think it means.
Mahalo
 
Old 01-27-2009, 02:37 PM   #4
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Mint
Posts: 17,809

Rep: Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743
Quote:
Originally Posted by arunlfc View Post
Hello.
I'm completely new to linux.
Linux configuration files are text files with a lot of strange characters.
I really wonder how people (the linux pros) can understand that stuff and be able to edit those configurations and do a lot of fun stuff.
My questions are:
1. Is it some kind of scripting language like html that linux uses??
2. Do i have to learn all those syntax to be able to understand what's in those files, and if i do, will i be learning something that is specific only to linux or is this type of syntax and language used elsewhere than in configuration files for linux?
Linux is built and maintained by "strange characters"--I guess some could have gotten stuck in some files.....

Seriously, what do you mean by "strange characters"? What you will see in the typical configuration scripts is the BASH shell language---something you definitely should learn to be really proficient with Linux. The language is all done with the ascii character set---nothing strange there....

Start with the Bash Guide for Beginners---free at http://tldp.org

(html is not a scripting language---it's for page layout----totally different world.)
 
Old 01-27-2009, 03:51 PM   #5
onebuck
Moderator
 
Registered: Jan 2005
Location: Central Florida 20 minutes from Disney World
Distribution: SlackwareŽ
Posts: 13,925
Blog Entries: 44

Rep: Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159
Hi,

I guess I'm stuck in a file!

You should look at 'UNIX Tutorial for Beginners'. The 'BASH' guide that was suggested is a must if you plan on scripting. Another good guide would be the 'Advanced Bash-Scripting Guide'.

You can also look at the 'Programming' section of the 'Slackware-Links'. More than just SlackwareŽ links!
 
Old 01-27-2009, 06:05 PM   #6
salasi
Senior Member
 
Registered: Jul 2007
Location: Directly above centre of the earth, UK
Distribution: SuSE, plus some hopping
Posts: 4,070

Rep: Reputation: 897Reputation: 897Reputation: 897Reputation: 897Reputation: 897Reputation: 897Reputation: 897
Quote:
Originally Posted by arunlfc View Post
with a lot of strange characters...
Not usually; there is the hash bang (#!) but you should only see those as the first few characters of the file.

Maybe comment characters (#, ; ) meaning that the line isn't to be executed, or is just a comment.

Beyond those, if you are seeing lots of "strange characters" (and it isn't paranoia or delusions, which are often beyond the scope of LinuxQuestions) then that's difficult to understand. Do you have a strange language or keyboard set-up (strange = using characters not in the normal English set, which may not be strange to you, of course)?

Beyond that, maybe you can post a sample so we can see which characters you consider strange, please?
 
Old 01-29-2009, 12:46 AM   #7
arunlfc
LQ Newbie
 
Registered: Jan 2009
Posts: 21

Original Poster
Rep: Reputation: 15
I'm sorry i confused you all with that 'strange' word. I used it metaphorically to mean that those characters, that are perfectly normal ASCIIs, look strange to me because they do not make sense as to why they are there and the way they are used. That's just what i meant by strange.
But from the replies i guess i am right in thinking that they are part of the BASH SCRIPTING language, am i?

Oh btw...
I learnt that these scripts are interpreted.
What is responsible for interpreting them?? The shell, the kernel or something else???

Thanks for your help so far people

Last edited by arunlfc; 01-29-2009 at 12:50 AM.
 
Old 01-29-2009, 05:21 AM   #8
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,360

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
The bash shell program reads those script lines one at a time and acts on them. Note that some cmds in a script may be internal shell cmds eg 'cd' (see 'man bash'), others are external aka standalone programs eg sed.
You should find these links helpful:

http://rute.2038bug.com/index.html.gz
http://www.tldp.org/LDP/abs/html/
 
Old 01-29-2009, 05:42 AM   #9
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682
There are different kinds of configuration files/. I'm sure you will find more "strange characters" in the Windows registry.

Often a configuration file will have entries of the form:
item=value

This type of configuration file is run and the items are variables that the script or program uses. An example of this form is the ifcfg-eth0 config file that configures your NIC device.
Code:
BOOTPROTO='dhcp'
BROADCAST=''
ETHTOOL_OPTIONS=''
IPADDR=''
MTU=''
NAME='RTL-8169 Gigabit Ethernet'
NETMASK=''
....
A startup script will run (aka source) this file and the value of BOOTPROTO for example will be used when the "ifup-eth0" script is run.

Another type of config file is similar to the old Windows 3.1 .ini files. An example of this is /etc/samba/smb.conf.
Code:
[global]
        workgroup = HOME
        wins support = yes
        printing = cups
        printcap name = cups
        printcap cache time = 750
        cups options = raw
...
This type has section headers in square brackets and value/item pairs below the section header.

Another common type of config file has items separated by a character such as a colon. Look at the /etc/passwd file for an example.

Look at the /etc/sudoers file (sudo less /etc/sudoers). Notice how well commented it is. It also contains examples you might use simply by uncommenting the line. Look also at the comments above the line with "UsePAM yes" line in /etc/ssh/sshd_config. The comments contain full instructions what to do if you want to use Public Key encryption.

Also, configuration files often have their own man pages.
man 5 passwd
man 5 smb.conf
man 5 sshd_config
 
Old 01-29-2009, 07:12 AM   #10
onebuck
Moderator
 
Registered: Jan 2005
Location: Central Florida 20 minutes from Disney World
Distribution: SlackwareŽ
Posts: 13,925
Blog Entries: 44

Rep: Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159
Hi,
Quote:
Originally Posted by arunlfc View Post
I'm sorry i confused you all with that 'strange' word. I used it metaphorically to mean that those characters, that are perfectly normal ASCIIs, look strange to me because they do not make sense as to why they are there and the way they are used. That's just what i meant by strange.
But from the replies i guess i am right in thinking that they are part of the BASH SCRIPTING language, am i?

Oh btw...
I learnt that these scripts are interpreted.
What is responsible for interpreting them?? The shell, the kernel or something else???

Thanks for your help so far people
If you want to be proficient with UNIX/Linux system administration you should learn to use or understand BASH scripting. By understanding the BASH script you will be able to interpret what some system scripts are actually doing.

The 'BASH' file consists of commands that the shell will perform when executed. The file must have the execute attributes/permission set to allow the script to be executed by the user. For the script to be interpreted by the shell the first line must contain the (sha-bang); '#!/bin/sh'. This indicates to the bash shell it is a script. The '#!/bin/sh' states that the following commands by the head of a script tells your system that this file is a set of commands to be fed/passed to the command interpreter. Some commands are internal shell commands while others are external commands to the shell. You must be certain to provide the complete path to the external commands if the 'PATH' is not setup to indicate or have proper direction to the desired commands.

The 'Advanced Bash-Scripting Guide' is a excellent document with good examples that you should read for reference. BASH scripts along with other programs or commands will greatly enhance your system administration abilities.

Last edited by onebuck; 01-30-2009 at 05:01 PM.
 
Old 01-29-2009, 08:52 AM   #11
GazL
LQ Veteran
 
Registered: May 2008
Posts: 6,897

Rep: Reputation: 5019Reputation: 5019Reputation: 5019Reputation: 5019Reputation: 5019Reputation: 5019Reputation: 5019Reputation: 5019Reputation: 5019Reputation: 5019Reputation: 5019
sendmail.cf is enough to make anyone run away screaming,

And as for 'sudoers'... have you ever looked at the man page for it? Its one of the rare cases where you're likely to understand the file better without reading the manpage.

On the whole though, linux config files are usually pretty simple. (I have a pet hate about the more recent trend to xml based config files though)
 
Old 01-29-2009, 05:58 PM   #12
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682
Quote:
Originally Posted by GazL View Post
sendmail.cf is enough to make anyone run away screaming,

And as for 'sudoers'... have you ever looked at the man page for it? Its one of the rare cases where you're likely to understand the file better without reading the manpage.

On the whole though, linux config files are usually pretty simple. (I have a pet hate about the more recent trend to xml based config files though)
I was going to include XML when I started my post but forgot for some unknown reason.

The "Art of Unix Programming" by Steven Raymond is available on the web. Chapter 10 deals with configuration files. Steven Raymond shares your aversion for XML configuration files because of the large overhead needed to process them when writing an app and the diversion from being able to use simple text utilities for processing, which Unix/Linux is so famously good at.

http://catb.org/~esr/writings/taoup/html/

For very complicated configurations, it can be a plus. Richard "Fyoder" Lyons resisted XML but not prefers processing XML output for results over the grep option.
http://nmap.org/book/

I agree with you about the sudoers man page vs the self-documenting configuration file (/etc/sudoers) itself.

Last edited by jschiwal; 01-29-2009 at 06:02 PM.
 
  


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
Kubuntu 915resolution Configuration Confusion on Dell Inspiron 6000 ubernerd356 Ubuntu 4 10-11-2007 10:44 AM
3c509 configuration problem (or confusion) will_kranz Linux - Networking 1 04-25-2006 12:31 PM
samba configuration confusion akidd Linux - Networking 0 12-07-2004 07:20 PM
Woody 2.2.20 kernel and zen1200 (rtl-8139) nic .. missing files or just confusion. Martiniv Linux - Laptop and Netbook 2 04-21-2004 02:01 PM
Where are programs files and configuration files stored? nutshell Linux - General 2 03-09-2002 10:24 AM

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

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