Run applications with bash from Linux Mint [closed] - linux

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 4 years ago.
Improve this question
I started learning Bash on Mint Linux. The thing is I want to know how to open and execute programs. I have a test.sh in my junk directory so that I can mess around but when ever I type in gnome-open test.sh it just opens the file and not actually run it. In the test.sh file I have echo hi in there so that I can see that it worked and I gave the file the permissions for it to be an executable file so it should execute.

You need to do two things:
Give the file execution permission (+x)
Execute the file
First you give the file permission no 755:
chmod 755 test.sh
Then you start it:
./test.sh
The dotslash means "current directory", it's like saying c:\file.bat if \ is the current directory. You need that because the current dir (called PWD) is not in your PATH variable which means that you either need to specify the complete path, eg. /users/user/file.sh or using the dot which is a shortcut for the current directory.
The file permission number 755 means:
owner: 7 (read, write, exec)
group: 5 (read, exec)
other: 5 (read, exec)
If you want to be the only one to be able to even open the file you may specify 700 instead. There are plenty of combinations, but 755 is most commonly used for scripts.
edit:
I forgot to mention that you need the dotslash everytime you run the script, but you only need to issue the chmod command once for every file.

Related

What does the command "sudo mv home/* *" do? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 4 years ago.
Improve this question
I know each part of this command.
sudo mv home/* *
sudo: super-user do, execute with root privileges.
mv: move a file or directory.
home/*: argument of mv command. It indicates the content of home directory. The asterisk * is a wildcard that expands to the list of files in the current directory in lexicographic order.
The next argument is the destiny folder. However, I specify an asterisk as destiny directory, and if I execute the command the folder disappear completely. So, what does the * in this case?
Let's say you have /home/userA, /home/userB and /home/userC. Let's further say you're running this in a directory that contains 1.txt, 2.txt, and a directory 3.d.
Under those circumstances, this would expand to:
sudo mv /home/userA /home/userB /home/userC 1.txt 2.txt 3.d
That is to say, both globs are expanded -- the first to the list of entries in /home, an the subject to the list of files in the current working directory -- and the result is everything being moved into the directory 3.d.
Flagged Community Wiki since this is an answer to an off-topic question.

Why do I need to put dot forward slash when running a 'sh' command in Linux? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 7 years ago.
Improve this question
I have found that if I have a .sh file in a certain directory then I can run it (using sh) from that folder with or without dot forward slash. So why even bother adding it?
Please check http://www.linfo.org/dot_slash.html as well.
Basically this is a safety mechanism to indicate the program to execute is in the current directory and NOT a built-in command, a command in some other folder specified in the PATH etc.
From the link:
Files in the current directory can be accessed for reading and writing by merely entering the command name (e.g., cat or vi) followed by the name of the file. That is, no absolute path is necessary. However, when execution is desired, either an absolute path (or its dot slash equivalent) or the inclusion of the directory containing the command's executable file in the PATH variable is necessary. This is a built-in safety mechanism.
If your script is running without ./ then it means the specific location is in the path or . is in the path as mentioned in comments.
Hope it helps.
Your PATH is a list of directories which is searched to find files to execute. If your command is in one of those directories it will be executed. If it is in a different directory, then you need to indicate to the shell what directory it is in. . means the current directory, so
./prog
will run the prog file found in the current directory
/some/other/path/prog
will run the file in the directort /some/other/path
and
subdir/prog
will run prog in subdir relative to your current directory.
To see what your path is set to type echo $PATH.

Why is the 'mv' command not working when moving a file up multiple levels [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 7 years ago.
Improve this question
Operating system: SLES12 VM
So I start off in a directory:
DirA: /home/user/testA/testB
My goal is to move a file from this directory to a directory given by
DirB_rel: /home/user/testA/testB/../../deliverables/rpm/SOURCE
Note: testA is a symlink which is not included in DirB_abs
Which, when I cd to it, gives a pwd of
DirB_abs:/home/user/deliverables/rpm/SOURCE
The problem is, when I try move a file using mv (have tried tar.gz and .txt) from DirA to DirB_rel, the file is deleted from original location as expected, but it does not appear at new location and is therefore lost.
E.g. mv testFile.txt DirB_rel -> File disappears
However, when I use the absolute path for directory B, mv works correctly.
E.g. mv testFile.txt DirB_abs -> Success
Any idea whats going on here?
Thanks!
The problem is with the symlink. When you do user/testA/testB/../../ and testA is asymlink, you wont go back to user, but to the parent directory of the directory testA links to
the mv command will reference the directory you are currently in and not from where the file is. So if we are in home ~/ and want to move ~/A/file to ~/B/file you use mv as follows:
mv A/file B/
Note that if you use this
mv A/file ../B/
the command will look for B in /home/B and not ~/B since we are in the ~/ directory issuing the command.

Typed wrong mv command [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 8 years ago.
Improve this question
Hi i worked on Linux server , and was running this command mv matter/*/* .
but instead i have typed this mv matter /*/* .
because of which some errors starts coming on the screen , and then i was not able to login and when we reboot the server its not coming up.
so can you please tell me what this command has done mv matter /*/* .
You can find out for yourself by inserting an echo at the beginning of the command line:
echo mv matter /*/* .
The expanded command looks like this:
mv matter /bin/ash /bin/bash /bin/echo /bin/false [...] /home/yourname [...] .
All files and directories from the top-level directories (echo /*/) have been moved to this one directory where you executed that command. It's hard to separate them from there, but you can try using a rescue CD:
move all executable files to /bin
make /sbin a symlink to /bin
move all files that look like configuration files to /etc
But since you couldn't find out for yourself what the mv command was doing exactly, you should rather ask someone who knows to fix it for you. It's a lot of work, though.

Will the program installed in a folder function properly if I remove the write permission in linux? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 9 years ago.
Improve this question
I have a user account on a cluster( a server), and can only install program like python on the home folder. In case I might accidentally delete the bin, lib, share,include folders coming with the installation of python on the home folder. I change the permissions of the above folder like this
chmod -w folder
but I am worried when the program need to write/delete some files of the folders, it might not function because the removal of write permission. Am I right? or I the run, including write files in the folder, of a program have permissions different than the permission of user.
BTW, is there a way to hide the folders without changing the names?
Wouldn't this stop python from running all together? For example:
$ cd ~
$ mkdir -p python/bin/
$ echo "echo 'hi'" > python/bin/python
$ python/bin/python
hi
$ chmod -x python
$ python/bin/python
bash: python/bin/python: Permission denied
As for your second question, no, there is no other way to selectively hide one folder without changing the name.
Edit: re-reading, I may have mis read what you were saying about the folders. You could always apply a "chmod -r folder" and nothing inside will be visable. This is not hiding it, just turning off permissions to view it.

Resources