Search Engine

Loading

Sallar

Sallar
RedhatEnterpriseLinux Blog

Executing Commands in a Bash Script



To execute a series of commands in a Bash script, list each command on a separate line. For example, Listing shows the very basic Bash script that gathers information about system resources.

Writing Scripts with Bash


The GNU Bourne Again Shell (Bash) scripting language is useful when trying to automate a sequence of commands or when you want to execute the same command over and over again until a certain limit is reached.

Emergency Mode & Filesystem Repairing


Emergency Mode
Emergency mode is similar to single-user mode except the root filesystem is mounted read-only and runlevel 1 is not used. Boot into emergency mode using the same method as single-user mode except replace the word single with emergency in the boot method.
Because the filesystem is mounted read-only, files can not be changed or repaired, but files can be retrieved off the system.
Filesystem Repair
If one or more filesystem are corrupt, boot into rescue mode and do not mount the filesystem. Even if you can boot into single-user mode, do not use it because the filesystem cannot be repaired if it is mounted.

Single-User Mode


Single-user mode is equivalent to runlevel 1 on the system. If runlevel 1 is not configured properly, you will not be able to boot into single-user mode. Rescue mode requires a boot media, but single-user mode is specified as a kernel option using the installed boot loader and does not require additional boot media. However, it does require that the boot loader is working properly and that the filesystem be mounted. It does not provide the ability to start a network connection.

Recovery and Repair Linux system


To analyze or repair a system failure, you might need to boot into the system. But, what if the boot loader is corrupt or what if the filesystem can’t be mounted anymore? Red Hat Enterprise Linux includes alternative boot methods for system repair: rescue mode, single user mode, and emergency mode.

The rsync Utility


The rsync Utility
When developing backup scripts, consider using the rsync utility. The rsync utility allows you to copy from the local system to a remote system or copy between two local directories. If the files exist in the destination directory, rsync only transfers the differences in the files, which is ideal for backups. The rsync RPM package is required and should already be installed on your system.
After the rsync command-line arguments are listed, the first directory listed is the source, and the second directory listed is the destination. If either directory is preceded by a hostname and a colon (:), the directory is a remote directory. For example, to transfer all home directories to the backup/ directory on the remote server backup.example.com:

The tar Utility and compression


 The tar Utility
When backing up data that is no longer being used or data that is not frequently changed, consider creating a compressed archive file using the tar archive utility in combination with one of the compression tools such as gzip or bzip2. Creating a compressed archive file results in one file that must be decompressed and unarchived before files can be restored from it. The compression of the files saves room on the backup media. To use tar, the tar RPM package must be installed. It should be installed on your system unless you chose to only install a specific set of packages. The tar utility does not preserve access control lists.

Powered by Blogger.

Ads

 
Copyright © Redhat Enterprise linux. Original Concept and Design by My Blogger Themes
My name is Abdul Razaq but people call me Raziq. Here is my home page: www.redhatenterpriselinux.blogspot.com I live in Quetta, Pakistan and work as an IT-Engineer.