- Suse linux manual pdf download

Looking for:

- (PDF) SUSE Linux Toolbox plus Commands | Aristide Kouame -  













































   

 

Suse linux manual pdf download.SUSE product documentation



  This guide covers system administration tasks like maintaining, monitoring and cus- tomizing an initially installed system. Publication Date: January 26, Download mstflint tools: zypper install mstflint. 2. Check the device's PCI. lspci | grep mellanox. 3. Check if SR-IOV is enabled in the firmware. Software repositories — Short procedures to find and download thousands of applications. ❑ Online resources — Listings of the best locations to find SUSE.  


Installing the SUSE Linux Enterprise Server Operating System



 

Note that the default for the clock setting is Universal Coordinated Time. Usually this is a server feature. Desktop Selection What type of desktop to run. Other options may include text mode only or a minimal X Window server for light resources. Installation Settings Review install options. Change any install options, such as partitioning, here and review prior to continuing. Package Begin the installation.

The system is now being initial- Installation ized and installed with the set- tings chosen. Password for Set the password for the Make it difficult to guess. Administrator Hostname and Set the host and domain. Select a hostname for the system Domain Name and optionally a domain name. Network Set up networking options. Test Internet Test if the Internet connection Here you can test if your network Connection is activated.

Additional Configure software add-ons. Configure extra software reposito- Installation Sources ries, possibly containing software packages that cannot be distributed with the openSUSE distribution.

Authentication Various screens for filling in The screens you see here will setup authentication information. Writing the System Applying settings to the system. Release Notes Notes about this version.

Last minute details about openSUSE are presented. Hardware Set up system hardware. YaST sets up hardware devices Configuration such as video cards, sound cards, and printers. Installation Installation has finished. YaST has finished installing the Complete system. You have an option to clone all settings used for this install, to use with AutoYaST.

This simple partitioning scheme is sufficient for most users. If these directories are located on separate partitions, the problems are contained on file systems other than the one root needs to use to log in and fix things. An RPM package. That information can include software descriptions, depend- encies, computer architecture, vendor, size, licensing, and other information.

RPMs may include installation scripts. The yast command is preferred over rpm for installing packages in most cases because yast will get dependent packages needed by those packages you request to install. Also, by get- ting packages from official repositories, you are most likely to get the latest avail- able packages.

Use zypper to add repositories Software Catalogs in YaST as well as search for and display information about available software packages, patches, and updates. As with YaST, zypper will automatically resolve software package dependencies, so you do not have to hunt around for every package needed to install a single piece of software.

Note, however, that Novell does not recommend mixing zypper with an environment managed by Novell ZENworks, since zypper does not use the ZENworks zmd database. There is some functionality built in to RPM to download and install individual packages from FTP and web servers, however this is mostly for convenience in contrast to downloading and installing the package in two steps. Related local commands and options are available for verifying software packages and repairing your local RPM database, if problems should occur.

The following sections deal with using software from repositories located around the world. Because there may be very different laws and regulations in some countries, you should check your local laws to determine the legal implications of using packages from third-party repositories. YaST has both a text-based flavor and a graphical version. The menu selections are the same in either utility.

If you are running a server, or low-resource installation, you will most likely encounter the command line text interface more frequently than the GUI. It is common for administrators to leave out the graphical libraries and desktop features when striving for an environment with a minimal maintenance and software foot- print.

This leaves a lean system with a minimized potential for software problems. A blue-themed interface will appear, showing two menus. You can toggle focus to the menus by pressing Tab, and then use the arrow keys to navigate the high- lighted selection bar over the menu items. When you have your selection highlighted, press Enter to proceed with that selection. You can also use the F1 key to bring up some information on navigating the YaST text interface.

The menu list on the left is a group of administrative areas and modules of the YaST environment. Table describes the YaST modules available for configuration. Hardware Configure video and sound cards, printers, hard disks, and all hardware connected to the system. Novell AppArmor Configure access control for software applications to minimize or eliminate threats caused by software vulnerabilities.

Security and Users Set up your firewall, users, groups, and sudo configurations. Miscellaneous View system logs, browse through release notes, configure AutoYaST, or post a support query. The next section focuses on the Software area of YaST for managing system software. These items fall under two basic categories: working with software from online servers and working with software from local directories, CD-ROM, or other disks on your system.

You can also verify Installation and Patch CDs from this area. The following sections describe the available menu items. Entering yast —l will show a list of modules you can enter at the command line without navigating the YaST dialog menus. For instance, entering yast sudo at the command line takes you right to the YaST Sudo Configuration module. Online Update When you select Online Update, YaST automatically begins synchronizing your sys- tem with the latest list of patches available from the Novell update sources.

You are then taken to a patch list and summary view where you can select which patches you want to install or apply to your existing system.

Once you are in the patch module, patches can be segregated into different groups by tabbing to the Filter item at the top left corner and pressing Enter to activate the pull- down menu. Select whether you want to view patches grouped into categories such as New, Recommended, or Security related.

You can also select the Search item from the pull-down menu to search for a specific patch. From this module you can quickly search for packages and view descriptions from a summary list about which packages offer which functionality.

Page or arrow through the software packages, then select Actions to add or delete packages as you choose. Dependencies for each package are automatically resolved upon selec- tion. When you have made all your selections, Tab to the Accept item in the lower right corner and press Enter.

Much like the Online Update module, a filter is available to limit the software summary view by different criteria such as functionality groups Office or Game software for instance , or only installed packages.

To search for packages, use the Filter menu and select Search. For example, if you enter the word magick, the filter will return all the packages it knows about which have the word magick in them such as the ImageMagick graphics conver- sion utility. Once a list of packages is displayed, you can act on the list of packages by selecting the Actions item, then the All Listed Packages menu. From there, you can choose to install all packages, delete them, or update them.

Selecting Accept and pressing Enter completes the tasks. Table shows other status flags you may select from the Actions menu. Keep the installed version indefinitely. You can set the time and day to download and apply the updates.

Daily and Weekly update intervals are available, as well as the ability to skip patches which may require administrative input such as accepting a license agreement prior to installation. You can enable the main update repository here as well as the popular Packman repository and many others scroll through the list to see more.

Installation into Directory The Installation into Directory module enables you to install additional SUSE Linux file sys- tems into a directory or create a tar file out of a file system. Using this method, you could use an offline file system as a test bed, or as an exported file system for a thin client or embedded device that could download its file system over NFS at boot time.

Note that Novell registration now requires you to use a web browser to complete the process, so you will not be able to do this from within the curses-based YaST tool. On the Configured Software Repositories screen, select the Add menu item at the bottom and press Enter. The Media Type screen appears. You can optionally configure YaST to download the repository descriptions when setting up the reposi- tory now, or it will do so later when you use the repository for the first time.

Uncheck Download repository description files if you do not want to do the download at this time. Select Next and press Enter. The next screen shows the Server and Directory menu.

For Authentication, you can leave Anonymous checked. Select Finish and press Enter. You should be prompted to accept the digital signing key for the repository you just entered. There is a warning given here that states There is no trust relationship to the owner of the key, and further down says it is safest to skip it.

It is generally good practice to import keys to validate any software you install. You will have to decide where your comfort level is. Much of this picture has been changing starting with the Utilities implementing Libzypp have emerged, with a utility called zypper being the focus for much of the command line package man- agement needs.

This leaves a lighter footprint on system resources as well as fewer require- ments for managing your software. Zypper can be used to search for, install, remove, and update software packages as well as manage installation sources called repositories. What follows are some useful ways of manag- ing software on openSUSE using the zypper utility. Working with zypper Repositories When you define a repository, zypper holds a configuration that tells zypper where to find software to work with.

If you have configured software locations in YaST, zypper will use them as well as other installation sources you may have configured through aptRPM, local file sources, and most ZENworks management systems.

You can use zypper to list, add, rename and delete repositories. Table shows the commands needed for managing zypper repositories, along with shortcut abbreviations for the commands. Also, keep in mind that command line help can be obtained by typing zypper —h at the command line. You will need to provide a URI for the install source as well as a name for it.

The source repos- itory has to be referred to by its alias. Remember to use quotes if you have whitespace or special shell characters in the alias. We can demon- strate adding a Zypper repository using this same install location. The following example tells zypper to show all the repositories it knows about as well as the status of those repositories in all example output, fields too long to display have been edited to fit the page width.

Main Repositor Zypper shows the repositories we had configured in YaST your list may look a bit different. After zypper is done, you can see it has added the new repository by issuing zypper lr as before. You can use the mr command to modify the Refresh or Enabled repository attrib- utes. Turning off the Refresh attribute will mean you have to refresh this repository manually; zypper will not do it automatically. You can see the ftp. Likewise, the following command turns off the Refresh of the ftp.

If you refresh all the repositories now, you can see ftp. All repositories have been refreshed. Note that the first repository is a DVD. You need to have the DVD mounted to refresh from that repository. You can use the —e flag, just as the —d flag was used, to re-enable the ftp. The —a flag, used the same way, will re-enable automatic-refresh. In the course of adding repositories, you may get prompted to accept a Package Signing Key.

