If the interface name is passed as an argument, ifconfig
command print the information about that interface only.
Example:
[mitesh@Matrix ~]$ ifconfig eth0
eth0 Link encap:Ethernet HWaddr 00:09:6B:CD:2B:87
inet addr:192.168.0.254 Bcast:192.168.0.255 Mask:255.255.255.0
inet6 addr:fe80::209:6bff:fecd:2b87/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:851525 errors:0 dropped:0 overruns:0 frame:0
TX packets:1132322 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:211140434 (201.3 MiB) TX bytes:1113058956 (1.0 GiB)
ifup ethX; ifconfig ethX up
ifdown ethX; ifconfig ethX down
System -> Preferences -> Network Connections
NOTE!: The system-config-network
also provides all the features listed above.
system-config-network
to configure your network interfaces, All the Network Interface settings are stored in /etc/sysconfig/network-scripts/
directory./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 =.
/-----------------------------------------------------------------------------------------------------------------------\ | 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. | | | \-----------------------------------------------------------------------------------------------------------------------/
The Global Network Settings are defined in the /etc/sysconfig/network
ifcfg
file.Examples:
[mitesh@Matrix ~]$ cat /etc/sysconfig/network
NETWORKING=yes
HOSTNAME=server1.example.com
GATEWAY=192.168.2.254
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.
/etc/resolv.conf
[mitesh@Matrix ~]$ cat /etc/resolv.conf
search example.com cracker.org
nameserver 192.168.0.254
nameserver 192.168.1.254
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.google.com
and will forward my request to one of them./etc/resolv.conf
/etc/resolv.conf
filesearch
The search specifies the Domain Name when incomplete DNS Name is give to the command.
/etc/resolv.conf
file contains the line: search example.com cracker.org
ping server1
server1
into server1.example.com
server1.example.com
is not found then system try server1.cracker.org
nameserver
System -> Administration -> Printing
OR Run the system-config-printer
on the terminallpr
Send job to the printerOptions
-P
: Select the specific printer.-#
: Set the number of copies to print from 1 to 100.Examples:
[mitesh@Matrix ~]$ lpr reports.txt
# Print 5 copies of the file reports.txt on the accounting printer
[mitesh@Matrix ~]$ lpr -P accounting -#5 reports.txt
lpq
Show printer queue status.Options
-P
: Select the specific printer.Example:
[mitesh@Matrix ~]$ lpq
Printer: ps@localhost
Queue: no printable jobs in queue
Server: no server active
Status: job 'jay@localhost+916' removed at 12:16:03.083
Rank Owner/ID Class Job Files Size Time
done jay@localhost+185 A 185 results 2067 08:38:04
lprm
: Removes a job from the print queue.Options
-P
: Select the specific printer.Examples:
[mitesh@Matrix ~]$ lprm 916
Printer ps@localhost:
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
: Prints cups status information.Options
-a
: List Configured Printers.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 sheetcups
chkconfig cups on | off
& service cups status | start | stop | restart
Configuration Files
/etc/cups/cupsd.conf
/etc/cups/printers.conf
Configuration Tools
lpr
lpq
lprm
lpstat
lpadmin
lpinfo
system-config-printer
System -> Administration -> Printing
system-config-date
System -> Administration -> Date & Time
Examples:
[root@Matrix ~]# date 01011010 # 1st Jan, at 10:10am.
[root@Matrix ~]# date 01010101.01 # 1st Jan, at 01:01:01 am.
[root@Matrix ~]# date 12312359 # 31st Dec, at 11:59pm.
[root@Matrix ~]# date 123123592007 # 31st Dec 2007, at 11:59pm.
[root@Matrix ~]# date 123123592007.05 # 31st Dec 2007, at 11:59:05pm.
NOTE!: $0
Specify the program name
$*
Holds all command-line arguments
$#
Holds the number of command-line arguments
Examples:
#!/bin/bash
# positionaltester
# Demonstrates the use of positional parameters
echo "The program name is $0"
printf "The first argument is %s and the second is %s\n" $1 $2
echo -e "All command line parameters are $*\n"
echo -e "Total number of command line parameters are $#\n"
[mitesh@Matrix ~]$ ./positionaltester Red Hat Enterprise Linux
The program name is ./positionaltester
The first argument is Red and the second is Hat
All command line parameters are Red Hat Enterprise Linux
Total number of command line parameters are 4
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).
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:
#!/bin/bash
echo -n "Enter name ( first last ): "
read FIRST LAST
echo "Your first name is $FIRST and your last name is $LAST"
#!/bin/bash
read -p "Enter name ( first last ): " FIRST LAST
echo "Your first name is $FIRST and your last name is $LAST"
#!/bin/bash
read -p "Enter several values: " value1 value2 value3
echo "value1 is $value1"
echo "value2 is $value2"
echo "value3 is $value3"