Go to the people. Learn from them. Live with them. Start with what they know. Build with what they have. The best of leaders when the job is done, when the task is accomplished, the people will say we have done it ourselves.
I light my candle from their torches.
If you can imagine it, you can achieve it; if you can dream it, you can become it.
Happy are those who dream dreams and are ready to pay the price to make them come true.
Take calculated risks. That is quite different from being rash.
Our greatest glory is not in never falling but in rising every time we fall.
Knowing is not enough; we must apply.
Willing is not enough; we must do.
Saturday, November 22, 2008
INSPIRATION POEM
When things go wrong, as they sometimes will,
When the road you're trudging seems all uphill,
When the funds are low and the debts are high,
And you want to smile, but you have to sigh,
When care is pressing you down a bit,
Rest, if you must, but don't you quit.
Life is queer with its twists and turns,
As every one of us sometimes learns,
And many a failure turns about,
When he might have won had he stuck it out;
Don't give up though the pace seems slow--
You may succeed with another blow.
Often the goal is nearer than,
It seems to a faint and faltering man,
Often the struggler has given up,
When he might have captured the victor's cup,
And he learned too late when the night slipped down,
How close he was to the golden crown.
Success is failure turned inside out--
The silver tint of the clouds of doubt,
And you never can tell how close you are,
It may be near when it seems so far,
So stick to the fight when you're hardest hit--
It's when things seem worst that you must not quit.
When the road you're trudging seems all uphill,
When the funds are low and the debts are high,
And you want to smile, but you have to sigh,
When care is pressing you down a bit,
Rest, if you must, but don't you quit.
Life is queer with its twists and turns,
As every one of us sometimes learns,
And many a failure turns about,
When he might have won had he stuck it out;
Don't give up though the pace seems slow--
You may succeed with another blow.
Often the goal is nearer than,
It seems to a faint and faltering man,
Often the struggler has given up,
When he might have captured the victor's cup,
And he learned too late when the night slipped down,
How close he was to the golden crown.
Success is failure turned inside out--
The silver tint of the clouds of doubt,
And you never can tell how close you are,
It may be near when it seems so far,
So stick to the fight when you're hardest hit--
It's when things seem worst that you must not quit.
Saturday, November 15, 2008
Basic Networking: Windows to Linux Fedora
Basic Networking: Windows to Linux Fedora
by Mark Rais, Senior Editor ReallyLinux.com and author of "Linux for the Rest of Us" 2nd Edition.
This article is for all of those readers asking for a very basic overview of networking Windows and Linux PCs. You will also benefit from my articles: Setting Up a Full Powered SAMBA Server and From Windows to Linux.
Can a Windows system and a Linux system talk together harmoniously? After all, there is a lot of work and personal data left on Windows PCs that many want to keep! So this question of networking the two systems is both reasonable and vital.
My response to the many beginners who inquire is that yes, indeed it can and should be done where ever necessary. Not only can it be done, but for years now a very concerted effort by many outstanding software developers has resulted in the creation of a file sharing protocol and tools known as SAMBA. This exotic sounding name is simply a name derived from the original UNIX SMB file sharing protocol.
But Samba is no longer simply a protocol. When used in the context of today's Linux flavors, you'll find that it includes a server (used to connect to other Windows or Linux PCs), a client, and even functions for workgroup and printer sharing. Most importantly, other PCs can connect to the Server via the Client and easily share files by simply dragging and dropping the files using a graphical interface.
Therefore, basic Windows file sharing can be done with relative ease if your Linux flavor includes the Samba tools. Of course, it also requires a little work on the Windows PC since any good communication comes from two sides!
The goal then, regardless which Linux flavor you're using, is to:
1. Ensure that Samba tools are included and available
2. Configure the PC network cards and settings
3. Configure the Windows PC to allow workgroup sharing
4. Configure Samba tools to recognize the Windows PC
I include details for each of these steps in the article. Implementing the steps above is somewhat unique across every major flavor I've used. Some flavors will require you to select Samba tools at the very beginning of the installation process. Other flavors include the full Samba suite of tools as part of the package, ready to go. It depends so much on your flavor that I can't provide specific guidance without writing another fifty pages on the subject. I plan to release an indepth SAMBA article here in the future.
However, what I can share with you now are steps needed to implement Samba using Fedora as a tutorial or guide. These steps are for making a basic WindowsXP Home Edition available to Linux.
My assumption is that before you begin, you've already familiarized yourself with the Post-Installation Configuration article, and that you have the two PCs connected properly with a network hub and cables.
1. Ensure that Samba tools are included and available
For most of us, the tools are preloaded and installed with the newest flavor of Linux Fedora Core 2 and greater. However, there may be a time when they did not get loaded. To check if Samba tools are loaded, in a terminal window, type the following command:
locate samba
You may also check to see that there is an existing Samba configuration file located under the /etc directory. Do so by using this command in a terminal window:
ls –alt /etc/samba/smb.conf
This will show the all important Samba configuration file, which you may need to review and edit in the future using a text editor.
Assuming that you have successfully found positive signs of Samba's existence, you can move on to the next step.
However, if nothing shows up when you ran the locate command, you will need to download and install Samba tools from the internet. One suggestion is to check your flavor's site for the latest Samba tools, or go to: www.samba.org
For the latest downloads review the list here and make sure to read the HOW-TO instructions first!
2. Configure the PC network cards and settings
Your next course of action is to identify whether your WindowsXP system is ready to talk to the Linux PC. Is the network connection active and are they on the same domain?
Checking this on your Linux PC is a very simply process. If you're not using Fedora, please read the Post-Installation Configuration chapter for the help in finding your network configuration tools.
With Fedora as the example, from the main menu, choose System Settings, then Network. Or simply type this command into a terminal:
system-config-network
Your Network Configuration tool will start. In the tool, you should see a fully operational eth0 network card device.
Now, click the Edit button to review the configuration for the eth0 network card to ensure that it is set up properly. What I include are samples from my own network. You may choose different network settings or try using exactly the same ones I provide below. The key is to remember that your Linux should not have different subnet mask information than your WindowsXP, or they won't communicate.
NOTICE: if you're in a business setting it is entirely likely that your DNS server HAS ALREADY ASSIGNED CORRECT IP information. The use of Static IPs is only provided to give an example. Leave the settings as "Auto obtain IP information" and be sure to select the "Automatically obtain DNS" checkbox in a dynamic setting.
Press OK when you've confirmed that you are using a Static IP address, and that the static IP and subnet mask work with what you plan to use on the WindowsXP (you'll soon see the way I configure my Windows PC).
Keep in mind that office PCs may be on their own IP naming scheme and have different mask and gateway information than shown!
Now select the eth0 device and click the Activate button. You will be prompted to save the changes. A small window will appear and should then disappear. As soon as it does, I recommend you reboot your Linux PC. This will ensure the changes take affect.
On the WindowsXP system, under the Start menu, choose Control Panel, then Network Connections. You should see a Local Area Network icon.
If you don't have any LAN connection icon under Network Connections, then you will need to run the new connection Wizard.
In the Windows wizard, choose Setup a home or small office network option. These wizard steps should properly configure your WindowsXP to use the network card.
Once you've finished you should see the Local Area Network icon.
Click your RIGHT mouse button over this icon and choose Properties. From here you need to select the Internet Protocol (TCP/IP) item. Once it's highlighted, you should press the Properties button.
Again, my simple screen shot should provide you with some general guidelines how to configure the individual items.
You must first select the Use the following IP address button. It is not always necessary to create a DNS server IP. As I was testing, I could get my PCs to talk with this setup.
Notice that the Linux PC was set to IP 10.2.2.2 and the Windows is set to 10.2.2.1 as a very rudimentary network configuration.
Now click OK to exit and save the IP configuration.
Once you're back on the Local Area Connection Properties window, choose the third tab labeled: Advanced. Under this tab you will see the firewall setting.
If your firewall setting is enabled, and you complete the steps, but your Linux PC still does not connect, you may need to disable it. I share this with you now since you will likely need to know where the firewall setting option is located in the future.
3. Configure the Windows PC to allow workgroup sharing
It's time to open up Windows Explorer (usually under the Start menu, then Accessories). In Windows Explorer you should highlight the disk drive of the WindowsXP system.
Once highlighted, click the right mouse button and choose from the menu: Properties.
You should see four tabs on the top of the new window. Click on the Sharing tab. This opens up your WindowsXP sharing attributes for the specific disk drive you've chosen. You should choose the two options:
* Share this drive on the network
* Allow network users to change my files (if this is desired)
Click the OK button to exit the drive properties window. Finally, your WindowsXP drive should now be available to the Linux PC.
4. Configure Samba tools to recognize the Windows PC
It's time to return to the Linux PC and make the connection. Thankfully, the Linux effort is a bit less intensive. From the Fedora main menu choose Network Servers.
If all is well, you should see a Windows Network icon appear. From the Network window, choose File, then Open Location (or press Ctrl and L). This will allow you to type a specific WindowsXP shared drive location. All Samba accessible shared drives begin with smb://
In my situation, I named my shared disk drive winxp
Pressing Open should reveal a new window with a Windows drive icon. By double clicking on the shared drive icon, I am now able to view the folders on my WindowsXP drive from Linux!
If all worked well you should now be able to transfer files to and from the Linux PC with a few simple mouse clicks.
To copy files from the WindowsXP PC to your Linux PC, try these steps. Note that I am simply conveying one method among many.
From the Fedora main menu, choose your Home icon on the desktop. This opens up a view of your Linux directory and files. Open the WindowsXP drive by choosing File, on the menu, then Open Location. As mentioned above, you need to type the proper Samba path. Now simply place the winxp shared disk window beside the Linux file system window, and copy files by drag-and-dropping the icons.
Troubleshooting Tips
If you're using Fedora Core 2+ and the steps above fail, you may try checking one of these common issues:
First, make sure that the permissions on the folder/directory you are sharing is set properly. You can change permissions using tips from this article.
Second, check to see that the smb daemon is running. You can do so with this simple command:
/sbin/chkconfig --list
You need to look for smb and then see 5:ON, which means that at run level 5 (normal boot up) your system automatically starts the smb daemon. If you've done all of the steps above and still nothing works, sometimes you need to restart/start the smb daemon manually. Try doing so with these two commands:
cd /etc/rc.d/init.d/
./smb start
Third, there is a great online book regarding Samba that I can recommend to folks who are more technically interested. Here is the book link. I recommend buying this book, among many from O'Reilly, that helps get going with SAMBA.
Troubleshooting for Non Fedora Users
Wait! Perhaps you're sitting there reading this detailed Samba configuration chapter while desperately trying to get SuSe, Mandriva, Debian, or some other Linux flavor using KDE to work properly with a Windows network. What solution do I give to the multitude of distinct flavor users?
I hate to leave hanging someone who is excited and interested. I wish I could lend everyone a hand in specifically describing their flavor's method of getting on to the Windows disk. However, I can't include that many examples and pages in this book (the editors are plucking and choosing pages to shorten the book even as I write!).
But for those desperate to get their own flavor working with the Samba, I offer a few tips below.
First: You must have all of the Samba components and programs installed. In many cases your flavor simply refuses to acknowledge the Windows network because it does not include critical files like sambawinbind. Your flavor's web site will have more details on this and other essential files.
Second: You must properly define the Samba location. Therefore, if you followed my previous examples, you may need to replace winxp with whatever you have decided to name your Windows shared drive.
Third: Be sure you have actually selected a Samba group name that is identical to your Windows network group name.
Fourth: Try opening a Konqueror window and insert into the Location field something similar to the following (replace winxp with group name of your windows pc): smb://winxp/ http://www.reallylinux.com/docs/basicnetworking.shtml
http://www.reallylinux.com/docs/basicnetworking.shtml
by Mark Rais, Senior Editor ReallyLinux.com and author of "Linux for the Rest of Us" 2nd Edition.
This article is for all of those readers asking for a very basic overview of networking Windows and Linux PCs. You will also benefit from my articles: Setting Up a Full Powered SAMBA Server and From Windows to Linux.
Can a Windows system and a Linux system talk together harmoniously? After all, there is a lot of work and personal data left on Windows PCs that many want to keep! So this question of networking the two systems is both reasonable and vital.
My response to the many beginners who inquire is that yes, indeed it can and should be done where ever necessary. Not only can it be done, but for years now a very concerted effort by many outstanding software developers has resulted in the creation of a file sharing protocol and tools known as SAMBA. This exotic sounding name is simply a name derived from the original UNIX SMB file sharing protocol.
But Samba is no longer simply a protocol. When used in the context of today's Linux flavors, you'll find that it includes a server (used to connect to other Windows or Linux PCs), a client, and even functions for workgroup and printer sharing. Most importantly, other PCs can connect to the Server via the Client and easily share files by simply dragging and dropping the files using a graphical interface.
Therefore, basic Windows file sharing can be done with relative ease if your Linux flavor includes the Samba tools. Of course, it also requires a little work on the Windows PC since any good communication comes from two sides!
The goal then, regardless which Linux flavor you're using, is to:
1. Ensure that Samba tools are included and available
2. Configure the PC network cards and settings
3. Configure the Windows PC to allow workgroup sharing
4. Configure Samba tools to recognize the Windows PC
I include details for each of these steps in the article. Implementing the steps above is somewhat unique across every major flavor I've used. Some flavors will require you to select Samba tools at the very beginning of the installation process. Other flavors include the full Samba suite of tools as part of the package, ready to go. It depends so much on your flavor that I can't provide specific guidance without writing another fifty pages on the subject. I plan to release an indepth SAMBA article here in the future.
However, what I can share with you now are steps needed to implement Samba using Fedora as a tutorial or guide. These steps are for making a basic WindowsXP Home Edition available to Linux.
My assumption is that before you begin, you've already familiarized yourself with the Post-Installation Configuration article, and that you have the two PCs connected properly with a network hub and cables.
1. Ensure that Samba tools are included and available
For most of us, the tools are preloaded and installed with the newest flavor of Linux Fedora Core 2 and greater. However, there may be a time when they did not get loaded. To check if Samba tools are loaded, in a terminal window, type the following command:
locate samba
You may also check to see that there is an existing Samba configuration file located under the /etc directory. Do so by using this command in a terminal window:
ls –alt /etc/samba/smb.conf
This will show the all important Samba configuration file, which you may need to review and edit in the future using a text editor.
Assuming that you have successfully found positive signs of Samba's existence, you can move on to the next step.
However, if nothing shows up when you ran the locate command, you will need to download and install Samba tools from the internet. One suggestion is to check your flavor's site for the latest Samba tools, or go to: www.samba.org
For the latest downloads review the list here and make sure to read the HOW-TO instructions first!
2. Configure the PC network cards and settings
Your next course of action is to identify whether your WindowsXP system is ready to talk to the Linux PC. Is the network connection active and are they on the same domain?
Checking this on your Linux PC is a very simply process. If you're not using Fedora, please read the Post-Installation Configuration chapter for the help in finding your network configuration tools.
With Fedora as the example, from the main menu, choose System Settings, then Network. Or simply type this command into a terminal:
system-config-network
Your Network Configuration tool will start. In the tool, you should see a fully operational eth0 network card device.
Now, click the Edit button to review the configuration for the eth0 network card to ensure that it is set up properly. What I include are samples from my own network. You may choose different network settings or try using exactly the same ones I provide below. The key is to remember that your Linux should not have different subnet mask information than your WindowsXP, or they won't communicate.
NOTICE: if you're in a business setting it is entirely likely that your DNS server HAS ALREADY ASSIGNED CORRECT IP information. The use of Static IPs is only provided to give an example. Leave the settings as "Auto obtain IP information" and be sure to select the "Automatically obtain DNS" checkbox in a dynamic setting.
Press OK when you've confirmed that you are using a Static IP address, and that the static IP and subnet mask work with what you plan to use on the WindowsXP (you'll soon see the way I configure my Windows PC).
Keep in mind that office PCs may be on their own IP naming scheme and have different mask and gateway information than shown!
Now select the eth0 device and click the Activate button. You will be prompted to save the changes. A small window will appear and should then disappear. As soon as it does, I recommend you reboot your Linux PC. This will ensure the changes take affect.
On the WindowsXP system, under the Start menu, choose Control Panel, then Network Connections. You should see a Local Area Network icon.
If you don't have any LAN connection icon under Network Connections, then you will need to run the new connection Wizard.
In the Windows wizard, choose Setup a home or small office network option. These wizard steps should properly configure your WindowsXP to use the network card.
Once you've finished you should see the Local Area Network icon.
Click your RIGHT mouse button over this icon and choose Properties. From here you need to select the Internet Protocol (TCP/IP) item. Once it's highlighted, you should press the Properties button.
Again, my simple screen shot should provide you with some general guidelines how to configure the individual items.
You must first select the Use the following IP address button. It is not always necessary to create a DNS server IP. As I was testing, I could get my PCs to talk with this setup.
Notice that the Linux PC was set to IP 10.2.2.2 and the Windows is set to 10.2.2.1 as a very rudimentary network configuration.
Now click OK to exit and save the IP configuration.
Once you're back on the Local Area Connection Properties window, choose the third tab labeled: Advanced. Under this tab you will see the firewall setting.
If your firewall setting is enabled, and you complete the steps, but your Linux PC still does not connect, you may need to disable it. I share this with you now since you will likely need to know where the firewall setting option is located in the future.
3. Configure the Windows PC to allow workgroup sharing
It's time to open up Windows Explorer (usually under the Start menu, then Accessories). In Windows Explorer you should highlight the disk drive of the WindowsXP system.
Once highlighted, click the right mouse button and choose from the menu: Properties.
You should see four tabs on the top of the new window. Click on the Sharing tab. This opens up your WindowsXP sharing attributes for the specific disk drive you've chosen. You should choose the two options:
* Share this drive on the network
* Allow network users to change my files (if this is desired)
Click the OK button to exit the drive properties window. Finally, your WindowsXP drive should now be available to the Linux PC.
4. Configure Samba tools to recognize the Windows PC
It's time to return to the Linux PC and make the connection. Thankfully, the Linux effort is a bit less intensive. From the Fedora main menu choose Network Servers.
If all is well, you should see a Windows Network icon appear. From the Network window, choose File, then Open Location (or press Ctrl and L). This will allow you to type a specific WindowsXP shared drive location. All Samba accessible shared drives begin with smb://
In my situation, I named my shared disk drive winxp
Pressing Open should reveal a new window with a Windows drive icon. By double clicking on the shared drive icon, I am now able to view the folders on my WindowsXP drive from Linux!
If all worked well you should now be able to transfer files to and from the Linux PC with a few simple mouse clicks.
To copy files from the WindowsXP PC to your Linux PC, try these steps. Note that I am simply conveying one method among many.
From the Fedora main menu, choose your Home icon on the desktop. This opens up a view of your Linux directory and files. Open the WindowsXP drive by choosing File, on the menu, then Open Location. As mentioned above, you need to type the proper Samba path. Now simply place the winxp shared disk window beside the Linux file system window, and copy files by drag-and-dropping the icons.
Troubleshooting Tips
If you're using Fedora Core 2+ and the steps above fail, you may try checking one of these common issues:
First, make sure that the permissions on the folder/directory you are sharing is set properly. You can change permissions using tips from this article.
Second, check to see that the smb daemon is running. You can do so with this simple command:
/sbin/chkconfig --list
You need to look for smb and then see 5:ON, which means that at run level 5 (normal boot up) your system automatically starts the smb daemon. If you've done all of the steps above and still nothing works, sometimes you need to restart/start the smb daemon manually. Try doing so with these two commands:
cd /etc/rc.d/init.d/
./smb start
Third, there is a great online book regarding Samba that I can recommend to folks who are more technically interested. Here is the book link. I recommend buying this book, among many from O'Reilly, that helps get going with SAMBA.
Troubleshooting for Non Fedora Users
Wait! Perhaps you're sitting there reading this detailed Samba configuration chapter while desperately trying to get SuSe, Mandriva, Debian, or some other Linux flavor using KDE to work properly with a Windows network. What solution do I give to the multitude of distinct flavor users?
I hate to leave hanging someone who is excited and interested. I wish I could lend everyone a hand in specifically describing their flavor's method of getting on to the Windows disk. However, I can't include that many examples and pages in this book (the editors are plucking and choosing pages to shorten the book even as I write!).
But for those desperate to get their own flavor working with the Samba, I offer a few tips below.
First: You must have all of the Samba components and programs installed. In many cases your flavor simply refuses to acknowledge the Windows network because it does not include critical files like sambawinbind. Your flavor's web site will have more details on this and other essential files.
Second: You must properly define the Samba location. Therefore, if you followed my previous examples, you may need to replace winxp with whatever you have decided to name your Windows shared drive.
Third: Be sure you have actually selected a Samba group name that is identical to your Windows network group name.
Fourth: Try opening a Konqueror window and insert into the Location field something similar to the following (replace winxp with group name of your windows pc): smb://winxp/ http://www.reallylinux.com/docs/basicnetworking.shtml
http://www.reallylinux.com/docs/basicnetworking.shtml
Basic Guide to Linux DSL Use
Basic Guide to Linux DSL Use
By Mark Rais, author of Linux For the Rest of Us, and senior editor of reallylinux.com
This brief chapter should help beginning Linux users get a DSL connection up and running. Keep in mind that I use a lot of graphics to help guide beginning users. For a Linux book that's good, but for someone with a dial-up internet connection it may be rather slow!
I use Fedora (using Gnome desktop) and SuSe (using KDE desktop) as specific real-world examples. Beginning users of Fedora/Gnome, please keep reading. For users of SuSe/KDE click here to get details.
You'll also notice that I refer to DSL and Cable modems several times in the chapter. Configuring DSL and Cable modems is very similar.
The following tips will hopefully help give a well rounded view into the necessary settings and configuration that apply to most newer flavors. Older flavors usually require you to install the PPPoE driver before configuration is possible. These drivers should be on your Linux flavor’s website.
You'll find that connectivity to your broadband service using almost all flavors of Linux is dependent on two things:
* What type of service you have purchased
* Correctly setting the IP and DNS configurations
The term “service provider” is different than “internet email” provider. In most cases your telephone or cable company run the service and other companies provide Windows software to run things like email, news, etc. For Linux, only your service provider is important.
This excerpt doesn’t include info about using static IP addresses, which usually comes with a premium broadband service.
Fedora/Gnome DSL Configuration (for SuSe/KDE info click here)
To start the broadband modem configuration and setup your DSL modem in Fedora Core 2, go to your Fedora main menu, choose System Settings, then Network.
This will start the Network Configuration tool.
Here you will ensure that:
1. Your ethernet device is properly configured to allow automatically receiving an IP address;
2. Your service provider’s information including your account id and password is setup — if needed.
On the Network Configuration screen, select your ethernet device (eth0) and press the Edit button.
You should now see the Ethernet Device screen.
Make sure that you have cleared out all information under the Statically set IP addresses field, and then selected the radio (round) button labeled Automatically obtain IP address settings with dhcp and the check box to also automatically obtain DNS.
Now click OK to return to the Network Configuration window.
Now its time to activate your ethernet device. Select the device from the list and then click the Activate button.
By doing so, you will enable the device to retrieve the DSL or Cable service provider IP address for your connection automatically.
You should then see an information window appear similar to this:
Once the system-config-network window disappears, you should be connected to the internet and enjoy surfing websites.
However, I always recommend at this point to reboot your Linux PC. This will ensure that all configuration changes are enabled. Once your Linux system is back up and you are able to use your desktop, you’re ready to enjoy broadband internet connectivity.
Open your Mozilla web browser and enjoy!!!
What if you don’t have an ethernet device listed?
This could be a serious problem with your ethernet card installation. Or, much more likely, it may simply mean that you need to manually install either an ethernet device or a DSL connection device.
Sometimes Fedora does not automatically recognize your ethernet card for internet use. In the rare event that your ethernet card was not available from the list, even after you have doubled checked that it is properly installed, try the following steps to get your Cable modem or DSL modem connection working.
There are two options to follow, and for this web excerpt I've included the more typical option.
Add a new broadband modem device to the list by following these steps:
From the Network Configuration window, press the New button. Usually, either your Cable or DSL modem configuration can be activated by simply creating an ethernet device configuration.
Choose Ethernet connection as the device type to create. Click Forward to continue.
Do not select the xDSL or other options.
You will be given the chance to double check which physically present ethernet card you want to configure. Make sure the correct item is highlighted and press Forward again.
On the Configure Network Settings window be sure that the Automatically obtain IP address… button is selected. Also select the check box option to Automatically obtain DNS… as shown below.
You can now click Forward, check the summary of changes, and click the Apply button. You should see the Network Configuration window.
From here, select the new ethernet device and press the Activate button. A small window will appear and then disappear. Once the window is gone, you should be connected to your internet service provider and may begin using a web browser.
Enjoy!
http://www.reallylinux.com/docs/dslandlinux.shtml
By Mark Rais, author of Linux For the Rest of Us, and senior editor of reallylinux.com
This brief chapter should help beginning Linux users get a DSL connection up and running. Keep in mind that I use a lot of graphics to help guide beginning users. For a Linux book that's good, but for someone with a dial-up internet connection it may be rather slow!
I use Fedora (using Gnome desktop) and SuSe (using KDE desktop) as specific real-world examples. Beginning users of Fedora/Gnome, please keep reading. For users of SuSe/KDE click here to get details.
You'll also notice that I refer to DSL and Cable modems several times in the chapter. Configuring DSL and Cable modems is very similar.
The following tips will hopefully help give a well rounded view into the necessary settings and configuration that apply to most newer flavors. Older flavors usually require you to install the PPPoE driver before configuration is possible. These drivers should be on your Linux flavor’s website.
You'll find that connectivity to your broadband service using almost all flavors of Linux is dependent on two things:
* What type of service you have purchased
* Correctly setting the IP and DNS configurations
The term “service provider” is different than “internet email” provider. In most cases your telephone or cable company run the service and other companies provide Windows software to run things like email, news, etc. For Linux, only your service provider is important.
This excerpt doesn’t include info about using static IP addresses, which usually comes with a premium broadband service.
Fedora/Gnome DSL Configuration (for SuSe/KDE info click here)
To start the broadband modem configuration and setup your DSL modem in Fedora Core 2, go to your Fedora main menu, choose System Settings, then Network.
This will start the Network Configuration tool.
Here you will ensure that:
1. Your ethernet device is properly configured to allow automatically receiving an IP address;
2. Your service provider’s information including your account id and password is setup — if needed.
On the Network Configuration screen, select your ethernet device (eth0) and press the Edit button.
You should now see the Ethernet Device screen.
Make sure that you have cleared out all information under the Statically set IP addresses field, and then selected the radio (round) button labeled Automatically obtain IP address settings with dhcp and the check box to also automatically obtain DNS.
Now click OK to return to the Network Configuration window.
Now its time to activate your ethernet device. Select the device from the list and then click the Activate button.
By doing so, you will enable the device to retrieve the DSL or Cable service provider IP address for your connection automatically.
You should then see an information window appear similar to this:
Once the system-config-network window disappears, you should be connected to the internet and enjoy surfing websites.
However, I always recommend at this point to reboot your Linux PC. This will ensure that all configuration changes are enabled. Once your Linux system is back up and you are able to use your desktop, you’re ready to enjoy broadband internet connectivity.
Open your Mozilla web browser and enjoy!!!
What if you don’t have an ethernet device listed?
This could be a serious problem with your ethernet card installation. Or, much more likely, it may simply mean that you need to manually install either an ethernet device or a DSL connection device.
Sometimes Fedora does not automatically recognize your ethernet card for internet use. In the rare event that your ethernet card was not available from the list, even after you have doubled checked that it is properly installed, try the following steps to get your Cable modem or DSL modem connection working.
There are two options to follow, and for this web excerpt I've included the more typical option.
Add a new broadband modem device to the list by following these steps:
From the Network Configuration window, press the New button. Usually, either your Cable or DSL modem configuration can be activated by simply creating an ethernet device configuration.
Choose Ethernet connection as the device type to create. Click Forward to continue.
Do not select the xDSL or other options.
You will be given the chance to double check which physically present ethernet card you want to configure. Make sure the correct item is highlighted and press Forward again.
On the Configure Network Settings window be sure that the Automatically obtain IP address… button is selected. Also select the check box option to Automatically obtain DNS… as shown below.
You can now click Forward, check the summary of changes, and click the Apply button. You should see the Network Configuration window.
From here, select the new ethernet device and press the Activate button. A small window will appear and then disappear. Once the window is gone, you should be connected to your internet service provider and may begin using a web browser.
Enjoy!
http://www.reallylinux.com/docs/dslandlinux.shtml
Basic Guide to Dial-up Internet with Linux
Basic Guide to Dial-up Internet with Linux
by Mark Rais, senior editor reallylinux.com and author of Linux for the Rest of Us 2nd Edition.
Our other related articles:
Basic Guide to DSL/Cable Use
Commands for Beginning Server Administrators
Full list of our exclusive Linux articles
This beginner article summarizes Mark Rais' experiences using a dial-up internet connection with SuSe and Fedora. It's intended as a review for the many people who are still using dial-up all around the world and need basic help getting started. In his desire to help everyone switch to Linux Mr. Rais did not want to leave out the dial-up crowd!
Before you start, please note that some modem manufacturers rely on Windows to operate their modem hardware (aka WinModems), and therefore your internal modem may not work. If you experience trouble then hopefully this page and this web site may help resolve the issue for you. Those with non-Winmodems and external Hayes compatible modems don't need to worry about this at all.
Step 1 Start by Connecting and Rebooting
Once you have properly connected your modem and made sure it is on, reboot your Linux system. In all likelihood, your modem will be detected by the Linux hardware detection tool and automatically installed.
Step 2 Get Details from Your ISP
After successfully loading your desktop, you will need to configure your modem, which will require some information from your ISP.
Most ISPs will accommodate you and provide clear answers to your questions, since you are paying them! However, some ISPs require you to use proprietary software to dial in and log on to their service. This may inhibit using the generic Linux tools and require you to use some form of emulator to run your ISP’s software under Linux. If you are stuck with such an ISP, you may want to consider an alternative FREE ISP who fully supports Linux. I’ll provide some tips later on the subject.
In most cases you will simply need to know the local dial-up number to call your ISP.
You should take the time now to contact them if you need to get this information. Here’s what you may want to communicate:
* Mention that you are planning to dial-up to your account through your Linux PC
* Ask for one or two local dial-up numbers
* And get their Domain Name Server IP addresses
TIP: If your ISP tech person mentions that the ISP “does not support Linux,” acknowledge you understand this and repeat your questions, since you’re not asking them to help provide tech support for Linux, you’re asking them how they allow access to their network for your use.
You will find out shortly something I’ve noticed from my experiences — some ISPs are far nicer about helping you do this than others!
Step 3 Configure the Modem and ISP Info
Once you have your ISP information, you can quickly configure the modem and enter details for accessing the ISP account. You will also need your account id and password, so have them handy as you begin.
As with other configuration examples, I will use actual steps from two of the major flavors (Fedora and SuSe). I’ve successfully used this information while installing other popular flavors too, so they will apply to most of the newer flavors. The tools are often determined by the Desktop you use and so Fedora (uses Gnome) and SuSe (uses KDE) help give a rather well rounded view of how to setup your modem across most flavors.
Step 4: Fedora Dial-Up (for SuSe Dial-up click here or scroll down)
In Fedora you will find a handy menu item under System Tools labeled Internet Connection Wizard.
It’s actually the Internet Druid configuration tool and will simplify the process of identifying the modem and ISP details. Go ahead and start the tool by clicking on it.
You can also get to this tool later by typing in a terminal prompt: internet-druid
Please notice that once in the tool you actually have the option of adding a number of new devices. For now just click once on the Modem connection and press the Forward button.
You will see the Select Modem screen. From here you should choose from the pull down top menu item the proper device for your modem. It may vary, but from my experience, in a majority of cases an external modem connected to the Serial port on the back of the PC will be /ttyS0.
I also recommend that you change the volume to ensure you can hear what the modem is doing. Set it to Medium and press Forward.
Now you will see the screen that offers the chance to input details regarding your ISP and account.
You will see a listing of preloaded ISPs on the left menu. If you reside in one of the countries where an ISP is listed, then you can choose the details from the menu, under the appropriate national flag. If you reside in other countries like the U.S. or Canada you will need to input the details.
Be sure that what you put into the Phone Number items are applicable to your calling location. In most cases, you do not need to enter anything into either Prefix or Area Code. The Provider name field, as in a number of other configurations like Debian and Mandrake, is not essential and is there for your own reference.
Make sure you type in the correct login and password! When you’ve finished filling out the details, press the Forward button again.
The next screen refers to your DNS settings. In most cases you should make sure that it is set to automatically receive your IP address.
Also, be sure to select automatically obtaining the DNS information!
You will now see the Network Configuration tool appear. In the future, you can access this tool again by either going to the main menu and selecting System Settings, then choosing the Network icon, or you can type into a terminal window the following:
system_config_network
Below is my screenshot of the Network Configuration tool:
By highlighting your Modem and then clicking on the Edit icon, you will be able to make changes to the configuration details. Most of the Modem configuration should already be completed and correct.
Click on each of the tabs (Router, Provider, etc.) and check. If everything looks like it matches your input then go to the Advanced tab and select the option to Let PPP do all authentication.
This allows the PPP (point to point protocol) to handle passing your login and account data to your ISP, which is the default for most situations. Press OK and return to the Network Configuration main window.
You can close your configuration window, which will give you the option to Save your changes. Click OK to save the changes you made.
Now, please reboot your Linux system. Rebooting has often resolved issues with hardware configuration and so I strongly recommend it after any new modem or network setup.
Once your Linux system is back up and running, you should be able to dialup your ISP and get online! Go to the main menu, choose System Set- tings, then Network to return to the Network Configuration tool.
Highlight your modem device, and then click on the Activate button.
You should see a small window appear with the words:
Activating network device… please wait.
When this window disappears you are ready to surf the internet. Open your Linux web browser and enjoy!
To end the dial-up session, return to Network Configuration tool, highlight the modem, and click the Deactivate button. That's it, hopefully now you can enjoy Linux with Dial-up!
NOTE: Troubleshooting and helpful TIPS are included at the end of this article.
Step 4: SuSe Dial-Up
If you use SuSe or some other flavor running the latest KDE desktop these tips will help you get online with a dial-up modem.
Remember that even though the screens may not exactly match your own (all flavors differ somewhat), the tips and information I provide, such as automatically setting DNS, will apply to all flavors.
Begin by starting up the YaST tool, or your flavor’s hardware configuration tool. If you’re not sure what I am referring to, please review the article Post-Installation Configuration for guidance.
To start SuSe’s YaST tool from your main menu choose System and then YaST. If it’s not listed there, then from your main menu choose System, then Configuration, and click on the YaST icon.
From the YaST main menu choose Network Devices, and click on the Modem icon.
The Modem configuration window will open and offer you the chance to either configure an existing modem or add a modem. In many cases SuSe hardware detection has already identified and configured your modem for you. You would see it listed under Available are:
However, for those who don’t see a modem listed or who get a modem listed that does not match the one installed, I include details on adding your modem below.
ADDING A MODEM TO SUSE:
To add a modem press the Change button, not the Configure button.
You will see a window that offers the option to Add your new modem and also Add ISP related information.
First begin by clicking on the upper Add button, which will allow you to configure your dialup modem.
Once you click Add you should see the Modem Parameters window.
The device name is very important. Sometimes the device is already preset to something like /dev/modem.
In many cases this is not correct and will not work. Instead, click on the pull down menu and select /ttyS0, which is usually the correct device name for a modem connected by a serial cable to the back of the Linux PC.
On the Modem Parameters window, you should also make sure that the Speaker on setting is selected and that any dialing prefix you need to dial out (such as 9 for dial out) is entered in the Dial prefix.
Click on the Next button to open the Select ISP window.
Here you will find a very thorough listing of many available ISPs. You will find a rather thorough list and if one of the ISPs is yours, you can simply select it and press Next.
However, for those folks who did not find their ISP listed, there is a very simple solution. Press the New button to configure it manually. Don’t worry, this is a quick process.
You will see the Provider parameters screen.
As I mentioned, almost all flavors I’ve used across the board included a “Provider Name” field. This is used exclusively for your information and is not essential to the login process. However, the phone number field must be correct! Once you finish filling out the information on this screen press Next one more time.
On the Connection Parameters screen you will find an important setting! The Modify DNS when connected option is actually allowing your ISP to set your Linux DNS and in almost every case you must select this.
Please make sure the options in the example below are set on your configuration screen as well. I’ve circled them for easy reference.
Selecting Firewall is another important option and will basically disable inbound connection requests. You should almost always have firewall selected. Only in cases when I’m using the Linux system as a server does the firewall sometimes impede rightful inbound requests.
Click Next and you will return to the Provider Parameters screen where all fields should now be filled in. You are ready to start your first Linux dial-up session as soon as you click Next and then the Finish button!
If you see the option to Configure Mail Now? select No. You can always do this later.
Now, reboot your Linux system
As I already mentioned earlier, rebooting can prevent many frustrating experiences with hardware configuration. I strongly recommend a reboot after any new modem or network setup. Once your Linux system has rebooted, look for the KDE Internet Tool located on the bottom right of your KDE menu. It looks like this:
You can press the right mouse button over the icon to view all of the tool’s options or to manually dial-in. Otherwise, you simply click one time on the icon to begin dialing.
Once your dial-in is completed, you’re ready to browse the internet! Open your Linux web browser and enjoy.
To end your dial-up connection click once more on the little KDE Internet Tool icon:
That's it!
TIPS for All Dial-Up Linux Users
Finding a Linux ISP
Sadly, a few ISPs are just not polite when it comes to helping you figure out the information needed to access them via Linux.
For this reason I strongly recommend that you run a web search (use your favorite search engine; I prefer using Google), and search on these words: free linux ISP
Depending on where you live, you will be surprised to know that there are ISPs in most major cities that fully support Linux users, and offer their service to Linux users for FREE! I used one in my local area to perform all of my dial-up modem testing. It worked great.
No, a free ISP will never be ultra fast, nor can it offer you the amazing selection others provide for monthly fees. However, the difference is that you can get online and start using Linux dial-up TODAY instead of waiting on the phone for a long time trying to get your current ISP to provide details how you can login via Linux. In fact, some ISPs don’t allow it at all!
Troubleshooting Dial-Up Connections
Remember that hardware is usually the reason a dial-up connection fails.
Some solutions to common problems include:
* You need to reboot your Linux system after you have made configuration changes and saved them.
* If you’re using an external modem, your touch tone option may be faster than the modem is able to initialize the dial tone. This happens when your modem has not yet gotten a dial tone before the Linux dialer sends the telephone number. You can usually hear this, as some numbers are dialed on the modem before you hear the dial tone. A simple but annoying fix is to disable touch tone.
* You hear the modem dial but then the connection fails. This may be a result of either your ISP not allowing direct dial-in connectivity from Linux, or improper ISP configuration. Double check to make sure you have provided the correct user id and password, and that the IP and DNS addresses are received automatically. You must sometimes clear out fields that use to have IP addresses in them. Make sure Host name and DNS information fields are blank!
* You hear the modem connect, you see the lights flashing, but nothing else happens. In most cases you are connected if the OH and CD modem lights are on. Open a web browser and try to access a site!
http://www.reallylinux.com/docs/basicdialup.shtml
by Mark Rais, senior editor reallylinux.com and author of Linux for the Rest of Us 2nd Edition.
Our other related articles:
Basic Guide to DSL/Cable Use
Commands for Beginning Server Administrators
Full list of our exclusive Linux articles
This beginner article summarizes Mark Rais' experiences using a dial-up internet connection with SuSe and Fedora. It's intended as a review for the many people who are still using dial-up all around the world and need basic help getting started. In his desire to help everyone switch to Linux Mr. Rais did not want to leave out the dial-up crowd!
Before you start, please note that some modem manufacturers rely on Windows to operate their modem hardware (aka WinModems), and therefore your internal modem may not work. If you experience trouble then hopefully this page and this web site may help resolve the issue for you. Those with non-Winmodems and external Hayes compatible modems don't need to worry about this at all.
Step 1 Start by Connecting and Rebooting
Once you have properly connected your modem and made sure it is on, reboot your Linux system. In all likelihood, your modem will be detected by the Linux hardware detection tool and automatically installed.
Step 2 Get Details from Your ISP
After successfully loading your desktop, you will need to configure your modem, which will require some information from your ISP.
Most ISPs will accommodate you and provide clear answers to your questions, since you are paying them! However, some ISPs require you to use proprietary software to dial in and log on to their service. This may inhibit using the generic Linux tools and require you to use some form of emulator to run your ISP’s software under Linux. If you are stuck with such an ISP, you may want to consider an alternative FREE ISP who fully supports Linux. I’ll provide some tips later on the subject.
In most cases you will simply need to know the local dial-up number to call your ISP.
You should take the time now to contact them if you need to get this information. Here’s what you may want to communicate:
* Mention that you are planning to dial-up to your account through your Linux PC
* Ask for one or two local dial-up numbers
* And get their Domain Name Server IP addresses
TIP: If your ISP tech person mentions that the ISP “does not support Linux,” acknowledge you understand this and repeat your questions, since you’re not asking them to help provide tech support for Linux, you’re asking them how they allow access to their network for your use.
You will find out shortly something I’ve noticed from my experiences — some ISPs are far nicer about helping you do this than others!
Step 3 Configure the Modem and ISP Info
Once you have your ISP information, you can quickly configure the modem and enter details for accessing the ISP account. You will also need your account id and password, so have them handy as you begin.
As with other configuration examples, I will use actual steps from two of the major flavors (Fedora and SuSe). I’ve successfully used this information while installing other popular flavors too, so they will apply to most of the newer flavors. The tools are often determined by the Desktop you use and so Fedora (uses Gnome) and SuSe (uses KDE) help give a rather well rounded view of how to setup your modem across most flavors.
Step 4: Fedora Dial-Up (for SuSe Dial-up click here or scroll down)
In Fedora you will find a handy menu item under System Tools labeled Internet Connection Wizard.
It’s actually the Internet Druid configuration tool and will simplify the process of identifying the modem and ISP details. Go ahead and start the tool by clicking on it.
You can also get to this tool later by typing in a terminal prompt: internet-druid
Please notice that once in the tool you actually have the option of adding a number of new devices. For now just click once on the Modem connection and press the Forward button.
You will see the Select Modem screen. From here you should choose from the pull down top menu item the proper device for your modem. It may vary, but from my experience, in a majority of cases an external modem connected to the Serial port on the back of the PC will be /ttyS0.
I also recommend that you change the volume to ensure you can hear what the modem is doing. Set it to Medium and press Forward.
Now you will see the screen that offers the chance to input details regarding your ISP and account.
You will see a listing of preloaded ISPs on the left menu. If you reside in one of the countries where an ISP is listed, then you can choose the details from the menu, under the appropriate national flag. If you reside in other countries like the U.S. or Canada you will need to input the details.
Be sure that what you put into the Phone Number items are applicable to your calling location. In most cases, you do not need to enter anything into either Prefix or Area Code. The Provider name field, as in a number of other configurations like Debian and Mandrake, is not essential and is there for your own reference.
Make sure you type in the correct login and password! When you’ve finished filling out the details, press the Forward button again.
The next screen refers to your DNS settings. In most cases you should make sure that it is set to automatically receive your IP address.
Also, be sure to select automatically obtaining the DNS information!
You will now see the Network Configuration tool appear. In the future, you can access this tool again by either going to the main menu and selecting System Settings, then choosing the Network icon, or you can type into a terminal window the following:
system_config_network
Below is my screenshot of the Network Configuration tool:
By highlighting your Modem and then clicking on the Edit icon, you will be able to make changes to the configuration details. Most of the Modem configuration should already be completed and correct.
Click on each of the tabs (Router, Provider, etc.) and check. If everything looks like it matches your input then go to the Advanced tab and select the option to Let PPP do all authentication.
This allows the PPP (point to point protocol) to handle passing your login and account data to your ISP, which is the default for most situations. Press OK and return to the Network Configuration main window.
You can close your configuration window, which will give you the option to Save your changes. Click OK to save the changes you made.
Now, please reboot your Linux system. Rebooting has often resolved issues with hardware configuration and so I strongly recommend it after any new modem or network setup.
Once your Linux system is back up and running, you should be able to dialup your ISP and get online! Go to the main menu, choose System Set- tings, then Network to return to the Network Configuration tool.
Highlight your modem device, and then click on the Activate button.
You should see a small window appear with the words:
Activating network device… please wait.
When this window disappears you are ready to surf the internet. Open your Linux web browser and enjoy!
To end the dial-up session, return to Network Configuration tool, highlight the modem, and click the Deactivate button. That's it, hopefully now you can enjoy Linux with Dial-up!
NOTE: Troubleshooting and helpful TIPS are included at the end of this article.
Step 4: SuSe Dial-Up
If you use SuSe or some other flavor running the latest KDE desktop these tips will help you get online with a dial-up modem.
Remember that even though the screens may not exactly match your own (all flavors differ somewhat), the tips and information I provide, such as automatically setting DNS, will apply to all flavors.
Begin by starting up the YaST tool, or your flavor’s hardware configuration tool. If you’re not sure what I am referring to, please review the article Post-Installation Configuration for guidance.
To start SuSe’s YaST tool from your main menu choose System and then YaST. If it’s not listed there, then from your main menu choose System, then Configuration, and click on the YaST icon.
From the YaST main menu choose Network Devices, and click on the Modem icon.
The Modem configuration window will open and offer you the chance to either configure an existing modem or add a modem. In many cases SuSe hardware detection has already identified and configured your modem for you. You would see it listed under Available are:
However, for those who don’t see a modem listed or who get a modem listed that does not match the one installed, I include details on adding your modem below.
ADDING A MODEM TO SUSE:
To add a modem press the Change button, not the Configure button.
You will see a window that offers the option to Add your new modem and also Add ISP related information.
First begin by clicking on the upper Add button, which will allow you to configure your dialup modem.
Once you click Add you should see the Modem Parameters window.
The device name is very important. Sometimes the device is already preset to something like /dev/modem.
In many cases this is not correct and will not work. Instead, click on the pull down menu and select /ttyS0, which is usually the correct device name for a modem connected by a serial cable to the back of the Linux PC.
On the Modem Parameters window, you should also make sure that the Speaker on setting is selected and that any dialing prefix you need to dial out (such as 9 for dial out) is entered in the Dial prefix.
Click on the Next button to open the Select ISP window.
Here you will find a very thorough listing of many available ISPs. You will find a rather thorough list and if one of the ISPs is yours, you can simply select it and press Next.
However, for those folks who did not find their ISP listed, there is a very simple solution. Press the New button to configure it manually. Don’t worry, this is a quick process.
You will see the Provider parameters screen.
As I mentioned, almost all flavors I’ve used across the board included a “Provider Name” field. This is used exclusively for your information and is not essential to the login process. However, the phone number field must be correct! Once you finish filling out the information on this screen press Next one more time.
On the Connection Parameters screen you will find an important setting! The Modify DNS when connected option is actually allowing your ISP to set your Linux DNS and in almost every case you must select this.
Please make sure the options in the example below are set on your configuration screen as well. I’ve circled them for easy reference.
Selecting Firewall is another important option and will basically disable inbound connection requests. You should almost always have firewall selected. Only in cases when I’m using the Linux system as a server does the firewall sometimes impede rightful inbound requests.
Click Next and you will return to the Provider Parameters screen where all fields should now be filled in. You are ready to start your first Linux dial-up session as soon as you click Next and then the Finish button!
If you see the option to Configure Mail Now? select No. You can always do this later.
Now, reboot your Linux system
As I already mentioned earlier, rebooting can prevent many frustrating experiences with hardware configuration. I strongly recommend a reboot after any new modem or network setup. Once your Linux system has rebooted, look for the KDE Internet Tool located on the bottom right of your KDE menu. It looks like this:
You can press the right mouse button over the icon to view all of the tool’s options or to manually dial-in. Otherwise, you simply click one time on the icon to begin dialing.
Once your dial-in is completed, you’re ready to browse the internet! Open your Linux web browser and enjoy.
To end your dial-up connection click once more on the little KDE Internet Tool icon:
That's it!
TIPS for All Dial-Up Linux Users
Finding a Linux ISP
Sadly, a few ISPs are just not polite when it comes to helping you figure out the information needed to access them via Linux.
For this reason I strongly recommend that you run a web search (use your favorite search engine; I prefer using Google), and search on these words: free linux ISP
Depending on where you live, you will be surprised to know that there are ISPs in most major cities that fully support Linux users, and offer their service to Linux users for FREE! I used one in my local area to perform all of my dial-up modem testing. It worked great.
No, a free ISP will never be ultra fast, nor can it offer you the amazing selection others provide for monthly fees. However, the difference is that you can get online and start using Linux dial-up TODAY instead of waiting on the phone for a long time trying to get your current ISP to provide details how you can login via Linux. In fact, some ISPs don’t allow it at all!
Troubleshooting Dial-Up Connections
Remember that hardware is usually the reason a dial-up connection fails.
Some solutions to common problems include:
* You need to reboot your Linux system after you have made configuration changes and saved them.
* If you’re using an external modem, your touch tone option may be faster than the modem is able to initialize the dial tone. This happens when your modem has not yet gotten a dial tone before the Linux dialer sends the telephone number. You can usually hear this, as some numbers are dialed on the modem before you hear the dial tone. A simple but annoying fix is to disable touch tone.
* You hear the modem dial but then the connection fails. This may be a result of either your ISP not allowing direct dial-in connectivity from Linux, or improper ISP configuration. Double check to make sure you have provided the correct user id and password, and that the IP and DNS addresses are received automatically. You must sometimes clear out fields that use to have IP addresses in them. Make sure Host name and DNS information fields are blank!
* You hear the modem connect, you see the lights flashing, but nothing else happens. In most cases you are connected if the OH and CD modem lights are on. Open a web browser and try to access a site!
http://www.reallylinux.com/docs/basicdialup.shtml
Starting Processes in Fedora, SuSe, Ubuntu by Mark Rais, senior editor reallylinux.com.
Learn more about configuration with: Configuring a Linux Server
At some point we all need to get into our Linux system, and ensure that key processes are started correctly at boot-up.
There are many ways to accomplish this task, but few have dedicated an article to clarifying how to do this using the existing GUI interfaces for the most common Linux versions.
This very brief guide will show you how to find and start your system processes also called services by using the cron process as an example. You can follow these same steps to start other processes as well.
I share the basic steps for FEDORA, SUSE, and UBUNTU below.
FEDORA SERVICES START
1. From your Fedora main menu, choose Desktop, then System Settings, then Server Settings, and click on Services.
2. You will see the Service Configuration window with a list of all active and disabled services.
3. Scroll down the list, and click on the box to check a service you wish to be activated automatically upon restart.
4. You can also immediately force a service to start by highlighting it and then pressing the Start button.
Starting the example cron service in Fedora
5. When finished, choose File from the menu, then Save Changes. You can now reboot your system.
SUSE SERVICES START
1. From your SuSe main menu, choose System, then Configuration, and click on YaST.
2. In YaST, which is the SuSe configuration tool, choose System.
Finding the process/services tool in SuSe
4. On the right you will notice a number of options. Scroll down until you see Runlevel Editor. Click on it.
5. Locate cron (or whatever process you need) on the list and ensure that it is enabled. It should have the word Yes beside it. If it does not, then highlight cron and press the Enable button.
Starting the example cron service in SuSe
5. Now press the Finish button to save your changes and reboot your system.
UBUNTU SERVICES START
1. From the main menu, choose System, then Administration, and click on Services.
2. You will see the Service Settings window.
3. Find your service. In my example I am trying to start cron. So I locate and highlight Actions scheduler (cron) and click on the box to add a check mark. This ensures the process will automatically start.
4. Now press the OK button, and go ahead and restart your system.
http://reallylinux.com/docs/basicprocesses.shtml
At some point we all need to get into our Linux system, and ensure that key processes are started correctly at boot-up.
There are many ways to accomplish this task, but few have dedicated an article to clarifying how to do this using the existing GUI interfaces for the most common Linux versions.
This very brief guide will show you how to find and start your system processes also called services by using the cron process as an example. You can follow these same steps to start other processes as well.
I share the basic steps for FEDORA, SUSE, and UBUNTU below.
FEDORA SERVICES START
1. From your Fedora main menu, choose Desktop, then System Settings, then Server Settings, and click on Services.
2. You will see the Service Configuration window with a list of all active and disabled services.
3. Scroll down the list, and click on the box to check a service you wish to be activated automatically upon restart.
4. You can also immediately force a service to start by highlighting it and then pressing the Start button.
Starting the example cron service in Fedora
5. When finished, choose File from the menu, then Save Changes. You can now reboot your system.
SUSE SERVICES START
1. From your SuSe main menu, choose System, then Configuration, and click on YaST.
2. In YaST, which is the SuSe configuration tool, choose System.
Finding the process/services tool in SuSe
4. On the right you will notice a number of options. Scroll down until you see Runlevel Editor. Click on it.
5. Locate cron (or whatever process you need) on the list and ensure that it is enabled. It should have the word Yes beside it. If it does not, then highlight cron and press the Enable button.
Starting the example cron service in SuSe
5. Now press the Finish button to save your changes and reboot your system.
UBUNTU SERVICES START
1. From the main menu, choose System, then Administration, and click on Services.
2. You will see the Service Settings window.
3. Find your service. In my example I am trying to start cron. So I locate and highlight Actions scheduler (cron) and click on the box to add a check mark. This ensures the process will automatically start.
4. Now press the OK button, and go ahead and restart your system.
http://reallylinux.com/docs/basicprocesses.shtml
Post Installation Configuration for Beginners IN LINUX
Post Installation Configuration for Beginners
This article on basic Linux network and hardware configuration comes courtesy of the Reallylinux.com editorial staff.
NOTICE this is ONLY the Basic post-installation guide. We also have a number of other beginner articles including:
NEW Windows to Linux: A Startup Guide for Beginners
Using DSL/Cable Modems with Linux
Full list of over 30 beginner help articles
This brief article will provide some encouragement for those with hardware concerns and needing a very basic overview of how and where to find their flavor’s configuration tools.
Most HOWTOs seem to assume that after installation all works well and that you no longer need help configuring anything! Well, sometimes it just isn’t so. Yet, we will be the first to admit that to-day’s flavors do install very smoothly for the most part.
However, when they do not, the solutions are usually a few clicks away using your configuration tools.
The goal of this article is to guide you to your tools so that you are empowered to make configuration changes whenever you need.
We use Fedora, Mandrake (Mandriva), and SuSe as examples below. Hopefully some of these examples will help to guide you to the necessary tools. Please note that there are a LOT OF IMAGES in this article that may be slow for those using dial-up. Sorry, but hopefully the images help clarify the steps far better!
1. Network Configuration
SuSe Network Configuration (Fedora and Mandrake are further below)
You’ll be happy to know that all network, hardware, and software configuration under SuSe is done through a tool called YaST.
It’s easily found under your main menu by selecting System, then selecting Configuration, and YaST.
From the YaST tool you need to select Network Devices and then click on Network Card. This will open up a configuration module that allows you to configure your Linux system’s network IP and host information.
Notice that if you already have a configured network card you will need to click on the Change button instead of the Configure button.
If you’re Changing a network card configuration (usually the case) then you should click the Edit button. In most cases your network card was already detected by SuSe and is listed.
Under the Network address setup you will find the option to select a static IP address, ensure that the subnet mask is correct for your network, and also change the Host name and DNS server details.
Click on the Host name and name server button. Now you can fill in details regarding your network routing. Be sure to use a fully qualified hostname and domain name. Also notice that I entered my Linux server’s IP and domain name in to the DNS fields as well. NOTICE: for intranets and situations where you do not have a static IP, then you must ensure that the Change host name via DHCP box is selected and other fields are empty!
Pressing Finish will complete and save your new network settings.
Fedora Network Config
If you’re using Fedora, you simply need to traverse the main menu to find System Settings. Under this menu item you will need to select Network to begin the network configuration tool.
Another way to start this tool is to type the following command into a terminal window:
system-config-network
In this tool you can change your network card settings, add network hardware, or make changes to your host information.
Click on the DNS and Hosts tabs to make changes to your hostname and the IP address information. The image shows an example of a properly configured and working Linux server.
Mandrake Network Config
Mandrake users will likewise find their hardware configuration tool under the System icon from the main menu. You would select System, then Configuration, then Configure your computer.
From here you will see the main Mandrake Control Center. You should become well versed with all of the features here since it offers almost all of the core configuration tools you need.
To change your network configuration you will need to select the item Network & Internet. Under this menu you will need to find and choose the option New connection, which allows you to create any form of new Network type.
If you choose LAN you will find the settings to choose whether it is using DHCP or manually enter the IP address. Usually you can leave the setting on DHCP.
TIP: Sometimes using the menu to do something may take longer than simply typing the command in the konsole. To quickly open the Control Center, type this command: drakconf
2. Hardware Configuration
SuSe Hardware Config
As mentioned earlier, SuSe has made configuration very easy by placing all of the configuration modules under one single tool named YaST.
The fastest way to start the YaST configuration tool and change hardware settings is by typing the following into a konsole or at a terminal prompt:
kdesu /sbin/yast2
Another way to get access to the YaST tool and change your hardware settings is by simply going to the main menu, selecting System, then Configuration, then choosing YaST. This will give you a nice thorough listing of all of the configuration modules available.
By selecting Hardware you see a list of modules to choose from. Most of these allow you to directly change configuration settings. For example, clicking on the Printer icon brings up a configuration tool to add a printer to your system.
There are an amazing number of easily configurable options!
Desktop Configuration
The means to change desktop and environment details are included in depth in the next section Desktop Interfaces. There you will find the details to change not only menu items but the design themes for your entire Linux experience.
SuSe’s YaST also comes with a number of other unique and very helpful options that you may need when trying to address configuration issues.
One very fast way to fix hardware problems is to use the SuSe Plugger module that is almost always found on your Desktop menu.
You can also get to it using the command: suseplugger
This is an extremely straightforward and fast way to check existing hardware and to correct problems with drivers or configuration. Another unique and helpful feature is the YaST module that allows you to install drivers from your hardware manufacturer. Look under your YaST main menu for Misc. Select it and you will see an option to Load Vendor Driver from the CD. This will become more and more useful as hardware vendors include Linux driver databases on CDs they ship.
Fedora Hardware Config
You need to be logged in as root or have full rights access to use most of the Fedora configuration tools.
Most of the individual configuration tools for your different hardware are located under System Settings from the main menu. For example, selecting Display will start the display configuration. Some of the tools also offer helpful wizards that walk you step-by-step through the configuration such as the Printing tool, while some others do nothing but present information such as the Soundcard tool.
For those who prefer to use shortcut commands rather than use the menu and icons to select configuration, below is a brief list of configuration tools. To use any of these simply type the command into a terminal:
* system-config-display
* system-config-keyboard
* system-config-printer
* system-config-users
If your hardware was not properly detected, try restarting the system. The latest Fedora core includes many updated drivers that are initiated at bootup.
Mandrake Hardware Config
Configuring most of the other hardware can also be done using the Mandrake Control Center with the drakconf tool. For more refined or rudimentary Mandrake hardware configurations you can also use the tool called: harddrake2.
You access the harddrake2 hardware configuration under the System icon from the main menu. You will see the Configuration option, then select Hardware and Hard Drake, or you may choose Configure your computer and choose Hardware twice.
Remember if you’re not already logged in as root to enter your root password. These configuration changes are only accessible to root.
You will see a listing of most of your hardware. Select an item you are interested in configuring from the list.
Now you will see one or two buttons appear at the base of the window. Choose the button Run config tool. This will apply to almost all of the hardware components. From this point on you will need to choose a driver, specify details about your hardware, or run the troubleshooting tool if it is available.
In a number of cases, especially with modems, the installation can not configure the modem because it requires a proprietary driver. In this case the listing will show the error and where you can get more help.
Hopefully this brief review helped you identify the tools available for configuration and how best to access them whenever you desire.
http://www.reallylinux.com/docs/basicconfig.shtml
This article on basic Linux network and hardware configuration comes courtesy of the Reallylinux.com editorial staff.
NOTICE this is ONLY the Basic post-installation guide. We also have a number of other beginner articles including:
NEW Windows to Linux: A Startup Guide for Beginners
Using DSL/Cable Modems with Linux
Full list of over 30 beginner help articles
This brief article will provide some encouragement for those with hardware concerns and needing a very basic overview of how and where to find their flavor’s configuration tools.
Most HOWTOs seem to assume that after installation all works well and that you no longer need help configuring anything! Well, sometimes it just isn’t so. Yet, we will be the first to admit that to-day’s flavors do install very smoothly for the most part.
However, when they do not, the solutions are usually a few clicks away using your configuration tools.
The goal of this article is to guide you to your tools so that you are empowered to make configuration changes whenever you need.
We use Fedora, Mandrake (Mandriva), and SuSe as examples below. Hopefully some of these examples will help to guide you to the necessary tools. Please note that there are a LOT OF IMAGES in this article that may be slow for those using dial-up. Sorry, but hopefully the images help clarify the steps far better!
1. Network Configuration
SuSe Network Configuration (Fedora and Mandrake are further below)
You’ll be happy to know that all network, hardware, and software configuration under SuSe is done through a tool called YaST.
It’s easily found under your main menu by selecting System, then selecting Configuration, and YaST.
From the YaST tool you need to select Network Devices and then click on Network Card. This will open up a configuration module that allows you to configure your Linux system’s network IP and host information.
Notice that if you already have a configured network card you will need to click on the Change button instead of the Configure button.
If you’re Changing a network card configuration (usually the case) then you should click the Edit button. In most cases your network card was already detected by SuSe and is listed.
Under the Network address setup you will find the option to select a static IP address, ensure that the subnet mask is correct for your network, and also change the Host name and DNS server details.
Click on the Host name and name server button. Now you can fill in details regarding your network routing. Be sure to use a fully qualified hostname and domain name. Also notice that I entered my Linux server’s IP and domain name in to the DNS fields as well. NOTICE: for intranets and situations where you do not have a static IP, then you must ensure that the Change host name via DHCP box is selected and other fields are empty!
Pressing Finish will complete and save your new network settings.
Fedora Network Config
If you’re using Fedora, you simply need to traverse the main menu to find System Settings. Under this menu item you will need to select Network to begin the network configuration tool.
Another way to start this tool is to type the following command into a terminal window:
system-config-network
In this tool you can change your network card settings, add network hardware, or make changes to your host information.
Click on the DNS and Hosts tabs to make changes to your hostname and the IP address information. The image shows an example of a properly configured and working Linux server.
Mandrake Network Config
Mandrake users will likewise find their hardware configuration tool under the System icon from the main menu. You would select System, then Configuration, then Configure your computer.
From here you will see the main Mandrake Control Center. You should become well versed with all of the features here since it offers almost all of the core configuration tools you need.
To change your network configuration you will need to select the item Network & Internet. Under this menu you will need to find and choose the option New connection, which allows you to create any form of new Network type.
If you choose LAN you will find the settings to choose whether it is using DHCP or manually enter the IP address. Usually you can leave the setting on DHCP.
TIP: Sometimes using the menu to do something may take longer than simply typing the command in the konsole. To quickly open the Control Center, type this command: drakconf
2. Hardware Configuration
SuSe Hardware Config
As mentioned earlier, SuSe has made configuration very easy by placing all of the configuration modules under one single tool named YaST.
The fastest way to start the YaST configuration tool and change hardware settings is by typing the following into a konsole or at a terminal prompt:
kdesu /sbin/yast2
Another way to get access to the YaST tool and change your hardware settings is by simply going to the main menu, selecting System, then Configuration, then choosing YaST. This will give you a nice thorough listing of all of the configuration modules available.
By selecting Hardware you see a list of modules to choose from. Most of these allow you to directly change configuration settings. For example, clicking on the Printer icon brings up a configuration tool to add a printer to your system.
There are an amazing number of easily configurable options!
Desktop Configuration
The means to change desktop and environment details are included in depth in the next section Desktop Interfaces. There you will find the details to change not only menu items but the design themes for your entire Linux experience.
SuSe’s YaST also comes with a number of other unique and very helpful options that you may need when trying to address configuration issues.
One very fast way to fix hardware problems is to use the SuSe Plugger module that is almost always found on your Desktop menu.
You can also get to it using the command: suseplugger
This is an extremely straightforward and fast way to check existing hardware and to correct problems with drivers or configuration. Another unique and helpful feature is the YaST module that allows you to install drivers from your hardware manufacturer. Look under your YaST main menu for Misc. Select it and you will see an option to Load Vendor Driver from the CD. This will become more and more useful as hardware vendors include Linux driver databases on CDs they ship.
Fedora Hardware Config
You need to be logged in as root or have full rights access to use most of the Fedora configuration tools.
Most of the individual configuration tools for your different hardware are located under System Settings from the main menu. For example, selecting Display will start the display configuration. Some of the tools also offer helpful wizards that walk you step-by-step through the configuration such as the Printing tool, while some others do nothing but present information such as the Soundcard tool.
For those who prefer to use shortcut commands rather than use the menu and icons to select configuration, below is a brief list of configuration tools. To use any of these simply type the command into a terminal:
* system-config-display
* system-config-keyboard
* system-config-printer
* system-config-users
If your hardware was not properly detected, try restarting the system. The latest Fedora core includes many updated drivers that are initiated at bootup.
Mandrake Hardware Config
Configuring most of the other hardware can also be done using the Mandrake Control Center with the drakconf tool. For more refined or rudimentary Mandrake hardware configurations you can also use the tool called: harddrake2.
You access the harddrake2 hardware configuration under the System icon from the main menu. You will see the Configuration option, then select Hardware and Hard Drake, or you may choose Configure your computer and choose Hardware twice.
Remember if you’re not already logged in as root to enter your root password. These configuration changes are only accessible to root.
You will see a listing of most of your hardware. Select an item you are interested in configuring from the list.
Now you will see one or two buttons appear at the base of the window. Choose the button Run config tool. This will apply to almost all of the hardware components. From this point on you will need to choose a driver, specify details about your hardware, or run the troubleshooting tool if it is available.
In a number of cases, especially with modems, the installation can not configure the modem because it requires a proprietary driver. In this case the listing will show the error and where you can get more help.
Hopefully this brief review helped you identify the tools available for configuration and how best to access them whenever you desire.
http://www.reallylinux.com/docs/basicconfig.shtml
Basics of Setting up a WEBServer IN LINUX
REALLY Raw Basics of Setting up a WEBServer
NOTE : This document assumes you are using a fully installed version of LINUX. The author has tried to remain fairly generic, but some commands and functions refer to Fedora. You may also benefit from these server commands and this article on more advanced server configuration.
Getting Started - Raw Basics
How to Test if httpd (the web server process) is already installed.
1st: Check to see there IS a webserver installed! At the prompt type: locate apache |more
OR from a web browser try hitting your localhost with an http:// web call.
2nd: Now don't forget to verify that your web server is actually running! One simple way to do this is to check for the httpd process. At the command line type:
ps -e | grep httpd
This should tell you right away IF you have httpd process available. If you do not have this process (ie. if it is not listed) then you need to get help! Try our message boards or search. Otherwise, if you see an httpd process listed, you're in fine shape!
How to look at your pages: your LINUX installation should have Netscape installed. You can also launch the Konquerer browser if you are using KDE. But start a browser and start looking around your web server directories... most likely something like:
/var/www/html.
This all depends on what the locate command above showed you!
Network Configuration
Okay, so let's not forget that before Apache will work, or you can even think about serving WEB pages, it's key to do the network configuration! I won't try to explain the configuration of your personal network because it's really information I should write in a different document.
However, here are some of the basics you'll need to keep in mind:
* Use Network Configurator (usually under Administration in X) to assign IP addresses as needed.
* Use LinuxConf (usually under System in X) to assign proper rights to your account to allow setting up server etc.
* Check to make sure you have a hostname properly assigned by typing:
hostname
Let's assume your network is properly configured and move on!
Basic WEB Serving
It's important to note the directory that you will use extensively (maybe slightly different based on your version):
/var/www/html
This directory contains rather self-explanatory sub-directories such as where you should put the html files like index.html. In fact, you'll find that you spend most of the time in: /var/www/html, /var/www/cgi-bin. You might as well go ahead and open several Xterminal sessions looking at these dirs!
Don't waste time trying to do things right now without using Root login. You should be careful and make back-up copies of files you are about to edit by typing:
cp filename.ext filename.ext.old
Basic Information Resources
Documentation is all over, but the best place is the dummy index.html page on your web server system under /var/www/html.
We have some more helpful ideas under our Linux Help page.
Also, there is a well documented location of beginner web stuff than at http://www.bignosebird.com. This is probably a very good start for any new web engineer or web master.
NOTE : This document assumes you are using a fully installed version of LINUX. The author has tried to remain fairly generic, but some commands and functions refer to Fedora. You may also benefit from these server commands and this article on more advanced server configuration.
Getting Started - Raw Basics
How to Test if httpd (the web server process) is already installed.
1st: Check to see there IS a webserver installed! At the prompt type: locate apache |more
OR from a web browser try hitting your localhost with an http:// web call.
2nd: Now don't forget to verify that your web server is actually running! One simple way to do this is to check for the httpd process. At the command line type:
ps -e | grep httpd
This should tell you right away IF you have httpd process available. If you do not have this process (ie. if it is not listed) then you need to get help! Try our message boards or search. Otherwise, if you see an httpd process listed, you're in fine shape!
How to look at your pages: your LINUX installation should have Netscape installed. You can also launch the Konquerer browser if you are using KDE. But start a browser and start looking around your web server directories... most likely something like:
/var/www/html.
This all depends on what the locate command above showed you!
Network Configuration
Okay, so let's not forget that before Apache will work, or you can even think about serving WEB pages, it's key to do the network configuration! I won't try to explain the configuration of your personal network because it's really information I should write in a different document.
However, here are some of the basics you'll need to keep in mind:
* Use Network Configurator (usually under Administration in X) to assign IP addresses as needed.
* Use LinuxConf (usually under System in X) to assign proper rights to your account to allow setting up server etc.
* Check to make sure you have a hostname properly assigned by typing:
hostname
Let's assume your network is properly configured and move on!
Basic WEB Serving
It's important to note the directory that you will use extensively (maybe slightly different based on your version):
/var/www/html
This directory contains rather self-explanatory sub-directories such as where you should put the html files like index.html. In fact, you'll find that you spend most of the time in: /var/www/html, /var/www/cgi-bin. You might as well go ahead and open several Xterminal sessions looking at these dirs!
Don't waste time trying to do things right now without using Root login. You should be careful and make back-up copies of files you are about to edit by typing:
cp filename.ext filename.ext.old
Basic Information Resources
Documentation is all over, but the best place is the dummy index.html page on your web server system under /var/www/html.
We have some more helpful ideas under our Linux Help page.
Also, there is a well documented location of beginner web stuff than at http://www.bignosebird.com. This is probably a very good start for any new web engineer or web master.
This is a basic article on how to configure Linux so that it will run your webserver, telnet, ftp, mysql etc.
This is a basic article on how to configure Linux so that it will run your webserver, telnet, ftp, mysql etc. It is primarily focused for Fedora/RedHat releases but applies to almost all server based flavors. I also recommend you get familiar with these Commands for Server Administrators .
Summary of Commands
Trying to Start:
Then try doing this:
httpd cd /etc/rc.d/init.d/
then type:
./httpd start
mysql cd /etc/rc.d/init.d/
then type:
./mysqld start
telnet Edit the file /etc/xinetd.d/telnetd
changing the two lines to:
# default: on
disabled = no
then try doing this
/etc/rc.d/init.d/xinetd restart
ftp
Edit the file /etc/xinetd.d/wu-ftpd
changing the two lines to:
# default: on
disabled = no
then run the command
/etc/rc.d/init.d/xinetd restart
Details of Configuring Linux
EDITORS NOTE: Some of the newest flavors of Linux have changed the locations of the configuration files. For this reason please note that most of these commands apply best to Fedora/Redhat. However, some configuration commands like the use of xinetd or running chkconfig are useful on almost all Linux/Unix systems.
First off, I should mention that this guide is best used when in front of your Linux computer, with an open xterm session. The exact commands come from RedHat 7.1+ related server, but apply to most Linux servers.
TIP 1. When you need to find a particular file/directory then use the 'locate' command (on Fedora slocate works well too) to find things on your server. Like, typing: locate xinetd
TIP 2. If you did not know this already, all of the web server html files for Fedora are placed under: /var/www/html
Step 1. Which Processes are Running On Your Server?
If you don't know, then you need to find out asap! Use the command:
/sbin/chkconfig --list
The output would look something like:
…
httpd 0:off 1:off 2:off 3:off 4:off 5:off 6:off
telnet: off
…
The above command will give you a long list of processes with info beside them like "off". Any process with the word "off" next to it can be assumed disabled by default during startup. You should look for your processes that are usually needed for running a webserver like httpd, telnet, wu-ftp, mysqld. All of these should be "on" by default.
Step 2. Get Processes Started
Starting up your webserver (httpd), mysql (mysqld), sendmail, etc. is easy so long as you follow the directions from the steps below.
For your webserver and mysql, you can enable these things right away for use during this session.
Change to the initialization (aka init) directory:
cd /etc/rc.d/init.d/
This directory (when listed) shows all processes you can start like httpd and mysqld. For now let's start our web server with the command:
./httpd start
You should then see:
Starting httpd: [ OK ]
Now enable your webserver (httpd) for ALL future STARTUPS!
1. Edit the config files as applied to the "rc" directory of your choice. Remember that all resource files activated at different run times are in different rc.d directories. For instance, when your server is loaded at runtime level 5 (usual) then all the resources under rc5.d are activated. Change directory to:
/etc/rc.d/rc5.d
Remember that the rc5.d is a resource directory (under /etc) for run level 5... etc.
You edit files in these directories to control what occurs at different run levels. Files with a prefix of K are NOT installed to run at startup. Files with S are ready to run at startup. Example names: K74ypserv or S14nfslock.
You can always use something like the command:
/sbin/chkconfig --add httpd
to add the web server to the future startups. However, I prefer doing my change manually.
2. You can manually force this by simply using a command like:
mv K15httpd S15httpd
Summary for those needing one... You now should have your webserver started and ready as default for all future starts with:
* ./httpd start
* mv k15httpd s15httpd
Step 3. What About telnet and ftp?
Ok, you're smart enough to have noticed that following the steps above you can not get telnet or ftp started. That's because they are not part of the initd process, but rather the xinetd process. The xinetd process handles the startup of all of your network related protocols etc.
1st Start telnet first by changing directories to xinetd:
cd /etc/xinetd.d/
Next type ls to list all of the processes that can be configured. You'll notice for instance the file telnet.
2nd Edit the telnet file and change two lines:
# default: on
...
disabled = no
These lines are not adjacent, but usually the first and last lines of the configuration file (in our case telnet). You need to edit all configuration files that apply to things you're trying to start. Many processes come by default turned off and disabled = yes. You can edit files like telnet, wu-ftp, etc.
3rd Once you have edited and saved the files with the default on and disabled = no, you can force an automatic restart of the xinetd to load without rebooting:
/etc/rc.d/init.d/xinetd restart
Finally, you should see:
Stopping xinetd: [ OK ] Starting xinetd: [ OK ]
Believe it or not, following all of this you should now have running:
* httpd (webserver)
* telnet
Now check to see what processes you have running again by using:
/sbin/chkconfig –list
or use the long "process" ps command like: ps -e | grep http.
You can use these same steps above to get mysql and ftp running. Replace httpd with mysql, and telnet with wu-ftpd. Always remember there is a difference between configuration and startup files under initd and xinetd.
Summary of Commands
Trying to Start:
Then try doing this:
httpd cd /etc/rc.d/init.d/
then type:
./httpd start
mysql cd /etc/rc.d/init.d/
then type:
./mysqld start
telnet Edit the file /etc/xinetd.d/telnetd
changing the two lines to:
# default: on
disabled = no
then try doing this
/etc/rc.d/init.d/xinetd restart
ftp
Edit the file /etc/xinetd.d/wu-ftpd
changing the two lines to:
# default: on
disabled = no
then run the command
/etc/rc.d/init.d/xinetd restart
Details of Configuring Linux
EDITORS NOTE: Some of the newest flavors of Linux have changed the locations of the configuration files. For this reason please note that most of these commands apply best to Fedora/Redhat. However, some configuration commands like the use of xinetd or running chkconfig are useful on almost all Linux/Unix systems.
First off, I should mention that this guide is best used when in front of your Linux computer, with an open xterm session. The exact commands come from RedHat 7.1+ related server, but apply to most Linux servers.
TIP 1. When you need to find a particular file/directory then use the 'locate' command (on Fedora slocate works well too) to find things on your server. Like, typing: locate xinetd
TIP 2. If you did not know this already, all of the web server html files for Fedora are placed under: /var/www/html
Step 1. Which Processes are Running On Your Server?
If you don't know, then you need to find out asap! Use the command:
/sbin/chkconfig --list
The output would look something like:
…
httpd 0:off 1:off 2:off 3:off 4:off 5:off 6:off
telnet: off
…
The above command will give you a long list of processes with info beside them like "off". Any process with the word "off" next to it can be assumed disabled by default during startup. You should look for your processes that are usually needed for running a webserver like httpd, telnet, wu-ftp, mysqld. All of these should be "on" by default.
Step 2. Get Processes Started
Starting up your webserver (httpd), mysql (mysqld), sendmail, etc. is easy so long as you follow the directions from the steps below.
For your webserver and mysql, you can enable these things right away for use during this session.
Change to the initialization (aka init) directory:
cd /etc/rc.d/init.d/
This directory (when listed) shows all processes you can start like httpd and mysqld. For now let's start our web server with the command:
./httpd start
You should then see:
Starting httpd: [ OK ]
Now enable your webserver (httpd) for ALL future STARTUPS!
1. Edit the config files as applied to the "rc" directory of your choice. Remember that all resource files activated at different run times are in different rc.d directories. For instance, when your server is loaded at runtime level 5 (usual) then all the resources under rc5.d are activated. Change directory to:
/etc/rc.d/rc5.d
Remember that the rc5.d is a resource directory (under /etc) for run level 5... etc.
You edit files in these directories to control what occurs at different run levels. Files with a prefix of K are NOT installed to run at startup. Files with S are ready to run at startup. Example names: K74ypserv or S14nfslock.
You can always use something like the command:
/sbin/chkconfig --add httpd
to add the web server to the future startups. However, I prefer doing my change manually.
2. You can manually force this by simply using a command like:
mv K15httpd S15httpd
Summary for those needing one... You now should have your webserver started and ready as default for all future starts with:
* ./httpd start
* mv k15httpd s15httpd
Step 3. What About telnet and ftp?
Ok, you're smart enough to have noticed that following the steps above you can not get telnet or ftp started. That's because they are not part of the initd process, but rather the xinetd process. The xinetd process handles the startup of all of your network related protocols etc.
1st Start telnet first by changing directories to xinetd:
cd /etc/xinetd.d/
Next type ls to list all of the processes that can be configured. You'll notice for instance the file telnet.
2nd Edit the telnet file and change two lines:
# default: on
...
disabled = no
These lines are not adjacent, but usually the first and last lines of the configuration file (in our case telnet). You need to edit all configuration files that apply to things you're trying to start. Many processes come by default turned off and disabled = yes. You can edit files like telnet, wu-ftp, etc.
3rd Once you have edited and saved the files with the default on and disabled = no, you can force an automatic restart of the xinetd to load without rebooting:
/etc/rc.d/init.d/xinetd restart
Finally, you should see:
Stopping xinetd: [ OK ] Starting xinetd: [ OK ]
Believe it or not, following all of this you should now have running:
* httpd (webserver)
* telnet
Now check to see what processes you have running again by using:
/sbin/chkconfig –list
or use the long "process" ps command like: ps -e | grep http.
You can use these same steps above to get mysql and ftp running. Replace httpd with mysql, and telnet with wu-ftpd. Always remember there is a difference between configuration and startup files under initd and xinetd.
WINDOWS POWER SHELL
Get-Acl Get permission settings for a file or registry key
Set-Acl Set permissions
Get-Alias gal Return alias names for Cmdlets
Import-Alias ipal Import an alias list from a file
New-Alias nal Create a new alias.
Set-Alias sal Create or change an alias
Get-AuthenticodeSignature Get the signature object associated with a file
Set-AuthenticodeSignature Place a signature in a .ps1 script or other file
c
Set-Location cd/chdir/sl Set the current working location
Get-ChildItem dir/ls/gci Get child items (contents of a folder or registry key)
Get-Command gcm Retrieve basic information about a command
Measure-Command Measure running time
Trace-Command Trace an expression or command
Add-Content ac Add to the content of the item
Get-Content cat/type/gc Get content from item (specific location)
Set-Content sc Set content in the item (specific location)
Clear-Content clc Remove content from a file/item
ConvertTo-Html Convert the input into an HTML table
ConvertFrom-SecureString Convert a secure string into an encrypted standard string
ConvertTo-SecureString Convert an encrypted standard string into a secure string
Clear-Host clear/cls Clear the screen
Clear-Item cli Remove content from a variable or an alias
Copy-Item copy/cp/cpi Copy an item from a namespace location
Get-Credential Get a security credential (username/password)
Get-Culture Get region information (language and keyboard layout)
d
Get-ChildItem dir/ls/gci Get child items (contents of a folder or registry key)
Get-Date Get current date and time
Set-Date Set system time on the host system
Get-PSDrive gdr Get drive information (DriveInfo)
New-PSDrive mount/ndr Install a new drive on the machine
Remove-PSDrive rdr Remove a provider/drive from its location
e
Get-Eventlog Get eventlog data
Get-ExecutionPolicy Get the execution policy for the shell
Set-ExecutionPolicy Change the execution policy (user preference)
Export-Alias epal Export an alias list to a file
Export-Clixml Produce a clixml representation of powershell objects
Export-Console Export console configuration to a file
Export-Csv epcsv Export to Comma Separated Values (spreadsheet)
Invoke-Expression Run a PowerShell expression
Exit Exit Powershell
f
ForEach-Object foreach Loop for each object in the pipeline
ForEach Loop through values in the pipeline
Format-Custom fc Format output using a customized view
Format-List fl Format output as a list of properties, each on a new line
Format-Table ft Format output as a table
Format-Wide fw Format output as a table listing one property only
g
Get-Item gi Get a file/registry object (or any other namespace object)
Get-ChildItem dir/ls/gci Get child items (contents of a folder or registry key)
h
Get-Help help Open the help file
Add-History Add entries to the session history
Get-History history/h/ghy Get a listing of the session history
Invoke-History r/ihy Invoke a previously executed Cmdlet
Get-Host Get host information
Clear-Host clear/cls Clear the screen
Read-Host Read a line of input from the host console
Write-Host Display objects through the host user interface
i
if Conditionally perform a command
Import-Clixml Import a clixml file and rebuild the PS object
Import-Csv ipcsv Take values from a CSV list and send objects down the pipeline.
Get-Item gi Get a file object or get a registry (or other namespace) object
Invoke-Item ii Invoke an executable or open a file (START)
New-Item ni Create a new item in a namespace
Remove-Item rm/del/erase/rd/ri/rmdir Remove an item
Set-Item si Change the value of an item
Clear-ItemProperty Delete the value of a property
Copy-ItemProperty Copy a property along with its value
Get-ItemProperty Retrieve the properties of an object
Move-ItemProperty Move a property from one location to another
New-ItemProperty Set a new property of an item at a location
Remove-ItemProperty Delete the property and its value from an item
Rename-ItemProperty Rename a property of an item
Set-ItemProperty Set the value of a property
k
Stop-Process kill/spps Stop a running process
l
Get-Location pwd / gl Get and display the current location
Pop-Location popd Set the current working location from the stack
Push-Location pushd Push a location to the stack
Set-Location cd/chdir/sl Set the current working location
m
Add-Member Add a member to an instance of a PowerShell object
Get-Member gm Enumerate the properties of an object
Move-Item move/mv/mi Move an item from one location to another
o
Compare-Object Compare the properties of objects
Group-Object group Group the objects that contain the same value for a common property
Measure-Object Measure the properties of an object
New-Object Create a new .Net object
Select-Object select Select properties of objects.
Sort-Object sort Sort objects by property value
Where-Object Filter the objects passed along the command pipeline.
Out-Default Send output to default
Out-File Send command output to a file
Out-Host oh Send the pipelined output to the host
Out-Null Send output to null
Out-Printer lp Send the output to a printer
Out-String Send objects to the host as strings
p
Powershell Launch a powershell session
Convert-Path cvpa Convert a ps path to a provider path
Join-Path Combine a path and child-path
Resolve-Path rvpa Resolves the wildcards in a path
Split-Path Return part of a path
Test-Path Return true if the path exists, otherwise return false
Get-Pfxcertificate Get pfx certificate information
Pop-Location popd Set the current working location from the stack
Push-Location pushd Push a location to the stack
Get-Process ps/gps Get a list of processes on a machine
Stop-Process kill/spps Stop a running process
Clear-ItemProperty clp Remove the property value from a property
Copy-ItemProperty cpp Copy a property along with it's value
Get-ItemProperty gp Retrieve the properties of an object
Move-ItemProperty mp Move a property from one location to another
New-ItemProperty Set a new property
Remove-ItemProperty rp Remove a property and its value
Rename-ItemProperty rnp Renames a property at its location
Set-ItemProperty sp Set a property at the specified location to a specified value
Get-PsProvider Get information for the specified provider
Set-PSdebug Turn script debugging on or off
Add-PsSnapIn Add snap-ins to the console
Get-PsSnapin List PowerShell snap-ins on this computer
Remove-PSSnapin Remove PowerShell snap-ins from the console
r
Read-Host Read a line of input from the host console
Remove-Item rm/del/erase/rd/ri/rmdir Remove an item
Rename-Item ren/rni Change the name of an existing item
Rename-ItemProperty Rename a property of an item
s
Get-Service gsv Get a list of services
New-Service Create a new service
Restart-Service Stop and then restart a service
Resume-Service Resume a suspended service
Set-Service Change the start mode/properties of a service
Sort-Object sort Sort objects by property value
Start-Service sasv Start a stopped service
Stop-Service spsv Stop a running service
Suspend-Service Suspend a running service
Start-Sleep sleep Suspend shell, script, or runspace activity
Select-String Search through strings or files for patterns
t
Tee-Object Send input objects to two places
New-Timespan Create a timespan object
Trace-Command Trace an expression or command
Get-Tracesource Get components that are instrumented for tracing.
Set-Tracesource Trace a PowerShell component
Start-Transcript Start a transcript of a command shell session
Stop-Transcript Stop the transcription process
u
Get-Uiculture Get the ui culture information
Get-Unique gu Get the unique items in a collection
Update-Formatdata Update and append format data files
Update-Typedata Update the current extended type configuration
v
Clear-Variable clv Remove the value from a variable
Get-Variable gv Get a powershell variable
New-Variable nv Create a new variable
Remove-Variable rv Remove a variable and its value
Set-Variable set/sv Set a variable and a value
w
Where-Object where Filter input from the pipeline
While (condition) {action} else {action}
Get-WMIobject Get WMI class information
Write-Debug Write a debug message to the host display
Write-Error Write an object to the error pipeline.
Write-Output echo Write an object to the pipeline
Write-Progress Display a progress bar
Write-Verbose Write a string to the host's verbose display
Write-Warning Write a warning message
# Comment / Remark
Set-Acl Set permissions
Get-Alias gal Return alias names for Cmdlets
Import-Alias ipal Import an alias list from a file
New-Alias nal Create a new alias.
Set-Alias sal Create or change an alias
Get-AuthenticodeSignature Get the signature object associated with a file
Set-AuthenticodeSignature Place a signature in a .ps1 script or other file
c
Set-Location cd/chdir/sl Set the current working location
Get-ChildItem dir/ls/gci Get child items (contents of a folder or registry key)
Get-Command gcm Retrieve basic information about a command
Measure-Command Measure running time
Trace-Command Trace an expression or command
Add-Content ac Add to the content of the item
Get-Content cat/type/gc Get content from item (specific location)
Set-Content sc Set content in the item (specific location)
Clear-Content clc Remove content from a file/item
ConvertTo-Html Convert the input into an HTML table
ConvertFrom-SecureString Convert a secure string into an encrypted standard string
ConvertTo-SecureString Convert an encrypted standard string into a secure string
Clear-Host clear/cls Clear the screen
Clear-Item cli Remove content from a variable or an alias
Copy-Item copy/cp/cpi Copy an item from a namespace location
Get-Credential Get a security credential (username/password)
Get-Culture Get region information (language and keyboard layout)
d
Get-ChildItem dir/ls/gci Get child items (contents of a folder or registry key)
Get-Date Get current date and time
Set-Date Set system time on the host system
Get-PSDrive gdr Get drive information (DriveInfo)
New-PSDrive mount/ndr Install a new drive on the machine
Remove-PSDrive rdr Remove a provider/drive from its location
e
Get-Eventlog Get eventlog data
Get-ExecutionPolicy Get the execution policy for the shell
Set-ExecutionPolicy Change the execution policy (user preference)
Export-Alias epal Export an alias list to a file
Export-Clixml Produce a clixml representation of powershell objects
Export-Console Export console configuration to a file
Export-Csv epcsv Export to Comma Separated Values (spreadsheet)
Invoke-Expression Run a PowerShell expression
Exit Exit Powershell
f
ForEach-Object foreach Loop for each object in the pipeline
ForEach Loop through values in the pipeline
Format-Custom fc Format output using a customized view
Format-List fl Format output as a list of properties, each on a new line
Format-Table ft Format output as a table
Format-Wide fw Format output as a table listing one property only
g
Get-Item gi Get a file/registry object (or any other namespace object)
Get-ChildItem dir/ls/gci Get child items (contents of a folder or registry key)
h
Get-Help help Open the help file
Add-History Add entries to the session history
Get-History history/h/ghy Get a listing of the session history
Invoke-History r/ihy Invoke a previously executed Cmdlet
Get-Host Get host information
Clear-Host clear/cls Clear the screen
Read-Host Read a line of input from the host console
Write-Host Display objects through the host user interface
i
if Conditionally perform a command
Import-Clixml Import a clixml file and rebuild the PS object
Import-Csv ipcsv Take values from a CSV list and send objects down the pipeline.
Get-Item gi Get a file object or get a registry (or other namespace) object
Invoke-Item ii Invoke an executable or open a file (START)
New-Item ni Create a new item in a namespace
Remove-Item rm/del/erase/rd/ri/rmdir Remove an item
Set-Item si Change the value of an item
Clear-ItemProperty Delete the value of a property
Copy-ItemProperty Copy a property along with its value
Get-ItemProperty Retrieve the properties of an object
Move-ItemProperty Move a property from one location to another
New-ItemProperty Set a new property of an item at a location
Remove-ItemProperty Delete the property and its value from an item
Rename-ItemProperty Rename a property of an item
Set-ItemProperty Set the value of a property
k
Stop-Process kill/spps Stop a running process
l
Get-Location pwd / gl Get and display the current location
Pop-Location popd Set the current working location from the stack
Push-Location pushd Push a location to the stack
Set-Location cd/chdir/sl Set the current working location
m
Add-Member Add a member to an instance of a PowerShell object
Get-Member gm Enumerate the properties of an object
Move-Item move/mv/mi Move an item from one location to another
o
Compare-Object Compare the properties of objects
Group-Object group Group the objects that contain the same value for a common property
Measure-Object Measure the properties of an object
New-Object Create a new .Net object
Select-Object select Select properties of objects.
Sort-Object sort Sort objects by property value
Where-Object Filter the objects passed along the command pipeline.
Out-Default Send output to default
Out-File Send command output to a file
Out-Host oh Send the pipelined output to the host
Out-Null Send output to null
Out-Printer lp Send the output to a printer
Out-String Send objects to the host as strings
p
Powershell Launch a powershell session
Convert-Path cvpa Convert a ps path to a provider path
Join-Path Combine a path and child-path
Resolve-Path rvpa Resolves the wildcards in a path
Split-Path Return part of a path
Test-Path Return true if the path exists, otherwise return false
Get-Pfxcertificate Get pfx certificate information
Pop-Location popd Set the current working location from the stack
Push-Location pushd Push a location to the stack
Get-Process ps/gps Get a list of processes on a machine
Stop-Process kill/spps Stop a running process
Clear-ItemProperty clp Remove the property value from a property
Copy-ItemProperty cpp Copy a property along with it's value
Get-ItemProperty gp Retrieve the properties of an object
Move-ItemProperty mp Move a property from one location to another
New-ItemProperty Set a new property
Remove-ItemProperty rp Remove a property and its value
Rename-ItemProperty rnp Renames a property at its location
Set-ItemProperty sp Set a property at the specified location to a specified value
Get-PsProvider Get information for the specified provider
Set-PSdebug Turn script debugging on or off
Add-PsSnapIn Add snap-ins to the console
Get-PsSnapin List PowerShell snap-ins on this computer
Remove-PSSnapin Remove PowerShell snap-ins from the console
r
Read-Host Read a line of input from the host console
Remove-Item rm/del/erase/rd/ri/rmdir Remove an item
Rename-Item ren/rni Change the name of an existing item
Rename-ItemProperty Rename a property of an item
s
Get-Service gsv Get a list of services
New-Service Create a new service
Restart-Service Stop and then restart a service
Resume-Service Resume a suspended service
Set-Service Change the start mode/properties of a service
Sort-Object sort Sort objects by property value
Start-Service sasv Start a stopped service
Stop-Service spsv Stop a running service
Suspend-Service Suspend a running service
Start-Sleep sleep Suspend shell, script, or runspace activity
Select-String Search through strings or files for patterns
t
Tee-Object Send input objects to two places
New-Timespan Create a timespan object
Trace-Command Trace an expression or command
Get-Tracesource Get components that are instrumented for tracing.
Set-Tracesource Trace a PowerShell component
Start-Transcript Start a transcript of a command shell session
Stop-Transcript Stop the transcription process
u
Get-Uiculture Get the ui culture information
Get-Unique gu Get the unique items in a collection
Update-Formatdata Update and append format data files
Update-Typedata Update the current extended type configuration
v
Clear-Variable clv Remove the value from a variable
Get-Variable gv Get a powershell variable
New-Variable nv Create a new variable
Remove-Variable rv Remove a variable and its value
Set-Variable set/sv Set a variable and a value
w
Where-Object where Filter input from the pipeline
While (condition) {action} else {action}
Get-WMIobject Get WMI class information
Write-Debug Write a debug message to the host display
Write-Error Write an object to the error pipeline.
Write-Output echo Write an object to the pipeline
Write-Progress Display a progress bar
Write-Verbose Write a string to the host's verbose display
Write-Warning Write a warning message
# Comment / Remark
DOS
ADDUSERS Add or list users to/from a CSV file
ARP Address Resolution Protocol
~ ASSOC Change file extension associations
ASSOCIAT One step file association
AT Schedule a command to run at a later time
ATTRIB Change file attributes
b
BOOTCFG Edit Windows boot settings
BROWSTAT Get domain, browser and PDC info
c
CACLS Change file permissions
~ CALL Call one batch program from another
~ CD Change Directory - move to a specific Folder
CHANGE Change Terminal Server Session properties
CHKDSK Check Disk - check and repair disk problems
CHKNTFS Check the NTFS file system
CHOICE Accept keyboard input to a batch file
CIPHER Encrypt or Decrypt files/folders
CleanMgr Automated cleanup of Temp files, recycle bin
CLEARMEM Clear memory leaks
CLIP Copy STDIN to the Windows clipboard.
~ CLS Clear the screen
CLUSTER Windows Clustering
CMD Start a new CMD shell
~ COLOR Change colors of the CMD window
COMP Compare the contents of two files or sets of files
COMPACT Compress files or folders on an NTFS partition
COMPRESS Compress individual files on an NTFS partition
CON2PRT Connect or disconnect a Printer
CONVERT Convert a FAT drive to NTFS.
~ COPY Copy one or more files to another location
CSCcmd Client-side caching (Offline Files)
CSVDE Import or Export Active Directory data
d
~ DATE Display or set the date
Dcomcnfg DCOM Configuration Utility
DEFRAG Defragment hard drive
~ DEL Delete one or more files
DELPROF Delete NT user profiles
DELTREE Delete a folder and all subfolders
DevCon Device Manager Command Line Utility
~ DIR Display a list of files and folders
DIRUSE Display disk usage
DISKCOMP Compare the contents of two floppy disks
DISKCOPY Copy the contents of one floppy disk to another
DISKPART Disk Administration
DNSSTAT DNS Statistics
DOSKEY Edit command line, recall commands, and create macros
DSADD Add user (computer, group..) to active directory
DSQUERY List items in active directory
DSMOD Modify user (computer, group..) in active directory
e
~ ECHO Display message on screen
~ ENDLOCAL End localisation of environment changes in a batch file
~ ERASE Delete one or more files
~ EXIT Quit the current script/routine and set an errorlevel.
EXPAND Uncompress files
EXTRACT Uncompress CAB files
f
FC Compare two files
FIND Search for a text string in a file
FINDSTR Search for strings in files
~ FOR /F Loop command: against a set of files
~ FOR /F Loop command: against the results of another command
~ FOR Loop command: all options Files, Directory, List
FORFILES Batch process multiple files
FORMAT Format a disk
FREEDISK Check free disk space (in bytes)
FSUTIL File and Volume utilities
FTP File Transfer Protocol
~ FTYPE Display or modify file types used in file extension associations
g
GLOBAL Display membership of global groups
~ GOTO Direct a batch program to jump to a labelled line
h
HELP Online Help
i
~ IF Conditionally perform a command
IFMEMBER Is the current user in an NT Workgroup
IPCONFIG Configure IP
k
KILL Remove a program from memory
l
LABEL Edit a disk label
LOCAL Display membership of local groups
LOGEVENT Write text to the NT event viewer.
LOGOFF Log a user off
LOGTIME Log the date and time in a file
m
MAPISEND Send email from the command line
MBSAcli Baseline Security Analyzer.
MEM Display memory usage
~ MD Create new folders
MKLINK Create a symbolic link (linkd)
MODE Configure a system device
MORE Display output, one screen at a time
MOUNTVOL Manage a volume mount point
~ MOVE Move files from one folder to another
MOVEUSER Move a user from one domain to another
MSG Send a message
MSIEXEC Microsoft Windows Installer
MSINFO Windows NT diagnostics
MSTSC Terminal Server Connection (Remote Desktop Protocol)
MUNGE Find and Replace text within file(s)
MV Copy in-use files
n
NET Manage network resources
NETDOM Domain Manager
NETSH Configure network protocols
NETSVC Command-line Service Controller
NBTSTAT Display networking statistics (NetBIOS over TCP/IP)
NETSTAT Display networking statistics (TCP/IP)
NOW Display the current Date and Time
NSLOOKUP Name server lookup
NTBACKUP Backup folders to tape
NTRIGHTS Edit user account rights
p
~ PATH Display or set a search path for executable files
PATHPING Trace route plus network latency and packet loss
~ PAUSE Suspend processing of a batch file and display a message
PERMS Show permissions for a user
PERFMON Performance Monitor
PING Test a network connection
~ POPD Restore the previous value of the current directory saved by PUSHD
PORTQRY Display the status of ports and services
PRINT Print a text file
PRNCNFG Display, configure or rename a printer
PRNMNGR Add, delete, list printers set the default printer
~ PROMPT Change the command prompt
PsExec Execute process remotely
PsFile Show files opened remotely
PsGetSid Display the SID of a computer or a user
PsInfo List information about a system
PsKill Kill processes by name or process ID
PsList List detailed information about processes
PsLoggedOn Who's logged on (locally or via resource sharing)
PsLogList Event log records
PsPasswd Change account password
PsService View and control services
PsShutdown Shutdown or reboot a computer
PsSuspend Suspend processes
~ PUSHD Save and then change the current directory
q
QGREP Search file(s) for lines that match a given pattern.
r
RASDIAL Manage RAS connections
RASPHONE Manage RAS connections
RECOVER Recover a damaged file from a defective disk.
REG Registry: Read, Set, Export, Delete keys and values
REGEDIT Import or export registry settings
REGSVR32 Register or unregister a DLL
REGINI Change Registry Permissions
~ REM Record comments (remarks) in a batch file
~ REN Rename a file or files.
REPLACE Replace or update one file with another
~ RD Delete folder(s)
RMTSHARE Share a folder or a printer
ROBOCOPY Robust File and Folder Copy
ROUTE Manipulate network routing tables
RUNAS Execute a program under a different user account
RUNDLL32 Run a DLL command (add/remove print connections)
s
SC Service Control
SCHTASKS Create or Edit Scheduled Tasks
SCLIST Display NT Services
~ SET Display, set, or remove environment variables
~ SETLOCAL Control the visibility of environment variables
SETX Set environment variables permanently
SHARE List or edit a file share or print share
~ SHIFT Shift the position of replaceable parameters in a batch file
SHORTCUT Create a windows shortcut (.LNK file)
SHOWGRPS List the NT Workgroups a user has joined
SHOWMBRS List the Users who are members of a Workgroup
SHUTDOWN Shutdown the computer
SLEEP Wait for x seconds
SOON Schedule a command to run in the near future
SORT Sort input
~ START Start a program or command in a separate window.
SU Switch User
SUBINACL Edit file and folder Permissions, Ownership and Domain
SUBST Associate a path with a drive letter
SYSTEMINFO List system configuration
t
TASKLIST List running applications and services
TASKKILL Remove a running process from memory
~ TIME Display or set the system time
TIMEOUT Delay processing of a batch file
~ TITLE Set the window title for a CMD.EXE session
TLIST Task list with full path
TOUCH Change file timestamps
TRACERT Trace route to a remote host
TREE Graphical display of folder structure
~ TYPE Display the contents of a text file
u
USRSTAT List domain usernames and last login
v
~ VER Display version information
~ VERIFY Verify that files have been saved
~ VOL Display a disk label
w
WHERE Locate and display files in a directory tree
WHOAMI Output the current UserName and domain
WINDIFF Compare the contents of two files or sets of files
WINMSD Windows system diagnostics
WINMSDP Windows system diagnostics II
WMIC WMI Commands
x
XCACLS Change file permissions
XCOPY Copy files and folders
~ :: Comment / Remark
Parameters Command Line Parameters %1 %~f1
Variables Create/read environment variables
Redirection Spooling output to a file, piping input
AND/OR Logic Conditional Execution (If-Then-Else)
Loops Loops and Subroutines
Services List of Windows XP Services
Evaluating expressions
Using brackets to Group and expand expressions
SET /A Environment variable arithmetic
VarSubstring Extract part of a variable (substring)
VarSearch Search & replace part of a variable
Escape chars, delimiters and quotes
Wildcards Match multiple files
Batch Files
DateMath.zip Add or subtract days from any date
GetDate.cmd Get todays date (any region, any OS)
GetTime.cmd Get the time now
datetime.vbs Get Date, Time and daylight savings
deQuote Remove quotes from a string
DelOlder.cmd Delete files more than n days old
StampMe.cmd Rename a file with the date/time
StampMS.cmd Rename with date/time (milliseconds)
Which.cmd Display full path to any command
Reference/How to
Slow Browsing Speed up network browsing
Printing Printer connections and print drivers
Qchange Script to change Printer connections
Permissions Local vs Global workgroups
Long Filenames NTFS filename issues
WorkGroups Built-In Users and Security Groups
autoexec Run commands at startup
Recovery The Recovery Console
WinXP Registry User interface settings
ARP Address Resolution Protocol
~ ASSOC Change file extension associations
ASSOCIAT One step file association
AT Schedule a command to run at a later time
ATTRIB Change file attributes
b
BOOTCFG Edit Windows boot settings
BROWSTAT Get domain, browser and PDC info
c
CACLS Change file permissions
~ CALL Call one batch program from another
~ CD Change Directory - move to a specific Folder
CHANGE Change Terminal Server Session properties
CHKDSK Check Disk - check and repair disk problems
CHKNTFS Check the NTFS file system
CHOICE Accept keyboard input to a batch file
CIPHER Encrypt or Decrypt files/folders
CleanMgr Automated cleanup of Temp files, recycle bin
CLEARMEM Clear memory leaks
CLIP Copy STDIN to the Windows clipboard.
~ CLS Clear the screen
CLUSTER Windows Clustering
CMD Start a new CMD shell
~ COLOR Change colors of the CMD window
COMP Compare the contents of two files or sets of files
COMPACT Compress files or folders on an NTFS partition
COMPRESS Compress individual files on an NTFS partition
CON2PRT Connect or disconnect a Printer
CONVERT Convert a FAT drive to NTFS.
~ COPY Copy one or more files to another location
CSCcmd Client-side caching (Offline Files)
CSVDE Import or Export Active Directory data
d
~ DATE Display or set the date
Dcomcnfg DCOM Configuration Utility
DEFRAG Defragment hard drive
~ DEL Delete one or more files
DELPROF Delete NT user profiles
DELTREE Delete a folder and all subfolders
DevCon Device Manager Command Line Utility
~ DIR Display a list of files and folders
DIRUSE Display disk usage
DISKCOMP Compare the contents of two floppy disks
DISKCOPY Copy the contents of one floppy disk to another
DISKPART Disk Administration
DNSSTAT DNS Statistics
DOSKEY Edit command line, recall commands, and create macros
DSADD Add user (computer, group..) to active directory
DSQUERY List items in active directory
DSMOD Modify user (computer, group..) in active directory
e
~ ECHO Display message on screen
~ ENDLOCAL End localisation of environment changes in a batch file
~ ERASE Delete one or more files
~ EXIT Quit the current script/routine and set an errorlevel.
EXPAND Uncompress files
EXTRACT Uncompress CAB files
f
FC Compare two files
FIND Search for a text string in a file
FINDSTR Search for strings in files
~ FOR /F Loop command: against a set of files
~ FOR /F Loop command: against the results of another command
~ FOR Loop command: all options Files, Directory, List
FORFILES Batch process multiple files
FORMAT Format a disk
FREEDISK Check free disk space (in bytes)
FSUTIL File and Volume utilities
FTP File Transfer Protocol
~ FTYPE Display or modify file types used in file extension associations
g
GLOBAL Display membership of global groups
~ GOTO Direct a batch program to jump to a labelled line
h
HELP Online Help
i
~ IF Conditionally perform a command
IFMEMBER Is the current user in an NT Workgroup
IPCONFIG Configure IP
k
KILL Remove a program from memory
l
LABEL Edit a disk label
LOCAL Display membership of local groups
LOGEVENT Write text to the NT event viewer.
LOGOFF Log a user off
LOGTIME Log the date and time in a file
m
MAPISEND Send email from the command line
MBSAcli Baseline Security Analyzer.
MEM Display memory usage
~ MD Create new folders
MKLINK Create a symbolic link (linkd)
MODE Configure a system device
MORE Display output, one screen at a time
MOUNTVOL Manage a volume mount point
~ MOVE Move files from one folder to another
MOVEUSER Move a user from one domain to another
MSG Send a message
MSIEXEC Microsoft Windows Installer
MSINFO Windows NT diagnostics
MSTSC Terminal Server Connection (Remote Desktop Protocol)
MUNGE Find and Replace text within file(s)
MV Copy in-use files
n
NET Manage network resources
NETDOM Domain Manager
NETSH Configure network protocols
NETSVC Command-line Service Controller
NBTSTAT Display networking statistics (NetBIOS over TCP/IP)
NETSTAT Display networking statistics (TCP/IP)
NOW Display the current Date and Time
NSLOOKUP Name server lookup
NTBACKUP Backup folders to tape
NTRIGHTS Edit user account rights
p
~ PATH Display or set a search path for executable files
PATHPING Trace route plus network latency and packet loss
~ PAUSE Suspend processing of a batch file and display a message
PERMS Show permissions for a user
PERFMON Performance Monitor
PING Test a network connection
~ POPD Restore the previous value of the current directory saved by PUSHD
PORTQRY Display the status of ports and services
PRINT Print a text file
PRNCNFG Display, configure or rename a printer
PRNMNGR Add, delete, list printers set the default printer
~ PROMPT Change the command prompt
PsExec Execute process remotely
PsFile Show files opened remotely
PsGetSid Display the SID of a computer or a user
PsInfo List information about a system
PsKill Kill processes by name or process ID
PsList List detailed information about processes
PsLoggedOn Who's logged on (locally or via resource sharing)
PsLogList Event log records
PsPasswd Change account password
PsService View and control services
PsShutdown Shutdown or reboot a computer
PsSuspend Suspend processes
~ PUSHD Save and then change the current directory
q
QGREP Search file(s) for lines that match a given pattern.
r
RASDIAL Manage RAS connections
RASPHONE Manage RAS connections
RECOVER Recover a damaged file from a defective disk.
REG Registry: Read, Set, Export, Delete keys and values
REGEDIT Import or export registry settings
REGSVR32 Register or unregister a DLL
REGINI Change Registry Permissions
~ REM Record comments (remarks) in a batch file
~ REN Rename a file or files.
REPLACE Replace or update one file with another
~ RD Delete folder(s)
RMTSHARE Share a folder or a printer
ROBOCOPY Robust File and Folder Copy
ROUTE Manipulate network routing tables
RUNAS Execute a program under a different user account
RUNDLL32 Run a DLL command (add/remove print connections)
s
SC Service Control
SCHTASKS Create or Edit Scheduled Tasks
SCLIST Display NT Services
~ SET Display, set, or remove environment variables
~ SETLOCAL Control the visibility of environment variables
SETX Set environment variables permanently
SHARE List or edit a file share or print share
~ SHIFT Shift the position of replaceable parameters in a batch file
SHORTCUT Create a windows shortcut (.LNK file)
SHOWGRPS List the NT Workgroups a user has joined
SHOWMBRS List the Users who are members of a Workgroup
SHUTDOWN Shutdown the computer
SLEEP Wait for x seconds
SOON Schedule a command to run in the near future
SORT Sort input
~ START Start a program or command in a separate window.
SU Switch User
SUBINACL Edit file and folder Permissions, Ownership and Domain
SUBST Associate a path with a drive letter
SYSTEMINFO List system configuration
t
TASKLIST List running applications and services
TASKKILL Remove a running process from memory
~ TIME Display or set the system time
TIMEOUT Delay processing of a batch file
~ TITLE Set the window title for a CMD.EXE session
TLIST Task list with full path
TOUCH Change file timestamps
TRACERT Trace route to a remote host
TREE Graphical display of folder structure
~ TYPE Display the contents of a text file
u
USRSTAT List domain usernames and last login
v
~ VER Display version information
~ VERIFY Verify that files have been saved
~ VOL Display a disk label
w
WHERE Locate and display files in a directory tree
WHOAMI Output the current UserName and domain
WINDIFF Compare the contents of two files or sets of files
WINMSD Windows system diagnostics
WINMSDP Windows system diagnostics II
WMIC WMI Commands
x
XCACLS Change file permissions
XCOPY Copy files and folders
~ :: Comment / Remark
Parameters Command Line Parameters %1 %~f1
Variables Create/read environment variables
Redirection Spooling output to a file, piping input
AND/OR Logic Conditional Execution (If-Then-Else)
Loops Loops and Subroutines
Services List of Windows XP Services
Evaluating expressions
Using brackets to Group and expand expressions
SET /A Environment variable arithmetic
VarSubstring Extract part of a variable (substring)
VarSearch Search & replace part of a variable
Escape chars, delimiters and quotes
Wildcards Match multiple files
Batch Files
DateMath.zip Add or subtract days from any date
GetDate.cmd Get todays date (any region, any OS)
GetTime.cmd Get the time now
datetime.vbs Get Date, Time and daylight savings
deQuote Remove quotes from a string
DelOlder.cmd Delete files more than n days old
StampMe.cmd Rename a file with the date/time
StampMS.cmd Rename with date/time (milliseconds)
Which.cmd Display full path to any command
Reference/How to
Slow Browsing Speed up network browsing
Printing Printer connections and print drivers
Qchange Script to change Printer connections
Permissions Local vs Global workgroups
Long Filenames NTFS filename issues
WorkGroups Built-In Users and Security Groups
autoexec Run commands at startup
Recovery The Recovery Console
WinXP Registry User interface settings
bash command
alias Create an alias
apropos Search Help manual pages (man -k)
apt-get Search for and install software packages (Debian)
aspell Spell Checker
awk Find and Replace text, database sort/validate/index
b
bash GNU Bourne-Again SHell
bc Arbitrary precision calculator language
bg Send to background
break Exit from a loop
builtin Run a shell builtin
bzip2 Compress or decompress named file(s)
c
cal Display a calendar
case Conditionally perform a command
cat Display the contents of a file
cd Change Directory
cfdisk Partition table manipulator for Linux
chgrp Change group ownership
chmod Change access permissions
chown Change file owner and group
chroot Run a command with a different root directory
cksum Print CRC checksum and byte counts
clear Clear terminal screen
cmp Compare two files
comm Compare two sorted files line by line
command Run a command - ignoring shell functions
continue Resume the next iteration of a loop
cp Copy one or more files to another location
cron Daemon to execute scheduled commands
crontab Schedule a command to run at a later time
csplit Split a file into context-determined pieces
cut Divide a file into several parts
d
date Display or change the date & time
dc Desk Calculator
dd Convert and copy a file, write disk headers, boot records
ddrescue Data recovery tool
declare Declare variables and give them attributes
df Display free disk space
diff Display the differences between two files
diff3 Show differences among three files
dig DNS lookup
dir Briefly list directory contents
dircolors Colour setup for `ls'
dirname Convert a full pathname to just a path
dirs Display list of remembered directories
du Estimate file space usage
e
echo Display message on screen
egrep Search file(s) for lines that match an extended expression
eject Eject removable media
enable Enable and disable builtin shell commands
env Environment variables
ethtool Ethernet card settings
eval Evaluate several commands/arguments
exec Execute a command
exit Exit the shell
expect Automate arbitrary applications accessed over a terminal
expand Convert tabs to spaces
export Set an environment variable
expr Evaluate expressions
f
false Do nothing, unsuccessfully
fdformat Low-level format a floppy disk
fdisk Partition table manipulator for Linux
fg Send job to foreground
fgrep Search file(s) for lines that match a fixed string
file Determine file type
find Search for files that meet a desired criteria
fmt Reformat paragraph text
fold Wrap text to fit a specified width.
for Expand words, and execute commands
format Format disks or tapes
free Display memory usage
fsck File system consistency check and repair
ftp File Transfer Protocol
function Define Function Macros
g
gawk Find and Replace text within file(s)
getopts Parse positional parameters
grep Search file(s) for lines that match a given pattern
groups Print group names a user is in
gzip Compress or decompress named file(s)
h
hash Remember the full pathname of a name argument
head Output the first part of file(s)
history Command History
hostname Print or set system name
i
id Print user and group id's
if Conditionally perform a command
ifconfig Configure a network interface
ifdown Stop a network interface
ifup Start a network interface up
import Capture an X server screen and save the image to file
install Copy files and set attributes
j
join Join lines on a common field
k
kill Stop a process from running
l
less Display output one screen at a time
let Perform arithmetic on shell variables
ln Make links between files
local Create variables
locate Find files
logname Print current login name
logout Exit a login shell
look Display lines beginning with a given string
lpc Line printer control program
lpr Off line print
lprint Print a file
lprintd Abort a print job
lprintq List the print queue
lprm Remove jobs from the print queue
ls List information about file(s)
lsof List open files
m
make Recompile a group of programs
man Help manual
mkdir Create new folder(s)
mkfifo Make FIFOs (named pipes)
mkisofs Create an hybrid ISO9660/JOLIET/HFS filesystem
mknod Make block or character special files
more Display output one screen at a time
mount Mount a file system
mtools Manipulate MS-DOS files
mv Move or rename files or directories
n
netstat Networking information
nice Set the priority of a command or job
nl Number lines and write files
nohup Run a command immune to hangups
nslookup Query Internet name servers interactively
o
open Open a file in its default application
op Operator access
p
passwd Modify a user password
paste Merge lines of files
pathchk Check file name portability
ping Test a network connection
popd Restore the previous value of the current directory
pr Prepare files for printing
printcap Printer capability database
printenv Print environment variables
printf Format and print data
ps Process status
pushd Save and then change the current directory
pwd Print Working Directory
q
quota Display disk usage and limits
quotacheck Scan a file system for disk usage
quotactl Set disk quotas
r
ram ram disk device
rcp Copy files between two machines.
read read a line from standard input
readonly Mark variables/functions as readonly
renice Alter priority of running processes
remsync Synchronize remote files via email
return Exit a shell function
rev Reverse lines of a file
rm Remove files
rmdir Remove folder(s)
rsync Remote file copy (Synchronize file trees)
s
screen Multiplex terminal, run remote shells via ssh
scp Secure copy (remote file copy)
sdiff Merge two files interactively
sed Stream Editor
select Accept keyboard input
seq Print numeric sequences
set Manipulate shell variables and functions
sftp Secure File Transfer Program
shift Shift positional parameters
shopt Shell Options
shutdown Shutdown or restart linux
sleep Delay for a specified time
slocate Find files
sort Sort text files
source Run commands from a file `.'
split Split a file into fixed-size pieces
ssh Secure Shell client (remote login program)
strace Trace system calls and signals
su Substitute user identity
sudo Execute a command as another user
sum Print a checksum for a file
symlink Make a new name for a file
sync Synchronize data on disk with memory
t
tail Output the last part of files
tar Tape ARchiver
tee Redirect output to multiple files
test Evaluate a conditional expression
time Measure Program running time
times User and system times
touch Change file timestamps
top List processes running on the system
traceroute Trace Route to Host
trap Run a command when a signal is set(bourne)
tr Translate, squeeze, and/or delete characters
true Do nothing, successfully
tsort Topological sort
tty Print filename of terminal on stdin
type Describe a command
u
ulimit Limit user resources
umask Users file creation mask
umount Unmount a device
unalias Remove an alias
uname Print system information
unexpand Convert spaces to tabs
uniq Uniquify files
units Convert units from one scale to another
unset Remove variable or function names
unshar Unpack shell archive scripts
until Execute commands (until error)
useradd Create new user account
usermod Modify user account
users List users currently logged in
uuencode Encode a binary file
uudecode Decode a file created by uuencode
v
v Verbosely list directory contents (`ls -l -b')
vdir Verbosely list directory contents (`ls -l -b')
vi Text Editor
vmstat Report virtual memory statistics
w
watch Execute/display a program periodically
wc Print byte, word, and line counts
whereis Report all known instances of a command
which Locate a program file in the user's path.
while Execute commands
who Print all usernames currently logged in
whoami Print the current user id and name (`id -un')
Wget Retrieve web pages or files via HTTP, HTTPS or FTP
write Send a message to another user
x
xargs Execute utility, passing constructed argument list(s)
yes Print a string until interrupted
. Run a command script in the current shell
### Comment / Remark
apropos Search Help manual pages (man -k)
apt-get Search for and install software packages (Debian)
aspell Spell Checker
awk Find and Replace text, database sort/validate/index
b
bash GNU Bourne-Again SHell
bc Arbitrary precision calculator language
bg Send to background
break Exit from a loop
builtin Run a shell builtin
bzip2 Compress or decompress named file(s)
c
cal Display a calendar
case Conditionally perform a command
cat Display the contents of a file
cd Change Directory
cfdisk Partition table manipulator for Linux
chgrp Change group ownership
chmod Change access permissions
chown Change file owner and group
chroot Run a command with a different root directory
cksum Print CRC checksum and byte counts
clear Clear terminal screen
cmp Compare two files
comm Compare two sorted files line by line
command Run a command - ignoring shell functions
continue Resume the next iteration of a loop
cp Copy one or more files to another location
cron Daemon to execute scheduled commands
crontab Schedule a command to run at a later time
csplit Split a file into context-determined pieces
cut Divide a file into several parts
d
date Display or change the date & time
dc Desk Calculator
dd Convert and copy a file, write disk headers, boot records
ddrescue Data recovery tool
declare Declare variables and give them attributes
df Display free disk space
diff Display the differences between two files
diff3 Show differences among three files
dig DNS lookup
dir Briefly list directory contents
dircolors Colour setup for `ls'
dirname Convert a full pathname to just a path
dirs Display list of remembered directories
du Estimate file space usage
e
echo Display message on screen
egrep Search file(s) for lines that match an extended expression
eject Eject removable media
enable Enable and disable builtin shell commands
env Environment variables
ethtool Ethernet card settings
eval Evaluate several commands/arguments
exec Execute a command
exit Exit the shell
expect Automate arbitrary applications accessed over a terminal
expand Convert tabs to spaces
export Set an environment variable
expr Evaluate expressions
f
false Do nothing, unsuccessfully
fdformat Low-level format a floppy disk
fdisk Partition table manipulator for Linux
fg Send job to foreground
fgrep Search file(s) for lines that match a fixed string
file Determine file type
find Search for files that meet a desired criteria
fmt Reformat paragraph text
fold Wrap text to fit a specified width.
for Expand words, and execute commands
format Format disks or tapes
free Display memory usage
fsck File system consistency check and repair
ftp File Transfer Protocol
function Define Function Macros
g
gawk Find and Replace text within file(s)
getopts Parse positional parameters
grep Search file(s) for lines that match a given pattern
groups Print group names a user is in
gzip Compress or decompress named file(s)
h
hash Remember the full pathname of a name argument
head Output the first part of file(s)
history Command History
hostname Print or set system name
i
id Print user and group id's
if Conditionally perform a command
ifconfig Configure a network interface
ifdown Stop a network interface
ifup Start a network interface up
import Capture an X server screen and save the image to file
install Copy files and set attributes
j
join Join lines on a common field
k
kill Stop a process from running
l
less Display output one screen at a time
let Perform arithmetic on shell variables
ln Make links between files
local Create variables
locate Find files
logname Print current login name
logout Exit a login shell
look Display lines beginning with a given string
lpc Line printer control program
lpr Off line print
lprint Print a file
lprintd Abort a print job
lprintq List the print queue
lprm Remove jobs from the print queue
ls List information about file(s)
lsof List open files
m
make Recompile a group of programs
man Help manual
mkdir Create new folder(s)
mkfifo Make FIFOs (named pipes)
mkisofs Create an hybrid ISO9660/JOLIET/HFS filesystem
mknod Make block or character special files
more Display output one screen at a time
mount Mount a file system
mtools Manipulate MS-DOS files
mv Move or rename files or directories
n
netstat Networking information
nice Set the priority of a command or job
nl Number lines and write files
nohup Run a command immune to hangups
nslookup Query Internet name servers interactively
o
open Open a file in its default application
op Operator access
p
passwd Modify a user password
paste Merge lines of files
pathchk Check file name portability
ping Test a network connection
popd Restore the previous value of the current directory
pr Prepare files for printing
printcap Printer capability database
printenv Print environment variables
printf Format and print data
ps Process status
pushd Save and then change the current directory
pwd Print Working Directory
q
quota Display disk usage and limits
quotacheck Scan a file system for disk usage
quotactl Set disk quotas
r
ram ram disk device
rcp Copy files between two machines.
read read a line from standard input
readonly Mark variables/functions as readonly
renice Alter priority of running processes
remsync Synchronize remote files via email
return Exit a shell function
rev Reverse lines of a file
rm Remove files
rmdir Remove folder(s)
rsync Remote file copy (Synchronize file trees)
s
screen Multiplex terminal, run remote shells via ssh
scp Secure copy (remote file copy)
sdiff Merge two files interactively
sed Stream Editor
select Accept keyboard input
seq Print numeric sequences
set Manipulate shell variables and functions
sftp Secure File Transfer Program
shift Shift positional parameters
shopt Shell Options
shutdown Shutdown or restart linux
sleep Delay for a specified time
slocate Find files
sort Sort text files
source Run commands from a file `.'
split Split a file into fixed-size pieces
ssh Secure Shell client (remote login program)
strace Trace system calls and signals
su Substitute user identity
sudo Execute a command as another user
sum Print a checksum for a file
symlink Make a new name for a file
sync Synchronize data on disk with memory
t
tail Output the last part of files
tar Tape ARchiver
tee Redirect output to multiple files
test Evaluate a conditional expression
time Measure Program running time
times User and system times
touch Change file timestamps
top List processes running on the system
traceroute Trace Route to Host
trap Run a command when a signal is set(bourne)
tr Translate, squeeze, and/or delete characters
true Do nothing, successfully
tsort Topological sort
tty Print filename of terminal on stdin
type Describe a command
u
ulimit Limit user resources
umask Users file creation mask
umount Unmount a device
unalias Remove an alias
uname Print system information
unexpand Convert spaces to tabs
uniq Uniquify files
units Convert units from one scale to another
unset Remove variable or function names
unshar Unpack shell archive scripts
until Execute commands (until error)
useradd Create new user account
usermod Modify user account
users List users currently logged in
uuencode Encode a binary file
uudecode Decode a file created by uuencode
v
v Verbosely list directory contents (`ls -l -b')
vdir Verbosely list directory contents (`ls -l -b')
vi Text Editor
vmstat Report virtual memory statistics
w
watch Execute/display a program periodically
wc Print byte, word, and line counts
whereis Report all known instances of a command
which Locate a program file in the user's path.
while Execute commands
who Print all usernames currently logged in
whoami Print the current user id and name (`id -un')
Wget Retrieve web pages or files via HTTP, HTTPS or FTP
write Send a message to another user
x
xargs Execute utility, passing constructed argument list(s)
yes Print a string until interrupted
. Run a command script in the current shell
### Comment / Remark
FIFO(LINUX)
Book to be followed : UNIX Network Programming by W.Richard Stevens
Chapter-3
FIFO stands for First In First Out. Named pipes exist as device
special files in the file system. [pipes] can be used for IPC only
between processes of common ancestors, whereas processes of different
ancestors can share data through named pipes. After the I/O operation
(IPC) by the processes, the FIFO remains in the file system for later
use unless explicitly removed. Like pipes, FIFO allows one way flow of
data. For both-way communication two FIFOs are used. Unlike pipes FIFO
does not have separate read-end and write-end.
Create a directory [ fifo ] in your home directory. The assignments
should be done in this directory.
$ mkdir $HOME/fifo
$ cd $HOME/fifo
$ ftp IP-address-of-laboratory-FTP-server
Bring the file [fifo.txt] in $HOME/fifo directory.
Creation of FIFO:
A FIFO can be created with [ mknod ] shell command.
$ /bin/mknod ./aaa -m 0666 p
Check creation of of a FIFO [aaa] in the current directory.
$ file ./aaa
A FIFO can also be created with shell command [ mkfifo ].
Create a FIFO [ ./xxx ] under [ /tmp/ ] directory with read and write
permissions for group and others
$ mkfifo /tmp/xxx -m 0606
The created FIFO is checked with two commands and their likely outputs
are shown below
$ ls -l /tmp/xxx
total 0
prw----rw- 1 _______ ______ 0 Sep 25 15:39 xxx
$ file /tmp/xxx
/tmp/xxx: fifo (named pipe)
Delete the FIFO [/tmp/xxx].
$ rm /tmp/xxx
FIFO can be created by system call [mknod(2)]. Read [ mknod(2) ]. This
system call is not in POSIX. In the following example library function
[ mkfifo(3) ] is used to create FIFO as this is POSIX compliant. Read
manual [ mkfifo(3) ].
A client-server model is described using a FIFO. In this example, one
way communication, from client to server, is described using a single
FIFO.
Copy the following code in a file named [f1.c].
-------------------------------------------------------------------
// file-name f1.c
// one way FIFO server - reads data from client
// and prints on standard output
#include
#include
#include
#include
#include
#include
#include
#define FIFOPATH "/tmp/your-name"
#define MODE ( S_IFIFO | S_IRUSR | S_IWUSR | S_IROTH | S_IWOTH )
// it is a FIFO, user and others have read and write permissions
#define BUFFERSIZE 1024
extern int errno;
int main ( void )
{
int fdr,fdw,n;
ssize_t i;
char buffer[BUFFERSIZE];
// remove stale FIFO if any
n = unlink( FIFOPATH );
if( n == -1 ) { perror("unlink"); } // note absence of exit()
else printf("removed stale FIFO %s\n", FIFOPATH );
// file creation mask is cleared
umask(0000);
// a FIFO is tried to be created
n = mkfifo( FIFOPATH, MODE );
if( n == -1 ) { perror("mkfifo"); exit(1); }
printf("created FIFO <%s> \n", FIFOPATH );
// server reads data from client from this descriptor
fdr = open( FIFOPATH, O_RDONLY );
if( fdr == -1 ) { perror("open-rdonly"); exit(1); }
fdw = open( FIFOPATH, O_WRONLY );
if( fdw == -1 ) { perror("open-wronly"); exit(1); }
// this descriptor is not used by the server but it ensures
// that the FIFO has a writer during lifetime of the server
while ( 1 ) //endless loop.
{
printf("waiting for data from a client\n");
memset(buffer, '\0', BUFFERSIZE );
// server reads data from a client
i = read( fdr, buffer, BUFFERSIZE );
if( i == -1 ) { perror("read"); exit(1); }
write( STDOUT_FILENO, "server: from client-> ", 22 );
write( STDOUT_FILENO, buffer, i );
//printf("%s\n", buffer );
}
close(fdr); close(fdw);
return 0;
}
-------------------------------------------------------------------
A FIFO (/tmp/your-name) is created with [ mkfifo(3) ] library function
with read & write permissions for owner and others. The FIFO is
created in [/tmp/] directory, as this directory has execute permission
for all. Execute permission of a directory means search permission.
All users can access the FIFO in [/tmp/] directory.
The FIFO is opened twice by the server; first in read-only mode and
then in write-only mode.
The server-client arrangement is shown below
---------------------
| |
SERVER <---- fdr | /tmp/_________ | fdw <----- CLIENT
fdw | |
---------------------
When the server starts, it blocks in [open()] call in read-only mode,
as yet there is no other process (a client) which has the FIFO opened
for writing. This can be verified by using [strace] command to run the
server. When the first client starts, server's FIFO is opened in read-
only mode and then in write-only mode. The descriptor [fdw] is not
used further by the server. This open descriptor ensures that a
process has the FIFO opened for writing, even after a client exits.
When no process have the FIFO opened for writing, [read()] call on the
FIFO returns with zero, indicating end of file. This property of FIFO
and pipe, is described in Optional Assignment-2.
When any process have the FIFO opened for writing, [read()] call on
an empty FIFO blocks until there is data in the FIFO.
In the endless loop the server reads the FIFO, when data is written
by a client, prints it in standard output and blocks on [read()] call
for the next client.
Compile the program
$ gcc -Wall ./f1.c -o ./1way-fifo-server
Use the following command
$ strace ./1way-fifo-server
Did the program block in opening FIFO in read-only mode ( Y / n )
Stop the command with CTRL-C
Start the server
$ ./1way-fifo-server
Login as [ guest ] in another terminal. As the FIFO, created by the
server has write permission by others, [ guest ] is able to write into
the FIFO using shell command.
T-4 guest $ echo "I am guest" > /tmp/your-name
Was the server able to receive data from [guest] ? ( Y / n )
You may allow the server to run or terminate with CTRL-C.
Save the following as the FIFO client program.
------------------------------------------------------------------
// file-name f2.c
// One way FIFO client - writes a string to the FIFO server
#include
#include
#include
#include
#define FIFOPATH "/tmp/your-name"
// the FIFOPATH is known to client program. This need not be
// known to users, using the client program
int main( int argc, char *argv[] )
{
int fd;
ssize_t i;
// argument checking
if( argc != 2 )
{
printf("usage: %s \"any-string within quotes\" \n", argv[0] );
exit(1);
}
fd = open( FIFOPATH, O_WRONLY );
if( fd == -1 ) { perror("open"); exit(1); }
// client] writes the string in the server's FIFO
i = write( fd, argv[1], strlen( argv[1] ) );
if( i == -1 ) { perror("write"); exit(1); }
close(fd);
return 0;
}
------------------------------------------------------------------
Compile the program
$ gcc -Wall ./f2.c -o ./1way-fifo-client
Copy the executable in [/tmp/] directory so that all users may run the
client program.
Stale executable if any, has to be removed as [root] user
# rm /tmp/1way-fifo-client
$ cp ./1way-fifo-client /tmp/
Start the server from your account
T-3 you $ ./1way-fifo-server
From other terminals run the client as different users.
T-4 guest $ /tmp/1way-fifo-client "Hi server, this is guest"
T-4 guest $ /tmp/1way-fifo-client "My name is hizbizbiz"
T-5 sumit $ /tmp/1way-fifo-client "My name is Sumit"
Was the server able to receive data from unrelated processes ? (Y / n)
Terminate the server
T-3 you $ CTRL-C
Two FIFOs are used for two way communication between two processes,
if proper permissions of the FIFO exist.
The following is the FIFO server program.
--------------------------------------------------------------
// file-name f3.c Two way FIFO server
#include
#include
#include
#include
#include
#define FIFO1 "/tmp/XX"
#define FIFO2 "/tmp/YY"
#define BUFFERSIZE 4098
#define MODE 0606 // use symbolic constants !
int main ( void )
{
int XXr, XXw, YYw, YYr, n;
ssize_t i,j;
char buffer[BUFFERSIZE];
// remove stale FIFO if any
n = unlink(FIFO1);
if( n == -1 ) perror("unlink-1");
n = unlink(FIFO2);
if( n == -1 ) perror("unlink-2");
umask(0000);
// two FIFOs are created
n = mkfifo( FIFO1, MODE );
if( n == -1 ) { perror("mkfifo-1"); exit(1); }
n = mkfifo( FIFO2, MODE );
if( n == -1 ) { perror("mkfifo-2"); exit(1); }
XXr = open( FIFO1, O_RDONLY );
if( XXr == -1 ) { perror("open-XX-rdonly"); exit(1); }
XXw = open( FIFO1, O_WRONLY );
if( XXw == -1 ) { perror("open-XX-wronly"); exit(1); }
// XXw is not used by server
YYw = open( FIFO2, O_WRONLY );
if( YYw == -1 ) { perror("open-YY-wronly"); exit(1); }
YYr = open( FIFO2, O_RDONLY );
if( YYr == -1 ) { perror("open-YY-rdonly"); exit(1); }
// YYr is not used by server
while ( 1 ) //endless loop.
{
write(STDOUT_FILENO,"waiting for data from client\n", 29);
memset(buffer, '\0', BUFFERSIZE );
// server reads data from client
i = read( XXr, buffer, BUFFERSIZE );
if( i == -1 ) { perror("read"); exit(1); }
write(STDOUT_FILENO, "server: from client-> ", 22 );
j = write(STDOUT_FILENO, buffer, i );
if( j == -1 ) { perror("write-1"); }
// server writes data to client
i = write( YYw,"This is server \n", 16 );
if( i == -1 ) { perror("write-2"); }
}
close(XXr); close(XXw); close(YYw);
return 0;
}
--------------------------------------------------------------
In the above example, the server creates two FIFOs [ /tmp/XX ] and
[ /tmp/YY ] for both way communication.
The arrangement for communication between server and client, using the
two FIFOs is shown below:
------------- ------------
| | <--------- XXr (/tmp/XX) XXwc <---------- | |
| SERVER | | CLIENT |
| | ---------> YYw (/tmp/YY) YYrc ----------> | |
------------- -------------
XXw and YYr are not
used by server
The server opens both the FIFOs for reading and writing. So the server
has four descriptors of the two FIFOs. They are XXr, XXw, YYr and YYw.
The server reads data from a client from XXr and writes data to client
in YYw. Descriptors XXw and YYr are not used by the server.
XXw ensures that FIFO [ /tmp/XX ] always has a writer. The reason for
this was explained in connection with [f1.c].
YYr ensures that FIFO [/tmp/YY] always has a reader even when there is
no client process in existence. If the server writes to the FIFO
[/tmp/YY] when the FIFO has no reader, SIGPIPE signal is delivered to
the server. The default action of this signal is to terminate the
server process, if the signal is not handled. This is a property of
FIFO and pipe. This property is described in Optional Assignment-3.
The following is the client program.
--------------------------------------------------------------
// file-name f4.c Two way FIFO client
#include
#include
#include
#include
#include
#define FIFO1 "/tmp/XX"
#define FIFO2 "/tmp/YY"
#define BUFFERSIZE 4098
int main( void )
{
int XXwc,YYrc;
int n;
ssize_t i;
char buffer[BUFFERSIZE];
char *username;
//If opened in read only mode first, there would be deadlock
XXwc = open( FIFO1, O_WRONLY );
if( XXwc == -1 ) { perror("open-wronly"); exit(1); }
YYrc = open( FIFO2, O_RDONLY );
if( YYrc == -1 ) { perror("open-rdonly"); exit(1); }
username = getlogin();
// buffer is prepared
sprintf( buffer,"I am client <%s>, my uid = %u\n",
username, getuid() );
// buffer is sent to server
n = write( XXwc, buffer, strlen(buffer) );
if( n == -1 ) { perror("write"); exit(1); }
memset( buffer, '\0', BUFFERSIZE );
// reading data from server
i = read(YYrc, buffer, BUFFERSIZE );
write(STDOUT_FILENO, "from server-->", 14 );
write(STDOUT_FILENO, buffer, i );
close(XXwc); close( YYrc );
return 0;
}
--------------------------------------------------------------
Compile
$ gcc -Wall ./f4.c -o ./2way-fifo-client
Copy the executable under [/tmp/] directory
$ cp ./2way-fifo-client /tmp/
Start the server
T-3 you/fifo $ ./2way-fifo-server
Test the server from other terminals and observe the results in the
server's terminal.
T-4 you $ /tmp/2way-fifo-client
T-5 guest $ /tmp/2way-fifo-client
T-6 sumit $ /tmp/2way-fifo-client
Stop server with CTRL-C
T-3 you/fifo $ CTRL-C
Optional Assignment-1.
The [ make ] utility automatically determines
which pieces of a large program need to be recompiled, and issues
commands to recompile them.
The above line is reproduced from "GNU Make Manual". You may read the
manual.
$ info make
[make] utility is described with a VERY simple example. The above 2way
FIFO client-server programs are modified to for the example.
The headers needed for server and client programs are kept in a
file named [headers].
----------------------
// file-name headers
#include
#include
#include
#include
#include
----------------------
The definitions needed for server and client programs are kept in a
file named [definitions].
------------------------------------------------------------------
// file-name definitions
#define FIFO1 "/tmp/XX"
#define FIFO2 "/tmp/YY"
#define BUFFERSIZE 4098
#define MODE ( S_IFIFO | S_IRUSR | S_IWUSR | S_IROTH | S_IWOTH )
// it is a FIFO, user and others have read and write permissions
------------------------------------------------------------------
Save the following lines in a file [f5.c]
--------------------------------------------------------------
// file-name f5.c FIFO server-duplex
#include "headers"
#include "definitions"
int main ( void )
{
int XXr, XXw, YYw, YYr, n;
ssize_t i;
char buffer[BUFFERSIZE];
// remove stale FIFO if any
n = unlink(FIFO1);
if( n == -1 ) perror("unlink-1");
n = unlink(FIFO2);
if( n == -1 ) perror("unlink-2");
umask(0000);
// two FIFOs are created
n = mkfifo( FIFO1, MODE );
if( n == -1 ) { perror("mkfifo-1"); exit(1); }
n = mkfifo( FIFO2, MODE );
if( n == -1 ) { perror("mkfifo-2"); exit(1); }
XXr = open( FIFO1, O_RDONLY );
if( XXr == -1 ) { perror("open-XX-rdonly"); exit(1); }
XXw = open( FIFO1, O_WRONLY );
if( XXw == -1 ) { perror("open-XX-wronly"); exit(1); }
// XXw is not used by server
YYw = open( FIFO2, O_WRONLY );
if( YYw == -1 ) { perror("open-YY-wronly"); exit(1); }
YYr = open( FIFO2, O_RDONLY );
if( YYr == -1 ) { perror("open-YY-rdonly"); exit(1); }
while ( 1 ) //endless loop.
{
write(STDOUT_FILENO,"waiting for data from client\n", 29);
memset(buffer, '\0', BUFFERSIZE );
// server reads data from client
i = read( XXr, buffer, BUFFERSIZE );
if( i == -1 ) { perror("read"); exit(1); }
write(STDOUT_FILENO, "server: from client-> ", 22 );
printf("%s\n", buffer );
// server writes data to client
n = write( YYw,"This is server \n", 16 );
}
close(XXr); close(XXw); close(YYw);
return 0;
}
--------------------------------------------------------------
Save the following lines in a file [f6.c]
--------------------------------------------------------------
// file-name f6.c FIFO client-duplex
#include "headers"
#include "definitions"
int main( void )
{
int XXw,YYr;
int n;
ssize_t i;
char buffer[BUFFERSIZE];
char *username;
//If opened in read only mode first, there would be deadlock
XXw = open( FIFO1, O_WRONLY );
if( XXw == -1 ) { perror("open-wronly"); exit(1); }
YYr = open( FIFO2, O_RDONLY );
if( YYr == -1 ) { perror("open-rdonly"); exit(1); }
username = getlogin();
// buffer is prepared
sprintf( buffer,"I am client <%s>, my uid = %u\n",
username, getuid() );
// buffer is sent to server
n = write( XXw, buffer, strlen(buffer) );
if( n == -1 ) { perror("write"); exit(1); }
memset( buffer, '\0', BUFFERSIZE );
// reading data from server
i = read(YYr, buffer, BUFFERSIZE );
write(STDOUT_FILENO, "from server-->", 14 );
write(STDOUT_FILENO, buffer, i );
close(XXw); close( YYr );
return 0;
}
--------------------------------------------------------------
The [ make ] utility needs a file [ Makefile ] to specify the targets,
prerequisites and rules to create the target. Save the following lines
in a file [Makefile]
--------------------------------------------------------------------
# file-name Makefile
# Using [makefile] as file-name should also work
# [fs] is the target. It depends on one object file [f5.o]
fs : ./f5.o
gcc -Wall ./f5.o -o ./fs
# The rule to make target [fs] is given by the above command
# NOTE: rules must start with a TAB
# target [f5.o] depends on files [f5.c], [headers] and [definitions]
f5.o : ./f5.c ./headers ./definitions
gcc -Wall -c ./f5.c
# Command [ gcc -Wall -c s2.c -o s.o ] should also work; but
# output file-name must not be used, when working with more than
# one input file
# target [fc] depends on the object file [f6.o].
fc : ./f6.o
gcc -Wall ./f6.o -o ./fc
# target [f6.o] depends on files [f6.c], [headers] and [definitions]
f6.o : ./f6.c ./headers ./definitions
gcc -Wall -c ./f6.c
install : ./fs ./fc
/bin/cp ./fs /tmp/fs
/bin/cp ./fc /tmp/fc
clean :
/bin/rm ./f5.o ./f6.o ./fs ./fc
all-clean :
/bin/rm ./f5.o ./f6.o ./fs ./fc /tmp/fs /tmp/fc
--------------------------------------------------------------------
The above [ Makefile ] has seven targets.
In target [install], installation is done in [/tmp/] directory, which
is not done in actual practice. This is done, as it is convenient for
laboratory experiment.
In the following [make] commands, typical outputs are shown.
$ make fs
gcc -Wall -c ./f5.c
gcc -Wall ./f5.o -o ./fs
As the first target depended on [f5.o], the second target [ f5.o ] was
created first and then first target was created.
Note: To examine the intermediate files created in a compilation, use
the following command
$ gcc --save-temp ./f1.c
where [f1.c] is a C source code
Try to make the first target again
$ make fs
make: `fs' is up to date.
Make the other targets:
$ make fc
gcc -Wall -c ./f6.c
gcc -Wall ./f6.o -o ./fc
$ make install
/bin/cp ./fs /tmp/fs
/bin/cp ./fc /tmp/fc
After the installations, the temporary files in the current directory
may be removed with target [clean].
$ make clean
/bin/rm ./f5.o ./f6.o ./fs ./fc
To remove the temporary files in the working directory and the
installed files may be removed with target [all-clean]
$ make all-clean
/bin/rm ./f5.o ./f6.o fs fc /tmp/fs /tmp/fc
/bin/rm: cannot remove `./f5.o': No such file or directory
/bin/rm: cannot remove `./f6.o': No such file or directory
/bin/rm: cannot remove `fs': No such file or directory
/bin/rm: cannot remove `fc': No such file or directory
make: *** [all-clean] Error 1
Try the following command
$ make install
gcc -Wall -c ./f5.c
gcc -Wall ./f5.o -o ./fs
gcc -Wall -c ./f6.c
gcc -Wall ./f6.o -o ./fc
/bin/cp ./fs /tmp/fs
/bin/cp ./fc /tmp/fc
$ make clean
/bin/rm ./f5.o ./f6.o ./fs ./fc
Start the FIFO server from your account
T-3 $ /tmp/fs
Run client from accounts of other users
T-4 guest $ /tmp/fc
T-5 sumit $ /tmp/fc
Was client-server communication possible ? ( Y / n )
Optional Assignment-2.
When a process reads from a FIFO, which has no
writer, [read()] call returns with zero, indicating end of file. This
is not an error. This is a property of FIFO ( and pipe ).
------------------------------------------------------------------
// file-name f7.c
// reading a FIFO with and without writer
//#include
#include
#include
#include
#include
#include
#define FIFO "./xx"
#define MODE 0606 // symbolic constants should be used !
extern int errno;
int main( void )
{
int fd;
int n;
ssize_t i;
pid_t m;
// removing stale FIFO
n = unlink( FIFO );
if( n == -1 ) perror("unlink");
// creating a FIFO
n = mkfifo( FIFO, MODE );
if( n == -1 ) perror("mkfifo");
m = fork();
if( m == -1 ) { perror("fork"); exit(1); }
if( m == 0 ) // child process block
{
sleep(10);
fd = open( FIFO, O_WRONLY );
if( fd == -1 ) { perror("open-child"); exit(1); }
sleep(12);
printf("child: FIFO writer is exiting !\n");
exit(0);
} // end of child process block
// rest is parent process
write( STDOUT_FILENO,"parent: opening FIFO for reading: ", 34 );
system("/bin/date");
fd = open( FIFO, O_RDONLY );
if( fd == -1 ) { perror("open-parent"); exit(1); }
write( STDOUT_FILENO,"parent: opened FIFO for reading: ", 34 );
system("/bin/date");
// errno is cleared
errno = 0;
for( n = 0; n<=3; n++ )
{
write( STDOUT_FILENO, "parent: reading FIFO : ", 24 );
system("/bin/date");
printf("parent: before read() call: errno = %u\n", errno );
i = read( fd, "Hello\n", 6);
if( i == -1 ) printf( "read() call failed\n" );
printf("parent: after read() call: errno = %u\n", errno );
write( STDOUT_FILENO, "parent: after reading : ", 24 );
system("/bin/date");
printf("parent: %u bytes read from FIFO\n\n", i );
}
close( fd );
return 0;
}
------------------------------------------------------------------
The parent blocks when it tries to open the FIFO in read-only mode.
This open() call returns, when the child opens the FIFO for writing
after 10 seconds. So the parent blocks in open() call for about 10
seconds. The parent then blocks in read() call, till data is available
in the FIFO or at least one writer of the FIFO exists. The child exits
after 12 seconds of opening the FIFO, for writing. The child does not
write any data in the FIFO. So the parent blocks in read() call for
about 12 seconds. Without a writer of the FIFO, the read() call of the
parent returns immediately with zero and this not an error.
Compile and run the program
$ gcc -Wall ./f7.c -o ./seven
$ ./seven
Optional Assignment-3.
When data is written in a FIFO without a reader,
error number is set to EPIPE and SIGPIPE signal is delivered to the
calling process. This is another property of FIFO ( and pipe ).
The default action of SIGPIPE signal is to terminate the process
unless this signal is handled.
------------------------------------------------------------------
// file-name f8.c
// writing a FIFO with and without reader
//#include
#include
#include
#include
#include
#include
#include
#include
#define FIFO "./xx"
#define MODE 0606 // symbolic constants should be used !
extern int errno;
// function prototype
void sighandler( int signum );
int main( void )
{
int fd;
int n;
ssize_t i;
pid_t m;
struct sigaction action;
char buffer[100];
// removing stale FIFO
n = unlink( FIFO );
if( n == -1 ) perror("unlink");
// creating a FIFO
n = mkfifo( FIFO, MODE );
if( n == -1 ) perror("mkfifo");
printf("EPIPE = %u\n", EPIPE );
m = fork();
if( m == -1 ) { perror("fork"); exit(1); }
if( m == 0 ) // child process block
{
sleep(10);
fd = open( FIFO, O_RDONLY );
if( fd == -1 ) { perror("open-child"); exit(1); }
memset(buffer,' ',100);
i = read(fd,buffer,100);
if( i == -1 ) { perror("read-child"); exit(1); }
write(STDOUT_FILENO,"child : received from FIFO-->",29);
write(STDOUT_FILENO, buffer,i );
sleep(12);
printf("child: FIFO reader is exiting !\n");
exit(0);
} // end of child process block
// rest is parent process
// a signal handler for SIGPIPE is installed
action.sa_handler = sighandler;
n = sigaction( SIGPIPE, &action, NULL );
if( n == -1 ) { perror("sigaction"); exit(1); }
printf("parent: my PID = %u\n", getpid() );
write( STDOUT_FILENO,"parent: opening FIFO for writing: ", 34 );
system("/bin/date");
fd = open( FIFO, O_WRONLY );
if( fd == -1 ) { perror("open-parent"); exit(1); }
write( STDOUT_FILENO,"parent: opened FIFO for writing: ", 34 );
system("/bin/date");
// errno is cleared
errno = 0;
while(1)
{
write( STDOUT_FILENO, "parent: writing FIFO : ", 24 );
system("/bin/date");
printf("parent: before write() call: errno = %u\n", errno );
i = write( fd, "This is parent\n", 15);
if( i == -1 )
{
printf("parent: write() call failed; errno = %u\n", errno);
exit(1);
}
printf("parent: after write() call: errno = %u\n", errno );
write( STDOUT_FILENO, "parent: after reading : ", 24 );
system("/bin/date");
printf("parent: %u bytes written in FIFO\n\n", i );
sleep(6);
}
close( fd );
return 0;
}
void sighandler( int signum )
{
printf("process-%u: received signal %u \n", getpid(),signum );
return;
}
------------------------------------------------------------------
The parent installs a signal handler for SIGPIPE. The purpose of this
signal handler is to confirm that SIGPIPE ( signal number 13 ) is
delivered to the process writing to a FIFO, which has no reader. The
parent blocks when it tries to open the FIFO in write-only mode. This
open() call returns when the child opens the FIFO for reading after 10
seconds. So the parent blocks in open() call for about 10 seconds. The
child blocks in read() call, till data is available in the FIFO. The
parent writes data in FIFO in an endless loop. It sleeps for 6 seconds
after a passes in the endless loop. The child reads data from FIFO and
prints it on standard output and exits after 12 seconds. When child
exits, no process has the FIFO opened for reading. When parent tries
to write in the FIFO, after the exit of the child, write() call fails
with [ errno ] set to EPIPE and SIGPIPE signal is delivered to the
parent. The program is terminated with explicit exit(1) call, when the
write() call returns minus one.
Compile and run the program
$ gcc -Wall ./f8.c -o ./eight
$./eight
Chapter-3
FIFO stands for First In First Out. Named pipes exist as device
special files in the file system. [pipes] can be used for IPC only
between processes of common ancestors, whereas processes of different
ancestors can share data through named pipes. After the I/O operation
(IPC) by the processes, the FIFO remains in the file system for later
use unless explicitly removed. Like pipes, FIFO allows one way flow of
data. For both-way communication two FIFOs are used. Unlike pipes FIFO
does not have separate read-end and write-end.
Create a directory [ fifo ] in your home directory. The assignments
should be done in this directory.
$ mkdir $HOME/fifo
$ cd $HOME/fifo
$ ftp IP-address-of-laboratory-FTP-server
Bring the file [fifo.txt] in $HOME/fifo directory.
Creation of FIFO:
A FIFO can be created with [ mknod ] shell command.
$ /bin/mknod ./aaa -m 0666 p
Check creation of of a FIFO [aaa] in the current directory.
$ file ./aaa
A FIFO can also be created with shell command [ mkfifo ].
Create a FIFO [ ./xxx ] under [ /tmp/ ] directory with read and write
permissions for group and others
$ mkfifo /tmp/xxx -m 0606
The created FIFO is checked with two commands and their likely outputs
are shown below
$ ls -l /tmp/xxx
total 0
prw----rw- 1 _______ ______ 0 Sep 25 15:39 xxx
$ file /tmp/xxx
/tmp/xxx: fifo (named pipe)
Delete the FIFO [/tmp/xxx].
$ rm /tmp/xxx
FIFO can be created by system call [mknod(2)]. Read [ mknod(2) ]. This
system call is not in POSIX. In the following example library function
[ mkfifo(3) ] is used to create FIFO as this is POSIX compliant. Read
manual [ mkfifo(3) ].
A client-server model is described using a FIFO. In this example, one
way communication, from client to server, is described using a single
FIFO.
Copy the following code in a file named [f1.c].
-------------------------------------------------------------------
// file-name f1.c
// one way FIFO server - reads data from client
// and prints on standard output
#include
#include
#include
#include
#include
#include
#include
#define FIFOPATH "/tmp/your-name"
#define MODE ( S_IFIFO | S_IRUSR | S_IWUSR | S_IROTH | S_IWOTH )
// it is a FIFO, user and others have read and write permissions
#define BUFFERSIZE 1024
extern int errno;
int main ( void )
{
int fdr,fdw,n;
ssize_t i;
char buffer[BUFFERSIZE];
// remove stale FIFO if any
n = unlink( FIFOPATH );
if( n == -1 ) { perror("unlink"); } // note absence of exit()
else printf("removed stale FIFO %s\n", FIFOPATH );
// file creation mask is cleared
umask(0000);
// a FIFO is tried to be created
n = mkfifo( FIFOPATH, MODE );
if( n == -1 ) { perror("mkfifo"); exit(1); }
printf("created FIFO <%s> \n", FIFOPATH );
// server reads data from client from this descriptor
fdr = open( FIFOPATH, O_RDONLY );
if( fdr == -1 ) { perror("open-rdonly"); exit(1); }
fdw = open( FIFOPATH, O_WRONLY );
if( fdw == -1 ) { perror("open-wronly"); exit(1); }
// this descriptor is not used by the server but it ensures
// that the FIFO has a writer during lifetime of the server
while ( 1 ) //endless loop.
{
printf("waiting for data from a client\n");
memset(buffer, '\0', BUFFERSIZE );
// server reads data from a client
i = read( fdr, buffer, BUFFERSIZE );
if( i == -1 ) { perror("read"); exit(1); }
write( STDOUT_FILENO, "server: from client-> ", 22 );
write( STDOUT_FILENO, buffer, i );
//printf("%s\n", buffer );
}
close(fdr); close(fdw);
return 0;
}
-------------------------------------------------------------------
A FIFO (/tmp/your-name) is created with [ mkfifo(3) ] library function
with read & write permissions for owner and others. The FIFO is
created in [/tmp/] directory, as this directory has execute permission
for all. Execute permission of a directory means search permission.
All users can access the FIFO in [/tmp/] directory.
The FIFO is opened twice by the server; first in read-only mode and
then in write-only mode.
The server-client arrangement is shown below
---------------------
| |
SERVER <---- fdr | /tmp/_________ | fdw <----- CLIENT
fdw | |
---------------------
When the server starts, it blocks in [open()] call in read-only mode,
as yet there is no other process (a client) which has the FIFO opened
for writing. This can be verified by using [strace] command to run the
server. When the first client starts, server's FIFO is opened in read-
only mode and then in write-only mode. The descriptor [fdw] is not
used further by the server. This open descriptor ensures that a
process has the FIFO opened for writing, even after a client exits.
When no process have the FIFO opened for writing, [read()] call on the
FIFO returns with zero, indicating end of file. This property of FIFO
and pipe, is described in Optional Assignment-2.
When any process have the FIFO opened for writing, [read()] call on
an empty FIFO blocks until there is data in the FIFO.
In the endless loop the server reads the FIFO, when data is written
by a client, prints it in standard output and blocks on [read()] call
for the next client.
Compile the program
$ gcc -Wall ./f1.c -o ./1way-fifo-server
Use the following command
$ strace ./1way-fifo-server
Did the program block in opening FIFO in read-only mode ( Y / n )
Stop the command with CTRL-C
Start the server
$ ./1way-fifo-server
Login as [ guest ] in another terminal. As the FIFO, created by the
server has write permission by others, [ guest ] is able to write into
the FIFO using shell command.
T-4 guest $ echo "I am guest" > /tmp/your-name
Was the server able to receive data from [guest] ? ( Y / n )
You may allow the server to run or terminate with CTRL-C.
Save the following as the FIFO client program.
------------------------------------------------------------------
// file-name f2.c
// One way FIFO client - writes a string to the FIFO server
#include
#include
#include
#include
#define FIFOPATH "/tmp/your-name"
// the FIFOPATH is known to client program. This need not be
// known to users, using the client program
int main( int argc, char *argv[] )
{
int fd;
ssize_t i;
// argument checking
if( argc != 2 )
{
printf("usage: %s \"any-string within quotes\" \n", argv[0] );
exit(1);
}
fd = open( FIFOPATH, O_WRONLY );
if( fd == -1 ) { perror("open"); exit(1); }
// client] writes the string in the server's FIFO
i = write( fd, argv[1], strlen( argv[1] ) );
if( i == -1 ) { perror("write"); exit(1); }
close(fd);
return 0;
}
------------------------------------------------------------------
Compile the program
$ gcc -Wall ./f2.c -o ./1way-fifo-client
Copy the executable in [/tmp/] directory so that all users may run the
client program.
Stale executable if any, has to be removed as [root] user
# rm /tmp/1way-fifo-client
$ cp ./1way-fifo-client /tmp/
Start the server from your account
T-3 you $ ./1way-fifo-server
From other terminals run the client as different users.
T-4 guest $ /tmp/1way-fifo-client "Hi server, this is guest"
T-4 guest $ /tmp/1way-fifo-client "My name is hizbizbiz"
T-5 sumit $ /tmp/1way-fifo-client "My name is Sumit"
Was the server able to receive data from unrelated processes ? (Y / n)
Terminate the server
T-3 you $ CTRL-C
Two FIFOs are used for two way communication between two processes,
if proper permissions of the FIFO exist.
The following is the FIFO server program.
--------------------------------------------------------------
// file-name f3.c Two way FIFO server
#include
#include
#include
#include
#include
#define FIFO1 "/tmp/XX"
#define FIFO2 "/tmp/YY"
#define BUFFERSIZE 4098
#define MODE 0606 // use symbolic constants !
int main ( void )
{
int XXr, XXw, YYw, YYr, n;
ssize_t i,j;
char buffer[BUFFERSIZE];
// remove stale FIFO if any
n = unlink(FIFO1);
if( n == -1 ) perror("unlink-1");
n = unlink(FIFO2);
if( n == -1 ) perror("unlink-2");
umask(0000);
// two FIFOs are created
n = mkfifo( FIFO1, MODE );
if( n == -1 ) { perror("mkfifo-1"); exit(1); }
n = mkfifo( FIFO2, MODE );
if( n == -1 ) { perror("mkfifo-2"); exit(1); }
XXr = open( FIFO1, O_RDONLY );
if( XXr == -1 ) { perror("open-XX-rdonly"); exit(1); }
XXw = open( FIFO1, O_WRONLY );
if( XXw == -1 ) { perror("open-XX-wronly"); exit(1); }
// XXw is not used by server
YYw = open( FIFO2, O_WRONLY );
if( YYw == -1 ) { perror("open-YY-wronly"); exit(1); }
YYr = open( FIFO2, O_RDONLY );
if( YYr == -1 ) { perror("open-YY-rdonly"); exit(1); }
// YYr is not used by server
while ( 1 ) //endless loop.
{
write(STDOUT_FILENO,"waiting for data from client\n", 29);
memset(buffer, '\0', BUFFERSIZE );
// server reads data from client
i = read( XXr, buffer, BUFFERSIZE );
if( i == -1 ) { perror("read"); exit(1); }
write(STDOUT_FILENO, "server: from client-> ", 22 );
j = write(STDOUT_FILENO, buffer, i );
if( j == -1 ) { perror("write-1"); }
// server writes data to client
i = write( YYw,"This is server \n", 16 );
if( i == -1 ) { perror("write-2"); }
}
close(XXr); close(XXw); close(YYw);
return 0;
}
--------------------------------------------------------------
In the above example, the server creates two FIFOs [ /tmp/XX ] and
[ /tmp/YY ] for both way communication.
The arrangement for communication between server and client, using the
two FIFOs is shown below:
------------- ------------
| | <--------- XXr (/tmp/XX) XXwc <---------- | |
| SERVER | | CLIENT |
| | ---------> YYw (/tmp/YY) YYrc ----------> | |
------------- -------------
XXw and YYr are not
used by server
The server opens both the FIFOs for reading and writing. So the server
has four descriptors of the two FIFOs. They are XXr, XXw, YYr and YYw.
The server reads data from a client from XXr and writes data to client
in YYw. Descriptors XXw and YYr are not used by the server.
XXw ensures that FIFO [ /tmp/XX ] always has a writer. The reason for
this was explained in connection with [f1.c].
YYr ensures that FIFO [/tmp/YY] always has a reader even when there is
no client process in existence. If the server writes to the FIFO
[/tmp/YY] when the FIFO has no reader, SIGPIPE signal is delivered to
the server. The default action of this signal is to terminate the
server process, if the signal is not handled. This is a property of
FIFO and pipe. This property is described in Optional Assignment-3.
The following is the client program.
--------------------------------------------------------------
// file-name f4.c Two way FIFO client
#include
#include
#include
#include
#include
#define FIFO1 "/tmp/XX"
#define FIFO2 "/tmp/YY"
#define BUFFERSIZE 4098
int main( void )
{
int XXwc,YYrc;
int n;
ssize_t i;
char buffer[BUFFERSIZE];
char *username;
//If opened in read only mode first, there would be deadlock
XXwc = open( FIFO1, O_WRONLY );
if( XXwc == -1 ) { perror("open-wronly"); exit(1); }
YYrc = open( FIFO2, O_RDONLY );
if( YYrc == -1 ) { perror("open-rdonly"); exit(1); }
username = getlogin();
// buffer is prepared
sprintf( buffer,"I am client <%s>, my uid = %u\n",
username, getuid() );
// buffer is sent to server
n = write( XXwc, buffer, strlen(buffer) );
if( n == -1 ) { perror("write"); exit(1); }
memset( buffer, '\0', BUFFERSIZE );
// reading data from server
i = read(YYrc, buffer, BUFFERSIZE );
write(STDOUT_FILENO, "from server-->", 14 );
write(STDOUT_FILENO, buffer, i );
close(XXwc); close( YYrc );
return 0;
}
--------------------------------------------------------------
Compile
$ gcc -Wall ./f4.c -o ./2way-fifo-client
Copy the executable under [/tmp/] directory
$ cp ./2way-fifo-client /tmp/
Start the server
T-3 you/fifo $ ./2way-fifo-server
Test the server from other terminals and observe the results in the
server's terminal.
T-4 you $ /tmp/2way-fifo-client
T-5 guest $ /tmp/2way-fifo-client
T-6 sumit $ /tmp/2way-fifo-client
Stop server with CTRL-C
T-3 you/fifo $ CTRL-C
Optional Assignment-1.
The [ make ] utility automatically determines
which pieces of a large program need to be recompiled, and issues
commands to recompile them.
The above line is reproduced from "GNU Make Manual". You may read the
manual.
$ info make
[make] utility is described with a VERY simple example. The above 2way
FIFO client-server programs are modified to for the example.
The headers needed for server and client programs are kept in a
file named [headers].
----------------------
// file-name headers
#include
#include
#include
#include
#include
----------------------
The definitions needed for server and client programs are kept in a
file named [definitions].
------------------------------------------------------------------
// file-name definitions
#define FIFO1 "/tmp/XX"
#define FIFO2 "/tmp/YY"
#define BUFFERSIZE 4098
#define MODE ( S_IFIFO | S_IRUSR | S_IWUSR | S_IROTH | S_IWOTH )
// it is a FIFO, user and others have read and write permissions
------------------------------------------------------------------
Save the following lines in a file [f5.c]
--------------------------------------------------------------
// file-name f5.c FIFO server-duplex
#include "headers"
#include "definitions"
int main ( void )
{
int XXr, XXw, YYw, YYr, n;
ssize_t i;
char buffer[BUFFERSIZE];
// remove stale FIFO if any
n = unlink(FIFO1);
if( n == -1 ) perror("unlink-1");
n = unlink(FIFO2);
if( n == -1 ) perror("unlink-2");
umask(0000);
// two FIFOs are created
n = mkfifo( FIFO1, MODE );
if( n == -1 ) { perror("mkfifo-1"); exit(1); }
n = mkfifo( FIFO2, MODE );
if( n == -1 ) { perror("mkfifo-2"); exit(1); }
XXr = open( FIFO1, O_RDONLY );
if( XXr == -1 ) { perror("open-XX-rdonly"); exit(1); }
XXw = open( FIFO1, O_WRONLY );
if( XXw == -1 ) { perror("open-XX-wronly"); exit(1); }
// XXw is not used by server
YYw = open( FIFO2, O_WRONLY );
if( YYw == -1 ) { perror("open-YY-wronly"); exit(1); }
YYr = open( FIFO2, O_RDONLY );
if( YYr == -1 ) { perror("open-YY-rdonly"); exit(1); }
while ( 1 ) //endless loop.
{
write(STDOUT_FILENO,"waiting for data from client\n", 29);
memset(buffer, '\0', BUFFERSIZE );
// server reads data from client
i = read( XXr, buffer, BUFFERSIZE );
if( i == -1 ) { perror("read"); exit(1); }
write(STDOUT_FILENO, "server: from client-> ", 22 );
printf("%s\n", buffer );
// server writes data to client
n = write( YYw,"This is server \n", 16 );
}
close(XXr); close(XXw); close(YYw);
return 0;
}
--------------------------------------------------------------
Save the following lines in a file [f6.c]
--------------------------------------------------------------
// file-name f6.c FIFO client-duplex
#include "headers"
#include "definitions"
int main( void )
{
int XXw,YYr;
int n;
ssize_t i;
char buffer[BUFFERSIZE];
char *username;
//If opened in read only mode first, there would be deadlock
XXw = open( FIFO1, O_WRONLY );
if( XXw == -1 ) { perror("open-wronly"); exit(1); }
YYr = open( FIFO2, O_RDONLY );
if( YYr == -1 ) { perror("open-rdonly"); exit(1); }
username = getlogin();
// buffer is prepared
sprintf( buffer,"I am client <%s>, my uid = %u\n",
username, getuid() );
// buffer is sent to server
n = write( XXw, buffer, strlen(buffer) );
if( n == -1 ) { perror("write"); exit(1); }
memset( buffer, '\0', BUFFERSIZE );
// reading data from server
i = read(YYr, buffer, BUFFERSIZE );
write(STDOUT_FILENO, "from server-->", 14 );
write(STDOUT_FILENO, buffer, i );
close(XXw); close( YYr );
return 0;
}
--------------------------------------------------------------
The [ make ] utility needs a file [ Makefile ] to specify the targets,
prerequisites and rules to create the target. Save the following lines
in a file [Makefile]
--------------------------------------------------------------------
# file-name Makefile
# Using [makefile] as file-name should also work
# [fs] is the target. It depends on one object file [f5.o]
fs : ./f5.o
gcc -Wall ./f5.o -o ./fs
# The rule to make target [fs] is given by the above command
# NOTE: rules must start with a TAB
# target [f5.o] depends on files [f5.c], [headers] and [definitions]
f5.o : ./f5.c ./headers ./definitions
gcc -Wall -c ./f5.c
# Command [ gcc -Wall -c s2.c -o s.o ] should also work; but
# output file-name must not be used, when working with more than
# one input file
# target [fc] depends on the object file [f6.o].
fc : ./f6.o
gcc -Wall ./f6.o -o ./fc
# target [f6.o] depends on files [f6.c], [headers] and [definitions]
f6.o : ./f6.c ./headers ./definitions
gcc -Wall -c ./f6.c
install : ./fs ./fc
/bin/cp ./fs /tmp/fs
/bin/cp ./fc /tmp/fc
clean :
/bin/rm ./f5.o ./f6.o ./fs ./fc
all-clean :
/bin/rm ./f5.o ./f6.o ./fs ./fc /tmp/fs /tmp/fc
--------------------------------------------------------------------
The above [ Makefile ] has seven targets.
In target [install], installation is done in [/tmp/] directory, which
is not done in actual practice. This is done, as it is convenient for
laboratory experiment.
In the following [make] commands, typical outputs are shown.
$ make fs
gcc -Wall -c ./f5.c
gcc -Wall ./f5.o -o ./fs
As the first target depended on [f5.o], the second target [ f5.o ] was
created first and then first target was created.
Note: To examine the intermediate files created in a compilation, use
the following command
$ gcc --save-temp ./f1.c
where [f1.c] is a C source code
Try to make the first target again
$ make fs
make: `fs' is up to date.
Make the other targets:
$ make fc
gcc -Wall -c ./f6.c
gcc -Wall ./f6.o -o ./fc
$ make install
/bin/cp ./fs /tmp/fs
/bin/cp ./fc /tmp/fc
After the installations, the temporary files in the current directory
may be removed with target [clean].
$ make clean
/bin/rm ./f5.o ./f6.o ./fs ./fc
To remove the temporary files in the working directory and the
installed files may be removed with target [all-clean]
$ make all-clean
/bin/rm ./f5.o ./f6.o fs fc /tmp/fs /tmp/fc
/bin/rm: cannot remove `./f5.o': No such file or directory
/bin/rm: cannot remove `./f6.o': No such file or directory
/bin/rm: cannot remove `fs': No such file or directory
/bin/rm: cannot remove `fc': No such file or directory
make: *** [all-clean] Error 1
Try the following command
$ make install
gcc -Wall -c ./f5.c
gcc -Wall ./f5.o -o ./fs
gcc -Wall -c ./f6.c
gcc -Wall ./f6.o -o ./fc
/bin/cp ./fs /tmp/fs
/bin/cp ./fc /tmp/fc
$ make clean
/bin/rm ./f5.o ./f6.o ./fs ./fc
Start the FIFO server from your account
T-3 $ /tmp/fs
Run client from accounts of other users
T-4 guest $ /tmp/fc
T-5 sumit $ /tmp/fc
Was client-server communication possible ? ( Y / n )
Optional Assignment-2.
When a process reads from a FIFO, which has no
writer, [read()] call returns with zero, indicating end of file. This
is not an error. This is a property of FIFO ( and pipe ).
------------------------------------------------------------------
// file-name f7.c
// reading a FIFO with and without writer
//#include
#include
#include
#include
#include
#include
#define FIFO "./xx"
#define MODE 0606 // symbolic constants should be used !
extern int errno;
int main( void )
{
int fd;
int n;
ssize_t i;
pid_t m;
// removing stale FIFO
n = unlink( FIFO );
if( n == -1 ) perror("unlink");
// creating a FIFO
n = mkfifo( FIFO, MODE );
if( n == -1 ) perror("mkfifo");
m = fork();
if( m == -1 ) { perror("fork"); exit(1); }
if( m == 0 ) // child process block
{
sleep(10);
fd = open( FIFO, O_WRONLY );
if( fd == -1 ) { perror("open-child"); exit(1); }
sleep(12);
printf("child: FIFO writer is exiting !\n");
exit(0);
} // end of child process block
// rest is parent process
write( STDOUT_FILENO,"parent: opening FIFO for reading: ", 34 );
system("/bin/date");
fd = open( FIFO, O_RDONLY );
if( fd == -1 ) { perror("open-parent"); exit(1); }
write( STDOUT_FILENO,"parent: opened FIFO for reading: ", 34 );
system("/bin/date");
// errno is cleared
errno = 0;
for( n = 0; n<=3; n++ )
{
write( STDOUT_FILENO, "parent: reading FIFO : ", 24 );
system("/bin/date");
printf("parent: before read() call: errno = %u\n", errno );
i = read( fd, "Hello\n", 6);
if( i == -1 ) printf( "read() call failed\n" );
printf("parent: after read() call: errno = %u\n", errno );
write( STDOUT_FILENO, "parent: after reading : ", 24 );
system("/bin/date");
printf("parent: %u bytes read from FIFO\n\n", i );
}
close( fd );
return 0;
}
------------------------------------------------------------------
The parent blocks when it tries to open the FIFO in read-only mode.
This open() call returns, when the child opens the FIFO for writing
after 10 seconds. So the parent blocks in open() call for about 10
seconds. The parent then blocks in read() call, till data is available
in the FIFO or at least one writer of the FIFO exists. The child exits
after 12 seconds of opening the FIFO, for writing. The child does not
write any data in the FIFO. So the parent blocks in read() call for
about 12 seconds. Without a writer of the FIFO, the read() call of the
parent returns immediately with zero and this not an error.
Compile and run the program
$ gcc -Wall ./f7.c -o ./seven
$ ./seven
Optional Assignment-3.
When data is written in a FIFO without a reader,
error number is set to EPIPE and SIGPIPE signal is delivered to the
calling process. This is another property of FIFO ( and pipe ).
The default action of SIGPIPE signal is to terminate the process
unless this signal is handled.
------------------------------------------------------------------
// file-name f8.c
// writing a FIFO with and without reader
//#include
#include
#include
#include
#include
#include
#include
#include
#define FIFO "./xx"
#define MODE 0606 // symbolic constants should be used !
extern int errno;
// function prototype
void sighandler( int signum );
int main( void )
{
int fd;
int n;
ssize_t i;
pid_t m;
struct sigaction action;
char buffer[100];
// removing stale FIFO
n = unlink( FIFO );
if( n == -1 ) perror("unlink");
// creating a FIFO
n = mkfifo( FIFO, MODE );
if( n == -1 ) perror("mkfifo");
printf("EPIPE = %u\n", EPIPE );
m = fork();
if( m == -1 ) { perror("fork"); exit(1); }
if( m == 0 ) // child process block
{
sleep(10);
fd = open( FIFO, O_RDONLY );
if( fd == -1 ) { perror("open-child"); exit(1); }
memset(buffer,' ',100);
i = read(fd,buffer,100);
if( i == -1 ) { perror("read-child"); exit(1); }
write(STDOUT_FILENO,"child : received from FIFO-->",29);
write(STDOUT_FILENO, buffer,i );
sleep(12);
printf("child: FIFO reader is exiting !\n");
exit(0);
} // end of child process block
// rest is parent process
// a signal handler for SIGPIPE is installed
action.sa_handler = sighandler;
n = sigaction( SIGPIPE, &action, NULL );
if( n == -1 ) { perror("sigaction"); exit(1); }
printf("parent: my PID = %u\n", getpid() );
write( STDOUT_FILENO,"parent: opening FIFO for writing: ", 34 );
system("/bin/date");
fd = open( FIFO, O_WRONLY );
if( fd == -1 ) { perror("open-parent"); exit(1); }
write( STDOUT_FILENO,"parent: opened FIFO for writing: ", 34 );
system("/bin/date");
// errno is cleared
errno = 0;
while(1)
{
write( STDOUT_FILENO, "parent: writing FIFO : ", 24 );
system("/bin/date");
printf("parent: before write() call: errno = %u\n", errno );
i = write( fd, "This is parent\n", 15);
if( i == -1 )
{
printf("parent: write() call failed; errno = %u\n", errno);
exit(1);
}
printf("parent: after write() call: errno = %u\n", errno );
write( STDOUT_FILENO, "parent: after reading : ", 24 );
system("/bin/date");
printf("parent: %u bytes written in FIFO\n\n", i );
sleep(6);
}
close( fd );
return 0;
}
void sighandler( int signum )
{
printf("process-%u: received signal %u \n", getpid(),signum );
return;
}
------------------------------------------------------------------
The parent installs a signal handler for SIGPIPE. The purpose of this
signal handler is to confirm that SIGPIPE ( signal number 13 ) is
delivered to the process writing to a FIFO, which has no reader. The
parent blocks when it tries to open the FIFO in write-only mode. This
open() call returns when the child opens the FIFO for reading after 10
seconds. So the parent blocks in open() call for about 10 seconds. The
child blocks in read() call, till data is available in the FIFO. The
parent writes data in FIFO in an endless loop. It sleeps for 6 seconds
after a passes in the endless loop. The child reads data from FIFO and
prints it on standard output and exits after 12 seconds. When child
exits, no process has the FIFO opened for reading. When parent tries
to write in the FIFO, after the exit of the child, write() call fails
with [ errno ] set to EPIPE and SIGPIPE signal is delivered to the
parent. The program is terminated with explicit exit(1) call, when the
write() call returns minus one.
Compile and run the program
$ gcc -Wall ./f8.c -o ./eight
$./eight
Subscribe to:
Posts (Atom)
