Linux - NewbieThis 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!
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Introduction to Linux - A Hands on Guide
This guide was created as an overview of the Linux Operating System, geared toward new users as an exploration tour and getting started guide, with exercises at the end of each chapter.
For more advanced trainees it can be a desktop reference, and a collection of the base knowledge needed to proceed with system and network administration. This book contains many real life examples derived from the author's experience as a Linux system and network administrator, trainer and consultant. They hope these examples will help you to get a better understanding of the Linux system and that you feel encouraged to try out things on your own.
Click Here to receive this Complete Guide absolutely free.
I actually use two scripts that I coded up, one for use at work, and one for at home. Of course these are greatly simplified, but you get the idea.
# cat home
ifconfig eth0 down
ifconfig wan0 down
ifconfig eth0 up
ifconfig eth0 192.168.2.14 255.255.255.0
route add default gw 192.168.2.1
echo "192.168.2.1" > /etc/resolv.conf
# cat work
ifconfig eth0 down
ifconfig wan0 down
iwconfig wan0 ESSID="Work AP" AP="blah" key="Secret"
ifconfig wan0 up
ifconfig wan0 18.104.22.168 255.255.248.0
route add default gw 22.214.171.124
echo "126.96.36.199 > /etc/resolv.conf
As to how to get your router and computer talking, if they're on different subnets (172.16 and 192.168) you're likely to have problems. The easiest method may be to run your dhcp client daemon (`dhcpcd` on Slackware) and pick up an address and DNS settings directly from the router in question.
I tend to use the GUI as little as possible -- perhaps that's due to my Slackware background, which is why I have actually never used the network manager.
You may put these scripts really anywhere you'd like -- I myself just keep them in root's home directory (/root), for easy access when I `su` to root. Before using the above scripts for your own setup, make sure to read the ifconfig man page, and if applicable (for wireless), iwconfig.
To write those scripts, I just opened up vi (a text-editing program) from the command line and entered the above, saving the first as 'home' and the second as 'work'. You have to make sure they are executable, by using the `chmod` program. Again, read its man page for additional help. Unlike in Windows, there is no specific extention that makes a script or program executable; it's all handled through the file's permissions, which again are edited by `chmod`.
To execute those commands, I just run `su -c "/root/home"` or `su -c "/root/work"` as necessary. Others may have their own favored methodologies for doing this, but mine works for me and is fairly straightforward. The important part is that these files have to be run as root, because normally ifconfig, iwconfig, route, and resolv.conf aren't able to be accessed by normal, unprivileged users.
Also, if you update your profile information to include your distribution, it can help people here at LQ tailor their responses to your specific distro.
I don't know what distribution you're using, but Mandriva has something called "Network profiles", configured in GUI from the Mandriva Control Center.
You should probably investigate and see if your distribution provides something equivalent.
That you can -- something with using su -c however is that you need to tell it exactly where the file is, since it's likely not in your PATH. If your 'workh' is in /root, try `su -c "/root/workh"` instead.
I second the recommendation for DHCP. If you want a static IP at home, then you can configure your DHCP server (probably your router) to always serve up the same IP address for your laptop's MAC address.