I've got a screen session running for the user heechan on my linux server:
heechan#vps3712:~$ ls -laR /var/run/screen/
/var/run/screen/:
total 0
drwxrwxr-x 5 root utmp 100 Aug 31 08:22 .
drwxr-xr-x 18 root root 640 Sep 18 05:24 ..
drwx------ 2 grt grt 60 Aug 27 04:03 S-grt
drwx------ 2 heechan heechan 40 Sep 1 09:44 S-heechan # <== THIS ONE
/var/run/screen/S-heechan:
total 0
drwx------ 2 heechan heechan 40 Sep 1 09:44 .
drwxrwxr-x 5 root utmp 100 Aug 31 08:22 ..
But when I do screen -ls I don't see the session:
heechan#vps3712:~$ screen -ls
No Sockets found in /var/run/screen/S-heechan.
heechan#vps3712:~$ screen -r
There is no screen to be resumed.
heechan#vps3712:~$
Where is this session and how I I resume it?
As you can see, /var/run/screen/S-heechan is empty, so there is no socket file inside.
Your screen is terminated. Perhaps you forgot to detach and exited instead? (To detach, use ctrl+a d )
Related
/var/www/html/talent-media.com/public_html/help/scp/apps/.htaccess
shows up, but there is no .htaccess file as per
[root#0rcan0mic apps]# ls -al
total 12
drwxr-xr-x. 2 root root 4096 Apr 28 00:05 .
drwxr-xr-x. 6 root root 4096 Mar 20 01:11 ..
-rw-r--r--. 1 root root 1349 Mar 20 01:11 dispatcher.php
[root#0rcan0mic apps]# pwd
/var/www/html/talent-media.com/public_html/help/scp/apps
[root#0rcan0mic apps]#
Thoughts?
If I do ls -la, I get results like
total 16
drwxr-xr-x 4 rockse staff 136 Apr 28 16:55 .
drwx------+ 23 rockse staff 782 Apr 28 16:48 ..
-rw-r--r-- 1 rockse staff 32 Apr 28 16:49 1.sh
-rw-r--r-- 1 rockse staff 215 Apr 28 17:01 ls-1.txt
But if I do ls -la > ls-1.txt, I get this
total 8
drwxr-xr-x 4 rockse staff 136 Apr 28 16:55 .
drwx------+ 23 rockse staff 782 Apr 28 16:48 ..
-rw-r--r-- 1 rockse staff 32 Apr 28 16:49 1.sh
-rw-r--r-- 1 rockse staff 0 Apr 28 17:06 ls-1.txt
I understand that a file is created and then ls -la is written to the same but why doesn't it capture the snapshot of ls -la before creating the file because we are just writing stdout to a file ?
The redirection is done by the shell, not the program you're running. The processing done by the shell to implement this is similar to this (simplified):
Fork a child process
Open the output file
Connect stdout to the output file stream
Execute the program
Step 2 creates the file, so it will be visible when the program runs in step 4.
If step 2 were done after step 4, it wouldn't be possible to change the program's stdout to point to it.
I have this linux command:
candump -l -e -x -s 0 -n 10 any,0~0,#FFFFFFFF 2> /dev/null > /tmp/can.log &
It works correctly when I run it directly in shell.
I want to add it in my script with this method:
#!/bin/sh
# I tried this 2 syntax
# MYVAR="candump -l -e -x -s 0 -n 10 any,0~0,#FFFFFFFF 2> /dev/null > /tmp/can.log &"
MYVAR='candump -l -e -x -s 0 -n 10 any,0~0,#FFFFFFFF 2> /dev/null > /tmp/can.log &'
$MYVAR
When I execute my script I get this error:
SIOCGIFINDEX: No such device
I have tested these script and it works:
#!/bin/sh
MYVAR='ls -l'
$MYVAR
Result:
total 8
drwxr-xr-x 2 root root 0 Nov 5 2015 bin
drwxr-xr-x 2 root root 0 Oct 22 2015 boot
drwxr-xr-x 5 root root 13460 Jan 1 00:00 dev
drwxr-xr-x 8 root root 0 Nov 5 2015 etc
drwxr-xr-x 3 root root 0 Nov 5 2015 home
-rwsr-xr-x 1 root root 258 Nov 5 2015 init
drwxr-xr-x 3 root root 0 Nov 5 2015 lib
drwxr-xr-x 3 root root 0 Nov 5 2015 media
drwxr-xr-x 3 root root 0 Nov 5 2015 mnt
dr-xr-xr-x 67 root root 0 Jan 1 00:00 proc
drwx------ 2 root root 0 Oct 22 2015 root
drwxr-xr-x 4 root root 0 Jan 1 00:00 run
drwxr-xr-x 2 root root 0 Nov 5 2015 sbin
dr-xr-xr-x 14 root root 0 Jan 1 00:00 sys
-rwxr-xr-x 1 root root 33 Jan 1 00:04 test
drwxrwxrwt 2 root root 0 Jan 1 00:00 tmp
drwxr-xr-x 9 root root 0 Oct 22 2015 usr
drwxr-xr-x 7 root root 0 Oct 22 2015 var
I can't see the error, can you explain me the error?
Better (and safer) to use a shell function rather that a variable:
#!/bin/sh
myfunc() {
candump -l -e -x -s 0 -n 10 any,0~0,#FFFFFFFF 2>/dev/null >/tmp/can.log &
}
# call it
myfunc
I'm using the following command to download some file in another machine.
It works fine when the file size of senselist.txt is small(<1G maybe, no accurate number just a estimate).
When the file size grow bigger, it failed to download one of the senselist.txt.
wget -r -N -l inf -nd -np -q --accept=senselist.txt* \
-t 30 -T 60 -c --limit-rate=100M \
ftp://ftp:ftp#hostname/home/work/data/20150922 \
-P ./data_tmp/20150921000000/tmp_dir
Currently there are eight files on the source machine. Sometimes, I failed to download senselist.txt4. But it can't be reproduced, it happens occasionally.
How to fix this, or how to find the reason for this?
-rw-rw-rw- 1 root root 1.4G Sep 21 19:04 senselist.txt0
-rw-rw-rw- 1 root root 100 Sep 21 19:04 senselist.txt0.md5
-rw-rw-rw- 1 root root 1019.8M Sep 21 19:33 senselist.txt1
-rw-rw-rw- 1 root root 100 Sep 21 19:34 senselist.txt1.md5
-rw-rw-rw- 1 root root 1.1G Sep 21 20:42 senselist.txt2
-rw-rw-rw- 1 root root 100 Sep 21 20:42 senselist.txt2.md5
-rw-rw-rw- 1 root root 1.1G Sep 21 21:25 senselist.txt3
-rw-rw-rw- 1 root root 100 Sep 21 21:25 senselist.txt3.md5
-rw-rw-rw- 1 root root 1017.0M Sep 21 21:59 senselist.txt4
-rw-rw-rw- 1 root root 100 Sep 21 22:00 senselist.txt4.md5
-rw-rw-rw- 1 root root 895.2M Sep 21 22:37 senselist.txt5
-rw-rw-rw- 1 root root 100 Sep 21 22:38 senselist.txt5.md5
-rw-rw-rw- 1 root root 1.2G Sep 21 23:22 senselist.txt6
-rw-rw-rw- 1 root root 100 Sep 21 23:22 senselist.txt6.md5
-rw-rw-rw- 1 root root 1.2G Sep 21 23:54 senselist.txt7
-rw-rw-rw- 1 root root 100 Sep 21 23:54 senselist.txt7.md5
UPDATE
I wrote the command in a shell script, and use the following code:
eval "$cmd_str" 2>>$ERRFILE 1>>$LOGFILE
I have a bare git repository setup for user fred:
/home/fred/foo.git
I have set the group of every file in foo.git to bar:
$ chown -R fred:bar /home/fred/foo.git
(Note that fred is not a member of group bar)
And I have set the setgid bit on for every directory in foo.git:
$ find foo.git -type d -print0 | xargs -0 chmod g+s
However when fred commits to the git repository, the group is not preserved in some files.
Specifically in the objects directory I see:
foo.git/objects:
drwxrws--- 46 fred bar 4096 Apr 7 23:43 .
drwxrws--- 7 fred bar 4096 Apr 6 17:12 ..
drwxrws--- 2 fred bar 4096 Apr 6 17:11 07
drwxrws--- 2 fred bar 4096 Apr 6 17:11 10
drwxrwx--- 2 fred bar 4096 Apr 7 22:14 14 <--- HERE
drwxrws--- 2 fred bar 4096 Apr 6 17:11 17
^--- HERE
Notice that in objects/14 the setgid bit is not set. So consequently when a new object is added to that directory:
foo.git/objects/14:
drwxrwx--- 2 fred bar 4096 Apr 7 22:14 .
drwxrws--- 46 fred bar 4096 Apr 7 23:43 ..
-r--r----- 1 fred fred 2595 Apr 7 22:14 95482f8..9d6bfe21
So now the 95482.. file doesn't have group bar, it has group fred.
I suspect that when fred commited, git created a new directory on-demand called objects/14 to hold a new object, when it did this for some unknown reason the setgid bit on the new 14 directory was not set, even though its parent directory objects has the setgid bit set.
If I try to reproduce this manually:
$ su fred # as user fred
$ mkdir test1 # create test1 dir
$ sudo chgrp bar test1 # set group to bar
$ sudo chmod g+s test1 # set setgid bit
$ ls -l
drwxrwsr-x 2 fred bar 4096 Apr 8 21:33 test1
$ mkdir test1/test2 # create dir test1/test2
$ ls -l
drwxrwsr-x 2 fred bar 4096 Apr 8 21:35 test2
^--- HERE
Notice the setgid bit in the new test1/test2 is preserved, so when I...
$ touch test1/test2/test3
The new file is still group bar as expected:
$ ls -l test1/test2
-rw-rw-r-- 1 fred bar 0 Apr 8 21:36 test3
Why doesn't git seem to preserve the setgid bit when it creates new directories in the .git directory?
Is there some git setting I can make to fix this? Or can you explain what is causing this?
It turns out that when you specify the core.sharedrepository config, git does chmod()s on the files it creates. That way, the result is correct despite filesystem types and mount options, except in your one case where the repository owner isn't a member of the group it's shared with.
That bad result happens because git's chmod() appears to succeed -- you can see it in an strace -- but ignores anything the issuing user isn't authorized to ask for.
So to avoid that weirdity, the thing to do is
git config --unset core.sharedrepository
(or not specify --shared at all on the init) so git doesn't touch the filesystem's default permissions at all. Amusingly enough that makes everything work:
~/sandbox/75276/s$ find ../s.git -ls
12193569 4 drwxrws--- 4 jthill mail 4096 Apr 9 13:52 ../s.git
12193571 4 -rw-rw---- 1 jthill mail 73 Apr 8 20:40 ../s.git/description
12193572 4 -rw-rw---- 1 jthill mail 23 Apr 8 20:40 ../s.git/HEAD
12721086 4 drwxrws--- 2 jthill mail 4096 Apr 9 13:52 ../s.git/objects
12193570 4 drwxrws--- 2 jthill mail 4096 Apr 9 13:52 ../s.git/refs
12193578 4 -rw-rw---- 1 jthill mail 104 Apr 9 13:37 ../s.git/config
~/sandbox/75276/s$ cat ../s.git/config
[core]
repositoryformatversion = 0
filemode = true
bare = true
[receive]
denyNonFastforwards = true
~/sandbox/75276/s$ git push origin master
Counting objects: 3, done.
Writing objects: 100% (3/3), 198 bytes, done.
Total 3 (delta 0), reused 0 (delta 0)
To /home/jthill/sandbox/75276/s.git
* [new branch] master -> master
~/sandbox/75276/s$ find ../s.git -ls
12193569 4 drwxrws--- 4 jthill mail 4096 Apr 9 13:52 ../s.git
12193571 4 -rw-rw---- 1 jthill mail 73 Apr 8 20:40 ../s.git/description
12193572 4 -rw-rw---- 1 jthill mail 23 Apr 8 20:40 ../s.git/HEAD
12721086 4 drwxrws--- 5 jthill mail 4096 Apr 9 13:53 ../s.git/objects
16777964 4 drwxrwsr-x 2 jthill mail 4096 Apr 9 13:53 ../s.git/objects/58
16777965 4 -r--r--r-- 1 jthill mail 17 Apr 9 13:53 ../s.git/objects/58/7be6b4c3f93f93c489c0111bba5596147a26cb
16777962 4 drwxrwsr-x 2 jthill mail 4096 Apr 9 13:53 ../s.git/objects/ab
16777963 4 -r--r--r-- 1 jthill mail 46 Apr 9 13:53 ../s.git/objects/ab/69b4abf3bb84d4e268bd42d84e4a9a5e242bd3
16777960 4 drwxrwsr-x 2 jthill mail 4096 Apr 9 13:53 ../s.git/objects/81
16777961 4 -r--r--r-- 1 jthill mail 120 Apr 9 13:53 ../s.git/objects/81/210f2df9629e5df5f6dfa0923a2cf72369314d
12193570 4 drwxrws--- 3 jthill mail 4096 Apr 9 13:53 ../s.git/refs
12193573 4 drwxrwsr-x 2 jthill mail 4096 Apr 9 13:53 ../s.git/refs/heads
12193574 4 -rw-rw-r-- 1 jthill mail 41 Apr 9 13:53 ../s.git/refs/heads/master
12193578 4 -rw-rw---- 1 jthill mail 104 Apr 9 13:37 ../s.git/config
~/sandbox/75276/s$