Basic System Configuration Tools
Overview
1. Network Configuration
- Most networks use TCP/IP as the basic protocols for network communications. Regardless of the operating system you use.
- Certain TCP/IP settings always need to be configured for your system to communicate with other systems.
Important Network Settings
- Device Activation
- IP Configuration
- Default Gateway
- DNS Configuration
Basics Of Network Setting
- Network Interface Card’s IP Address
- Subnet Mask
-
Network Number
- In general these settings and more will be provided automatically by your network’s Dynamic Host Configuration Protocol (DHCP) Server.
-
Even when manual configuration is required, often the IP Address, which is used to identify your host, is the only one of these that needs to be set explicitly.
- If you are not using DHCP Server, you will also need to specify:
- Default Gateway
-
DNS Server
- The Default Gateway is the IP Address of the Device or System to which Communications Destinated for Hosts on another Network.
-
It is the job of the gateway to see that such messages reach their intended destinations.
- The DNS Server is used to translate Domain Names like
google.com
to IP Addresses like216.58.196.110
Managing Ethernet Connections
- Network interfaces are named sequentially:
eth0
,eth1
,wlan0
- Multiple addresses can be assigned to a device with aliases
- Aliases are labeled:
eth0:1
,eth0:2
, etc -
Aliases are treated like separate interface
- Every system has a special network interface called lo (LocalHost or LoopBack) with
127.0.0.1
IP Address.
Network Interface Configuration
NOTE!: By Default, ifconfig
command print the information about all active interfaces.
If the interface name is passed as an argument, ifconfig
command print the information about that interface only.
Example:
Enable/Disable Network Interface
Graphical Network Configuration:
System -> Preferences -> Network Connections
- Add, Edit, Delete Network Interface
- Assign IP Addresses/DHCP
- Modify Gateway Address
- Modify DNS Setting
NOTE!: The system-config-network
also provides all the features listed above.
Network Configuration File
Ethernet Devices
- Whether or not you use
system-config-network
to configure your network interfaces, All the Network Interface settings are stored in/etc/sysconfig/network-scripts/
directory. - The Network Interface Configuration is stored in a Text Files
/etc/sysconfig/network-scripts/ifcfg-ethX
NOTE!: These files are read by system-config-network
, ifup
, ifdown
and other tools that bring the Network Interface up and down.
Example:
/-------------------------------------------------------------------------------\ | Dynamic Configuration | Static Configuration | |-------------------------------------------------------------------------------- | | | DEVICE=ethX | DEVICE=ethX | | HWADDR=00:09:6B:CD:2B:87 | HWADDR=00:09:6B:CD:2B:87 | | BOOTPROTO=dhcp | IPADDR=192.168.0.123 | | ONBOOT=yes | NETMASK=255.255.255.0 | | TYPE=Ethernet | GATEWAY=192.168.0.254 | | | ONBOOT=yes | | | TYPE=Ethernet | \-------------------------------------------------------------------------------/
NOTE!: The Network Interface file is just a collection of bash variables that define the interface’s setting.
Remember the syntax of bash variable is VARIABLE=VALUE
, with no spaces on either side of the =.
Network Interface Configuration
/-----------------------------------------------------------------------------------------------------------------------\ | Setting | Meaning | |------------------------------------------------------------------------------------------------------------------------ | | | DEVICE | Specify the Network Interface Name or Alias (Example eth0) | | | | HWADDR | Hardwaare(MAC) Address. | | | This setting is optional & can cause problems, | | | when ethernet card is replaced | | | | BOOTPROTO | Where IP Settings should be retrieved from. | | | Set to dhcp to use DHCP. | | | Leave the variable unset or set it to static for manual IP Settings. | | | | IPADDR & | Basic IP Settings. | | NETMASK | Only necessary when not using the DHCP Server. | | | | GATEWAY | Only necessary when not using the DHCP Server. | | | The Gateway can also be set in /etc/sysconfig/network file. | | | If the Gateway is defined in the /etc/sysconfig/network and ifcfg file, | | | The Gateway defined in the most recently activated ifcfg file is used. | | | | ONBOOT | Whether to bring the network interface up automatically when the system boots. | | | Set to yes or no. The default value is no. | | | | USERCTL | Whether to allow non-root users to bring this interface up & down. | | | Set to yes or no. The default value is no. | | | | TYPE | Specify the type of network interface. | | | \-----------------------------------------------------------------------------------------------------------------------/
Global Network Setting
- Some Network Settings are defined globally, rather than on a per-interface basis.
-
The Global Network Settings are defined in the
/etc/sysconfig/network
- Many may be provided by DHCP Server.
- GATEWAY can be overridden in
ifcfg
file.
Examples:
NOTE!: If the Gateway is defined in the /etc/sysconfig/network
and ifcfg
file,
The Gateway defined in the most recently activated ifcfg
file is used.
DNS Configuration
- Domain Name Service Translate Hostname to IP Address.
- The DNS Server address is specified by DHCP or in
/etc/resolv.conf
Explain DNS
- When we type
www.google.com
into web browser, it initiates a DNS Lookup, in which it ask Local DNS Server what IP Address is assigned to that name. - If Local DNS Server does not know, it will try to find out which other
DNS Server on the internet know about the
google.com
and will forward my request to one of them.
Local DNS Server
- Local DNS Configuration is performed using the
/etc/resolv.conf
- Remember two things while creating or modifying
/etc/resolv.conf
file
search
-
The search specifies the Domain Name when incomplete DNS Name is give to the command.
- If
/etc/resolv.conf
file contains the line:search example.com cracker.org
- Now when we try to run following command
ping server1
- In this case system automatically convert
server1
intoserver1.example.com
- If the
server1.example.com
is not found then system tryserver1.cracker.org
nameserver
- The nameserver is most important, as it specify the IP Address of the DNS Server that your system should use.
- Multiple nameserver are added but remember that nameserver are tried in order, So be sure to put the fastest and available namesserver at first place.
2. Printing in Linux
- Printing on Linux system is handled by the Common Unix Printing System (CUPS).
- Printers May Be
- Local (serial, parallel or usb)
- Networked
Supported printer connections
- Local (serial, parallel or usb)
- Unix/Linux print server
- Netware print server
- Windows print server
- HP JetDirect
- IPP - Internet Printing Protocol
Queues
- Print request are sent to the queues.
- Different queues for the same printer may have different priority or output options.
- Queued jobs are sent to the printer on a First Come First Served basis.
Jobs
- Once a file has been sent to a queue for printing, it is called a job.
- Jobs may be canceled before or during printing.
system-config-printer
- A Graphical Configuration Tool is used to adding new printers to your systems.
- To run this tools
Select
System -> Administration -> Printing
OR Run thesystem-config-printer
on the terminal
Printing Commands
lpr command
lpr
Send job to the printer- Accepts ASCII, PDF, PostScript and other Formats
- Most applications under Linux output PostScript Formats
Options
-P
: Select the specific printer.-#
: Set the number of copies to print from 1 to 100.
Examples:
lpq command
lpq
Show printer queue status.
Options
-P
: Select the specific printer.
Example:
lprm command
lprm
: Removes a job from the print queue.
Options
-P
: Select the specific printer.
Examples:
- In this example,
lprm
responds with the name of the queue from which the job was removed.
NOTE!: A user may only remove his own jobs from the queue.
lpstat command
lpstat
: Prints cups status information.
Options
-a
: List Configured Printers.
Printing Utilities
evince
: Views PDF Documentsps2pdf
: Converts PostScript to PDFpdf2ps
: Converts PDF to PostScript. Which makes it easy to print PDF Documents right from the command line.pdftotext
: Converts PDF to Plain Textenscript
,a2ps
: Converts Text to PostScriptmpage
: Prints multiple pages per sheet
Managing Printers With CUPS
- Daemons:
cups
- Services:
chkconfig cups on | off
&service cups status | start | stop | restart
Configuration Files
/etc/cups/cupsd.conf
/etc/cups/printers.conf
Configuration Tools
- CLI:
lpr
lpq
lprm
lpstat
lpadmin
lpinfo
- GUI:
system-config-printer
System -> Administration -> Printing
- Web Based: http://localhost:631
3. System’s Date and Time
GUI Method
-
system-config-date
System -> Administration -> Date & Time
- Can set Date/Time Manually or use NTP
- Additional NTP Servers can be added
- Can use Local Time or UTC
CLI Method
- date [MMDDhhmm[[CC]YY][.ss]]
Examples:
4. Shell Scripting
- Taking Input With Positional Parameters:
- Many commands and scripts can perform different tasks depending on the arguments supplied to the program.
- Positional Parameters are special variables that hold the command-line arguments to the script.
- The available Positional Parameters are: $0, $1, $2, $3, $4, $5, $6, $7, $8, $9, ${10}, ${11}…
NOTE!: $0
Specify the program name
$*
Holds all command-line arguments
$#
Holds the number of command-line arguments
Examples:
read command
- Taking Input With Read Command
-
The read commands takes a line from the STDIN and breaks it down into individual words. (Usaually a word is defined as a character string surrounded by white space such as spaces and tabs).
- The way the shell interprets words may be changed by setting the
IFS
variable.
NOTE! IFS=’:’ will tells the shell that words are separated by colons instead of white space).
-
The 1st word is assigned to the 1st variable The 2nd word is assigned to the 2nd variable and so on.
-
If there are more words than variables, All the remaining words are assigned to the last variable.
Options
-p
: Designates prompt to display.
Examples:
Newsletter
Get updated when I create new content.
Unsubscribe whenever. Never any spam.