scp links! wrong permissions


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting scp links! wrong permissions
# 1  
Old 10-08-2010
scp links! wrong permissions

I had to copy /bin from one server to another because i accidently removed /bin ... now all copied and working but some of the soft links seems to have been created as file and their permissions set to 777 by default.. how can i recopy those ones? or change their permission to be same as the source server?

see below
source server:
Code:
lrwxrwxrwx 1 root root 4 Sep 27 11:47 sh -> bash
lrwxrwxrwx 1 root root 4 Sep 27 11:47 awk -> gawk
lrwxrwxrwx 1 root root 2 Sep 27 11:47 red -> ed
lrwxrwxrwx 1 root root 4 Sep 27 11:48 fgrep -> grep
lrwxrwxrwx 1 root root 4 Sep 27 11:48 egrep -> grep
lrwxrwxrwx 1 root root 10 Sep 27 11:48 tracert -> traceroute
lrwxrwxrwx 1 root root 10 Sep 27 11:48 traceroute6 -> traceroute
lrwxrwxrwx 1 root root 10 Sep 27 11:48 tcptraceroute -> traceroute
lrwxrwxrwx 1 root root 3 Sep 27 11:48 gtar -> tar
lrwxrwxrwx 1 root root 8 Sep 27 11:48 ypdomainname -> hostname
lrwxrwxrwx 1 root root 8 Sep 27 11:48 nisdomainname -> hostname
lrwxrwxrwx 1 root root 8 Sep 27 11:48 domainname -> hostname
lrwxrwxrwx 1 root root 8 Sep 27 11:48 dnsdomainname -> hostname
lrwxrwxrwx 1 root root 2 Sep 27 11:48 view -> vi
lrwxrwxrwx 1 root root 2 Sep 27 11:48 rview -> vi
lrwxrwxrwx 1 root root 2 Sep 27 11:48 rvi -> vi
lrwxrwxrwx 1 root root 2 Sep 27 11:48 ex -> vi
lrwxrwxrwx 1 root root 4 Sep 27 11:49 csh -> tcsh
lrwxrwxrwx 1 root root 21 Sep 27 11:50 ksh -> /etc/alternatives/ksh
lrwxrwxrwx 1 root root 4 Sep 27 11:51 mailx -> mail
[oracle@node01 bin]$ ls -ltr | grep vi
-rwxr-xr-x 1 root root 632912 Jun 12 2009 vi
lrwxrwxrwx 1 root root 2 Sep 27 11:48 view -> vi
lrwxrwxrwx 1 root root 2 Sep 27 11:48 rview -> vi
lrwxrwxrwx 1 root root 2 Sep 27 11:48 rvi -> vi
lrwxrwxrwx 1 root root 2 Sep 27 11:48 ex -> vi

target server:
Code:
[oracle@node02 bin]$ ls -ltr | grep vi
-rwxrwxrwx 1 root root 632912 Oct 5 11:52 rview
-rwxrwxrwx 1 root root 632912 Oct 5 11:52 view
-rwxr-xr-x 1 root root 632912 Oct 5 11:52 vi
-rwxrwxrwx 1 root root 632912 Oct 5 11:52 rvi
[oracle@node02 bin]$ ls -ltr | grep mail
-rwxr-xr-x 1 root root 84856 Oct 5 11:52 mail
-rwxrwxrwx 1 root root 84856 Oct 5 11:52 mailx
[oracle@node02 bin]$


Moderator's Comments:
Mod Comment Use code tags!
# 2  
Old 10-08-2010
Code:
 
scp -p source destination
-p  
Preserves modification times, access times, and modes from the original file.

# 3  
Old 10-08-2010
tried but it didnt work ...

Code:
[root@nodedb02 bin]# scp -p nodedb01:/bin/mailx /bin/
root@nodedb01's password:
mailx                                                                            100%   83KB  82.9KB/s   00:00
[root@nodedb02 bin]# ls -ltr | grep mail
-rwxr-xr-x 1 root root   84856 Jul 13  2006 mailx.orig
-rwxr-xr-x 1 root root   84856 Jul 13  2006 mailx
-rwxr-xr-x 1 root root   84856 Oct  5 11:52 mail
[root@nodedb02 bin]#


on the source the owner is mail but here it created it as root!! still the l in the beggining of the line is missing ( lrwxrwxrwx )
and didnt create it as a link

Code:
[oracle@source bin]$ ls -ltr | grep mail
-rwxr-xr-x 1 root mail   84856 Jul 13  2006 mail
lrwxrwxrwx 1 root root       4 Sep 27 11:51 mailx -> mail

Moderator's Comments:
Mod Comment Use code tags!
# 4  
Old 10-08-2010
Hi,

As of my knowledge, when your copying the directories, the "login user" will be the owner of the copied files and not the one in Source server.

Instead of copying the file as symbolic links, the whole file will be copied and you need to create the sysmbolic links explicilty after the copy.
# 5  
Old 10-12-2010
Now my server is not booting.

I get screen saying (none)login: ... if I enter root and press enter it comes back with the same prompt again and again!!
it also mentioned of init=/bin/sh and init cant execute /etc/x11/prefdm
init id x respawning too fast…
tried rebooting from the console by doing ctrl + alt +del but comes back with /cant open /var/run/shutdown.pid

I tried the following but no joy!
Inserted the linux installation cd.. ( rescue mode)...
Checked the permission on /bin and it was set to ?r- -rw-rx tried to do chmod –R 775 but got error operation not permitted ...
Already had backup of /bin so Untar’d the /bin/bin.tar and tried to over write the /bin but got this error: can not overwite /bin bin not a directory...
For some strange reason /bin is not own by root the owner and group name are both numeric, So i tried chown –R root but keep getting user root does not exist!
If I do id.. i can see that i have logged on as root and it does exist in /etc/passwd

Last edited by halacil; 10-12-2010 at 07:33 AM..
Login or Register to Ask a Question

Previous Thread | Next Thread

8 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Why result is wrong here ? whether break statement is wrong ?

Hi ! all I am just trying to check range in my datafile pls tell me why its resulting wrong admin@IEEE:~/Desktop$ cat test.txt 0 28.4 5 28.4 10 28.4 15 28.5 20 28.5 25 28.6 30 28.6 35 28.7 40 28.7 45 28.7 50 28.8 55 28.8 60 28.8 65 28.1... (2 Replies)
Discussion started by: Akshay Hegde
2 Replies

2. AIX

List all the soft links and hard links

Hi I'm logged in as root in an aix box Which command will list all the soft links and hard links present in the server ? (2 Replies)
Discussion started by: newtoaixos
2 Replies

3. Solaris

Hard Links and Soft or Sym links

When loooking at files in a directory using ls, how can I tell if I have a hard link or soft link? (11 Replies)
Discussion started by: Harleyrci
11 Replies

4. Shell Programming and Scripting

ksh; Change file permissions, update file, change permissions back?

Hi, I am creating a ksh script to search for a string of text inside files within a directory tree. Some of these file are going to be read/execute only. I know to use chmod to change the permissions of the file, but I want to preserve the original permissions after writing to the file. How can I... (3 Replies)
Discussion started by: right_coaster
3 Replies

5. Debian

scp not preserving properties and links

I'm trying to get a number of old disks on HP-UX 10.2 copied over to a new Debian machine which has a NAS on it. The HP does not have rsync, but does have scp. Scp unfortunately does not always preserve permissions, and does not save links which were on the disk. Apparently rsync has a flag... (3 Replies)
Discussion started by: PasadenaDave
3 Replies

6. HP-UX

To give the "unzip" permissions & "create" file permissions

Hi, I am a Unix Admin. I have to give the permissions to a user for creating new file in a directory in HP-Ux 11.11 system since he cannot able to create a new file in the directory. Thanks in advance. Mike (3 Replies)
Discussion started by: Mike1234
3 Replies

7. UNIX for Advanced & Expert Users

About links

why directory has two links as default. what's the purpose? (1 Reply)
Discussion started by: nagalenoj
1 Replies

8. Solaris

SCP from one solaris box to another without copying links

I am doing a scp (directory)from one solaris box to another.The problem is that all links present in that directory also get copied .I do not want the links to get copied .currently I am using following syntax scp -rvp pcserver info@appudemo.sea.us.wam.net:/home/info I checked the man... (1 Reply)
Discussion started by: u449064
1 Replies
Login or Register to Ask a Question