I've got a bash script that I want to make executable in Cygwin. So I ran chmod 755 file.sh but it does nothing. Here is the file before and after the chmod command:
-rw-r--r-- 1 Myname None 234 Mar 29 17:05 file.sh
Any idea how to make it work?
Ok I found out what the issue was. It's because I had changed my /etc/fstab file to fix another issue with file permissions, specifically I had it setup like this:
none /cygdrive cygdrive binary,noacl,posix=0,user 0 0
but since it's causing problems, I've now restored it to its default state:
none /cygdrive cygdrive binary,posix=0,user 0 0
And no more issues with chmod.
Related
When I clear Linux caches, I use this:
echo 3 > /proc/sys/vm/drop_caches
It tells me: Insufficient permissions
Then I inspect the file drop_caches with:
ls -l /proc/sys/vm/drop_caches
and I get this:
-rw-r--r-- 1 root root 0 1月 22 01:21 /proc/sys/vm/drop_caches
So I use:
chmod 777 /proc/sys/vm/drop_caches
to change the file permissions, but insufficient permissions is printed again.
Current user is root, how can I change the permissions of this file?
As root, echo 3 > /proc/sys/vm/drop_caches should work. Run whoami to make sure you are root.
If not, type sudo -i or su to open a root shell where you can run these commands.
You can't.
Permissions on /proc nodes are defined in the kernel, and cannot be changed at runtime.
I would like to edit a file with a shell script which is in the same group but not the "caller" user.
-rwsr-xr-x 1 root root 4896 Oct 21 00:59 /usr/bin/luxus
-rw-rw-r-- 1 root root 4096 Oct 20 23:01 <path>/file1
lrwxrwxrwx 1 root root 0 Oct 20 23:00 <path>/dir1
/usr/bin/luxus: the shell script
file1: the file to edit
dir1: file1's parent directory (symlink)
In the shell script, this is the line where the permission issue is:
echo "string" > /usr/bin/tee <path>/file1
Output:
/usr/bin/tee: <path>/file1: Permission denied
I am trying to create an AUR package for the shell script. The latter is meant to be install on the system from a PKGBUILD. In vain, I attempted to give enough permissions to the script to edit the targeted file.
This is a PKGBUILD's sample:
install -Dm755 src/${pkgname} "${pkgdir}/usr/bin/${pkgname}"
chown root.root "${pkgdir}/usr/bin/${pkgname}"
chmod 4755 "${pkgdir}/usr/bin/${pkgname}"
After investigating, I think it is quite simply impossible because of security or because of the parent dir's rights.
Nevertheless I am asking you for a solution.
As you said "you can't do anything".
The following post quite simply explains why it won't work:
https://unix.stackexchange.com/questions/364/allow-setuid-on-shell-scripts
I've installed frequent-cron, according to the installation instructions on https://github.com/homer6/frequent-cron.
I've changed /etc/init.d/frequent_service/init_script.tpl for my own needs:
# This is arbitrary. Change it to whatever you'd like.
SERVICE_NAME="frequent_service"
# Frequent cron must exist at this path. Optionally, you can change it to a path where it does exist.
EXEC=/usr/bin/frequent-cron
# Change this to the path of your choice.
#PIDFILE=/var/run/${SERVICE_NAME}.pid
PIDFILE=/var/run/${Odoo_OPC}.pid
# Point this to the shell (or program) that you'd like to run. /tmp/myshell.sh is just an example.
#COMMAND=/tmp/myshell.sh
COMMAND=python /usr/bin/OPCConnectie/OdooNaarOPC.py
# Frequency is in milliseconds. The command will be invoked every frequency interval.
FREQUENCY=1000
But when I want to start frequent-cron with:
sudo /etc/init.d/frequent_service start
It gives these errors:
hew#hew-VirtualBox:~$ sudo /etc/init.d/frequent_service start
/usr/bin/OPCConnectie/OdooNaarOPC.py: 1: /usr/bin/OPCConnectie/OdooNaarOPC.py: import: not found
/usr/bin/OPCConnectie/OdooNaarOPC.py: 2: /usr/bin/OPCConnectie/OdooNaarOPC.py: Syntax error: "(" unexpected
Starting frequent_service frequent cron...
/etc/init.d/frequent_service: 32: /etc/init.d/frequent_service: /usr/bin/frequent-cron: Permission denied
frequent_service started.
Even after:
sudo chmod -R 777 /usr/bin/OPCConnectie/
sudo chmod -R 777 /etc/init.d/frequent_service
It gives the same errors.
I think I can split this problem in 2 problems.
1) Error about the python script:
I don't know what's wrong because it runs fine in a normal cronjob.
Is there anything wrong with how I want to start the script in init_script.tpl?
2) Error Permission denied:
I always thought chmod -R 777 gives the folder + all subfolders and files ALL permissions? So why permission is still denied?
Edit: Checked the permissions as exussum recommended:
hew#hew-VirtualBox:~$ namei -m /etc/init.d/frequent_service
f: /etc/init.d/frequent_service
drwxr-xr-x /
drwxr-xr-x etc
drwxr-xr-x init.d
-rwxrwxrwx frequent_service
hew#hew-VirtualBox:~$ namei -m /usr/bin/OPCConnectie/
f: /usr/bin/OPCConnectie/
drwxr-xr-x /
drwxr-xr-x usr
drwxr-xr-x bin
drwxrwxrwx OPCConnectie
Are these correct? Or, should these permissions be enough?
Edit 2: Answer to problem 1 (python)
Had to put the following line on top of the python script:
#!/usr/bin/env python
Found here: Crontab wont run python script
Still need permissions for /usr/bin/frequent-cron though.
It's likely you don't have permission (x) on one of the paths leading to it.
namei -m /your/path/here
will show all permissions of the path to that point.
Edit
On second look looks like your missing a shebang line
#!/usr/bin/python
at the top of the file.
Similar to this question, I am unable to unset execute permissions on files after recently upgrading Cygwin.
I have a file with the following permissions:
ls -l filename
-rw-rwxr--+ 1 gstrycker Users 1334935 Jan 26 09:23 filename
I'm trying to get rid of execute privileges, but running chmod -x or even chmod 0 does not seem to work now (note that it always did work for me before -- but I don't believe there were this many columns in the POSIX security permissions)
chmod 0 filename
ls -l filename
----rwx---+ 1 gstrycker Users 1334935 Jan 26 09:23 filename
Why can I not seem to be able to modify this central group of privileges now? I've always been able to before. I even tried to change the group owner, but that didn't seem to help.
I'm stuck -- any ideas? Is this a new Cygwin bug? Did Cygwin recently add columns to the POSIX permissions, and if so, how do I access these?
I am very puzzled by this problem I am having. I am trying to execute a file in Ubuntu 12.04 LTS via command line. I have a script that calls a program to run and write the results in a hard drive. I changed the permissions and ownership of everything to be wxr. Here is the ls -l of my script (called TEST-star):
-rwxrwxrwx 1 root root 950 Nov 15 13:16 TEST-star
Here is the ls -l of the package my script calls:
-rwxrwxrwx 1 root root 1931414 Nov 10 12:37 STAR
Finally the ls -l of the hard drive mounted in /media/CLC"
drwxrwxrwx 1 root root 8192 Nov 15 13:04 CLC
I have been trying to run it since yesterday and always get a message that I don't have permission to write the results:
EXITING because of FATAL ERROR: could not create output file ./_STARtmp//Unmapped.out.mate1.thread14
Solution: check that you have permission to write this file
I thought if I change the permissions to rwx and run my script as root it would not have a problem (using sudo). Right now I run out of options. Any suggestion would be appreciated. Please let me know what other information you would need solve this issue.
Thank you.
Here is the first line of script I am trying to run:
#!/bin/sh
cd /media/CLC/ANOPHELES-STAR-v2.4f1/; mkdir GambFemAnt1 && cd GambFemAnt1; echo $PWD && echo Starting mapping of GambFemAnt1; /home/aedes/Documents/STAR_2.4.0f1/STAR --genomeDir /media/Galaxy/Galaxy_data/Anopheles/STAR/Genome --readFilesIn /media/Galaxy/Galaxy_data/Anopheles/QC/GambFemAnt1/GambFemAnt1.fastq --runThreadN 23 --outFilterMismatchNmax 4 --outFilterMatchNminOverLread 0.75 --seedSearchLmax 30 --seedSearchStartLmax 30 --seedPerReadNmax 100000 --seedPerWindowNmax 100 --alignTranscriptsPerReadNmax 100000 --alignTranscriptsPerWindowNmax 10000 --outSAMstrandField intronMotif --outFilterIntronMotifs RemoveNoncanonical --outSAMtype BAM SortedByCoordinate --outReadsUnmapped Fastx; mv Aligned.sortedByCoord.out.bam GambFemAnt1.bam; mv Unmapped.out.mate1 GambFemAnt1-unmapped.fastq; cp *.fastq /media/CLC/ANOPHELES-STAR-v2.4f1/UNMAPED-reads/; cd /media/CLC/ANOPHELES-STAR-v2.4f1 && echo $PWD && echo GambFemAnt1 mapping finished;
I also posted a question for the authors of the package.
Turns out all the permissions were set correctly. The problem resigns within the package. I found out that it works using --runThreadN 12 instead of --runThreadN 23.