Linux questions

Hi everyone,

I came from a diffrent UNIX background and am trying to learn Linux (Red Hat) in a hurry. I would be very grateful if you could help me with the following questions. I know the answers for questions 1, 3, and 4 in a Sun Solaris environment, but not in Linux... Thanks in advance for your help!

  1. When the command "touch" is used to create a file, it assigns some default permissions to the file. What would you do to make "touch" command create files with different default permissions?

  2. Using bash shell, run the following commands in a clean directory:

for ((i=20000;i--;)) ; do touch test$i ; done
for ((i=10;i--;)) ; do touch file$i ; done

This will take a while.

Now try to list all files beginning with 'test':

ls test*

This will give an error:

bash: /bin/ls: Argument list too long

How would you get around this problem (i.e., successfully list all these files)?

  1. How would you automatically mount a device each time the system starts up?

  2. While trying to "umount" a device, it will fail if the device is busy. How would you determine which process is causing the device to be busy?

-- Enigma777

  1. I think you have to set a different umask in the shell startup file, e.g. .bashrc

umask 0022

See bash(1) manpage

  1. Edit the corresponding entry in /etc/fstab and change from noauto to auto

The solutions listed below will work on Linux as well as other UNIX systems. Here is the summary (based on my research and your replies):

  1. You can use the "umask" command to make the "touch" command create files with different default permissions.

  2. To avoid the limitation of the "ls" command, you can use the following command to list large number of files:

find . -name "test*"

  1. You can use the /etc/fstab file to automatically mount a device each time the system starts up.

  2. To determine which process is causing the device to be busy, you can use the "fuser" command like this (just an example):

fuser -v /mnt/cdrom

Thanks for your replies!

--Enigma777

For (2), you may also try

ls | xargs -i echo {}