Never been to DZone Snippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

About this user

Fred

« Newer Snippets
Older Snippets »
Showing 1-3 of 3 total  RSS 

SCP Secure CP

// description of your code here

Scp is a utility which allows files to be copied between machines. Scp is an updated version of an older utility named Rcp. It works the same, except that information (including the password used to log in) is encrypted. Also, if you have set up your .shosts file to allow you to ssh between machines without using a password as described in help on setting up your .shosts file, you will be able to scp files between machines without entering your password.
Usage of the Scp Command

The general form of the command is:

	% scp source-specification destination-specification
	

where source-specification indicates which file or directory is to be copied, and destination-specification indicates where the copied material is to be placed.

Either the source or the destination may be on the remote machine; i.e., you may copy files or directories into the account on the remote system OR copy them from the account on the remote system into the account you are logged into.

Example:

	% scp myfile xyz@sdcc7:myfile
	

To copy a directory, use the -r (recursive) option. Example:

	% scp -r mydir xyz@sdcc7:mydir
	

File Specification Formats

The format for the remote specification (source or destination) is:

	user@machine:filename
	

where filename is the name (path) of the file or directory relative to the home (login) directory on the remote system.

The format for file specification on the local system is just:

	filename
	

where fname is the name (path) relative to the current working directory on that system.
How scp is similar to cp

Just like the cp command, scp will overwrite an existing destination file. In addition, if the destination is an existing directory, the copied material will be placed beneath the directory.
Examples of remote file copies

   1. While logged into xyz on sdcc7, copy file "letter" into file "application" in remote account abc on sdcc3:

      	% scp letter abc@sdcc3:application
      	

   2. While logged into abc on sdcc3, copy file "foo" from remote account xyz on sdcc7 into filename "bar" in abc:

      	% scp xyz@sdcc7:foo bar

      	

   3. While logged into account xyz on sdcc7, copy file "garfield" from subdirectory "comix" into filename "fatcat" in subdirectory "stuff" in remote account abc on sdcc3:

      	% scp comix/garfield abc@sdcc3:stuff/fatcat
      	

   4. While logged into account abc on sdcc3, copy file "garfield" from subdirectory "comix" of account xyz on sdcc7 into subdirectory "stuff" with the same name "garfield":

      	% scp xyz@sdcc7:comix/garfield stuff
      	

   5. While logged into account abc on sdcc3 , copy subdirectory "Section" into a new subdirectory called "Section" in existing subdirectory "Chapter" in account xyz on sdcc7:

      	% scp -r Section xyz@sdcc7:Chapter
      	

   6. From account abc on sdcc3, copy entire account to ir123 on iacs5. This needs to be done from the parent directory of the account to be moved.

      	% cd
      	% cd ..
      	% scp -r abc ir123@iacs5:abc
      	


Forgot Root Passwd

Insta-redoominhas(and anywww.jsu becadescription of your code heretest1

What can you do if you forget your root password? To reset it to a different password, boot into rescue mode or single-user mode, and use the passwd command to reset the root password.

By booting the system from the Red Hat Enterprise Linux CD-ROM #1.

Once you have booted using one of the described methods, add the keyword rescue as a kernel parameter. For example, for an x86 system, type the following command at the installation boot prompt:

linux rescue

chroot /mnt/sysimage

passwd

Fedora Start-up Scripts

// description of your code here

have a fedora core box which needs to run different scripts on startup to connect to other boxes on the network.

After a bit of fiddling around, I found what appears to be the best solution for me, using ntsysv and init.d. Here's how it's done;

1.) make a new file in the /etc/init.d/ directory
2.) add your script to this file with the following lines at the top;
#!/bin/bash
# chkconfig: 345 85 15
# description: of your file

3.) enter this in the shell;
chkconfig --add startup_filename

4.) type ntsysv - your startup script should now be in the list, checked and ready for action!
« Newer Snippets
Older Snippets »
Showing 1-3 of 3 total  RSS