UNIX Hints & Hacks

ContentsIndex

Chapter 3: Security

 

Previous ChapterNext Chapter

Sections in this Chapter:

 

3.1 Delegating root to Multiple Admins

 

3.5 Permissions Levels

 

3.8 File Encryption

 

3.6 Protect root at All Costs

 

3.9 Clear and Lock

3.3 Monitoring root in the Password File

 

3.7 File Collecting

 

3.10 Power Tools

3.4 Vulnerabilities in UNIX

 

 

 

 

 

3.6 Protect root at All Costs

3.6.1 Description

3.6.1 Description

Safeguard against removing the root level files.

Example

Flavors: All

Syntax:

touch file
chmod mode file

This uses the -i argument in the rm command to remove files. The -i argument seeks confirmation before any removal of the file or directory takes place. It also known as an interactive removal process.

You place a -i at the top of the root directory; when the rm command progresses through the list of files, it picks up the -i as an argument, not as a file, and proceeds interactively requesting confirmation before it removes any files and your kernel.

Warning - Test this first in a nondestructive test area first. If you don't, you risk removing the files under the root directory.


rocket 13% cd /usr/tmp
rocket 14% mkdir foo
rocket 15% touch /usr/tmp/foo/\-i
rocket 16% chmod 000 /usr/tmp/foo/\-i

Note - Use the fully qualified path to create the file when creating.


rocket 17% cd foo
rocket 18% touch fee fii foo fum
rocket 19% rm -rf *

To safely execute this process for testing, create a directory called foo in /usr/tmp. Then touch a file called -i. Change the permissions so that it has no permissions. If the -i doesn't force the interactive confirmation, the lack of permission on the file stops the removal process at the point where it hits that special file. Go into the foo directory and create test files with touch. Finally, test to verify that it works with the rm command.

Reason

Accidents happen and sometimes files at the root level get deleted. This adds one more layer of protection for securing the root files and saving the kernel from getting deleted.

Real World Experience

Things happen; sometimes you fat-finger the key and other times you aren't paying attention to what directory you are in when you use the rm command. It's a nice little bonus feature. When it works, it saves much time in restoring from backups.

This -i can go in any directory where you are afraid to lose the files or the subdirectories; it does not have to go only at the root level.

Other Resources

Man pages:

chmod, rm, touch

UNIX Hints & Hacks

ContentsIndex

Chapter 3: Security

 

Previous ChapterNext Chapter

Sections in this Chapter:

 

3.1 Delegating root to Multiple Admins

 

3.5 Permissions Levels

 

3.8 File Encryption

 

3.6 Protect root at All Costs

 

3.9 Clear and Lock

3.3 Monitoring root in the Password File

 

3.7 File Collecting

 

3.10 Power Tools

3.4 Vulnerabilities in UNIX

 

 

 

 

 

© Copyright Macmillan USA. All rights reserved.