There is a potential for malicious software to be introduced into your system through the use of third-party sources, which may be difficult to verify. The signing key is a way for your system to verify that the software came from where it says it came from. The odds may be slim, but nonethe- less there is some risk because the Internet is a public network. For more information about adding zypper services to openSUSE, visit the opensuse- community.

Searching for Software with zypper The zypper utility has a very feature-rich search utility built in that allows you to quickly and efficiently search through all, or certain, repositories for packages. Having the search utility right at your fingertips adds to making software maintenance very easy. Table shows some of the most useful search commands for zypper. Table Useful zypper Search Commands Command Abbreviation Description search se Use with a search pattern to narrow the search query or without to see all available packages.

Use —t to specify a resolvable to limit searching to. The following example shows how to add a repository and search for packages and patches using the zypper command. For installing wireless networking kernel drivers, having a repository custom tailored for your SUSE system can be very handy. Start by adding the Madwifi install location using the zypper command in the same way as the previous example.

Make sure you are adding the correct install location for the version of openSUSE you are running. Because we are using openSUSE You can see in the results that the search returned case-insensitive results for the original term.

In the first column of the output is the package Status. A v or i in this column indicates that another version of the package is installed, or the package, as listed, is already installed.

The second column shows in which Zypper repository the search word was found. The Type describes the type of resolvable the line refers to. Name and Version are obvious, and Arch lists whether this package is compiled for a specific system architecture. Zypper uses something called resolvables to designate the different types of resources you want it to work with. A resolvable can be a package, patch, pattern, language, or product.

It must match the Name column exactly: zypper patch-info fetchmsttfonts. Name: fetchmsttfonts. You can also view similar information about a package rather than a patch by issuing the info command with zypper: zypper info alsa-utils Installing and Removing Software with zypper To install and remove software with zypper, you need only give the install in or remove rm command along with the package name.

In the following example, zypper looks for information on the zoo archiving utility and finds it is in the Main Repository OSS.

After the operation, additional The following NEW patch is going to be installed: fetchmsttfonts. By using the shell command, you can work with zypper using a shell interface. This negates the need to include the zypper command every time you run a command.

Once in the shell, just enter the commands you would normally use on the command line. It is also a useful tool for installing, removing, and validat- ing RPMs that are available on your computer.

Using the rpm command, any user can query the local RPM database. To use the com- mand to install or remove software from your system, you must have root privileges. The example then installs the rpm package located in the current directory. Options in the rpm command include -U for update or install, -v for verbose, and -h to show progress hash marks. NOTE The -i option of rpm can also be used to install a package. However, most people use the -U option because it causes the package you are installing to replace an earlier, existing package of the same name if one exists.

You can use the -i option, however, if you want multiple instances of the same package to exist on the system. Having multiple kernel packages is an example of this. This approach works with http and ftp protocols. To upgrade, use the same rpm command line options, but with a newer package. This is one of the downsides of rpm — it does not resolve these dependencies. The command failed because of dependency issues. The best way to resolve depend- ency issues is to use zypper or yast to work through the dependencies automatically.

However, you may reach a point where you have to force the install or removal of a package. In this example, you specify that you want to remove the i version of the zoo package and ignore dependencies: rpm —e --nodeps zoo This example lists standard details about an installed package: rpm -qi zoo Name : zoo Relocations: not relocatable Version : 2. The compression rate of gzip is not reached, and thus zoo should only be used for decompressing old archives.

See the rpm man page for details. The most powerful rpm query option is --queryformat or --qf. It lets you build from scratch the output string. It may not perform correctly, or may not even start at all. Problems with corrupt packages from unstable network connections or power outages do happen. It becomes useful to check the files on the file system against the information stored in the RPM database.

So, use this tool as one way of checking the validity of your system, but not necessarily the only way. For each file verified, rpm runs multiple checks and displays the result in a series of characters at the beginning of the line. A dot means the check was okay. A letter or number means the check failed.

Table shows the most useful checks and the char- acters that represent their failure. This shows that the curl binary on the file system has a different size, MD5 checksum, and modification time than the one that came with the curl RPM. In other words, this file has been replaced. You can install the source RPM package, make changes to the source files of that package, and then rebuild the package using the commands shown in the following example: rpm -Uvh BashBurn The resulting RPM file is ready to be installed.

Extracting Files from RPMs An RPM is basically an archive of files that you want to install to your computer and some header information that identifies the software descriptions, checksums, build information, and so on. You can remove the archive from an RPM package and out- put the archive to a cpio archive file. The cpio format is similar to the tar format, described in Chapter 8, and can be similarly used for backing up and transporting files.

Instead of sending the output of the rpm2cpio command to a cpio archive file, you can pipe it through the cpio -tv command to view a long listing of the contents of that archive: rpm2cpio BashBurn For example, rpm -qlvp BashBurn To extract a single file from an RPM file, you can use rpm2cpio with a cpio -idv command that indicates the file you want. In the following command, the BashBurn. Using boot options, you can choose different install types and adapt to different environments.

To install additional software, you can use the YaST and zypper utilities to get packages from online repositories. To install packages locally, or query and verify installed pack- ages, you can use the RPM tools.

Besides its obvious use of Accessing the shell running commands, shells have many built-in fea- tures such as environment variables, aliases, and Using command his- a variety of functions for programming. Although tory and completion the shell used most often with Linux systems is Assigning aliases called the Bourne Again Shell bash , there are other shells available as well such as sh, csh, ksh, Gaining superuser tcsh, and others.

Some of these shells are out- access growths or replacement versions of older shells, a fact reflected by, for example, sh being a symbolic Writing simple shell link to bash. Terminal Windows and Shell Access The most common way to access a shell from a Linux graphical interface is using a Terminal window.

From a graphical interface, you can often access virtual terminals to get to a shell. With no graphical interface, with a text- based login you are typically dropped directly to a shell after login. The graphical examples in this book use the traditional KDE environment. This opens a konsole window, displaying a bash shell prompt.

Figure shows an example of a konsole window. Figure Type shell commands into a konsole window. The user name ericfj and hostname Brodgar appear in the title bar. The konsole window not only lets you access a shell, it also has controls for managing your shells.

The konsole window sup- ports a handy program called screen. Select New Screen Session from the Session menu to launch the screen program in a new tab. Some profile settings are cosmetic allow bold text, cursor blinks, terminal bell, colors, images, and transparency. Other settings are func- tional. For example, by default, the terminal saves scrollback lines. Some people like to be able to scroll back further and are willing to give up more memory to allow that.

See all the choices on the Settings menu for details. The Enlightenment desktop project offers the eterm terminal which includes features such as message logs on the screen background. Using Virtual Terminals When SUSE boots in multi-user mode runlevel 2, 3, or 5 , six virtual consoles known as tty1 through tty6 are created with text-based logins.

If an X Window System desktop is running, X is probably running in virtual console 7. Each console allows you to log in using different user accounts. When you switch to virtual terminal one through six, you see a login prompt similar to the following: Welcome to openSUSE You can have fewer or more virtual terminals by adding or deleting mingetty lines from that file.

Using the Shell After you open a shell whether from a text-based login or Terminal window , the shell environment is set up based on the user who started the shell.

Other shells use different con- figuration files. There are a variety of ways in which you can list and change your shell environment. Built into bash, as with other shells, is a history feature that lets you review, change, and reuse commands that you have run in the past. During a bash session, commands are added to history in memory. When bash exits, history in memory is written back to the. To list a previous number of history commands, follow history with a number.

With fc, you open the chosen command from history using the vi editor. The edited command runs when you exit the editor. NOTE By default, bash command history editing uses emacs-style commands. If you prefer the vi editor, you can use vi-style editing of your history by using the set command to set your editor to vi. To do that, type the following: set -o vi. Using Command Line Completion You can use the Tab key to complete different types of information on the command line.

The resulting process has two output streams: stdout for normal command output and stderr for error output. In the second example, stderr stream 2 is directed to errors. In the third example, the first two examples are combined. The last example directs both streams to the everything. That way any error messages can be sent to the person running the job. The second com- mand line displays Firefox processes taken from the long process list assuming the Firefox web browser is running.

The third command line lets you page through the process list. The last line displays the word rpm: followed by the path to the rpm man page, and then displays only the path to the man page the second ele- ment on the line.

Using backticks, you can execute one section of a command line first and feed the output of that command to the rest of the command line. The second command line finds the full path to the zypper command and does a long list ls -l of that command. Using the -t option to xargs, a verbose output of the command line appears before the com- mand is executed. Using alias Use the alias command to set and list aliases. Watching Files You can use the watch command to watch the size of a file.

For example, to watch a large ISO file named mydownload. You must have superuser permis- sions to access the messages file. Many sys- tem features are restricted to the root user, also referred to as the superuser. Using the su Command With a shell open as a regular user, you can use the su superuser command to become the root user. If no user is spec- ified, su defaults to the root user. The sudo facility is a great tool for granting specific escalated privileges when you have multiple users and logging everything the users do with those privi- leges.

Unless otherwise specified, sudo runs as root. A timestamp is set at that time as well. For the next five minutes by default , that user can type the command line above and have it work without being prompted for the password. Adding users and commands to the sudoers file can open your system to security breaches. The sudo command also allows the definition of aliases, or predefined groups of users, commands, and hosts.

Using Environment Variables Small chunks of information that are useful to your shell environment are stored in what are referred to as environment variables.

By convention, environment variable names are all uppercase although that convention is not enforced. The output just shown contains only a few examples of the environment variables you will see.

You can also set, or reset, any variables yourself. If you launch a command from that shell ls, cat, firefox, and so on , that new process will not see the vari- able. See Appendix B for a list of shell environment variables.

Bash and other shells include the basic constructs found in various programming languages, such as loops, tests, case statements, and so on. The main difference is that there is only one type of vari- able: strings. Editing and Running a Script Shell scripts are simple text files.

You can create them using your favorite text editor such as vi. To run, the shell script file must be executable. For example, if you created a shell script with a file name of myscript.

To correct this problem, you can edit your path, copy the script to a directory in your PATH, or enter the full or relative path to your script. This is a technique that could result in commands with the same file name as important, well-known commands such as ls or cat , which could be over- ridden if a command of the same name exists in the current directory.

Adding Content to Your Script Although a shell script can be a simple sequence of commands, shell scripts can also be used as you would any programming language. For example, a script can produce different results based on giving it different input. It then tests the input to see if it equals abc and acts based on the outcome of the test. If there is no match, then the else statement is used to produce the result.

Using the case statement, you can test for different cases and take an action based on the result. Similar to a switch statement in programming languages, case statements can take the place of several nested if statements. Each initscript takes actions based on what parameter was passed to it start, stop, and so on and the selection is done via a large case construct. The bash shell also offers standard loop constructs, illustrated by a few examples that follow.

Use that guide, along with reference material such as the bash man page, to step through many examples of good shell scripting techniques. Summary Despite improvements in graphical user interfaces, the shell is still the most common method for power users to work with Linux systems. The Bourne Again Shell bash is the most common shell used with Linux. It includes many helpful features for recalling commands history , completing commands, assigning aliases, and redirecting output from and input to commands.

You can make powerful commands of your own using simple shell scripting techniques. Associated with each file is a set of informa- tion that determines who can access the file and Traversing the file how they can access it. This chapter covers many system commands for exploring and working with files.

Creating and copying files Using hard and Understanding File Types symbolic links Directories and regular files are by far the file Changing file types you will use most often. However, there are attributes several other types of files you will encounter as you use Linux.

From the command line, there are Searching for files many ways you can create, find, and list different Listing and verifying types of files. There are character and block devices. There are hard links and soft links you can use to make the same file accessible from different locations. Less often used directly by regular users are named pipes and sockets, which pro- vide access points for processes to communicate with each other. Using Regular Files Regular files consist of data files documents, music, images, archives, and so on and commands binaries and scripts.

You can determine the type of a file using the file command. The file command that was run shows document files about the groff publishing and formatting of different formats. It can look inside the files and determine that a file contains text with troff markup used in man pages and old Unix documenta- tion , PostScript that can be sent directly to a printer, plain text, or HTML web page markup.

There is even a subdirectory shown examples. In this example, the file command did not guess correctly for the file ChangeLog. It does not contain C source code. In most cases, though, the file command is surprisingly accurate. Creating regular files can be done by any application that can save its data. If you just want to create some blank files to start with, there are many ways to do that. Commands are also regular files, but are saved as executables.

By running file on card, you can see that it is a shell script. Directories are called folders when you access them from graphical file managers.

To create new directories for storing your data, you can use the mkdir command. The second example creates directories as needed subdirectories a, b, and c to create the resulting new directory. The last command adds the -m option to set direc- tory permissions as well. Using Symbolic and Hard Links Instead of copying files and directories to different parts of the file system, links can be set up to access that same file from multiple locations.

Linux supports both soft links usually called symbolic links and hard links. When you try to open a symbolic link which points to a file or change to one that points to a directory, the command you run acts on the file or directory that is the target of that link.

The target has its own set of permissions and ownership that you cannot see from the symbolic link. The symbolic link can exist on a different disk partition than the tar- get. A hard link, by contrast, can only be used on files not directories and is basically a way of giving multiple names to the same physical file. Every physical file has at least one hard link, which is commonly thought of as the file itself. However, deleting one link will not remove the file; it will continue to exist until the last link to the file is deleted.

The -li option shows the inodes associated with each file. You can see that myfile and myfile-hardlink both have the inode number of signi- fying the exact same file on the hard disk. The myfile-symlink symbolic link has a different inode number.

And although the hard link simply appears as a file - , the symbolic link is identified as a link l with wide-open permissions. Devices are generally divided into block devices such as storage media and character devices such as serial ports and terminal devices. Each device file is associated with a major number indicating the type of device and minor number indicating the instance number of the device.

For example, terminal tty devices are represented by major character device 4, while SCSI hard disks are represented by major block device number 8. You must install the separate makedev package to get this command.

So most people never create device files manually. However, you can create your own device file using the mknod command. However, to provide a presence in the file system from which a process can communicate with other processes, you can create named pipes or sockets.

Named pipes are typically used for interprocess communication on the local system, while sockets can be used for processes to com- municate over a network. The second listing is a socket set up by the X GUI for interprocess communications. If you want to find where named pipes and sockets exist on your system, you can use the -type option to the find command, as described later in this chapter.

Setting File and Directory Permissions The ability to access files, run commands, and change to a directory can be restricted with permission settings for user, group, and other users. When you do a long list ls -l of files and directories in Linux, the beginning 10 characters shown indicate what the item is file, directory, block device, and so on along with whether or not the item can be read, written, or executed. Figure illustrates the meaning of those 10 characters.

Other types of files avail- able in Linux that would appear as the first character include character devices c , block devices b or symbolic links l , named pipes p , and sockets s. The next nine characters represent the permissions set on the file and directory. The first rwx indicates that the owner francois has read, write, and execute permissions on the directory. The group sales and all other users have only read and execute per- missions r-x ; the dash indicates the missing write permission.

For the hello. When you set out to change permissions, each permission can be represented by an octal number where read is 4, write is 2, and execute is 1 or a letter rwx. Generally speaking, read permission lets you view the contents of the directory, write lets you change add or modify the contents of the directory, and execute lets you change to in other words, access the directory. Changing Permissions with chmod The chmod command lets you change the access permissions of files and directories.

Table shows several chmod command lines and how access to the directory or file changes. All other users except root have no access. All others can change to the directory, but not view or change files in the directory. Good to protect a directory from errant chmod a-rwx changes. The first 0 in the mode line can usually be dropped so you can use instead of That placeholder has special meaning.

It is an octal digit that can be used on commands executables to indicate that the command can run as a set-UID program 4 , run as a set-GID program 2 , or become a sticky program 1. With set-UID and set-GID, the command runs with the assigned user or group permissions instead of running with permission of the user or group that launched the command.

SUID should not be used on shell scripts. Regardless of how secure you think the shell script is, it can be exploited to give the cracker a root shell. The final permission character is t instead of x on a sticky directory.

A command with sticky bit on used to cause the command to stay in memory, even while not being used. This is an old Unix feature that is not supported in Linux. The -R option is a handy feature of the chmod command. With -R, you can recursively change permissions of all files and directories starting from a point in the file system. Setting the umask Permissions given to a file or directory are assigned originally at the time that item is created.

Using the umask command, you can set the permissions given to files and directories when you create them. Changing Ownership When you create a file or directory, your user account is assigned to that file or direc- tory. So is your primary group. As with chmod, using chown recursively changes permissions for the directory named, along with its contents. Traversing the File System Basic commands for changing directories cd , checking the current directory pwd and listing directory contents ls are well known to even casual shell users.

So this sec- tion focuses on some less-common options to those commands, as well as other lesser- known features for moving around the file system.

However, symbolic links can cause some confusion about how parent directories are viewed. For example, cd -L.. Likewise, -P and -L options to pwd show permanent and link locations. Bash can remember a list of working directories. Such a list can be useful if you want to return to previously visited directories. That list is organized in the form of a stack. For example, pushd -0 pushes the last directory on the stack to the top of the stack making it the current directory. The pushd -2 com- mand pushes the third directory from the bottom of the stack to the top.

Copying Files Provided you have write permission to the target directory, copying files and directo- ries can be done with some fairly simple commands.

Here are some examples: cd ; touch index. In the next example, the index. In that case, because both hard links point to the same file, editing the file from either location will change the contents of the file in both locations. The dd command is another way to copy data. This command is very powerful because on Linux systems, everything is a file, including hardware peripherals.

The count is the number of blocks. By default, a block is bytes. The result is a bytes- long file full of null characters. You could use less or vi to view the contents of the file. Typically the partition should be unmounted before a backup such as this. Changing File Attributes Files and directories in Linux file systems all have read, write, and execute permissions associated with user, group, and others.

However, there are also other attributes that can be attached to files and directories that are specific to certain file system types. Files on ext2 and ext3 file systems have special attributes that you may choose to use. You can list these attributes with the lsattr command. Most attributes are obscure and not turned on by default. None are on by default. Those attributes are the following: a append only , c compressed , d no dump , i immutable , j data journalling , s secure deletion , t no tail-merging , u undeletable , A no atime updates , D synchronous directory updates , S synchro- nous updates , and T top of directory hierarchy.

You can change these attributes using the chattr command. Here, this prevents any arbitrary changes to the grub. Not even the root user can change the file until the i attribute is gone. In this case, we chose to not have a large ISO image backed up. To remove an attribute with chatter, use the minus sign -.

The locate command allows you to search that database. The results come back instantly, since the database is searched and not the actual file system. Before locate was avail- able, most Linux users ran the find command to find files in the file system. Both locate and find are covered here. Then, run the updatedb command to set up the database used by the locate command.

Finding Files with locate Because the database contains the name of every node in the file system, and not just commands, you can use locate to find commands, devices, man pages, data files, or anything else identified by a name in the file system. Although locate will come up with a file faster, find has many other powerful options for find- ing files based on attributes other than the name.

Before searching the whole file system, consider searching a subset of the file system or excluding certain directories or remotely mounted file systems. The find -exec spawns the command ls for each result it finds. The xargs command works more efficiently by passing many results as input to a single ls command. To negate a search criteria, place an exclamation point!

Finding files by size is a great way to determine what is filling up your hard disks. You may also want to run this command as root. From the example of whereis for the word man, you can see the man executable, its configuration file, and the location of man pages for the man command. With md5sum and sha1sum, you can verify the validity of a file.

Listing Files Although you are probably quite familiar with the ls command, you may not be familiar with many of the useful options for ls that can help you find out a lot about the files on your system. The next two examples display dif- ferent file types in different colors and lists output in columns, respectively.

Those files contain checksums that can be used to make sure that the file you downloaded is exactly the one that the repository published.

By combining the find command described earlier in this chapter with the md5sum command, you can verify any part of your file system. So the next step is to check the changed file and see if the changes to that file were intentional. Commands such as chmod can change the permissions associated with a file, while commands that include lsattr and chattr can be used to list and change file attributes that are associated with ext2 and ext3 file system types.

To move around the file system, people use the cd command most often. However, to move repeatedly among the same directories, you can use the pushd and popd commands to work with a stack of directories. Copying files is done with the cp command. However, the dd command can be used to copy files such as disk images from a device such as a CD-ROM drive.

For creat- ing directories, you can use the mkdir command. Instead of keeping multiple copies of a file around on the file system, you can use symbolic links and hard links to have multiple file names point to the same file or directory.

Symbolic links can be anywhere in the file system, while hard links must exist on the same partition that the original file is on. To search for files, Linux offers the locate and find commands.

To verify the integrity of files you download from the Internet, you can use the md5sum and sha1sum commands. Documents, program code, regular expressions configuration files, e-mail, and almost anything you created or configured was represented by Editing text files with text files. To work with those files, early develop- vi, JOE, or nano ers created many text manipulation tools.

Using graphical text editors Despite having graphical tools for working with text, most seasoned Linux users find command Listing text with cat, line tools to be more efficient and convenient.

Commands such as grep, sed, and awk and more can be used to find, and possibly change, pieces Paginating text with pr of information within text files. Searching for text This chapter shows how to use many popular with grep commands for working with text files in SUSE. Counting words, It also explores some of the less common uses of lines, and characters text manipulation commands that you might find with wc interesting.

Sorting output with sort Matching Text Stream editing with sed, tr, cut, and awk with Regular Expressions Searching binaries for text with strings Many of the tools for working with text allow you to use regular expressions, sometimes referred to as Finding differences in regex, to identify the text you are looking for based files with diff on some pattern.

It can also be specific find just the word hello or more inclusive find any word beginning with h and ending with o. Appendix C includes reference information for shell metacharacters that can be used in conjunction with regular expressions to do the exact kinds of matches you are look- ing for.

This section shows examples of using regular expressions with several differ- ent tools you encounter throughout this chapter. Table shows some examples using basic regular expressions to match text strings.

Many examples of regular expressions are used in examples throughout this chapter. Keep in mind that not every command that incorporates regex uses its features the same way. The editor that is most common is vi, which can be found virtually on any Unix system available today. One day, if you find yourself in a minimalist, foreign Linux environment trying to bring a server back online, vi is the tool that will almost always be there.

On SUSE, make sure you have the vim-enhanced package installed. Vim Vi IMproved with the vim-enhanced package will provide the most up-to-date, feature-rich and user-friendly vi editor. By default, SUSE just installs the regular vim packages. For more details about using vi, refer to Appendix A. Traditionally, the other popular Unix text editor has been Emacs and its more graphical variant, XEmacs. Emacs is also known for its very complex series of keyboard shortcuts that require three arms to execute properly.

In the mids, Emacs was ahead of vi in terms of features. If you are not already familiar with either vi or Emacs, we recommend you start by learning vi. There are many other command-line and GUI text editors available for Linux. Start any of those editors by typing its command name, optionally fol- lowed by the file name you want to edit. The following sections offer some quick descriptions of how to use each of those editors.

Using the JOE Editor If you have used classic word processors such as WordStar that worked with text files, you might be comfortable with the JOE editor from the joe package, installed by default. To use the spell checker in JOE, install the aspell package. With JOE, instead of entering a command or text mode, you are always ready to type.

To move around in the file, you can use control characters or the arrow keys. You can use keyboard shortcuts for many functions. Use arrow keys to move the cursor left, right, up, or down. Use the Delete key to delete text under the cursor or the Backspace to erase text to the left of the cursor.

Press Enter to add a line break. Table shows the most commonly used. Although Pico is free, it is not truly open source. SUSE provides both Pico and nano as optional packages. This section describes the nano editor. On SUSE, nano is part of the nano package and relies on the spell program for spell checking.

This program is not nor- mally available on SUSE, though. As with the JOE editor, instead of having command and typing modes, you can just begin typing. Use the Delete key to delete text under the cursor or the Backspace key to erase text to the left of the cursor. Table shows the control codes for nano that are described on the help screen. The main advantages of using a graphical text editor is that you can use a mouse to select menus, highlight text, cut and copy text, or run special plug-ins.

Features in gedit let you check spelling, list docu- ment statistics, change display fonts and colors, and print your documents.

It includes similar features to the GNOME text editor, along with many extras, such as the ability to send the current document with kmail or another user-configurable KDE component. Vim itself comes with an X GUI version. It is launched with the gvim command, which is part of the gvim package. Other text editors you can install include nedit with features for using macros and executing shell commands and leafpad which is similar to the Windows Notepad text editor.

The Scribes text editor scribes includes some advanced features for automatic correction, replacement, indentation, and word completion. Listing, Sorting, and Changing Text Instead of just editing a single text file, you can use a variety of Linux commands to display, search, and manipulate the contents of one or more text files at a time.

The cat command concatenates in other words, outputs as a string of characters the con- tents of a text file to your display by default. You can then use different shell metachar- acters to direct the contents of that file in different ways. You can specify the line count as a parameter to display any number of lines from the beginning of a file.

For example, in the example with ps above, more could not scroll up. The less command was created as a more powerful and user- friendly more. NOTE less has another benefit worth noting. Unlike text editors such as vi, it does not read the entire file when it starts.

This results in faster start-up times when viewing large files. If you are using less on a file not standard input , press v to open the current file in vi. If none are set, less defaults to vi. To scroll forward and back while using less, use the f and b keys, respectively. For example, 10f scrolls forward 10 lines and 15b scrolls back 15 lines. Type d to scroll down half a screen and u to scroll up half a screen. Paginating Text Files with pr The pr command provides a quick way to format a bunch of text into a form where it can be printed.

This can be particularly useful if you want to print the results of some commands, without having to open up a word processor or text editor. With pr, you can format text into pages with header information such as date, time, file name, and page num- ber.

Finally, the less command lets you page through the text. Instead of paging through the output, you can send the output to a file or to a printer. Searching for Text with grep The grep command comes in handy when you need to perform more advanced string searches in a file.

In fact, the phrase to grep has actually entered the computer jargon as a verb, just as to Google has entered the popular language. By searching apache2 for you can see requests to your web server for pages that were not found; these could be someone fishing to exploit your system, or a web page you moved or forgot to create. You must install a web server such as apache2 first. This procedure describes the final step of installing the SUSE Linux boot image on your server module.

Connect the server module to the same network as the PXE server, and power on the server module. When prompted, press the F8 key to begin downloading the PXE boot image. This procedure describes how to update the SUSE operating system. Because software is constantly being updated, your distribution media might not contain the most up-to-date versions of the operating system. Follow this procedure after your operating system is installed. If you are behind a network firewall and need to use a proxy server to access the Internet, you must first configure YaST with the correct proxy information.

