LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 11-10-2020, 11:08 AM   #1
mackowiakp
Member
 
Registered: Jun 2014
Location: Poland/Gdynia
Distribution: Mageia 9, SH4, Debian
Posts: 367

Rep: Reputation: 8
Wrong user/group of subdir and file created in /home/usernamedir/tmp


I have Debian Buster installed in LXC container on QNAP NAS. From container I run such script:

Code:
debian@Debian:~/Pobrane$ cat ampli 
#!/bin/bash

path_media="/share/homes/media/Pobrane/RADIO"
ssh_cmd="/usr/bin/ssh -p669 -x -q -i /home/debian/.ssh/id_debian admin@192.168.0.7"

[ ! -d /home/debian/tmp ] && mkdir /home/debian/tmp
$ssh_cmd $path_media/ampli $1 > /home/debian/tmp/ampli
Script "ampli" returns text output to stdout. The content of output is ok.
But both "/home/debian/tmp" dir and "/home/debian/tmp/ampli" file have user/group - root/root. Should be debian/debian. Why is not? Any idea?

Last edited by mackowiakp; 11-10-2020 at 11:09 AM.
 
Old 11-10-2020, 02:03 PM   #2
sgosnell
Senior Member
 
Registered: Jan 2008
Location: Baja Oklahoma
Distribution: Debian Stable and Unstable
Posts: 1,943

Rep: Reputation: 542Reputation: 542Reputation: 542Reputation: 542Reputation: 542Reputation: 542
Are you running ampli as root?
 
Old 11-10-2020, 02:07 PM   #3
mackowiakp
Member
 
Registered: Jun 2014
Location: Poland/Gdynia
Distribution: Mageia 9, SH4, Debian
Posts: 367

Original Poster
Rep: Reputation: 8
Of course NOT. I running it as user "debian". It is very strange for me. The same situation is when I try to create such file in /dev/shm/ (more useful for me). Can not access the file created by the script because once has root/root uid/gid.
 
Old 11-10-2020, 02:55 PM   #4
sgosnell
Senior Member
 
Registered: Jan 2008
Location: Baja Oklahoma
Distribution: Debian Stable and Unstable
Posts: 1,943

Rep: Reputation: 542Reputation: 542Reputation: 542Reputation: 542Reputation: 542Reputation: 542
/dev/shm/ and everything in it does belong to root. I don't understand why that is more useful, but you don't want to change the owner & group of anything in /dev. I ran your script (modified) from my home, and while it didn't entirely work because of not having packages installed, it did create the directories in my home, and they are owned by me. If you're running the script from outside your home, that may be why the directories are owned by root. Try running it as your user, from your home directory, and see what you get.
 
Old 11-11-2020, 01:29 AM   #5
mackowiakp
Member
 
Registered: Jun 2014
Location: Poland/Gdynia
Distribution: Mageia 9, SH4, Debian
Posts: 367

Original Poster
Rep: Reputation: 8
The case was cleared up. Never in my life would I have guessed the reason.
Well, due to a problem with QNAP CloudSync app, I had an open online support session with QNAP Support. As I learned from the QNAP Helpdesk, such a session causes each console session (no matter how initialized) to run it with root privileges.
And it doesn't matter that the system shows that I am a normal user and not root. Only that I do not work on the "native" QNAP partition, but in the LXC container. But according to the QNAP Helpdesk, it doesn't matter.
I don't understand it at all. Nevertheless, after disconnecting the support session, the script works fine. Complete quirk ...
 
  


Reply

Tags
bash, debian 10 buster, gid, mkdir, uid



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] why chown user:group wildcard in path /home/user/.*/* will modify all /home owner cociugcristina Linux - Server 11 05-07-2013 04:16 AM
Can't login, says tmp directory full but tmp file is empty! Could be linked to MySQL? bethanlowder Fedora 7 09-25-2009 07:17 AM
ID created with assigned group is not display in /etc/group file dwarf007 Linux - Security 2 08-21-2007 10:39 PM
How to change owner and group in a directory to include subdir and all files Lakota Linux - General 2 07-15-2004 09:35 AM
Create file using 'touch ./tmp.$$', file tmp.3941 is created, why? huangyanfeng Linux - General 1 04-13-2004 03:36 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 05:33 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration