Find the answer to your Linux question:
Results 1 to 4 of 4
Friends, I want to save some commands as aliases in the .bashrc so that I can execute them at my wish later. But after naming aliases for the commands, if ...
  1. #1
    Just Joined!
    Join Date
    Feb 2009
    Posts
    15

    ~/.bashrc -- Permission Denied

    Friends,

    I want to save some commands as aliases in the .bashrc so that I can execute them at my wish later. But after naming aliases for the commands, if I say ~/.bashrc it says "bash : /root/.bashrc : permission denied" . I logged in as root.
    What should I do?

  2. #2
    Just Joined!
    Join Date
    Feb 2009
    Posts
    45
    Answer:
    Quote Originally Posted by Goutham_Linux
    But after naming aliases for the commands, if I say ~/.bashrc it says "bash : /root/.bashrc : permission denied"
    Is the file executableč? If not, run
    Code:
    $> chmod +x ~/.bashrc;
    <EDIT time="2009-03-02T02:51:06.896142005+02:00" reason="correction">
    Quote Originally Posted by coopstah13
    ~/.bashrc is not a valid command, and it will give you that error
    This is correct. I forgot to mention that your ~/.bashrc file actually needs to be a bash script (thereʼs a “#! /bin/bash” header in your script) for my suggestion to make sense.
    </EDIT>

    Footnotes:
    1. In case it is not known how to detect this: Run
      Code:
      $> ls -l ~/.bashrc;
      Then thereʼs a privilege mask leftmost. It is 10 characters long. If thereʼs no “x” in there, itʼs not executable. If thereʼs an “x” in there but the leftmost character in that mask is not “-” (minus), then itʼs not a regular file and you might need to follow the link (if the leftmost character is a “l”) or your config is simply screwed up (if itʼs neither “l” nor “-”).

      An alternative of finding out is:
      Code:
      [ -x ~/.bashrc ]; echo $?
      If its output is “1”, the file is executable, else itʼs not executable.

  3. #3
    Linux Guru coopstah13's Avatar
    Join Date
    Nov 2007
    Location
    NH, USA
    Posts
    3,149
    can you post the exact code you are trying to execute in terminal? ~/.bashrc is not a valid command, and it will give you that error

  4. #4
    Just Joined!
    Join Date
    Feb 2009
    Posts
    45
    Quote Originally Posted by WuNMOjTIQanXWBcH View Post
    Is the file executableč? If not, run
    Code:
    $> chmod +x ~/.bashrc;
    Disregard that. What you are probably looking for is:
    Code:
    $> man bash
    […]
           source filename [arguments]
                  Read  and execute commands from filename in the current shell environment and return the exit status of the last command executed from filename.  If filename does not
                  contain a slash, file names in PATH are used to find the directory containing filename.  The file searched for in PATH need not be executable.  When bash  is  not  in
                  posix  mode,  the  current  directory  is  searched if no file is found in PATH.  If the sourcepath option to the shopt builtin command is turned off, the PATH is not
                  searched.  If any arguments are supplied, they become the positional parameters when filename is executed.  Otherwise the positional parameters  are  unchanged.   The
                  return status is the status of the last command exited within the script (0 if no commands are executed), and false if filename is not found or cannot be read.
    […]

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...