Imagine you have a Linux system and some administrator ran the following command:
# chmod a-x /bin/chmod
If you try reversing that after it's been done you'll get an error.
# chmod a+x /bin/chmod
-bash: /bin/chmod: Permission denied
I was asked this exact scenario in a Job Interview recently. The interesting thing to me is that one of the interviewers was leading me to believe that if you touched a new file (say /bin/changeme) then the default permissions for that new file would be rwxr-xr-x. This is incorrect. The default permissions for a new file on Linux are 666. After you apply the default root umask of 022, the permissions on that new file would be 644, or rw-r--r--.
So how do you go about fixing this problem? The real resolution is to copy a file that already exists in /bin. For example the file /bin/touch. You can then use dd or cat to get the contents of the /bin/chmod command into the copy file. You will then be able to use the copy file to "chmod" the /bin/chmod file to the correct permissions. See the example below for the actual commands to do this.
# cp /bin/touch /bin/changeme
# cat /bin/chmod > /bin/changeme
Or:
# dd if=/bin/chmod of=/bin/changeme
# /bin/changeme a+x /bin/chmod
Your /bin/chmod command will now function as normal.
The steps below are to scan for new LUNs from a SAN after the LUNs have been presented from the storage side when using QLogic HBA's . This post uses the QLogic Dynamic Target and LUN Discovery utilities which can be downloaded from:
http://driverdownloads.qlogic.com/QLogicDriverDownloads_UI/SearchByProduct.aspx?ProductCategory=39&Product=935&Os=126
The steps below will work on SUSE Linux Enterprise Server (SLES) 10 and Red Hat Enterprise Linux (RHEL) 5.
cat /etc/*ease
mkdir /tmp/ql_utils
Change to the /tmp/ql_utils directory:
cd /tmp/ql_utils
Retrieve the utilities from the download above and extract them from the zip file into the /tmp/ql_utils directory.
ql-dynamic-tgt-lun-disc.sh
The file that we are going to be using is the ql-dynamic-tgt-lun-disc.sh file. We need to ensure that it is set to executable:
chmod a+x /tmp/ql_utils/ql-dynamic-tgt-lun-disc.sh
The ql-dynamic-tgt-lun-disc.sh script has several options available. You can see what these options are by running:
/tmp/ql_utils/ql-dynamic-tgt-lun-disc.sh -h
http://driverdownloads.qlogic.com/QLogicDriverDownloads_UI/SearchByProduct.aspx?ProductCategory=39&Product=935&Os=126
The steps below will work on SUSE Linux Enterprise Server (SLES) 10 and Red Hat Enterprise Linux (RHEL) 5.
You can discover what version of Linux you are on by running:
cat /etc/*ease
Create a directory to hold the utilites. In this examle we will use the /tmp/ql_utils directory:
mkdir /tmp/ql_utils
Change to the /tmp/ql_utils directory:
cd /tmp/ql_utils
Retrieve the utilities from the download above and extract them from the zip file into the /tmp/ql_utils directory.
This will put five files into /tmp/ql_utils:
ql-dynamic-tgt-lun-disc.sh
README.ql-dynamic-tgt-lun-disc.txt
Copying
revision.qldynamic.txt
sg3_utils-1.23.tgz
The file that we are going to be using is the ql-dynamic-tgt-lun-disc.sh file. We need to ensure that it is set to executable:
chmod a+x /tmp/ql_utils/ql-dynamic-tgt-lun-disc.sh
/tmp/ql_utils/ql-dynamic-tgt-lun-disc.sh -h
The commands to scan for new LUNs are listed below. After the commands we'll describe what each command does. These commands should be run with root priveledges while inside the /tmp/ql_utils directory.
powermt display dev=all | egrep "Pseudo|Logical" > before
./ql-dynamic-tgt-lun-disc.sh
Please make sure there is no active I/O before running this script
Do you want to continue: (yes/no)? yes
Do you want to continue: (yes/no)? yes
powermt config
powermt display dev=all | egrep "Pseudo|Logical" > after
diff after before
powermt save
The first line outputs the current list of LUNs to the file named before. This is optional, but, makes it easy to see what new LUNs have been discovered later on.
The second line actually does the scan for new LUNs and prompts you to make sure that it's ok to run the script. Answer yes to the prompt.
The fifth line (powermt config) creates the emcpower devices in /dev.
The sixth line outputs the new list of LUNs to the file named after.
The seventh line runs a command to compare the list of new LUNs to the list of old LUNs. The differences will be displayed on screen. Make sure that names of the new LUNs show up in the output.
The last line saves the configuration.
After this is done, the LUNs can be setup with LVM. (see LVM post)
After this is done, the LUNs can be setup with LVM. (see LVM post)