Page 1 of 2

Linux root user question

Posted: Sat Sep 16, 2006 3:45 pm
by alex.barylski
Ok so i'm slowly learning about linuix (it's quite different from the way Windows works isn't it?) and right now I'm just learning about shell basics...

I had no idea it was the shell which actually expanded wildcards, etc I was always under the impression the program invoked was responsible for that, as most CLI applications I have worked with or viewed had most of that functionality implemented locally (possibly due to programmert naeivty who knows). Perhaps DOS does wildcard expansion as well.

Anyways, I have installed Linux RH on an old computer and just went with a web server setup (No KDE, etc)

I'm playing around with the CLI learning functions like pwd, etc...WOW have I been spoiled or mislead by Windows over the years :P

Anyways...one thing that struck me as odd. My computer had 2 drives (phsyical) and both appear to have 2 partitions ins each. One which I boot from or have marked as bootable I created a swap partition.

I login as root (I haven;t created any users yet - don't need to as of now) and i'm navigating the file structure. I am slowly grasping the concept of mounting, but again from a Windows perspective it's quite different, but interesting.

When logged in I am at the root user home directory, which is I assume lateral to others users home directorties? At first I assumed it was the parent, but now it appears (from reading only not experimenting) they are lateral?

I do a dir or ls -a and I am displayed a few .bash_* type files thats it???

I have no subdirectories or anything, where in the heck is Apache? from the root path I call apache start and I get appropriate errors saying ServerName can't be set so set with directives...not sure I fully understand, but I think I just need to modify the Apache conf file...

I assume it'sa because Apache's path is set in the environment variables...I just read a doc on that, so i'll reread again...

My question is...is this a typical Linux setup?

I assume root is just like other users but username is fixed as "root" and under root you have advanced permissions like installing applications in the BIN directory which are accessable from anywhere?

I just googled the following: http://www.secguru.com/files/cheatsheet ... ucture.jpg

Makes things a little more clear.

However, if I'm inside root and only everything inside of root is available to me using relative paths, if I wanted to edit Apache conf file or invoke Apache directly would I have to use some form of absolute path indicating it's outside of the root directory???

Sorry for the newbie questions...some areas I've made good progress and this is one that has me stumped..

Cheers :)

Posted: Sat Sep 16, 2006 3:58 pm
by volka
You may compare the home directory with the directory documents and settings on a win32 system. The root's home directory is not the root/parent of other home directory.
I do a dir or ls -a and I am displayed a few .bash_* type files thats it???
That's because you have no more "personal" settings or files for the user root.
I have no subdirectories or anything, where in the heck is Apache?
the home directory for user root is different from the root directory, cd ~root brings you to the home directory of the user root (~root usually expands to /root, also works with cd ~username, which brings you to the home directory of user username), cd / to the root directory.
rom the root path I call apache start and I get appropriate errors saying ServerName can't be set so set with directives...not sure I fully understand, but I think I just need to modify the Apache conf file...
Did you set a dns name while or after the red hat installation (don't know if or when RH ask for that)
The apache configuration files are probably in one of the following locations: /etc/apache/conf, /etc/httpd/conf, /etc/conf.d/apache (apache might be apache2).

Posted: Sat Sep 16, 2006 4:21 pm
by nickvd
When logged in I am at the root user home directory, which is I assume lateral to others users home directorties? At first I assumed it was the parent, but now it appears (from reading only not experimenting) they are lateral?
Not quite... the root users home dir is located at /root whereas regular users are located /home/<user> (/home/hockey)

try typing

Code: Select all

# find / -iname httpd.conf (or apache.conf)
that will start at the top (/) and try to find any files that are (case insensitive -iname) named http.conf

Posted: Sat Sep 16, 2006 4:46 pm
by alex.barylski
cd / to the root directory
Bam...thats what I was looking for...thank you very much :)
Did you set a dns name while or after the red hat installation (don't know if or when RH ask for that)
The apache configuration files are probably in one of the following locations: /etc/apache/conf, /etc/httpd/conf, /etc/conf.d/apache (apache might be apache2).
I used locate to determne the position, but is it possible there are more than one ocnfig file for apache, whihc one should I modify?

Red Hat did not ask to setup any DNS. :? As was under the I would just use a IP address. inconfig.exe under windows is what I used to access Apache while running windows, using this IP allowed any computer on the inside of my router to access the web page using the IP

http://xxx.xxx.xxx.xxx/index.php and so on...

If I setup a DNS locally, does that mean I could use something like: http://webhost/index.php instead??? That would be cool, but wouldn't it cause problems when accessing external web sources...like if there was a website called...www.webhost.com or would the dot COM suffix prevent name collisions???

thanks for the help

Posted: Sat Sep 16, 2006 4:47 pm
by alex.barylski
nickvd wrote:
When logged in I am at the root user home directory, which is I assume lateral to others users home directorties? At first I assumed it was the parent, but now it appears (from reading only not experimenting) they are lateral?
Not quite... the root users home dir is located at /root whereas regular users are located /home/<user> (/home/hockey)

try typing

Code: Select all

# find / -iname httpd.conf (or apache.conf)
that will start at the top (/) and try to find any files that are (case insensitive -iname) named http.conf
I used slocate/locate which worked, how is find any different? Nevermind actually I can read up on that one I guess ;)

Thanks for your help

Posted: Sat Sep 16, 2006 4:54 pm
by volka
Did the setup ask you for some kind of hostname? Do you have a file /etc/hostname and if so: what's in it?
RH probably ships with some tool to set this value and if so you should use it ... but, sorry, I don't know RH.
using this IP allowed any computer on the inside of my router to access the web page using the IP

http://xxx.xxx.xxx.xxx/index.php and so on...
and you're probably able to do so with your rh apache right now, too.
ServerName has a different meaning, see http://httpd.apache.org/docs/2.0/mod/co ... servername
I used locate to determne the position, but is it possible there are more than one ocnfig file for apache, whihc one should I modify?
multiple httpd.conf files? Where are they located?

Posted: Sat Sep 16, 2006 4:54 pm
by nickvd
Hockey wrote:I used slocate/locate which worked, how is find any different? Nevermind actually I can read up on that one I guess ;)

Thanks for your help
the 'find' command is real-time, so everytime you run it, it will scan the disk for the file

slocate/locate uses a database of the files/folders on the disk, the db gets updated once a day (usually) by the updatedb script. So as long as the file(s) you're looking for are in the db, use slocate/locate as it will be faster, use find if you need to locate files that are either new, or not in the db.

(alternativly, you could just run updatedb before running slocate to update the db prior to searching)

Posted: Sat Sep 16, 2006 5:10 pm
by alex.barylski
volka wrote:Did the setup ask you for some kind of hostname? Do you have a file /etc/hostname and if so: what's in it?
RH probably ships with some tool to set this value and if so you should use it ... but, sorry, I don't know RH.
using this IP allowed any computer on the inside of my router to access the web page using the IP

http://xxx.xxx.xxx.xxx/index.php and so on...
and you're probably able to do so with your rh apache right now, too.
ServerName has a different meaning, see http://httpd.apache.org/docs/2.0/mod/co ... servername
I used locate to determne the position, but is it possible there are more than one ocnfig file for apache, whihc one should I modify?
multiple httpd.conf files? Where are they located?
RH requested a host name yes...I used "webhost"

I just ran a PS command and Apache isn't running...when I try to start it manually using: apache start I get an error saying:
Cannot determine localhost name - Use ServeName directive to set it manually
(I assume RH didn't set it as webhost - which I used during install???) so now I need to open the httpd.conf using VI or similar find that directive and change it accordingly to webhost or my IP address which I get using ipconfig???

I'm looking for a directive switch for the httpd which i can pass when invoking it, just to see if that works before modifying any files...

Any ideas???

Cheers :)

NICKVD - Without even reading up on it I actually assumed that was the likely difference between them :P

Posted: Sat Sep 16, 2006 5:12 pm
by nickvd
dont use apache start...

try using apache2ctl start

(if running apache 1: apachectl start)

and to check if it's running, use

Code: Select all

ps ax | grep httpd

Posted: Sat Sep 16, 2006 5:37 pm
by alex.barylski
apachectl or apache2ctl both cause error of bad commands, apache start works, but then apache gives me an error. I know it's not running cuz I've already looked at the processes manually :?

Correction: I wasn't using apache start, but rather httpd start :P

Sorry, anyways, I updated httpd.conf and changed the host, etc and everything loaded fine...now I need to create a test file and see what happens :P

Posted: Sat Sep 16, 2006 5:41 pm
by nickvd
Hockey wrote:apachectl or apache2ctl both cause error of bad commands, apache start works, but then apache gives me an error. I know it's not running cuz I've already looked at the processes manually :?
When you looked, were you looking for "apache"?

You shouldn't find it :) but you should find httpd.

Posted: Sat Sep 16, 2006 5:56 pm
by volka
multiple httpd.conf files? Where are they located?

Posted: Sat Sep 16, 2006 6:20 pm
by alex.barylski
There were no additional conf files, but I have had that experience on Windows, likely due to multiple installs of apache :P I was just curious if that was possible using a default install...I searched and it appears not :P

I got HTTPD working :P or at least it appears to be...I've nslookup'ed my website and it gave me the proper info...ao I know my net connection is working and *nix recognized and configured the eth0...

I'm using ipconfig on my laptop (wireless connection) and I get the following IP details:

Code: Select all

Ethernet adapter Wireless Network Connection:

        Connection-specific DNS Suffix  . : xx.something.net
        IP Address. . . . . . . . . . . . : 192.168.1.100
        Subnet Mask . . . . . . . . . . . : 255.255.255.0
        Default Gateway . . . . . . . . . : 192.168.1.1

Ethernet adapter Local Area Connection:

        Media State . . . . . . . . . . . : Media disconnected
I entered that IP (192.168.1.100) into my browser, but I do not have a local copy of Apache on my laptop so I got an error, as that isn't the IP for my desktop...

What command would I use in Linux to get the IP? I have tried arp and it's various options, etc but all I get is the loopbak address 127.0.0.1 or whatever it is...

???

Thanks again, I think I'm almost there :)

Posted: Sat Sep 16, 2006 6:22 pm
by volka
try ifconfig

Posted: Sat Sep 16, 2006 6:36 pm
by alex.barylski
I did just that and got it working :P

Sweet :)

Although I'm noticing a pattern here...my laptop was assigned x.x.x.100 and my desktop which booted last was assigned x.x.x.101 so I can only assume those IP addresses will change as the computers are turned off and on again...

Is there a linux tool which I can use to send a message to all others on my internal network only(inside my router) that the IP address of said machine is: x.x.x.x??? That would certainly be handy as opposed to constantly having to ensure the desktop in the basement boots first before any others...

Even better...is there a Windows/Linux tool which will scan all IP addresses within a network (inside router) and ask for httpd daemon if it finds one, record the IP address and notify users???

I could actually write a little app that did that, if I can assume IP address will always be: 192.168.1.10x format...

I believe this is the case for IP's inside a router correct? So I could just ping:

Code: Select all

192.168.1.100
192.168.1.101
192.168.1.102
192.168.1.103
And so on until PING failed or I found a httpd in which case the IP is recorded and saved in IE's history or favourites...oh yea...that'[d be neato...then my dad wouldn't have to call me everytime he wanted to access the server...

Oh man this is sweet...

Thanks a ton