Configuration Files in Webmin
Most Webmin modules work by editing configuration files on your system, like
/etc/exports for NFS shares,
/etc/passwd for users
/etc/fstab for filesystems.
Each module knows which configuration files it manages, and what commands need to be run to activate them. Not all modules actually deal with config files though - for example, the MySQL module works by executing SQL commands.
As such, it cannot participate in the configuration backup process.
More in details at http://doxfer.com/Webmin/
Webmin Backup Configuration Files module
Most Webmin modules work by editing configuration files on your system, like /etc/exports for NFS shares, /etc/passwd for users and /etc/fstab for filesystems.
Each module knows which configuration files it manages, and what commands need to be run to activate them.
Not all modules actually deal with config files though - for example, the MySQL module works by executing SQL commands.
The Backup Configuration Files module
To perform an immediate config backup, follow these steps :
Click on the Backup now tab.
In the Modules to backup list, select the modules you want to backup config files for, such as Users and Groups. Multiple modules can be selected by ctrl-clicking.
In the Backup destination field, select Local file and enter a path to write the backup to. This should be given a tar.gz extension, as that is the file format used.
Click the Backup Now button.
Change priority of swap files
You can check the current priority of the swap file from /proc/swaps.
Inorder to change the priority of the swap partitions, you need to edit the “fstab” and append the new priority. If you have the fstab entry for your swap file /swap1 as:
/swap1 swap swap defaults 0 0
then append the following:
/swap1 swap swap pri=x,defaults 0 0
where x is the new priority you have set.
You can re-mount it by using ‘mount -a’ command.
Find text in a large number of files
If you need to find a string in a file, you would typically use:
grep -H “string” file-name.ext
However, grep doesn’t handle a large number of files well. If you specify grep “string” * or even grep “string” `find ./`you may find yourself facing this error:
bash: /bin/grep: Argument list too long
Simple bash script to do the searching.
In this sample, We will be looking for a string “welcome” in a directory named “./Document/”:
for i in `find ./Document/`; do grep -H “welcome” $i; done
This uses the find command to do the searching. It actually returns a list of filenames, which we can then grep one-by-one. The -H option tells grep to let us know the filename it found the string in so we can go right into that file to find the location of it.
Renaming Files
To rename all files in a directory and add a new extension the xargs command can be used:
ls | xargs -t -i mv {} {}.renamed
xargs reads each item from the ls ouput and executes the mv command. The ‘-i’ option tells xargs to replace ‘{}’ with the name of each item. The ‘-t’ option instructs xargs to print the command before executing it.