I made the script in my home folder, and it works perfectly, but I want to move it to another directory, for example to folder called "my scripts". How can I do it?
I tried different ways with chmod +x and ln -s , for example:

/home/user/downloads/my scripts/script.sh /usr/bin

I want to have the chance to copy and paste it anywhere on my Ubuntu folders, and execute it by clicking.


I'm not completely sure I understand your question... If using a GUI file manager, just copy and paste to your new folder and set permissions accordingly. If you're using the command line

mv /path/to/script.sh /path/to/new/dir

Then give your script executable permissions.

  • Thanks, it works. I couldn´t do that using GUI. I think it was ´cause my folders have names with space between. I don´t know. Now I created a folder with a short name with no space between ,and I use the command you gave to me and it works! – Etapas UseR Oct 5 '18 at 15:09
  • Glad that helped. I over looked the space in your path, but you're correct. If this solved your issue, please upvote the answer so this can be marked as solved. – BillWeckel Oct 5 '18 at 15:13

A script essentially is a simple text file. You can copy it anywhere in the same way as you copy regular files.

If you want to copy using the terminal, you use the cpcommand as in cp "/home/user/downloads/my scripts/script.sh" "/home/user/scripts/"

"/home/user/scripts/" in this example is the destination folder. It must exist for the cp command to proceed. If it does not exist, create the folder first.

`mkdir /home/user/scripts/'

You are mentioning /usr/bin This is a system folder, which would be a suitable folder for placing custom executable files that should be available for all users. You only can copy files into system folders if you have administrator (in Linux also known as 'super user' or 'root') rights. In that case, you can precede the command with sudo, i.e., "act as super user", as in

sudo cp "/home/user/downloads/my scripts/script.sh" "/usr/bin"

The sudo command will request your login password. If your account has root privileges, the command will be executed after you successfully entered your password.

That said, only change system files if you are absolutely sure what you want to achieve. If you want to use your custom scripts only for your self, it is a much better approach to create a "bin" folder in your own home folder. Whenever you open a terminal, Ubuntu automatically will include your private bin folder in the program path. As a result, you, but only you, will be able to execute the script simply by typing its name in the terminal. This eliminates any risk of you breaking the system by working in system folders.

  • I fixed with the first answer! but I will keep your commands lines in mind! of course.I will try this way too. Thanks! – Etapas UseR Oct 5 '18 at 15:18
  • 1
    Indeed, rather than copying cp, you may prefer just to move mv – vanadium Oct 5 '18 at 15:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.