-2

I am new to Ubuntu. I need to set path in my .bashrc file, but I am getting permission denied error even if am the admin of the system .

export TCFRAME_HOME=~/tcframe
alias tcframe=$TCFRAME_HOME/scripts/tcframe

Now when I type tcframe version I get

bash: /home/p46562/tcframe/scripts/tcframe: No such file or directory

How to fix this?

tripleee
  • 175,061
  • 34
  • 275
  • 318
user46562
  • 31
  • 9
  • Possible duplicate of [How to permanently set $PATH on Linux/Unix?](https://stackoverflow.com/questions/14637979/how-to-permanently-set-path-on-linux-unix) – LTClipp Jul 02 '18 at 19:30
  • This question is thoroughly and repeatedly documented on places like *ehem* stack overflow. – LTClipp Jul 02 '18 at 19:31
  • Permission denied is also commonly remedied by prepending `sudo` to your command, assuming you have administrative privileges. – LTClipp Jul 02 '18 at 19:32
  • 2
    There's nothing wrong with the alias definition here (although it would be simpler to just add `~/tcframe/scripts` to your path instead). You are probably missing the execute permissions on `tcframe` itself; `chmod +x ~/tcframe/scripts/tcframe`. – chepner Jul 02 '18 at 19:42
  • Hi .echo 'export TCFRAME_HOME=~/tcframe alias tcframe=$TCFRAME_HOME/scripts/tcframe' >> ~/.bashrc woud this work ? – user46562 Jul 02 '18 at 19:49
  • When do you get the denied error ? When you try to save the .bashrc ? – An0n Jul 02 '18 at 19:50
  • i am still unable to edit . I open the terminal add the following code but its not working – user46562 Jul 02 '18 at 19:53
  • Check my answer on your post. Below. – An0n Jul 02 '18 at 19:54
  • If it doesn't allow you, just do it as root. – An0n Jul 02 '18 at 19:54
  • 1
    @An0n That's thoroughly misguided advice. Editing your personal file as root will only lead to new permission problems. – tripleee Jul 02 '18 at 20:10
  • @tripleee I did not say edit the file.. I said edit the permission if you dont have any permission as normal user.. – An0n Jul 02 '18 at 20:11
  • 1
    That's misguided too, for the same reason. – tripleee Jul 02 '18 at 20:14
  • i opened terminal then gedit .bashrc , added the above lines . Now i just checked by typing tcframe version then its giving "bash: /home/p46562/tcframe/scripts/tcframe: No such file or directory" – user46562 Jul 02 '18 at 20:29
  • Your question should be self-contained; I edited it to include this error message, and also retitled it (nothing in your actual question about PATH changes). – tripleee Jul 03 '18 at 09:31

1 Answers1

0

The error message is telling you that you are trying to execute a file which does not exist.

We can vaguely guess about what files do exist, but without access to your system, we can't know for sure what you have actually installed and where.

Perhaps you have a file named tcframe in a directory called scripts in your home directory?

alias tcframe=$HOME/scripts/tcframe

A common arrangement to avoid littering your environment with one or more aliases for each random utility you have installed somewhere is to create a dedicated directory for your PATH - a common convention is to call it bin - and populate it with symlinks to things you want to have executable.

Just once,

mkdir $HOME/bin

and edit your .profile (or .bash_profile or .bashrc if you prefer) to include the line

PATH=$HOME/bin:$PATH

From now on, to make an executable script accessible from anywhere without an explicit path, create a symlink to it in bin;

ln -s $HOME/scripts/tcframe $HOME/bin

Notice that the syntax is like cp; the last argument is the destination (which can be a directory, or a new file name) and the first (and any subsequent arguments before the last, if the last is a directory) are the sources. When the destination is a directory, the file name of each source argument is used as the name of a new symlink within the destination directory.

Also notice that you generally want to use absolute paths; a relative path is resolved relative to bin (so e.g.

ln -s ../scripts/tcframe $HOME/bin

even if you are currently in a directory where ../scripts does not exist.)

Scripts, by definition, need to be executable. If they aren't, you get "permission denied" when you try to run them. This is controlled by permissions; each file has a set of permission bits which indicate whether you can read, write to (or overwrite), and execute this file. These permissions are also set separately for members of your group (so you can manage a crude form of team access) and everyone else. But for your personal scripts, you only really care that the x (executable) bit is set for yourself. If it isn't, you can change it - this is only required once.

chmod +x scripts/tcframe
tripleee
  • 175,061
  • 34
  • 275
  • 318
  • Sometimes you see recommendations to use `chmod 777` but this is a **serious seurity problem.** Don't panic; back away slowly, then run. – tripleee Jul 03 '18 at 09:43