Ubuntu denies me access again.

When I try to run a command in Ubuntu this happens:

bash: ./FILENAME.bin: Permission denied


How do I gain access?
I tried sudo su but it didn't work.
Here are some tips:

1. Use history and look at the recent commands.
2. Start by locating the file with which, locate, or find.
3. Use pwd to verify that you are in the same place or check your PATH.
4. Display a long listing via ls -l (I think Ubuntu has the alias ll for this).
5. Check the name of the file and that it has read and executable permissions.
6. Use groups or id to verify your login and primary group.
7. Use file and/or head to determine the file type; is it binary or a script? Some scripts are written to be "sourced" rather than "ran".

After that I usually determine that I'm the one to blame... ;)
chmod +x <filename> Duh.
When in doubt, ls -l.
Well, I don't use the Terminal much, I mean I can navigate and everything because the commands are very similar to Command Prompt, so gimme a break.
meh I accidentally typed chmod -X instead of -x thank you.
New problem:

Could not locate 'jvm/bin/java'.
Please ensure that you entered the proper path.

Which Java Virtual Machine would you like to use?
Note: the JVM must be version 1.5 or newer.


Normally in windows it would be in C:\Program Files\JVM but ...
which java will give you the directory
- just java will run it if it's installed -
Last edited on
chmod +x <filename>

I normally chmod 777 <file>. Am I a bad person?
Wait, doesn't that restrict all operations? 000 would allow all operations.
I thought 777 allowed read, write and execute to all users. As I'm the only user (except root) on the system I got into the habit of using 777.

The shame!
Helios, you might be thinking of the umask.
Get into the habit of chmod 755 file, even if you are the only user.
Last edited on
I realise 777 is a bad habit. What is 755?
So that'd be "read, write and execute" for the chmoding (current) user, and read and execute for every one else? That seems fair. 777 would then be read, write and execute for everyone :O
chrisname wrote:
I realise 777 is a bad habit. What is 755?


the value of each is:
Read = 4
Write = 2
Execute = 1

basically each number in the chmod format stands for this:
user | group | others
(there is 1 other unit but is more commonly omitted)

so the user is the users permissions (the person who owns the file(typically you), to check this use list long format( ls -l )), groups are things in linux that basically work like certain groups have certains permissions etc. I dunno how to explain it fully, but basically each user has a group, typically if your the owner and admin of the OS, then your group is the same as your username, however on large unix system you may have 1 group for level1 people, then another group for level2 etc. Additionally each program on the system has it's own group as well. This is to allow certain users to use certain programs.

others is everyone else, eg. people over network etc...


if we want to put read/write/exec on user 7
if we want to put read/exec on group and others then 5 = 4 + 1

so the format looks like this:

1 = execute
2 = write
3 = write / execute (2+1)
4 = read
5 = read / execute (4+1)
6 = read / write (4+2)
7 = read / write / execute (4+2+1)

typically 755 is normal, or 754 imo it's up to you... doesn't matter too much. keep in mind some files don't need execute permissions.

additionally files beginning with a dot ( . ) are hidden files, these are not shown using ls, or in normal GUI folder view. You need to specify to show hidden files, or use list with the "show all" flag -a : $ ls -a


helios wrote:
Wait, doesn't that restrict all operations? 000 would allow all operations.


there is another command called umask this is usually put into rc files to allow default permissions on files:
for some silly reason it works backwards to chmod. Don't ask why, I have no idea... it's dumb.
so lets say we want to put a default in our default shell which happens to be bash
in the .bashrc file in our home directory we can put:
# default permissions
umask 022

so before when we would add the number we want to have on the files, this time using umask we must put the numbers(permissions) we DON'T want on the files.
so in this case all files would be set as default 755
because we have specified 0 for user, 2 for groups, which means groups will not have write, and 2 for others- others don't get write.

chmod 777 = umask 000
chmod 755 = umask 022
chmod 400 = umask 377

Bazzy wrote:
which java will give you the directory
- just java will run it if it's installed -


like Bazzy suggested which is a good way of finding programs installed in your system, however it only reports the first entry found.
What I do is put as an alias in my .bashrc
alias which='type -a'
type -a is a much better format as it shows all programs found in your $PATH variable, and also any aliases eg.

$which which
which is aliased to type -a
which is /bin/which
which is /usr/bin/which
which is /usr/local/bin/which
which is /sbin/which

(seems I have a few 'which's installed :P), actually I made up the last 3 entries...
of course you don't need to add this to your rc you can simply type on command line;
$ type -a JVM
or
$ type -a java
java is /usr/bin/java

the find command can also be handy dealing with problems such as these. but typically the problem is people installing OpenJDK
OpenJDK is a piece of shit, uninstall it if you have it installed.
install sun JDK...
it is usually in most repositories just takes a bit more looking for. You could try compiling from source yourself by downloading off the website, but it is always better for the system to manage your software

I might be hopeless at C++, but I'm pretty good with unix. :P
Last edited on
Also I just wanted to add this handy bit of information for codeblocks users.
Go to the nightly builds page, click on any of the posts (it doesn't matter which), typically nightly builds are windows only, however if you read down the reply posts usually the 1st or second reply is for a linux repository. Jens is the person/poster If you open up this link and follow the posters instructions, which are very easy mind you, all you do is copy paste a couple lines of text into your console.

All you have to do is enter root, (sudo su) and then copy paste the below code into the console:
Don't worry if you get errors with the first 2 lines, it resolves after the 3rd/4th...

To install the packages using apt or one of its frontends please add the following lines to your /etc/apt/sources.list :
1
2
deb http://apt.jenslody.de/ any main
deb-src http://apt.jenslody.de/ any main 

The best and easiest way to add my public-key to apt's trustdb is to install the package jens-lody-debian-keyring with your preferred package-manager or with:
1
2
sudo apt-get update
sudo apt-get install jens-lody-debian-keyring

Please put the following lines to your sources.list too:
 
deb http://apt.wxwidgets.org/ lenny-wx main 

key-import to apt's trusted keys:
 
wget -q http://apt.wxwidgets.org/key.asc -O-  | sudo apt-key add - 



Now your done? done what exactly? every nightly build that is released (and quite often even before it is released in windows) synaptic will have the updated codeblocks ready for download. it tells you as soon as you startup the pc if there is a new available package, and then installs automatically.

Here is one example page. http://forums.codeblocks.org/index.php/topic,11875.0.html
Last edited on
sorry, I didn't realize this was never answered, But I figure you have probably worked it out by now... or gone on holidays.

DrChill wrote:
Normally in windows it would be in C:\Program Files\JVM but ...


/usr/lib/jvm/
/lib/jvm
all library files are stored in there same with your c++ includes which you need to add to some IDE's, and sometimes depending on the OS /usr/local/lib also has library files.
Last edited on
Ya, I didn't have java installed thanks though.
Topic archived. No new replies allowed.