LinuxQuestions.org
Register a domain and help support LQ
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-21-2009, 10:04 AM   #1
FireRaven
Member
 
Registered: Apr 2006
Location: Australia
Distribution: Debian Squeeze
Posts: 135

Rep: Reputation: 18
Running command "hostname mysite.com" at startup?


Hi,

I want to run this command at the startup since my system keeps resetting the hostname to "ubuntu" upon startup.

I tried adding it to crontab under "@reboot hostname mysite.com" and it would not work, it would work if i set cron to "* * * * * hostname mysite.com" but that means I have wait 1 minute after machine boots plus, it keeps running every minute on a schedule which is not good practice.

Where abouts am I supposed to run this command?
 
Old 07-21-2009, 10:20 AM   #2
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976
To change the hostname permanently you have to edit the file /etc/hostname and write the new hostname then run
Code:
/etc/init.d/hostname.sh restart
then you can also edit /etc/hosts and /etc/resolv.conf to change the hostname and the domain name accordingly. If for some reason it doesn't work (in that case you have to investigate the reasons) you can try to add the command to /etc/init.d/rc.local.
 
Old 07-21-2009, 10:32 AM   #3
FireRaven
Member
 
Registered: Apr 2006
Location: Australia
Distribution: Debian Squeeze
Posts: 135

Original Poster
Rep: Reputation: 18
It looks like it works if I do "crontab -e" and enter:

@reboot /bin/hostname mysite.com && /bin/echo "nameserver 4.2.2.2" > /etc/resolv.conf

But how can I be sure these will happen in the last order or the scripts that get run at startup?
I don't want them to be overwritten by the default "nameserver ubuntu" or whatever that gets run.

Changing it using your command doesn't save when you reboot either it looks like.
 
Old 07-29-2009, 09:41 AM   #4
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,332
Blog Entries: 55

Rep: Reputation: 3533Reputation: 3533Reputation: 3533Reputation: 3533Reputation: 3533Reputation: 3533Reputation: 3533Reputation: 3533Reputation: 3533Reputation: 3533Reputation: 3533
Quote:
Originally Posted by FireRaven View Post
echo "nameserver 4.2.2.2" > /etc/resolv.conf
If the machine uses DHCP then you should probably fix that with prepend, append or supersede statements in your dhclient.conf.
 
Old 07-29-2009, 10:08 AM   #5
onebuck
Moderator
 
Registered: Jan 2005
Location: Midwest USA, Central Illinois
Distribution: SlackwareŽ
Posts: 12,603
Blog Entries: 25

Rep: Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981
Hi,

I would also be careful with using 'third' level DNS. Not always there. You can always your ISP DNS then append to your file '/etc/resolv.conf' by 'echo "nameserver 4.2.2.2" >> /etc/resolv.conf';

Code:
~# echo "nameserver 4.2.2.1" >> /etc/resolv.conf
~# cat /etc/resolv.conf
search workgroup
nameserver xxx.xxx.xxx.xxx
nameserver 4.2.2.1
~#
 
Old 07-29-2009, 10:25 AM   #6
FireRaven
Member
 
Registered: Apr 2006
Location: Australia
Distribution: Debian Squeeze
Posts: 135

Original Poster
Rep: Reputation: 18
Quote:
Originally Posted by onebuck View Post
Hi,
I would also be careful with using 'third' level DNS. Not always there. You can always your ISP DNS then append to your file '/etc/resolv.conf' by 'echo "nameserver 4.2.2.2" >> /etc/resolv.conf';
What do you mean by 'third' level DNS?
 
Old 07-29-2009, 10:47 AM   #7
onebuck
Moderator
 
Registered: Jan 2005
Location: Midwest USA, Central Illinois
Distribution: SlackwareŽ
Posts: 12,603
Blog Entries: 25

Rep: Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981
Hi,
Quote:
Originally Posted by FireRaven View Post
What do you mean by 'third' level DNS?
The '4.2.2.2' is one of Verizon's Third level DNS;

Quote:
excerpt from 'Enter DNS';

Depending on its location in the name hierarchy, a domain may be called top-level, second-level, or third-level. More levels of subdivision occur, but are rare.
 
Old 07-29-2009, 11:58 AM   #8
FireRaven
Member
 
Registered: Apr 2006
Location: Australia
Distribution: Debian Squeeze
Posts: 135

Original Poster
Rep: Reputation: 18
Quote:
Originally Posted by onebuck View Post
Hi,


The '4.2.2.2' is one of Verizon's Third level DNS;
How did you hear that?
I have been using that address for DNS for a long time. Does this mean it's not recommended to use it or it's unreliable?

I do understand what top level, second level, third level mean in domain names (like zone.third.second.com) but didn't know what it means for an IP address such as 4.2.2.2
 
Old 07-29-2009, 12:45 PM   #9
onebuck
Moderator
 
Registered: Jan 2005
Location: Midwest USA, Central Illinois
Distribution: SlackwareŽ
Posts: 12,603
Blog Entries: 25

Rep: Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981
Hi,

Read the links that I provided. You should be using your ISP 'DNS'.

There are several third level DNS available;

Quote:
Verizon has these;

4.2.2.1
4.2.2.2
4.2.2.3
4.2.2.4
4.2.2.5
4.2.2.6
You can look at 'Listed DNS Servers'.

The above link and others are available from 'Slackware-Links'. More than just SlackwareŽ links!
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Hardy won't startup, stops with a "fail" and I have to "ctrl+alt+del" to boot. brjoon1021 Ubuntu 10 12-15-2008 07:29 PM
[PHP] unable to execute "hostname" command G00fy Programming 4 07-25-2008 09:27 AM
Standard commands give "-bash: open: command not found" even in "su -" and "su root" mibo12 Linux - General 4 11-11-2007 11:18 PM
Bash Script: Problem running variable command containing "" Paasan Programming 2 01-21-2004 02:45 AM


All times are GMT -5. The time now is 04:42 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration