Sponsored Content
Full Discussion: scp links! wrong permissions
Top Forums Shell Programming and Scripting scp links! wrong permissions Post 302461068 by halacil on Friday 8th of October 2010 10:58:41 AM
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!
 

8 More Discussions You Might Find Interesting

1. 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

2. 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

3. 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

4. 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

5. 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

6. 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

7. 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

8. 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
CP(1)							    BSD General Commands Manual 						     CP(1)

NAME
cp -- copy files SYNOPSIS
cp [-R [-H | -L | -P]] [-f | -i | -n] [-alpvx] source_file target_file cp [-R [-H | -L | -P]] [-f | -i | -n] [-alpvx] source_file ... target_directory DESCRIPTION
In the first synopsis form, the cp utility copies the contents of the source_file to the target_file. In the second synopsis form, the con- tents of each named source_file is copied to the destination target_directory. The names of the files themselves are not changed. If cp detects an attempt to copy a file to itself, the copy will fail. The following options are available: -H If the -R option is specified, symbolic links on the command line are followed. (Symbolic links encountered in the tree traversal are not followed.) -L If the -R option is specified, all symbolic links are followed. -P If the -R option is specified, no symbolic links are followed. This is the default. -R If source_file designates a directory, cp copies the directory and the entire subtree connected at that point. If the source_file ends in a /, the contents of the directory are copied rather than the directory itself. This option also causes symbolic links to be copied, rather than indirected through, and for cp to create special files rather than copying them as normal files. Created directo- ries have the same mode as the corresponding source directory, unmodified by the process' umask. Note that cp copies hard linked files as separate files. If you need to preserve hard links, consider using tar(1), cpio(1), or pax(1) instead. -a Archive mode. Same as -RpP. -f For each existing destination pathname, remove it and create a new file, without prompting for confirmation regardless of its permis- sions. (The -f option overrides any previous -i or -n options.) -i Cause cp to write a prompt to the standard error output before copying a file that would overwrite an existing file. If the response from the standard input begins with the character 'y' or 'Y', the file copy is attempted. (The -i option overrides any previous -f or -n options.) -l Create hard links to regular files in a hierarchy instead of copying. -n Do not overwrite an existing file. (The -n option overrides any previous -f or -i options.) -p Cause cp to preserve the following attributes of each source file in the copy: modification time, access time, file flags, file mode, ACL, user ID, and group ID, as allowed by permissions. If the user ID and group ID cannot be preserved, no error message is displayed and the exit value is not altered. If the source file has its set-user-ID bit on and the user ID cannot be preserved, the set-user-ID bit is not preserved in the copy's permissions. If the source file has its set-group-ID bit on and the group ID cannot be preserved, the set-group-ID bit is not pre- served in the copy's permissions. If the source file has both its set-user-ID and set-group-ID bits on, and either the user ID or group ID cannot be preserved, neither the set-user-ID nor set-group-ID bits are preserved in the copy's permissions. -v Cause cp to be verbose, showing files as they are copied. -x File system mount points are not traversed. For each destination file that already exists, its contents are overwritten if permissions allow. Its mode, user ID, and group ID are unchanged unless the -p option was specified. In the second synopsis form, target_directory must exist unless there is only one named source_file which is a directory and the -R flag is specified. If the destination file does not exist, the mode of the source file is used as modified by the file mode creation mask (umask, see csh(1)). If the source file has its set-user-ID bit on, that bit is removed unless both the source file and the destination file are owned by the same user. If the source file has its set-group-ID bit on, that bit is removed unless both the source file and the destination file are in the same group and the user is a member of that group. If both the set-user-ID and set-group-ID bits are set, all of the above conditions must be fulfilled or both bits are removed. Appropriate permissions are required for file creation or overwriting. Symbolic links are always followed unless the -R flag is set, in which case symbolic links are not followed, by default. The -H or -L flags (in conjunction with the -R flag) cause symbolic links to be followed as described above. The -H, -L and -P options are ignored unless the -R option is specified. In addition, these options override each other and the command's actions are determined by the last one specified. If cp receives a SIGINFO (see the status argument for stty(1)) signal, the current input and output file and the percentage complete will be written to the standard output. EXIT STATUS
The cp utility exits 0 on success, and >0 if an error occurs. EXAMPLES
Make a copy of file foo named bar: $ cp foo bar Copy a group of files to the /tmp directory: $ cp *.txt /tmp Copy the directory junk and all of its contents (including any subdirectories) to the /tmp directory: $ cp -R junk /tmp COMPATIBILITY
Historic versions of the cp utility had a -r option. This implementation supports that option, however, its behavior is different from his- torical FreeBSD behavior. Use of this option is strongly discouraged as the behavior is implementation-dependent. In FreeBSD, -r is a syn- onym for -RL and works the same unless modified by other flags. Historical implementations of -r differ as they copy special files as normal files while recreating a hierarchy. The -v and -n options are non-standard and their use in scripts is not recommended. SEE ALSO
mv(1), rcp(1), umask(2), fts(3), symlink(7) STANDARDS
The cp command is expected to be IEEE Std 1003.2 (``POSIX.2'') compatible. HISTORY
A cp command appeared in Version 1 AT&T UNIX. BSD
March 15, 2013 BSD
All times are GMT -4. The time now is 09:10 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy