strange behaviour with .git folder - linux

I have clone a git directory as user bob on a remote machine (after having forwarded the local key). When I clone the repo, the repo appears fine and everything shows up including a .git folder.
Now, I want to copy this folder over to another location which happens to be a link to a folder. When I do a cp -r /tmp/tmp.kk3a8xemvr/* /home/staging/myapp, everything gets copied, but not .git folder. When I explicitly call out the .git folder in the cp command, it gets copied. I also noticed the the .gitignore did not get copied either.
Another strange behavior is when I go to /home/staging/myapp, and I do a rm -rf ./*, the .git folder does not get deleted unless I call it out specifically.
How come simple unix commands behave differently for the .git directory? There is nothing special about its permissions. Could it be that the period in front of the file causes some problems?
drwxr-xr-x 8 staging staging 4096 Oct 12 03:42 .git/
My OS is Ubuntu 12.04 LTS.
Linux myapp 3.2.0-54-virtual #82-Ubuntu SMP Tue Sep 10 20:31:18 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux
EDIT
Provide more information for Jonathan: I have update the foldernames to match with the commands below:
# cd /tmp/tmp.kk3a8xemvr <- source, everything is good here.
root#myapp1:/tmp/tmp.kk3a8xemvr; ls -la
total 48
drwx------ 9 bob bob 4096 Oct 13 03:08 .
drwxrwxrwt 7 root root 4096 Oct 13 14:55 ..
drwxrwxr-x 3 bob bob 4096 Oct 13 03:08 ansible
drwxrwxr-x 4 bob bob 4096 Oct 13 03:08 backend
drwxrwxr-x 3 bob bob 4096 Oct 13 03:08 clientdb
drwxrwxr-x 15 bob bob 4096 Oct 13 03:08 dapi
drwxrwxr-x 3 bob bob 4096 Oct 13 03:08 docs
drwxrwxr-x 3 bob bob 4096 Oct 13 03:08 fabfile
drwxrwxr-x 8 bob bob 4096 Oct 13 03:08 .git
-rw-rw-r-- 1 bob bob 44 Oct 13 03:08 .gitignore
-rw-rw-r-- 1 bob bob 68 Oct 13 03:08 README.md
-rw-rw-r-- 1 bob bob 450 Oct 13 03:08 requirements.txt
# cd /home/staging; ls
lrwxrwxrwx 1 staging staging 62 Oct 13 03:06 myapp -> /srv/www/staging.myapp.com/public_html/myapp/
# command I use:
sudo cp -r /tmp/tmp.kk3a8xemvr/* /home/staging/myapp
# cd /home/staging/myapp; ls -la; # <- this is the intended destination;
# .git and .gitignore are missing after applying the cp command.
drwxr-xr-x 9 staging staging 4096 Oct 13 14:59 .
drwxr-xr-x 3 staging staging 4096 Oct 13 03:06 ..
drwxr-xr-x 3 staging staging 4096 Oct 13 03:08 ansible
drwxr-xr-x 4 staging staging 4096 Oct 13 03:08 backend
drwxrwxr-x 2 staging staging 4096 Oct 13 14:59 clientdb
drwxr-xr-x 15 staging staging 4096 Oct 13 03:09 dapi
drwxr-xr-x 3 staging staging 4096 Oct 13 03:08 docs
drwxr-xr-x 3 staging staging 4096 Oct 13 03:08 fabfile
-rw-r--r-- 1 staging staging 68 Oct 13 03:08 README.md
-rw-r--r-- 1 staging staging 450 Oct 13 03:08 requirements.txt

If you do:
sudo cp -r /tmp/tmp.kk3a8xemvr/* /home/staging/myapp
the shell expands the * into 'all file or directory names that do not start with .' (thus omitting .git, etc).
If you do:
sudo cp -r /tmp/tmp.kk3a8xemvr /home/staging/myapp
you will get a subdirectory tmp.kk3a8xemvr created in /home/staging/myapp, which is not what you want, I think.
However, if you do:
sudo cp -r /tmp/tmp.kk3a8xemvr/. /home/staging/myapp
you should find you get everything copied where you want it.

Related

Linux folder permissions not inherited with symfony new project

I'm setting up a new web server, and getting some issues with folder perms when generating a new symfony project.
All my websites are located into /var/www
My symfony installer is located in /usr/local/bin/symfony
And this my my symfony installer ownership and perms:
-rwxr-xr-x 1 root staff 233229 Oct 11 00:56 symfony
Here is what I did on my website main folder :
chown :www-data /var/www/
chmod g+s /var/www/
setfacl u:my-user:rwx,d:u:my-user:rwx,g:www-data:rwx,d:g:www-data:rwx /var/www
When uploading file, everything is fine, group and perms are inherited correctly.
The problem is when I generate a new symfony project with the following command while located into /var/www:
symfony new my_project
This is the project folder perms:
drwxr-xr-x 9 501 root 4096 Oct 15 00:20 test
And the perms inside the project folder:
drwxr-xr-x 4 501 staff 4096 Oct 15 00:20 app
drwxr-xr-x 2 501 staff 4096 Oct 15 00:20 bin
-rw-rw-rw- 1 root root 2032 Oct 15 00:20 composer.json
-rw-rw-rw- 1 root root 74614 Oct 15 00:20 composer.lock
-rw-rw-rw- 1 root root 248 Oct 15 00:20 .gitignore
-rw-r--r-- 1 501 staff 978 Oct 3 21:12 phpunit.xml.dist
-rw-rw-rw- 1 root root 68 Oct 15 00:20 README.md
drwxr-xr-x 3 501 staff 4096 Oct 15 00:20 src
drwxr-xr-x 3 501 staff 4096 Oct 15 00:20 tests
drwxr-xr-x 5 501 staff 4096 Oct 15 00:20 var
drwxr-xr-x 15 501 root 4096 Oct 15 00:20 vendor
drwxr-xr-x 3 501 staff 4096 Oct 3 21:14 web
ACL aren't inherited at all.
After a lookup, 501 seems to be the daemon user.
How can I fix this issue?
You need to use recursive Preciel.
Try:
setfacl -R ...
Also the commands you used sets the permission for /var/www, but nothing underneath that!

Touch command. permission denied

I was able to connect to my school server via SSH. I had an assignment in which I was supposed to use the touch command to create a new file. Yet it keeps returning permission denied. Others were able to do the same thing. Though why do I keep getting this error?
Below is what was the input from the terminal.
Last login: Tue Aug 23 09:16:18 on ttys000
Dominiks-Air:~ fsociety95$ ssh djaneka1#navajo.dtcc.edu
djaneka1#navajo.dtcc.edu's password:
Last login: Tue Aug 23 09:16:35 2016 from pool-72-94-210-193.phlapa.fios.verizon.net
Navajo is Linux shell server provided to staff, faculty, and students. The
operating system is RedHat Enterprise Linux 5.
Alpine, a Pine replacement, has been provided as a mail client. Run "pine"
at the command prompt.
This server also provides web space to users. Web pages can be stored in
the ~/www directory. This is also accessible by mapping a drive in Windows
to \navajo\homepage. The URL for your homepage is
http://user.dtcc.edu/~username/.
Your home directory is also accessible in Windows by mapping to
\navajo\.
If something appears broken or missing, please email path#dtcc.edu.
Could not chdir to home directory /u/d/j/djaneka1: No such file or directory
-bash-3.2$ touch today
touch: cannot touch `today': Permission denied
-bash-3.2$ pwd
/
-bash-3.2$ touch today
touch: cannot touch `today': Permission denied
-bash-3.2$
Edit: here is the result of ls -al
-bash-3.2$ ls -al
total 204
drwxr-xr-x 25 root root 4096 Aug 22 16:50 .
drwxr-xr-x 25 root root 4096 Aug 22 16:50 ..
-rw-r--r-- 1 root root 0 Aug 3 14:01 .autofsck
-rw-r--r-- 1 root root 0 Jan 30 2009 .autorelabel
-rw------- 1 root root 2050 Aug 3 14:00 .bash_history
drwxr-xr-x 2 root root 4096 May 4 04:14 bin
drwxr-xr-x 4 root root 3072 Aug 3 13:57 boot
drwxr-xr-x 11 root root 4060 Aug 3 14:02 dev
drwxr-xr-x 87 root root 12288 Aug 23 10:05 etc
drwxr-xr-x 3 root root 4096 Oct 1 2009 home
drwxr-xr-x 13 root root 12288 Jun 1 04:09 lib
drwx------ 2 root root 16384 Mar 24 2008 lost+found
drwxr-xr-x 3 root root 4096 Oct 1 2009 media
drwxr-xr-x 2 root root 0 Aug 3 14:02 misc
drwxr-xr-x 4 root root 4096 May 26 2012 mnt
drwxr-xr-x 2 root root 0 Aug 3 14:02 net
drwxr-xr-x 9 root root 4096 Jan 5 2009 nsr
drwxrwxr-x 3 root root 4096 Oct 12 2015 opt
dr-xr-xr-x 219 root root 0 Aug 3 14:01 proc
drwxr-x--- 12 root root 4096 Apr 22 10:06 root
drwxr-xr-x 2 root root 12288 Aug 4 04:02 sbin
drwxr-xr-x 2 root root 4096 Oct 1 2009 selinux
drwxr-xr-x 2 root root 4096 Oct 1 2009 srv
drwxr-xr-x 11 root root 0 Aug 3 14:01 sys
drwxrwxrwt 38 root root 4096 Aug 23 10:07 tmp
drwxr-xr-x 34 root root 4096 Jun 21 08:29 u
drwxr-xr-x 14 root root 4096 Apr 16 2010 usr
drwxr-xr-x 24 root root 4096 Apr 16 2010 var
-rw------- 1 root root 2865 Dec 16 2008 .viminfo
-bash-3.2$
EDIT:
Here is what I see after trying touch today in /home
So to try and create a new document in the root directory you need to be recognised as root. That means using the sudo command.
However for that you would need a password that you may not have. If you do perfect. But in any case I would not recommend adding files to the root directory.
Instead try the following:
cd home
touch today
This should work just fine and answer your question.
Still if you need/want to create today in your root directory try the following
sudo touch today
You will then be prompted for the root password that you can type (if you have it obviously)
In any case I suggest reading this which may be very helpful for you.
I wonder if this was ever truly answered.
If I was looking at it, I would try to see what the system thinks is the home directory of djaneka1, since it may have been setup partway and not completed, leaving stuff owned by root that should have been owned by djaneka1.
If you use the pwd command, and get back the "/" (root) directory there is something wrong with your setup.
The message: Could not chdir to home directory /u/d/j/djaneka1: No such file or directory
tells you it can't find your home directory.
-bash-3.2$ pwd
/
the command "pwd" revealing "/" is just an artifact of the system not being able to find your home directory.
To find what the system thinks is one's home directory,
one can search the file named '/etc/passwd' for one's login name.
I expect this is a possible result if you do that:
$ fgrep 'djaneka1' /etc/passwd
djaneka1:x:1505:1506::/u/d/j/djaneka1:/bin/bash
since it complained that it couldn't find that directory.
This needs to be fixed by someone who has more rights to the system, like root.
there is nothing djaneka1 can do a

OSX Homebrew /usr/local permisions for node

I have installed homebrew without any problems.
The problem was to install node.. I got permission errors about /usr/local directory and symlinks.
So I did
sudo chown -R myuser /usr/local
then I istalled node without problems and then I did
sudo chown -R root /usr/local
I don't remember how was the owners in first place. I just followed some suggestions from stackoverflow to change the owner of /usr/local (a voice inside me says I did bad).
So when I run
brew doctor
I got some warnings and suggestions to chown some folders in /usr/local directory, so I did them. Then when I run
brew doctor
brew update
I get no warnings or errors anymore and looks fine (there was no updates to do after all).
My directories now looks like below. Can anyone confirm if is secure like that? How should be the owners in /usr/local ? Tt's okay to have it owned by my user as they say at github? Thanks.
myuser#iMac:/usr$ ls -la
total 8
drwxr-xr-x# 12 root wheel 408B Sep 30 23:52 ./
drwxr-xr-x 30 root wheel 1.1K Jan 23 17:51 ../
drwxr-xr-x 5 root wheel 170B Aug 23 03:51 X11/
lrwxr-xr-x 1 root wheel 3B Sep 30 23:43 X11R6# -> X11
drwxr-xr-x 3 root wheel 102B Aug 27 04:17 adic/
drwxr-xr-x 1055 root wheel 35K Jan 23 17:51 bin/
drwxr-xr-x 263 root wheel 8.7K Jan 23 17:52 lib/
drwxr-xr-x 186 root wheel 6.2K Jan 23 17:51 libexec/
drwxrwxr-x 22 root admin 748B Feb 7 12:28 local/
drwxr-xr-x 243 root wheel 8.1K Jan 23 17:51 sbin/
drwxr-xr-x 45 root wheel 1.5K Sep 30 23:43 share/
drwxr-xr-x 4 root wheel 136B Sep 17 09:03 standalone/
myuser#iMac:/usr$ cd local/
myuser#iMac:/usr/local$ ls -la
total 104
drwxrwxr-x 22 root admin 748B Feb 7 12:28 ./
drwxr-xr-x# 12 root wheel 408B Sep 30 23:52 ../
drwxr-xr-x 15 myuser admin 510B Feb 7 12:56 .git/
-rw-r--r-- 1 root admin 847B Feb 6 10:48 .gitignore
-rw-r--r-- 1 root admin 1.3K Feb 6 10:48 .travis.yml
-rw-r--r-- 1 root admin 291B Feb 6 10:48 .yardopts
-rw-r--r-- 1 root admin 3.1K Feb 6 10:48 CODEOFCONDUCT.md
-rw-r--r-- 1 root admin 2.5K Feb 6 10:48 CONTRIBUTING.md
drwxr-xr-x 3 myuser admin 102B Feb 7 12:28 Cellar/
-rw-r--r-- 1 root admin 1.2K Feb 6 10:48 LICENSE.txt
drwxr-xr-x 10 myuser admin 340B Feb 7 12:28 Library/
-rw-r--r-- 1 root admin 2.4K Feb 6 10:48 README.md
-rw-r--r-- 1 root admin 23K Feb 6 10:48 SUPPORTERS.md
drwxrwxr-x 9 root admin 306B Feb 7 12:28 bin/
drwxr-xr-x 3 myuser admin 102B Feb 7 12:28 etc/
drwxr-xr-x 10 root wheel 340B Aug 3 2015 git/
drwxr-xr-x 20 root wheel 680B Dec 3 02:01 go/
drwxr-xr-x 3 myuser admin 102B Feb 7 12:28 include/
drwxr-xr-x 4 myuser admin 136B Feb 7 12:28 lib/
drwxr-xr-x 3 root wheel 102B May 15 2015 n/
drwxr-xr-x 3 myuser admin 102B Feb 7 12:28 opt/
drwxrwxr-x 5 root admin 170B Feb 7 12:28 share/
myuser#iMac:/usr/local$

.svn directory missing in new repository on Subversion 1.8 on centOS 6.x

I've done a fresh install of Subversion 1.8.10 on my CentOS server and created first repository.
svnadmin create --fs-type fsfs /var/www/svn/testrepo
cd /var/www/svn/testrepo
$ mkdir trunk
$ mkdir branches
$ mkdir tags
$ svn add *
svn: E155007: '/var/www/svn/testrepo' is not a working copy
on further digging the error i realized that .svn directory is missing. Following the listing of my testrepo directory.
drwxrwxr-x 9 dwac dwac 4096 Dec 20 05:06 .
drwxr-xr-x 11 dwac dwac 4096 Dec 20 05:05 ..
drwxrwxr-x 2 dwac dwac 4096 Dec 20 05:06 branches
drwxrwxr-x 2 dwac dwac 4096 Dec 20 05:05 conf
drwxrwsr-x 6 dwac dwac 4096 Dec 20 05:05 db
-r--r--r-- 1 dwac dwac 2 Dec 20 05:05 format
drwxrwxr-x 2 dwac dwac 4096 Dec 20 05:05 hooks
drwxrwxr-x 2 dwac dwac 4096 Dec 20 05:05 locks
-rw-rw-r-- 1 dwac dwac 246 Dec 20 05:05 README.txt
drwxrwxr-x 2 dwac dwac 4096 Dec 20 05:06 tags
drwxrwxr-x 2 dwac dwac 4096 Dec 20 05:06 trunk
Is there something that I'm missing ??
I've tried all options I could think of / find but no luck . Any help will be highly appreciated.
After you create your repository you need to checkout first in different directory. This directory will be your working copy.
First create repository
svnadmin create --fs-type fsfs /var/www/svn/testrepo
then your working copy
cd $HOME
mkdir svnWorkingCopy
cd svnWorkingCopy
svn checkout file:///var/www/svn/testrepo .
mkdir trunk
mkdir branches
mkdir tags
svn add *
svn commit

rotation of file in shell script

I need to write rotation of files shell script. I have following format data in a target directory(/backup/store_id/dates_folders)
Like :
cd /backup/
drwxr-xr-x 5 root root 4096 Mar 25 12:30 44
drwxr-xr-x 3 root root 4096 Mar 25 12:30 45
drwxr-xr-x 4 root root 4096 Mar 25 12:30 48
drwxr-xr-x 3 root root 4096 Mar 25 12:30 49
cd /backup/44/
drwxr-xr-x 2 root root 4096 Mar 25 12:30 22032014
drwxr-xr-x 2 root root 4096 Mar 25 12:30 23032014
drwxr-xr-x 2 root root 4096 Mar 25 12:30 24032014
drwxr-xr-x 2 root root 4096 Mar 25 12:30 25032014
now 44 (store_id) contain four dates folders. I want each store_id( like 44 folder) contain only three recent dates folder like 23,24,25 & 22 should be deleted. Please help me how to write in shell script. Please give me some hint
This should work:
cd /backup && ls -d */ | while read storeId; do rm -r `ls -r $storeId | tail -3`; done
I assume here that directory names are more important than their timestamps...
If that is not the case, you should use ls -tr instead of ls -r, to let ls command sort on timestamps...

Resources