Thursday, June 5, 2008

Command Line Interface

This is probably nothing new but for those who don't know yet ...

You can run every YaST2 module in Qt, GTK or Ncurses UI. Some of that modules has implemented also command line interface. Just type: yast module_name help and you will see something like this:


linux:/home/mzugec # yast lan help

YaST Configuration Module lan
------------------------------

Network Card Configuration

Basic Syntax:
yast2 lan interactive
yast2 lan [verbose] [options]
yast2 lan help
yast2 lan longhelp
yast2 lan xmlhelp
yast2 lan help

Commands:
add Add a network card
delete Delete a network card
edit Change existing configuration
list Display configuration summary
show Display configuration summary

Run 'yast2 lan help' for a list of available options.


In case module doesn't support CLI, output is like:

linux:/home/mzugec # yast dsl help
There is no user interface available for this module.



Option interactive is useful when you want to do several actions, because read and write are done only one. Difference between using ip or ifconfig commands and yast lan is that yast lan works with configurations, not only current status.

Ok, so let's start with example. List all network cards:

linux:/home/mzugec # yast lan list
0 Ethernet Network Card, DHCP

1 79c970 [PCnet32 LANCE], Not configured

2 79c970 [PCnet32 LANCE], DHCP

3 Ethernet Network Card, 10.20.30.40


See configuration of last device:

linux:/home/mzugec # yast lan show id=3
Ethernet Network Card
MAC : 08:00:27:d9:db:b7
Device Name: eth0
Started automatically at boot
IP address: 10.20.30.40, subnet mask 255.255.255.0


Change configuration to DHCP :

linux:/home/mzugec # yast lan edit id=3 bootproto=dhcp
Device Type : eth
Bootproto : dhcp
IP Address :
Mask :


Done, that was easy ;-)

Bye,
Michal

2 comments:

Michal Žugec said...

other usefull examples:

yast lan add name=vlan50 ethdevice=eth0 bootproto=dhcp
yast lan add name=br0 bridge_ports=eth0 eth1 bootproot=dhcp
yast lan add name=bond0 slaves=eth0 eth1 bootproto=dhcp

João said...

Hello friend, I really enjoyed your article. but could tell me how to run the command yast2 xen so that the same command line I say yes to all questions, for example yast2 xen - y, I must place it in a script but do not show such questions