When a task only needs to be done once, the graphical or ncurses interface is usually the best solution. If a task needs to be done repeatedly, it might be easier to use the YaST command line interface. Custom scripts can also use this interface for automating tasks.
View a list of all module names available on your system with yast -l or yast --list. To display the available options of a module, enter yast module_name help. If a module does not have a command line mode, a message informs you of this.
To display help for a module's command options, enter yast module_name command help. To set the option value, enter yast module_name command option=value.
Some modules do not support the command line mode because command line tools with the same functionality already exist. The modules concerned and the command line tools available are:
sw_single provides package management and system update functionality. Use rug instead of YaST in your scripts. Refer to Section 9.1, Update from the Command Line with rug.
online_update_setup configures automatic updating of your system. This can be configured with cron.
With inst_suse_register, register your SUSE Linux Enterprise. For more information about the registration, see Section 8.3.4, Registering SUSE Linux Enterprise.
hwinfo provides information about the hardware of your system. The command hwinfo does the same.
These modules control or configure AppArmor. AppArmor has its own command line tools.
The YaST commands for user management, unlike traditional commands, considers the configured authentication method and default user management settings of your system when creating, modifying, or removing users. For example, you do not need create home directory or copy skel files during or after the user addition. If you enter the username and password, all other settings are made automatically in accordance with default configuration. The functionality provided by the command line is the same as in the graphical interface.
The YaST module users is used for user management. To display the command options, enter yast users help.
To add multiple users, create a /tmp/users.txt file with a list of users to add. Enter one username per line and use the following script:
Example 8-2 Adding Multiple Users
#!/bin/bash # # adds new user, the password is same as username # for i in `cat /tmp/users.txt`; do yast users add username=$i password=$i done
Similarly to adding, you can delete users defined in /tmp/users.txt:
Example 8-3 Removing Multiple Users
#!/bin/bash # # the home will be not deleted # to delete homes, use option delete_home # for i in `cat /tmp/users.txt`; do yast users delete username=$i done
Network and firewall configuration commands are often wanted in scripts. Use yast lan for network configuration and yast firewall.
To display the YaST network card configuration options, enter yast lan help. To display the YaST firewall card configuration options, enter yast firewall help. The network and firewall configurations with YaST are persistent. After reboot, it is not necessary to execute scripts again.
To display a configuration summary for the network, use yast lan list. The first item in the output of Example 8-4 is a device ID. To get more information about the configuration of the device, use yast lan show id=<number>. In this example, the correct command is yast lan show id=0.
Example 8-4 Sample Output of yast lan list
0 Digital DECchip 21142/43, DHCP
The command line interface of the YaST firewall configuration is a fast and easy way to enable or disable services, ports, or protocols. To display allowed services, ports, and protocols, use yast firewall services show. For examples of how to enable a service or port, use yast firewall services help. To enable masquerading, enter yast firewall masquerade enable.