Archive for the tag 'Files'

Shell description is missed in crontab files after migration.

After the migration to the Parallels Plesk Panel 10.x, the cron jobs are not executed by chrootsh.

The SHELL value in the crontab is not copied from the target to the destination server during the migration. Say, servers A and B are configured to use chroot shell. When migrating a customer account with crontab and the SHELL value is omitted:

To resolve this issue, Determine the path to the chrootsh utility with the following command:

# grep chroot /etc/shells

Add the SHELL value to the crontab with the command:

# /usr/local/psa/bin/server_pref -u -crontab-secure-shell

Reference : http://parallels.com

Using RPM Verify to Monitor Changes to System Files

It is important for administrators of critical server systems to be able to track changes to files on their systems. Tracking file changes helps detect accidental or malicious modifications such as viruses, root kits, or hacking activity. RPM, the package management system used for all RPM based Linux distributions, provides an easy mechanism for tracking these changes. When a package is installed, the RPM database stores information about each file belonging to that package including the size, date, and MD5 sum among others. This data can later be compared to the existing files on the system to detect any changes.

Verifications are performed with the rpm command and the -V flag. This command should be executed as root so that all file attributes can be read from the system without file permissions getting in the way. For example:

To verify all files in the RPM database:

# rpm -Va

To verify all files belonging to a package, packagename:

# rpm -V packagename

To verify all files belonging a particular RPM file (local, FTP, HTTP):

# rpm -V path_to_the_file.rpm

All applicable files are checked, and any discrepancies are shown. The output is a string of eight characters, followed by an optional attribute marker. The string of eight characters indicates changes in size, permissions, MD5 sum, etc.

S file Size differs
M Mode differs (includes permissions and file type)
5 MD5 sum differs
D Device major/minor number mis-match
L readLink(2) path mis-match
U User ownership differs
G Group ownership differs
T mTime differs

For example:

S.5….T c /etc/wvdial.conf

This example shows that the configuration file, /etc/wvdial.conf, has a different size, MD5 sum, and modified time than the RPM database has on record. In this case, this is probably okay–it is a configuration file and it is normal for them to change.

How to use lsof command to Find Open Files

The lsof utility can help identify which files are being used by any given application, which network ports are open, and much more.

A process would show up in top or ps aux, but the executable may not seem to exist. Using lsof, we could hunt down the scripts or executables used to run the program. If we run just lsof, it will attempt to show all files (which includes network sockets, pipes and special files) that are open.

If we want to see all the open files owned by a process, we can use the -p option (for PID) like so:

lsof -p XXXXX

Just replace XXXXX with the process ID (PID) of the process you want to see. The output will show the command that has the file open, the PID, the user, the file descriptor, type, size of the file and the name of the file.

We can also see what files are open by users. Running lsof -u user will show all open files by processes owned by the user. You can also substitute the user ID (UID) for the username. If you want to eliminate a user from the listing, use ^user instead. The preceding caret will negate the selection, so the user will be ignored.

If we want to see what network sockets are owned by a particular user or process? Try ..

lsof -u user -a -i

That will show only the open TCP and UDP sockets. If we want to see what files are open over the network, use -i. This will show you which files and sockets are open, and their respective protocols, hostnames and so on. We can narrow network parameters down by IP version (-i4 for IPv4, -i6 for IPv6), protocol (UDP or TCP), and even hostname or port.

By default, lsof will look up hostnames, but we can turn this off using the -n option. It will run faster without needing to do name lookups.

lsof 4.81
latest revision: ftp://lsof.itap.purdue.edu/pub/tools/unix/lsof/
latest FAQ: ftp://lsof.itap.purdue.edu/pub/tools/unix/lsof/FAQ
latest man page: ftp://lsof.itap.purdue.edu/pub/tools/unix/lsof/lsof_man

How to find World/Group writable files and directories.

Finding world-writable files and directories

#find / -type f \( -perm -2 -o -perm -20 \) -exec ls -lg {} \;

#find / -type d \( -perm -2 -o -perm -20 \) -exec ls -lg {} \;

This will create a huge file with permission of all files having either write permission set to the group or everybody. Check the permissions and eliminate world writable files to everyone, by executing /bin/chmod on the files.

To remove the permission execute.

#/bin/chmod o-w [file-name]
SBDavid

Rolling back files in WHM

Rolling back files in WHM

WebHost Manager automatically saves a backup version of the following three files whenever they are changed:

*httpd.conf
*named.conf
*proftpd.conf or pure-ftpd.conf

You can revert to any of the previously saved versions whenever required. The restored version becomes the latest version, and does not delete other versions.

To roll back a file:

Please select a file to rollback:

Click on the Configuration File Rollback link in the Backup menu.

Click on the Back button button to review previous versions. As you change files, the Date field will update and the display area will update with the contents of the different file.
Click on the Restore button to roll back to the displayed version of the file.

« Prev - Next »