LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Copying file into root (https://www.linuxquestions.org/questions/linux-newbie-8/copying-file-into-root-847232/)

nitishjtm 11-29-2010 09:25 AM

Copying file into root
 
Hi, how can I copy a file into the root. I am new to linux and using fedora 13. I have to install jdk on the linux.

TB0ne 11-29-2010 09:39 AM

Quote:

Originally Posted by nitishjtm (Post 4174748)
Hi, how can I copy a file into the root. I am new to linux and using fedora 13. I have to install jdk on the linux.

You copy it the same way you copy any other file. But, you have to either be root, or use SUDO, to have the right permissions.

If you're root, remember to be VERY CAREFUL when you're doing anything.

nitishjtm 11-29-2010 09:44 AM

Quote:

Originally Posted by TB0ne (Post 4174761)
You copy it the same way you copy any other file. But, you have to either be root, or use SUDO, to have the right permissions.

If you're root, remember to be VERY CAREFUL when you're doing anything.

Please tell me the commands required for this. As I am new to linux so I am not much familiar with the commands.

e3399 11-29-2010 10:06 AM

Quote:

Originally Posted by nitishjtm (Post 4174770)
Please tell me the commands required for this. As I am new to linux so I am not much familiar with the commands.

$su

then enter your root passwd.

fredora 11-29-2010 11:33 AM

Commands
 
If you're new to Linux I would suggest using the "sudo" command.
Before your command precede it with "sudo <command>". This allows you to be the superuser for that single command.

TB0ne 11-29-2010 01:05 PM

Quote:

Originally Posted by nitishjtm (Post 4174770)
Please tell me the commands required for this. As I am new to linux so I am not much familiar with the commands.

The copy command is "cp". The installation instructions for installing JDK are well-documented, and have the steps you need to take to do it...did you read them?

And if you don't know the "cp" command, are you sure you should be installing files/programs as root??

Rahil Parikh 11-29-2010 08:15 PM

Hey,

To copy the file into /root directory you need to be root or have permission as TB0ne said. Now, if you are root you can copy the file by issuing --

Code:

cp mySrcFile1 [mySrcFile2 mySrcFile3 ...] /root/
Here, the mySrcFile1, mySrcFile2, mySrcFile3 etc.. are files that you want to copy and /root/ is destination where you want to copy. '[' and ']' braces shows that mySrcFile2, mySrcFile3 etc.. are optional.

If you are not root then you may use sudo command.

Code:

sudo <cmd>
Here, you may replace the <cmd> with the command (like cp for copying file) that you want to use.

Quote:

Copying Files
Copying files under Linux is similar to copying files under DOS. Here's an example using the cp (copy) command:
$ cp goulash recipes/hungarian
$ cp stuff stuff.bak
The first example copies the goulash file from the current directory and stores it in your recipes/hungarian directory. The second example creates a file called stuff.bak in the current directory that is identical to the source file stuff.

Note: The cp command will overwrite files with the same name without warning. To be prompted before overwriting, use the -i flag, like so:

$ cp -i goulash recipes/hungarian
cp: overwrite recipes/hungarian/goulash (y/n)?

Renaming Files

Use the mv command to rename a file or move it to another directory, like so:

$ mv stuff junk
$ mv junk trashcan

The first example renames the file stuff as junk, and the second moves the file junk into a directory called trashcan.

Note: The mv command will wipe out files without warning. To be prompted before overwriting, use the -i flag, like so:

$ mv -i stuff junk
mv: overwrite junk (y/n)?

Source :: lowfatlinux.com/linux-copy-files-cp.html

Sherlock_Holmes 09-06-2014 05:31 AM

Copying file into root
 
There is another way of getting a file into root or any other admin password protected dirrectory and that is.
Click on File system go to the dirrectory that you are wanting to copy a file into.
Right click on this and select open as administrater, enter your password when prompted.
Next go to the file that you want to copy into what was a protected dirrectory, right click the file and select copy, now go back to your dirrectory of importation and paste the file in to that dirrectory.
While there right click the file and select properties, you want to ensure that your user name has the right to acces that file so set the permisions to reflect what you want.

Hope that helps.

JeremyBoden 09-06-2014 10:01 AM

It is possible to use a GUI, with care!

Some file managers (e.g. nemo, nautilus(?)) allow you to open a directory as root.
Options such as copy & paste will work.
Since you are running as root, there is no limit to the potential damage you can do.


All times are GMT -5. The time now is 04:58 PM.