LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   Strange error on bash launch (https://www.linuxquestions.org/questions/linux-software-2/strange-error-on-bash-launch-887573/)

samineru 06-21-2011 11:53 AM

Strange error on bash launch
 
I get the following error whenever I launch bash:
Code:

mkdir: cannot create directory `/dev/cgroup/cpu/user/5900': No such file or directory
bash: /dev/cgroup/cpu/user/5900/tasks: No such file or directory
bash: /dev/cgroup/cpu/user/5900/notify_on_release: No such file or directory

It seems like it's probably from this part of .bashrc:
Code:

if [ "$PS1" ] ; then
  mkdir -m 0700 /dev/cgroup/cpu/user/$$
  echo $$ > /dev/cgroup/cpu/user/$$/tasks
  echo "1" > /dev/cgroup/cpu/user/$$/notify_on_release
fi

What does this code do, why, and what's causing it to go wrong?

colucix 06-21-2011 12:01 PM

If you don't know what this code is supposed to do, you can just ignore it and comment it out (until you find why it's there). Anyway, it should create a directory whose name is the process ID of the current shell ($$). It fails because the parent directory /dev/cgroup/cpu/user does not exist. The if [ "$PS1" ] part denotes it must be an interactive shell, PS1 being the environment variable which sets the appearance of the shell prompt.

TobiSGD 06-21-2011 12:03 PM

Did you install a custom kernel? Seems to me that your kernel lacks the support for cgroups.

MensaWater 06-21-2011 12:03 PM

At a guess I'd say its failing because you're logging in as a non-root user and trying to write to /dev which typically is not set to allow such writes.

As to why it is in your .bashrc in the first place I can't say. Did you maybe copy this from an older system? Is this a new user and it got copied in from /etc/skel?

The "$$" is the process ID for the bash shell that ran it which was 5900 when you ran it but would be different the next time.

What Linux distro are you running? (RHEL? SUSE? Ubuntu? Something Else?) What version of that distro?

What does "ls -ld /dev" show?

What does "df -h /dev" show?

/dev isn't a real filesystem so has no mount device. Its purpose is to hold all the special devices for various hardware on the system such as your hard drives (/dev/sd*, /dev/hd*), your serial ports (/dev/tty*) your pseudo terminals (/dev/pts/*) and a slew of others. Typically user processes wouldn't be creating anything in /dev though they are doing quite a bit of interaction with the devices that are already there.

smoker 06-21-2011 05:07 PM

You will not be able to succeed because you usually need root privileges to write to the /dev directory. What user is the .bashrc running as ?

samineru 06-21-2011 05:25 PM

I did not install a custom kernel.

I am using ElementaryOS an Ubuntu derivative based off of 10.04

Code:

$ ls -ld /dev
drwxr-xr-x 20 root root 3.8K 2011-06-21 18:00 /dev/

Code:

$ df -h /dev
Filesystem            Size  Used Avail Use% Mounted on
none                  1.9G  308K  1.9G  1% /dev

This is .bashrc as called by gnome-terminal so I assume it is running as my standard user account.

if [ "$PS1" ] ; then
mkdir -m 0700 /dev/cgroup/cpu/user/$$
echo $$ > /dev/cgroup/cpu/user/$$/tasks
echo "1" > /dev/cgroup/cpu/user/$$/notify_on_release
fi

chrism01 06-21-2011 07:49 PM

Don't assume: who did you login as? Also, for confirmation try the id http://linux.die.net/man/1/id cmd.
As above, it's an odd place to create a dir from the cmd line & you'd have to be root to do it.
Is there a particular reason you are trying to do this? If not, as above, just comment that block out, or even delete it...

samineru 06-21-2011 09:41 PM

I logged in through my graphical login manager, when running gnome-terminal I do not log in again. I am not trying to do this, it was in my .bashrc by default. I will contact them I guess.


All times are GMT -5. The time now is 05:42 PM.