Select the Network Services tab on the left, then the Proxy screen on the right. Exit the YaST utility and type the following command:. After successfully running the command, launch YaST again. Register with the Novell Customer Center. Select the Software tab on the left. Then select Novell Customer Center Configuration and follow the directions. After you are registered, select the Online Update tab to perform the software update.

This section describes how to install server-specific software from the Tools and Drivers CD. All files are located on the Tools and Drivers CD. When you are done, reboot the system to initialize the new driver:.

When the rpm command is done, reboot the system to initialize the new driver:.

   

 

Suse linux manual pdf download. SUSE Linux Enterprise Server Administration Guide



   

Continue to the next section for information on boot options. Add Boot Prompt Options If you choose to bypass the menu on the boot screen and start your install from a simple boot prompt, there are a lot of options you can enter to direct how installation proceeds.

You may want to consider using the ssh option whenever possible. If you run the install in text mode if your graphical screens are garbled , you will be work- ing in the YaST text mode tool. The installer will show you the SSH connection instructions on the screen. Most boot options you add to existing install types are meant to help work around problems that might occur during installation.

From the boot prompt, type linux, followed by one or more of the boot options shown in Table , to deal with common problems. Hardware improperly Tell the boot process to noprobe probed. System hangs trying to Disable hardware or nousb nopcmcia nofirewire enable some hardware. Use tty0 for the first virtual console, or ttyS0 for the first serial port. See the vesafb. Answering Installation Questions Most of the screens you see during installation are quite intuitive.

Table offers a quick review of those screens, along with tips where you might need some help. If you need support for additional languages, add them later. If the media passes, you can continue. License Agreement Novell software agreement. You must accept the license to install the openSUSE operating system.

Installation Mode Update or install mode. Update an existing openSUSE installation, or install a new one. You can also specify whether to use online repositories for SUSE packages. You will also need to configure a network connection.

Set the date and time zone for Time Zone your system. Note that the default for the clock setting is Universal Coordinated Time. Usually this is a server feature. Desktop Selection What type of desktop to run. Other options may include text mode only or a minimal X Window server for light resources.

Installation Settings Review install options. Change any install options, such as partitioning, here and review prior to continuing. Package Begin the installation. The system is now being initial- Installation ized and installed with the set- tings chosen. Password for Set the password for the Make it difficult to guess. Administrator Hostname and Set the host and domain. Select a hostname for the system Domain Name and optionally a domain name.

Network Set up networking options. Test Internet Test if the Internet connection Here you can test if your network Connection is activated. Additional Configure software add-ons. Configure extra software reposito- Installation Sources ries, possibly containing software packages that cannot be distributed with the openSUSE distribution.

Authentication Various screens for filling in The screens you see here will setup authentication information. Writing the System Applying settings to the system. Release Notes Notes about this version. Last minute details about openSUSE are presented. Hardware Set up system hardware. YaST sets up hardware devices Configuration such as video cards, sound cards, and printers. Installation Installation has finished. YaST has finished installing the Complete system.

You have an option to clone all settings used for this install, to use with AutoYaST. This simple partitioning scheme is sufficient for most users.

If these directories are located on separate partitions, the problems are contained on file systems other than the one root needs to use to log in and fix things. An RPM package.

That information can include software descriptions, depend- encies, computer architecture, vendor, size, licensing, and other information. RPMs may include installation scripts. The yast command is preferred over rpm for installing packages in most cases because yast will get dependent packages needed by those packages you request to install.

Also, by get- ting packages from official repositories, you are most likely to get the latest avail- able packages. Use zypper to add repositories Software Catalogs in YaST as well as search for and display information about available software packages, patches, and updates. As with YaST, zypper will automatically resolve software package dependencies, so you do not have to hunt around for every package needed to install a single piece of software.

Note, however, that Novell does not recommend mixing zypper with an environment managed by Novell ZENworks, since zypper does not use the ZENworks zmd database. There is some functionality built in to RPM to download and install individual packages from FTP and web servers, however this is mostly for convenience in contrast to downloading and installing the package in two steps. Related local commands and options are available for verifying software packages and repairing your local RPM database, if problems should occur.

The following sections deal with using software from repositories located around the world. Because there may be very different laws and regulations in some countries, you should check your local laws to determine the legal implications of using packages from third-party repositories. YaST has both a text-based flavor and a graphical version.

The menu selections are the same in either utility. If you are running a server, or low-resource installation, you will most likely encounter the command line text interface more frequently than the GUI. It is common for administrators to leave out the graphical libraries and desktop features when striving for an environment with a minimal maintenance and software foot- print.

This leaves a lean system with a minimized potential for software problems. A blue-themed interface will appear, showing two menus. You can toggle focus to the menus by pressing Tab, and then use the arrow keys to navigate the high- lighted selection bar over the menu items. When you have your selection highlighted, press Enter to proceed with that selection. You can also use the F1 key to bring up some information on navigating the YaST text interface.

The menu list on the left is a group of administrative areas and modules of the YaST environment. Table describes the YaST modules available for configuration. Hardware Configure video and sound cards, printers, hard disks, and all hardware connected to the system.

Novell AppArmor Configure access control for software applications to minimize or eliminate threats caused by software vulnerabilities. Security and Users Set up your firewall, users, groups, and sudo configurations. Miscellaneous View system logs, browse through release notes, configure AutoYaST, or post a support query. The next section focuses on the Software area of YaST for managing system software. These items fall under two basic categories: working with software from online servers and working with software from local directories, CD-ROM, or other disks on your system.

You can also verify Installation and Patch CDs from this area. The following sections describe the available menu items. Entering yast —l will show a list of modules you can enter at the command line without navigating the YaST dialog menus.

For instance, entering yast sudo at the command line takes you right to the YaST Sudo Configuration module. Online Update When you select Online Update, YaST automatically begins synchronizing your sys- tem with the latest list of patches available from the Novell update sources. You are then taken to a patch list and summary view where you can select which patches you want to install or apply to your existing system.

Once you are in the patch module, patches can be segregated into different groups by tabbing to the Filter item at the top left corner and pressing Enter to activate the pull- down menu. Select whether you want to view patches grouped into categories such as New, Recommended, or Security related. You can also select the Search item from the pull-down menu to search for a specific patch.

From this module you can quickly search for packages and view descriptions from a summary list about which packages offer which functionality. Page or arrow through the software packages, then select Actions to add or delete packages as you choose. Dependencies for each package are automatically resolved upon selec- tion. When you have made all your selections, Tab to the Accept item in the lower right corner and press Enter. Much like the Online Update module, a filter is available to limit the software summary view by different criteria such as functionality groups Office or Game software for instance , or only installed packages.

To search for packages, use the Filter menu and select Search. For example, if you enter the word magick, the filter will return all the packages it knows about which have the word magick in them such as the ImageMagick graphics conver- sion utility.

Once a list of packages is displayed, you can act on the list of packages by selecting the Actions item, then the All Listed Packages menu. From there, you can choose to install all packages, delete them, or update them. Selecting Accept and pressing Enter completes the tasks. Table shows other status flags you may select from the Actions menu. Keep the installed version indefinitely.

You can set the time and day to download and apply the updates. Daily and Weekly update intervals are available, as well as the ability to skip patches which may require administrative input such as accepting a license agreement prior to installation.

You can enable the main update repository here as well as the popular Packman repository and many others scroll through the list to see more. Installation into Directory The Installation into Directory module enables you to install additional SUSE Linux file sys- tems into a directory or create a tar file out of a file system.

Using this method, you could use an offline file system as a test bed, or as an exported file system for a thin client or embedded device that could download its file system over NFS at boot time. Note that Novell registration now requires you to use a web browser to complete the process, so you will not be able to do this from within the curses-based YaST tool. On the Configured Software Repositories screen, select the Add menu item at the bottom and press Enter.

The Media Type screen appears. You can optionally configure YaST to download the repository descriptions when setting up the reposi- tory now, or it will do so later when you use the repository for the first time. Uncheck Download repository description files if you do not want to do the download at this time. Select Next and press Enter. The next screen shows the Server and Directory menu. For Authentication, you can leave Anonymous checked. Select Finish and press Enter.

You should be prompted to accept the digital signing key for the repository you just entered. There is a warning given here that states There is no trust relationship to the owner of the key, and further down says it is safest to skip it. It is generally good practice to import keys to validate any software you install. You will have to decide where your comfort level is. Much of this picture has been changing starting with the Utilities implementing Libzypp have emerged, with a utility called zypper being the focus for much of the command line package man- agement needs.

This leaves a lighter footprint on system resources as well as fewer require- ments for managing your software. Zypper can be used to search for, install, remove, and update software packages as well as manage installation sources called repositories.

What follows are some useful ways of manag- ing software on openSUSE using the zypper utility. Working with zypper Repositories When you define a repository, zypper holds a configuration that tells zypper where to find software to work with. If you have configured software locations in YaST, zypper will use them as well as other installation sources you may have configured through aptRPM, local file sources, and most ZENworks management systems.

You can use zypper to list, add, rename and delete repositories. Table shows the commands needed for managing zypper repositories, along with shortcut abbreviations for the commands.

Also, keep in mind that command line help can be obtained by typing zypper —h at the command line. You will need to provide a URI for the install source as well as a name for it. The source repos- itory has to be referred to by its alias. Remember to use quotes if you have whitespace or special shell characters in the alias. We can demon- strate adding a Zypper repository using this same install location.

The following example tells zypper to show all the repositories it knows about as well as the status of those repositories in all example output, fields too long to display have been edited to fit the page width.

Main Repositor Zypper shows the repositories we had configured in YaST your list may look a bit different. After zypper is done, you can see it has added the new repository by issuing zypper lr as before. You can use the mr command to modify the Refresh or Enabled repository attrib- utes. Turning off the Refresh attribute will mean you have to refresh this repository manually; zypper will not do it automatically. You can see the ftp. Likewise, the following command turns off the Refresh of the ftp.

If you refresh all the repositories now, you can see ftp. All repositories have been refreshed. Note that the first repository is a DVD. You need to have the DVD mounted to refresh from that repository.

You can use the —e flag, just as the —d flag was used, to re-enable the ftp. The —a flag, used the same way, will re-enable automatic-refresh. In the course of adding repositories, you may get prompted to accept a Package Signing Key.

There is a potential for malicious software to be introduced into your system through the use of third-party sources, which may be difficult to verify.

The signing key is a way for your system to verify that the software came from where it says it came from. The odds may be slim, but nonethe- less there is some risk because the Internet is a public network.

For more information about adding zypper services to openSUSE, visit the opensuse- community. Searching for Software with zypper The zypper utility has a very feature-rich search utility built in that allows you to quickly and efficiently search through all, or certain, repositories for packages. Having the search utility right at your fingertips adds to making software maintenance very easy.

Table shows some of the most useful search commands for zypper. Table Useful zypper Search Commands Command Abbreviation Description search se Use with a search pattern to narrow the search query or without to see all available packages. Use —t to specify a resolvable to limit searching to. The following example shows how to add a repository and search for packages and patches using the zypper command.

For installing wireless networking kernel drivers, having a repository custom tailored for your SUSE system can be very handy. Start by adding the Madwifi install location using the zypper command in the same way as the previous example.

Make sure you are adding the correct install location for the version of openSUSE you are running. Because we are using openSUSE You can see in the results that the search returned case-insensitive results for the original term. In the first column of the output is the package Status. A v or i in this column indicates that another version of the package is installed, or the package, as listed, is already installed.

The second column shows in which Zypper repository the search word was found. The Type describes the type of resolvable the line refers to. Name and Version are obvious, and Arch lists whether this package is compiled for a specific system architecture.

Zypper uses something called resolvables to designate the different types of resources you want it to work with. A resolvable can be a package, patch, pattern, language, or product. It must match the Name column exactly: zypper patch-info fetchmsttfonts. Name: fetchmsttfonts. You can also view similar information about a package rather than a patch by issuing the info command with zypper: zypper info alsa-utils Installing and Removing Software with zypper To install and remove software with zypper, you need only give the install in or remove rm command along with the package name.

In the following example, zypper looks for information on the zoo archiving utility and finds it is in the Main Repository OSS. After the operation, additional The following NEW patch is going to be installed: fetchmsttfonts. By using the shell command, you can work with zypper using a shell interface. This negates the need to include the zypper command every time you run a command. Once in the shell, just enter the commands you would normally use on the command line.

It is also a useful tool for installing, removing, and validat- ing RPMs that are available on your computer. Using the rpm command, any user can query the local RPM database. To use the com- mand to install or remove software from your system, you must have root privileges.

The example then installs the rpm package located in the current directory. Options in the rpm command include -U for update or install, -v for verbose, and -h to show progress hash marks. NOTE The -i option of rpm can also be used to install a package. However, most people use the -U option because it causes the package you are installing to replace an earlier, existing package of the same name if one exists.

You can use the -i option, however, if you want multiple instances of the same package to exist on the system. Having multiple kernel packages is an example of this. This approach works with http and ftp protocols. To upgrade, use the same rpm command line options, but with a newer package. This is one of the downsides of rpm — it does not resolve these dependencies.

The command failed because of dependency issues. The best way to resolve depend- ency issues is to use zypper or yast to work through the dependencies automatically. However, you may reach a point where you have to force the install or removal of a package. In this example, you specify that you want to remove the i version of the zoo package and ignore dependencies: rpm —e --nodeps zoo This example lists standard details about an installed package: rpm -qi zoo Name : zoo Relocations: not relocatable Version : 2.

The compression rate of gzip is not reached, and thus zoo should only be used for decompressing old archives. See the rpm man page for details. The most powerful rpm query option is --queryformat or --qf. It lets you build from scratch the output string. It may not perform correctly, or may not even start at all. Problems with corrupt packages from unstable network connections or power outages do happen.

It becomes useful to check the files on the file system against the information stored in the RPM database. So, use this tool as one way of checking the validity of your system, but not necessarily the only way. For each file verified, rpm runs multiple checks and displays the result in a series of characters at the beginning of the line. A dot means the check was okay. A letter or number means the check failed. Table shows the most useful checks and the char- acters that represent their failure.

This shows that the curl binary on the file system has a different size, MD5 checksum, and modification time than the one that came with the curl RPM. In other words, this file has been replaced. You can install the source RPM package, make changes to the source files of that package, and then rebuild the package using the commands shown in the following example: rpm -Uvh BashBurn The resulting RPM file is ready to be installed. Extracting Files from RPMs An RPM is basically an archive of files that you want to install to your computer and some header information that identifies the software descriptions, checksums, build information, and so on.

You can remove the archive from an RPM package and out- put the archive to a cpio archive file. The cpio format is similar to the tar format, described in Chapter 8, and can be similarly used for backing up and transporting files.

Instead of sending the output of the rpm2cpio command to a cpio archive file, you can pipe it through the cpio -tv command to view a long listing of the contents of that archive: rpm2cpio BashBurn For example, rpm -qlvp BashBurn To extract a single file from an RPM file, you can use rpm2cpio with a cpio -idv command that indicates the file you want.

In the following command, the BashBurn. Using boot options, you can choose different install types and adapt to different environments. To install additional software, you can use the YaST and zypper utilities to get packages from online repositories. To install packages locally, or query and verify installed pack- ages, you can use the RPM tools. Besides its obvious use of Accessing the shell running commands, shells have many built-in fea- tures such as environment variables, aliases, and Using command his- a variety of functions for programming.

Although tory and completion the shell used most often with Linux systems is Assigning aliases called the Bourne Again Shell bash , there are other shells available as well such as sh, csh, ksh, Gaining superuser tcsh, and others. Some of these shells are out- access growths or replacement versions of older shells, a fact reflected by, for example, sh being a symbolic Writing simple shell link to bash.

Terminal Windows and Shell Access The most common way to access a shell from a Linux graphical interface is using a Terminal window. From a graphical interface, you can often access virtual terminals to get to a shell. With no graphical interface, with a text- based login you are typically dropped directly to a shell after login. The graphical examples in this book use the traditional KDE environment. This opens a konsole window, displaying a bash shell prompt.

Figure shows an example of a konsole window. Figure Type shell commands into a konsole window. The user name ericfj and hostname Brodgar appear in the title bar.

The konsole window not only lets you access a shell, it also has controls for managing your shells. The konsole window sup- ports a handy program called screen.

Select New Screen Session from the Session menu to launch the screen program in a new tab. Some profile settings are cosmetic allow bold text, cursor blinks, terminal bell, colors, images, and transparency. Other settings are func- tional. For example, by default, the terminal saves scrollback lines. Some people like to be able to scroll back further and are willing to give up more memory to allow that. See all the choices on the Settings menu for details.

The Enlightenment desktop project offers the eterm terminal which includes features such as message logs on the screen background. Using Virtual Terminals When SUSE boots in multi-user mode runlevel 2, 3, or 5 , six virtual consoles known as tty1 through tty6 are created with text-based logins.

If an X Window System desktop is running, X is probably running in virtual console 7. Each console allows you to log in using different user accounts. When you switch to virtual terminal one through six, you see a login prompt similar to the following: Welcome to openSUSE You can have fewer or more virtual terminals by adding or deleting mingetty lines from that file. Using the Shell After you open a shell whether from a text-based login or Terminal window , the shell environment is set up based on the user who started the shell.

Other shells use different con- figuration files. There are a variety of ways in which you can list and change your shell environment. Built into bash, as with other shells, is a history feature that lets you review, change, and reuse commands that you have run in the past. During a bash session, commands are added to history in memory. When bash exits, history in memory is written back to the. To list a previous number of history commands, follow history with a number.

With fc, you open the chosen command from history using the vi editor. The edited command runs when you exit the editor. NOTE By default, bash command history editing uses emacs-style commands. If you prefer the vi editor, you can use vi-style editing of your history by using the set command to set your editor to vi.

To do that, type the following: set -o vi. Using Command Line Completion You can use the Tab key to complete different types of information on the command line. The resulting process has two output streams: stdout for normal command output and stderr for error output.

In the second example, stderr stream 2 is directed to errors. In the third example, the first two examples are combined. The last example directs both streams to the everything. That way any error messages can be sent to the person running the job. The second com- mand line displays Firefox processes taken from the long process list assuming the Firefox web browser is running. The third command line lets you page through the process list. The last line displays the word rpm: followed by the path to the rpm man page, and then displays only the path to the man page the second ele- ment on the line.

Using backticks, you can execute one section of a command line first and feed the output of that command to the rest of the command line. The second command line finds the full path to the zypper command and does a long list ls -l of that command. Using the -t option to xargs, a verbose output of the command line appears before the com- mand is executed.

Using alias Use the alias command to set and list aliases. Watching Files You can use the watch command to watch the size of a file. For example, to watch a large ISO file named mydownload. You must have superuser permis- sions to access the messages file. Many sys- tem features are restricted to the root user, also referred to as the superuser. Using the su Command With a shell open as a regular user, you can use the su superuser command to become the root user.

If no user is spec- ified, su defaults to the root user. The sudo facility is a great tool for granting specific escalated privileges when you have multiple users and logging everything the users do with those privi- leges. Unless otherwise specified, sudo runs as root. A timestamp is set at that time as well. For the next five minutes by default , that user can type the command line above and have it work without being prompted for the password.

Adding users and commands to the sudoers file can open your system to security breaches. The sudo command also allows the definition of aliases, or predefined groups of users, commands, and hosts. Using Environment Variables Small chunks of information that are useful to your shell environment are stored in what are referred to as environment variables.

By convention, environment variable names are all uppercase although that convention is not enforced. The output just shown contains only a few examples of the environment variables you will see.

You can also set, or reset, any variables yourself. If you launch a command from that shell ls, cat, firefox, and so on , that new process will not see the vari- able. See Appendix B for a list of shell environment variables. Bash and other shells include the basic constructs found in various programming languages, such as loops, tests, case statements, and so on. The main difference is that there is only one type of vari- able: strings. Editing and Running a Script Shell scripts are simple text files.

You can create them using your favorite text editor such as vi. To run, the shell script file must be executable. For example, if you created a shell script with a file name of myscript. To correct this problem, you can edit your path, copy the script to a directory in your PATH, or enter the full or relative path to your script. This is a technique that could result in commands with the same file name as important, well-known commands such as ls or cat , which could be over- ridden if a command of the same name exists in the current directory.

Adding Content to Your Script Although a shell script can be a simple sequence of commands, shell scripts can also be used as you would any programming language. For example, a script can produce different results based on giving it different input. It then tests the input to see if it equals abc and acts based on the outcome of the test. If there is no match, then the else statement is used to produce the result. Using the case statement, you can test for different cases and take an action based on the result.

Similar to a switch statement in programming languages, case statements can take the place of several nested if statements. Each initscript takes actions based on what parameter was passed to it start, stop, and so on and the selection is done via a large case construct. The bash shell also offers standard loop constructs, illustrated by a few examples that follow.

Use that guide, along with reference material such as the bash man page, to step through many examples of good shell scripting techniques. Summary Despite improvements in graphical user interfaces, the shell is still the most common method for power users to work with Linux systems.

The Bourne Again Shell bash is the most common shell used with Linux. It includes many helpful features for recalling commands history , completing commands, assigning aliases, and redirecting output from and input to commands.

You can make powerful commands of your own using simple shell scripting techniques. Associated with each file is a set of informa- tion that determines who can access the file and Traversing the file how they can access it. This chapter covers many system commands for exploring and working with files. Creating and copying files Using hard and Understanding File Types symbolic links Directories and regular files are by far the file Changing file types you will use most often.

However, there are attributes several other types of files you will encounter as you use Linux. From the command line, there are Searching for files many ways you can create, find, and list different Listing and verifying types of files.

There are character and block devices. There are hard links and soft links you can use to make the same file accessible from different locations.

Less often used directly by regular users are named pipes and sockets, which pro- vide access points for processes to communicate with each other. Using Regular Files Regular files consist of data files documents, music, images, archives, and so on and commands binaries and scripts.

You can determine the type of a file using the file command. The file command that was run shows document files about the groff publishing and formatting of different formats. It can look inside the files and determine that a file contains text with troff markup used in man pages and old Unix documenta- tion , PostScript that can be sent directly to a printer, plain text, or HTML web page markup.

There is even a subdirectory shown examples. In this example, the file command did not guess correctly for the file ChangeLog. It does not contain C source code.

In most cases, though, the file command is surprisingly accurate. Creating regular files can be done by any application that can save its data. If you just want to create some blank files to start with, there are many ways to do that. Commands are also regular files, but are saved as executables. By running file on card, you can see that it is a shell script.

Directories are called folders when you access them from graphical file managers. To create new directories for storing your data, you can use the mkdir command. The second example creates directories as needed subdirectories a, b, and c to create the resulting new directory. The last command adds the -m option to set direc- tory permissions as well. Using Symbolic and Hard Links Instead of copying files and directories to different parts of the file system, links can be set up to access that same file from multiple locations.

Linux supports both soft links usually called symbolic links and hard links. When you try to open a symbolic link which points to a file or change to one that points to a directory, the command you run acts on the file or directory that is the target of that link.

The target has its own set of permissions and ownership that you cannot see from the symbolic link. The symbolic link can exist on a different disk partition than the tar- get. A hard link, by contrast, can only be used on files not directories and is basically a way of giving multiple names to the same physical file.

Every physical file has at least one hard link, which is commonly thought of as the file itself. However, deleting one link will not remove the file; it will continue to exist until the last link to the file is deleted. The -li option shows the inodes associated with each file. You can see that myfile and myfile-hardlink both have the inode number of signi- fying the exact same file on the hard disk. The myfile-symlink symbolic link has a different inode number.

And although the hard link simply appears as a file - , the symbolic link is identified as a link l with wide-open permissions. Devices are generally divided into block devices such as storage media and character devices such as serial ports and terminal devices.

Each device file is associated with a major number indicating the type of device and minor number indicating the instance number of the device. For example, terminal tty devices are represented by major character device 4, while SCSI hard disks are represented by major block device number 8. You must install the separate makedev package to get this command.

So most people never create device files manually. However, you can create your own device file using the mknod command. However, to provide a presence in the file system from which a process can communicate with other processes, you can create named pipes or sockets. Named pipes are typically used for interprocess communication on the local system, while sockets can be used for processes to com- municate over a network.

The second listing is a socket set up by the X GUI for interprocess communications. If you want to find where named pipes and sockets exist on your system, you can use the -type option to the find command, as described later in this chapter.

Setting File and Directory Permissions The ability to access files, run commands, and change to a directory can be restricted with permission settings for user, group, and other users. When you do a long list ls -l of files and directories in Linux, the beginning 10 characters shown indicate what the item is file, directory, block device, and so on along with whether or not the item can be read, written, or executed. Figure illustrates the meaning of those 10 characters. Other types of files avail- able in Linux that would appear as the first character include character devices c , block devices b or symbolic links l , named pipes p , and sockets s.

The next nine characters represent the permissions set on the file and directory. The first rwx indicates that the owner francois has read, write, and execute permissions on the directory. The group sales and all other users have only read and execute per- missions r-x ; the dash indicates the missing write permission. For the hello. When you set out to change permissions, each permission can be represented by an octal number where read is 4, write is 2, and execute is 1 or a letter rwx.

Generally speaking, read permission lets you view the contents of the directory, write lets you change add or modify the contents of the directory, and execute lets you change to in other words, access the directory.

Changing Permissions with chmod The chmod command lets you change the access permissions of files and directories. Table shows several chmod command lines and how access to the directory or file changes.

All other users except root have no access. All others can change to the directory, but not view or change files in the directory. Good to protect a directory from errant chmod a-rwx changes. The first 0 in the mode line can usually be dropped so you can use instead of That placeholder has special meaning. It is an octal digit that can be used on commands executables to indicate that the command can run as a set-UID program 4 , run as a set-GID program 2 , or become a sticky program 1.

With set-UID and set-GID, the command runs with the assigned user or group permissions instead of running with permission of the user or group that launched the command. SUID should not be used on shell scripts. Regardless of how secure you think the shell script is, it can be exploited to give the cracker a root shell. The final permission character is t instead of x on a sticky directory.

A command with sticky bit on used to cause the command to stay in memory, even while not being used. This is an old Unix feature that is not supported in Linux. The -R option is a handy feature of the chmod command. With -R, you can recursively change permissions of all files and directories starting from a point in the file system. Setting the umask Permissions given to a file or directory are assigned originally at the time that item is created.

Using the umask command, you can set the permissions given to files and directories when you create them. Changing Ownership When you create a file or directory, your user account is assigned to that file or direc- tory. So is your primary group. As with chmod, using chown recursively changes permissions for the directory named, along with its contents. Traversing the File System Basic commands for changing directories cd , checking the current directory pwd and listing directory contents ls are well known to even casual shell users.

So this sec- tion focuses on some less-common options to those commands, as well as other lesser- known features for moving around the file system. However, symbolic links can cause some confusion about how parent directories are viewed. For example, cd -L.. Likewise, -P and -L options to pwd show permanent and link locations. Bash can remember a list of working directories. Such a list can be useful if you want to return to previously visited directories.

That list is organized in the form of a stack. For example, pushd -0 pushes the last directory on the stack to the top of the stack making it the current directory. The pushd -2 com- mand pushes the third directory from the bottom of the stack to the top. Copying Files Provided you have write permission to the target directory, copying files and directo- ries can be done with some fairly simple commands. Here are some examples: cd ; touch index. In the next example, the index.

In that case, because both hard links point to the same file, editing the file from either location will change the contents of the file in both locations.

The dd command is another way to copy data. This command is very powerful because on Linux systems, everything is a file, including hardware peripherals. The count is the number of blocks. By default, a block is bytes. The result is a bytes- long file full of null characters.

You could use less or vi to view the contents of the file. Typically the partition should be unmounted before a backup such as this. Changing File Attributes Files and directories in Linux file systems all have read, write, and execute permissions associated with user, group, and others.

However, there are also other attributes that can be attached to files and directories that are specific to certain file system types. Files on ext2 and ext3 file systems have special attributes that you may choose to use. You can list these attributes with the lsattr command. Most attributes are obscure and not turned on by default. None are on by default. Those attributes are the following: a append only , c compressed , d no dump , i immutable , j data journalling , s secure deletion , t no tail-merging , u undeletable , A no atime updates , D synchronous directory updates , S synchro- nous updates , and T top of directory hierarchy.

You can change these attributes using the chattr command. Here, this prevents any arbitrary changes to the grub. Not even the root user can change the file until the i attribute is gone.

In this case, we chose to not have a large ISO image backed up. To remove an attribute with chatter, use the minus sign -. The locate command allows you to search that database. The results come back instantly, since the database is searched and not the actual file system.

Before locate was avail- able, most Linux users ran the find command to find files in the file system. Both locate and find are covered here. Then, run the updatedb command to set up the database used by the locate command. Finding Files with locate Because the database contains the name of every node in the file system, and not just commands, you can use locate to find commands, devices, man pages, data files, or anything else identified by a name in the file system. Although locate will come up with a file faster, find has many other powerful options for find- ing files based on attributes other than the name.

Before searching the whole file system, consider searching a subset of the file system or excluding certain directories or remotely mounted file systems. The find -exec spawns the command ls for each result it finds. The xargs command works more efficiently by passing many results as input to a single ls command.

To negate a search criteria, place an exclamation point! Finding files by size is a great way to determine what is filling up your hard disks. You may also want to run this command as root. From the example of whereis for the word man, you can see the man executable, its configuration file, and the location of man pages for the man command.

With md5sum and sha1sum, you can verify the validity of a file. Listing Files Although you are probably quite familiar with the ls command, you may not be familiar with many of the useful options for ls that can help you find out a lot about the files on your system.

The next two examples display dif- ferent file types in different colors and lists output in columns, respectively. Those files contain checksums that can be used to make sure that the file you downloaded is exactly the one that the repository published. By combining the find command described earlier in this chapter with the md5sum command, you can verify any part of your file system. So the next step is to check the changed file and see if the changes to that file were intentional.

Commands such as chmod can change the permissions associated with a file, while commands that include lsattr and chattr can be used to list and change file attributes that are associated with ext2 and ext3 file system types. To move around the file system, people use the cd command most often. However, to move repeatedly among the same directories, you can use the pushd and popd commands to work with a stack of directories. Copying files is done with the cp command. However, the dd command can be used to copy files such as disk images from a device such as a CD-ROM drive.

For creat- ing directories, you can use the mkdir command. Instead of keeping multiple copies of a file around on the file system, you can use symbolic links and hard links to have multiple file names point to the same file or directory. Symbolic links can be anywhere in the file system, while hard links must exist on the same partition that the original file is on.

To search for files, Linux offers the locate and find commands. To verify the integrity of files you download from the Internet, you can use the md5sum and sha1sum commands. Documents, program code, regular expressions configuration files, e-mail, and almost anything you created or configured was represented by Editing text files with text files.

To work with those files, early develop- vi, JOE, or nano ers created many text manipulation tools. Using graphical text editors Despite having graphical tools for working with text, most seasoned Linux users find command Listing text with cat, line tools to be more efficient and convenient. Commands such as grep, sed, and awk and more can be used to find, and possibly change, pieces Paginating text with pr of information within text files.

Searching for text This chapter shows how to use many popular with grep commands for working with text files in SUSE. Counting words, It also explores some of the less common uses of lines, and characters text manipulation commands that you might find with wc interesting.

Sorting output with sort Matching Text Stream editing with sed, tr, cut, and awk with Regular Expressions Searching binaries for text with strings Many of the tools for working with text allow you to use regular expressions, sometimes referred to as Finding differences in regex, to identify the text you are looking for based files with diff on some pattern. It can also be specific find just the word hello or more inclusive find any word beginning with h and ending with o.

Appendix C includes reference information for shell metacharacters that can be used in conjunction with regular expressions to do the exact kinds of matches you are look- ing for.

This section shows examples of using regular expressions with several differ- ent tools you encounter throughout this chapter. Table shows some examples using basic regular expressions to match text strings. Many examples of regular expressions are used in examples throughout this chapter. Keep in mind that not every command that incorporates regex uses its features the same way.

The editor that is most common is vi, which can be found virtually on any Unix system available today. One day, if you find yourself in a minimalist, foreign Linux environment trying to bring a server back online, vi is the tool that will almost always be there. On SUSE, make sure you have the vim-enhanced package installed. Vim Vi IMproved with the vim-enhanced package will provide the most up-to-date, feature-rich and user-friendly vi editor.

By default, SUSE just installs the regular vim packages. For more details about using vi, refer to Appendix A. Traditionally, the other popular Unix text editor has been Emacs and its more graphical variant, XEmacs. Emacs is also known for its very complex series of keyboard shortcuts that require three arms to execute properly.

In the mids, Emacs was ahead of vi in terms of features. If you are not already familiar with either vi or Emacs, we recommend you start by learning vi. There are many other command-line and GUI text editors available for Linux. Start any of those editors by typing its command name, optionally fol- lowed by the file name you want to edit. The following sections offer some quick descriptions of how to use each of those editors. Using the JOE Editor If you have used classic word processors such as WordStar that worked with text files, you might be comfortable with the JOE editor from the joe package, installed by default.

To use the spell checker in JOE, install the aspell package. With JOE, instead of entering a command or text mode, you are always ready to type. To move around in the file, you can use control characters or the arrow keys.

You can use keyboard shortcuts for many functions. Use arrow keys to move the cursor left, right, up, or down. Use the Delete key to delete text under the cursor or the Backspace to erase text to the left of the cursor.

Press Enter to add a line break. Table shows the most commonly used. Although Pico is free, it is not truly open source. SUSE provides both Pico and nano as optional packages. This section describes the nano editor. On SUSE, nano is part of the nano package and relies on the spell program for spell checking. This program is not nor- mally available on SUSE, though. As with the JOE editor, instead of having command and typing modes, you can just begin typing. Use the Delete key to delete text under the cursor or the Backspace key to erase text to the left of the cursor.

Table shows the control codes for nano that are described on the help screen. The main advantages of using a graphical text editor is that you can use a mouse to select menus, highlight text, cut and copy text, or run special plug-ins. Features in gedit let you check spelling, list docu- ment statistics, change display fonts and colors, and print your documents. It includes similar features to the GNOME text editor, along with many extras, such as the ability to send the current document with kmail or another user-configurable KDE component.

Vim itself comes with an X GUI version. It is launched with the gvim command, which is part of the gvim package. Other text editors you can install include nedit with features for using macros and executing shell commands and leafpad which is similar to the Windows Notepad text editor. The Scribes text editor scribes includes some advanced features for automatic correction, replacement, indentation, and word completion.

Listing, Sorting, and Changing Text Instead of just editing a single text file, you can use a variety of Linux commands to display, search, and manipulate the contents of one or more text files at a time.

When prompted, press the F8 key to begin downloading the PXE boot image. This procedure describes how to update the SUSE operating system. Because software is constantly being updated, your distribution media might not contain the most up-to-date versions of the operating system. Follow this procedure after your operating system is installed. If you are behind a network firewall and need to use a proxy server to access the Internet, you must first configure YaST with the correct proxy information.

Select the Network Services tab on the left, then the Proxy screen on the right. Exit the YaST utility and type the following command:. After successfully running the command, launch YaST again. Register with the Novell Customer Center. Select the Software tab on the left.

Then select Novell Customer Center Configuration and follow the directions. After you are registered, select the Online Update tab to perform the software update.

This section describes how to install server-specific software from the Tools and Drivers CD. All files are located on the Tools and Drivers CD. When you are done, reboot the system to initialize the new driver:. When the rpm command is done, reboot the system to initialize the new driver:.

When you are done, you can start and use the MSM utility. All Rights Reserved.



Comments