gudii9
asked on
cp command not working
hi,
i created aaa file under gp foler under root of tutorialpoint
sh-4.4$ /bin/bash
bash-4.4$ [wd
bash: [wd: command not found
bash-4.4$ pwd
/home/cg/root
bash-4.4$ mkdir gp
bash-4.4$ pwd
/home/cg/root
bash-4.4$ cd gp
bash-4.4$ pwd
/home/cg/root/gp
bash-4.4$ vi aaa
bash-4.4$ ls -ltr
total 4
-rw-r--r-- 1 33142 33142 9 Nov 3 01:46 aaa
bash-4.4$ cp aaa /root
cp: cannot stat '/root/aaa': Permission denied
bash-4.4$
https://www.tutorialspoint.com/unix_terminal_online.php
when i give command cp to copy file to root getting permission denied.
i wonder why i get that and what i have to d to practice cp comand therre
i created aaa file under gp foler under root of tutorialpoint
sh-4.4$ /bin/bash
bash-4.4$ [wd
bash: [wd: command not found
bash-4.4$ pwd
/home/cg/root
bash-4.4$ mkdir gp
bash-4.4$ pwd
/home/cg/root
bash-4.4$ cd gp
bash-4.4$ pwd
/home/cg/root/gp
bash-4.4$ vi aaa
bash-4.4$ ls -ltr
total 4
-rw-r--r-- 1 33142 33142 9 Nov 3 01:46 aaa
bash-4.4$ cp aaa /root
cp: cannot stat '/root/aaa': Permission denied
bash-4.4$
https://www.tutorialspoint.com/unix_terminal_online.php
when i give command cp to copy file to root getting permission denied.
i wonder why i get that and what i have to d to practice cp comand therre
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Try to copy somwhere else, e.g. /tmp
ls -ld /tmp/aaa # check if a file aaa already exists in /tmp
cp aaa /tmp
you mean copy to or copy from tmp?
please advise
ASKER
sh-4.4$ cp aaa /tmp
cp: cannot stat 'aaa': No such file or directory
above giving error
cp: cannot stat 'aaa': No such file or directory
above giving error
ASKER
this is just free tool
https://www.tutorialspoint.com/unix_terminal_online.php
iam not looging in to root or anything like that.
just go to above url and practice some commands
https://www.tutorialspoint.com/unix_terminal_online.php
iam not looging in to root or anything like that.
just go to above url and practice some commands
ASKER
ls -ld /tmp/aaa # check if a file aaa already exists in /tmp
ls -ld
what is meaning of above command?
a) go into home directoy: cd
b) check to see where you are now: pwd
c) display what's in this directoy: ls
d) create a file name 'aaa': touch aaa
e) copy this file to /tmp: cp aaa /tmp
f) list contents of /tmp: ls /tmp
g) remove my file from /tmp: rm /tmp/aaa
b) check to see where you are now: pwd
c) display what's in this directoy: ls
d) create a file name 'aaa': touch aaa
e) copy this file to /tmp: cp aaa /tmp
f) list contents of /tmp: ls /tmp
g) remove my file from /tmp: rm /tmp/aaa
ASKER
a) go into home directoy: cd
b) check to see where you are now: pwd
c) display what's in this directoy: ls
d) create a file name 'aaa': touch aaa
e) copy this file to /tmp: cp aaa /tmp
f) list contents of /tmp: ls /tmp
g) remove my file from /tmp: rm /tmp/aaa
above worked as below
bash-4.4$ cd
bash-4.4$ pwd
/home/cg/root
bash-4.4$ ls
README.txt abc.txt gp1 gp2 gp3
bash-4.4$ touch aaa
bash-4.4$ cp aaa /tmp
bash-4.4$ ls /tmp
aaa
bash-4.4$ cd /tmp
bash-4.4$ pwd
/tmp
bash-4.4$ ls -ltr
total 0
-rw-r--r-- 1 44728 44728 0 Nov 5 23:07 aaa
bash-4.4$ vi aaa
bash-4.4$ vi aaa
bash-4.4$ pwd
/tmp
bash-4.4$ rm aaa
bash-4.4$ ls -ltr
total 0
bash-4.4$ cd
bash-4.4$ ls -ltr
total 20
-rw-r--r-- 1 44728 44728 978 Nov 5 22:35 README.txt
drwxr-xr-x 2 44728 44728 4096 Nov 5 22:41 gp2
-rw-r--r-- 1 44728 44728 9 Nov 5 22:41 abc.txt
drwxr-xr-x 3 44728 44728 4096 Nov 5 22:54 gp1
drwxr-xr-x 3 44728 44728 4096 Nov 5 23:02 gp3
-rw-r--r-- 1 44728 44728 0 Nov 5 23:07 aaa
when i do ls -ltr at root why tmp is not showing for me.
please advise
Please clarify root of the filesystem is (/)
This is the base of the UNIX/Linux filesystem, devices, structure.
The main administrative user root, uid 0 /root is the admin user's hone dir.
/tmp is one level from the root of the filesystem.
This is the base of the UNIX/Linux filesystem, devices, structure.
The main administrative user root, uid 0 /root is the admin user's hone dir.
/tmp is one level from the root of the filesystem.
you mean
ls -ltr /
or
ls -ltr /tmp
?
ls -ltr /
or
ls -ltr /tmp
?
ASKER
you mean/home/cg/root
ls -ltr /
or
ls -ltr /tmp
bash-4.4$ ls -ltr/tmp
ls: invalid option -- '/'
Try 'ls --help' for more information.
bash-4.4$ ls -ltr /tmp
total 8
-rw-r--r-- 1 root root 72 Nov 14 19:23 lua_33W6hv
drwxr-xr-x 2 root root 4096 Nov 14 19:23 hsperfdata_root
bash-4.4$ pwd
/home/cg/root
bash-4.4$ ls -ltr /
total 52
drwxr-xr-x 2 root root 4096 Feb 10 2017 srv
lrwxrwxrwx 1 root root 8 Feb 10 2017 sbin -> usr/sbin
drwxr-xr-x 2 root root 4096 Feb 10 2017 mnt
drwxr-xr-x 2 root root 4096 Feb 10 2017 media
lrwxrwxrwx 1 root root 9 Feb 10 2017 lib64 -> usr/lib64
lrwxrwxrwx 1 root root 7 Feb 10 2017 lib -> usr/lib
dr-xr-xr-x 2 root root 4096 Feb 10 2017 boot
lrwxrwxrwx 1 root root 7 Feb 10 2017 bin -> usr/bin
drwx------ 2 root root 4096 Jul 5 21:46 lost+found
drwxr-xr-x 1 root root 4096 Jul 5 21:47 usr
drwxr-xr-x 1 root root 4096 Sep 9 08:45 var
drwxr-xr-x 1 root root 4096 Sep 9 09:16 run
drwxr-xr-x 1 root root 4096 Sep 9 10:25 home
drwxr-xr-x 1 root root 4096 Sep 9 20:40 opt
dr-xr-x--- 1 root root 4096 Sep 9 20:41 root
drwxrwxrwt 1 root root 4096 Nov 14 19:25 tmp
drwxr-xr-x 1 root root 4096 Nov 23 16:34 etc
dr-xr-xr-x 3972 root root 0 Nov 23 16:34 proc
dr-xr-xr-x 13 root root 0 Nov 23 16:34 sys
drwxr-xr-x 5 root root 340 Nov 23 16:34 dev
bash-4.4$ pwd
/home/cg/root
bash-4.4$ ls -ltr
total 4
-rw-r--r-- 1 20997 20997 978 Nov 23 16:34 README.txt
what is meaning of below?
ls -ltr /
how above different from below?
ls -ltr
what is meaning of below command?
ls -ltr /tmp
the unix commands are broken up and space is important
command arguments_for_command files_directories
comman arguments_for_commandfiles _directori es will always error out since the command will generate errors when an argument is being passed to it that it does not expect or can address.
It would be as if someone walks up to you and starts talking to you in a language you do not understand.
command arguments_for_command files_directories
comman arguments_for_commandfiles
It would be as if someone walks up to you and starts talking to you in a language you do not understand.
ASKER
ls -ltr /
what is meaning of above command?
what is meaning of above command?
ls - list
- options
l - long form display
t - sort by time
r - reverse
Commonly tine sorted will gave newest at the top; using the r option changed the ordering to gave newest at the bottom.
Please remember, you can whenever you need look at a command's usage description and how/what ...... Using:
man ls
- options
l - long form display
t - sort by time
r - reverse
Commonly tine sorted will gave newest at the top; using the r option changed the ordering to gave newest at the bottom.
Please remember, you can whenever you need look at a command's usage description and how/what ...... Using:
man ls
ASKER
sh-4.4$ ls -ltr
total 0
sh-4.4$ ls -ltr /
total 52
drwxr-xr-x 2 root root 4096 Feb 10 2017 srv
lrwxrwxrwx 1 root root 8 Feb 10 2017 sbin -> usr/sbin
drwxr-xr-x 2 root root 4096 Feb 10 2017 mnt
drwxr-xr-x 2 root root 4096 Feb 10 2017 media
lrwxrwxrwx 1 root root 9 Feb 10 2017 lib64 -> usr/lib64
lrwxrwxrwx 1 root root 7 Feb 10 2017 lib -> usr/lib
dr-xr-xr-x 2 root root 4096 Feb 10 2017 boot
lrwxrwxrwx 1 root root 7 Feb 10 2017 bin -> usr/bin
drwx------ 2 root root 4096 Jul 5 21:46 lost+found
drwxr-xr-x 1 root root 4096 Jul 5 21:47 usr
drwxr-xr-x 1 root root 4096 Sep 9 08:45 var
drwxr-xr-x 1 root root 4096 Sep 9 09:16 run
drwxr-xr-x 1 root root 4096 Sep 9 10:25 home
drwxr-xr-x 1 root root 4096 Sep 9 20:40 opt
dr-xr-x--- 1 root root 4096 Sep 9 20:41 root
drwxrwxrwt 1 root root 4096 Nov 14 19:25 tmp
drwxr-xr-x 1 root root 4096 Dec 19 16:38 etc
dr-xr-xr-x 1878 root root 0 Dec 19 16:38 proc
dr-xr-xr-x 13 root root 0 Dec 19 16:38 sys
drwxr-xr-x 5 root root 340 Dec 19 16:38 dev
how below two are different?
ls -ltr
and
ls -ltr /
one lists the directory where you are the other lists the contents of the root (/) directory.
ls -lrt shows the contents of current directory (pwd shows which it is) and
ls -ltr / shows the contents of directory / (which is also called the "root" directory)
ls -ltr /tmp therefore displays the contents of directoy /tmp
ls -ltr / shows the contents of directory / (which is also called the "root" directory)
ls -ltr /tmp therefore displays the contents of directoy /tmp
ASKER
let me try
not sure why below link strangely redirecting to some home page instead of unix editor
http://www.tutorialspoint.com/unix_terminal_online.php
please advise
not sure why below link strangely redirecting to some home page instead of unix editor
http://www.tutorialspoint.com/unix_terminal_online.php
please advise
This is not the forum to address issues on how someone chooses to organize their site. in short, the site seems to redirect to a coding related sub-section of the person's site.....
ASKER
bash-4.4$ ls -ltr /tmp
total 8
-rw-r--r-- 1 root root 72 Nov 14 19:23 lua_33W6hv
drwxr-xr-x 2 root root 4096 Nov 14 19:23 hsperfdata_root
above works fine
ASKER
ls -lrt shows the contents of current directory (pwd shows which it is) and
ls -ltr / shows the contents of directory / (which is also called the "root" directory)
ls -ltr /tmp therefore displays the contents of directoy /tmp
where is tmp directory located.? how to find that?
i thought it is under same folder so expected to see tmp when i typed
ls -ltr
but seems that is not the case here?
pls. try to learn a bit before coming back and answering new questions !!
/tmp ====> "tmp" under "/" directory !!
You seem to have no clue whatsoever -- sorry!
/tmp ====> "tmp" under "/" directory !!
You seem to have no clue whatsoever -- sorry!
ASKER
sh-4.4$ pwd
/home/cg/root
sh-4.4$ ls -ltr
total 4
-rw-r--r-- 1 18799 18799 978 Feb 20 21:36 README.txt
sh-4.4$ mv dir1 dir2/
mv: cannot stat 'dir1': No such file or directory
sh-4.4$ touch test
sh-4.4$ ls -ltr
total 4
-rw-r--r-- 1 18799 18799 978 Feb 20 21:36 README.txt
-rw-r--r-- 1 18799 18799 0 Feb 20 21:42 test
sh-4.4$ touch test1
sh-4.4$ mv test test_n
sh-4.4$ ls -ltr
total 4
-rw-r--r-- 1 18799 18799 978 Feb 20 21:36 README.txt
-rw-r--r-- 1 18799 18799 0 Feb 20 21:42 test_n
-rw-r--r-- 1 18799 18799 0 Feb 20 21:43 test1
sh-4.4$ cp test1 test1_n
sh-4.4$ ls -ltr
total 4
-rw-r--r-- 1 18799 18799 978 Feb 20 21:36 README.txt
-rw-r--r-- 1 18799 18799 0 Feb 20 21:42 test_n
-rw-r--r-- 1 18799 18799 0 Feb 20 21:43 test1
-rw-r--r-- 1 18799 18799 0 Feb 20 21:45 test1_n
sh-4.4$ mkdir gp
sh-4.4$ ls -ltr /tmp
total 8
-rw-r--r-- 1 root root 72 Nov 14 19:23 lua_33W6hv
drwxr-xr-x 2 root root 4096 Nov 14 19:23 hsperfdata_root
sh-4.4$ ls -ltr
total 8
-rw-r--r-- 1 18799 18799 978 Feb 20 21:36 README.txt
-rw-r--r-- 1 18799 18799 0 Feb 20 21:42 test_n
-rw-r--r-- 1 18799 18799 0 Feb 20 21:43 test1
-rw-r--r-- 1 18799 18799 0 Feb 20 21:45 test1_n
drwxr-xr-x 2 18799 18799 4096 Feb 20 21:49 gp
sh-4.4$ ls -ltr
total 8
-rw-r--r-- 1 18799 18799 978 Feb 20 21:36 README.txt
-rw-r--r-- 1 18799 18799 0 Feb 20 21:42 test_n
-rw-r--r-- 1 18799 18799 0 Feb 20 21:43 test1
-rw-r--r-- 1 18799 18799 0 Feb 20 21:45 test1_n
drwxr-xr-x 2 18799 18799 4096 Feb 20 21:49 gp
sh-4.4$ ls -ltr /
total 52
drwxr-xr-x 2 root root 4096 Feb 10 2017 srv
lrwxrwxrwx 1 root root 8 Feb 10 2017 sbin -> usr/sbin
/home/cg/root
sh-4.4$ ls -ltr
total 4
-rw-r--r-- 1 18799 18799 978 Feb 20 21:36 README.txt
sh-4.4$ mv dir1 dir2/
mv: cannot stat 'dir1': No such file or directory
sh-4.4$ touch test
sh-4.4$ ls -ltr
total 4
-rw-r--r-- 1 18799 18799 978 Feb 20 21:36 README.txt
-rw-r--r-- 1 18799 18799 0 Feb 20 21:42 test
sh-4.4$ touch test1
sh-4.4$ mv test test_n
sh-4.4$ ls -ltr
total 4
-rw-r--r-- 1 18799 18799 978 Feb 20 21:36 README.txt
-rw-r--r-- 1 18799 18799 0 Feb 20 21:42 test_n
-rw-r--r-- 1 18799 18799 0 Feb 20 21:43 test1
sh-4.4$ cp test1 test1_n
sh-4.4$ ls -ltr
total 4
-rw-r--r-- 1 18799 18799 978 Feb 20 21:36 README.txt
-rw-r--r-- 1 18799 18799 0 Feb 20 21:42 test_n
-rw-r--r-- 1 18799 18799 0 Feb 20 21:43 test1
-rw-r--r-- 1 18799 18799 0 Feb 20 21:45 test1_n
sh-4.4$ mkdir gp
sh-4.4$ ls -ltr /tmp
total 8
-rw-r--r-- 1 root root 72 Nov 14 19:23 lua_33W6hv
drwxr-xr-x 2 root root 4096 Nov 14 19:23 hsperfdata_root
sh-4.4$ ls -ltr
total 8
-rw-r--r-- 1 18799 18799 978 Feb 20 21:36 README.txt
-rw-r--r-- 1 18799 18799 0 Feb 20 21:42 test_n
-rw-r--r-- 1 18799 18799 0 Feb 20 21:43 test1
-rw-r--r-- 1 18799 18799 0 Feb 20 21:45 test1_n
drwxr-xr-x 2 18799 18799 4096 Feb 20 21:49 gp
sh-4.4$ ls -ltr
total 8
-rw-r--r-- 1 18799 18799 978 Feb 20 21:36 README.txt
-rw-r--r-- 1 18799 18799 0 Feb 20 21:42 test_n
-rw-r--r-- 1 18799 18799 0 Feb 20 21:43 test1
-rw-r--r-- 1 18799 18799 0 Feb 20 21:45 test1_n
drwxr-xr-x 2 18799 18799 4096 Feb 20 21:49 gp
sh-4.4$ ls -ltr /
total 52
drwxr-xr-x 2 root root 4096 Feb 10 2017 srv
lrwxrwxrwx 1 root root 8 Feb 10 2017 sbin -> usr/sbin
ASKER
sh-4.4$ pwd
/home/cg/root
sh-4.4$ ls -ltr
total 4
-rw-r--r-- 1 18799 18799 978 Feb 20 21:36 README.txt
sh-4.4$ mv dir1 dir2/
mv: cannot stat 'dir1': No such file or directory
sh-4.4$ touch test
sh-4.4$ ls -ltr
total 4
-rw-r--r-- 1 18799 18799 978 Feb 20 21:36 README.txt
-rw-r--r-- 1 18799 18799 0 Feb 20 21:42 test
sh-4.4$ touch test1
sh-4.4$ mv test test_n
sh-4.4$ ls -ltr
total 4
-rw-r--r-- 1 18799 18799 978 Feb 20 21:36 README.txt
-rw-r--r-- 1 18799 18799 0 Feb 20 21:42 test_n
-rw-r--r-- 1 18799 18799 0 Feb 20 21:43 test1
sh-4.4$ cp test1 test1_n
sh-4.4$ ls -ltr
total 4
-rw-r--r-- 1 18799 18799 978 Feb 20 21:36 README.txt
-rw-r--r-- 1 18799 18799 0 Feb 20 21:42 test_n
-rw-r--r-- 1 18799 18799 0 Feb 20 21:43 test1
-rw-r--r-- 1 18799 18799 0 Feb 20 21:45 test1_n
sh-4.4$ mkdir gp
sh-4.4$ ls -ltr /tmp
total 8
-rw-r--r-- 1 root root 72 Nov 14 19:23 lua_33W6hv
drwxr-xr-x 2 root root 4096 Nov 14 19:23 hsperfdata_root
sh-4.4$ ls -ltr
total 8
-rw-r--r-- 1 18799 18799 978 Feb 20 21:36 README.txt
-rw-r--r-- 1 18799 18799 0 Feb 20 21:42 test_n
-rw-r--r-- 1 18799 18799 0 Feb 20 21:43 test1
-rw-r--r-- 1 18799 18799 0 Feb 20 21:45 test1_n
drwxr-xr-x 2 18799 18799 4096 Feb 20 21:49 gp
sh-4.4$ ls -ltr
total 8
-rw-r--r-- 1 18799 18799 978 Feb 20 21:36 README.txt
-rw-r--r-- 1 18799 18799 0 Feb 20 21:42 test_n
-rw-r--r-- 1 18799 18799 0 Feb 20 21:43 test1
-rw-r--r-- 1 18799 18799 0 Feb 20 21:45 test1_n
drwxr-xr-x 2 18799 18799 4096 Feb 20 21:49 gp
sh-4.4$ ls -ltr /
total 52
drwxr-xr-x 2 root root 4096 Feb 10 2017 srv
lrwxrwxrwx 1 root root 8 Feb 10 2017 sbin -> usr/sbin
/home/cg/root
sh-4.4$ ls -ltr
total 4
-rw-r--r-- 1 18799 18799 978 Feb 20 21:36 README.txt
sh-4.4$ mv dir1 dir2/
mv: cannot stat 'dir1': No such file or directory
sh-4.4$ touch test
sh-4.4$ ls -ltr
total 4
-rw-r--r-- 1 18799 18799 978 Feb 20 21:36 README.txt
-rw-r--r-- 1 18799 18799 0 Feb 20 21:42 test
sh-4.4$ touch test1
sh-4.4$ mv test test_n
sh-4.4$ ls -ltr
total 4
-rw-r--r-- 1 18799 18799 978 Feb 20 21:36 README.txt
-rw-r--r-- 1 18799 18799 0 Feb 20 21:42 test_n
-rw-r--r-- 1 18799 18799 0 Feb 20 21:43 test1
sh-4.4$ cp test1 test1_n
sh-4.4$ ls -ltr
total 4
-rw-r--r-- 1 18799 18799 978 Feb 20 21:36 README.txt
-rw-r--r-- 1 18799 18799 0 Feb 20 21:42 test_n
-rw-r--r-- 1 18799 18799 0 Feb 20 21:43 test1
-rw-r--r-- 1 18799 18799 0 Feb 20 21:45 test1_n
sh-4.4$ mkdir gp
sh-4.4$ ls -ltr /tmp
total 8
-rw-r--r-- 1 root root 72 Nov 14 19:23 lua_33W6hv
drwxr-xr-x 2 root root 4096 Nov 14 19:23 hsperfdata_root
sh-4.4$ ls -ltr
total 8
-rw-r--r-- 1 18799 18799 978 Feb 20 21:36 README.txt
-rw-r--r-- 1 18799 18799 0 Feb 20 21:42 test_n
-rw-r--r-- 1 18799 18799 0 Feb 20 21:43 test1
-rw-r--r-- 1 18799 18799 0 Feb 20 21:45 test1_n
drwxr-xr-x 2 18799 18799 4096 Feb 20 21:49 gp
sh-4.4$ ls -ltr
total 8
-rw-r--r-- 1 18799 18799 978 Feb 20 21:36 README.txt
-rw-r--r-- 1 18799 18799 0 Feb 20 21:42 test_n
-rw-r--r-- 1 18799 18799 0 Feb 20 21:43 test1
-rw-r--r-- 1 18799 18799 0 Feb 20 21:45 test1_n
drwxr-xr-x 2 18799 18799 4096 Feb 20 21:49 gp
sh-4.4$ ls -ltr /
total 52
drwxr-xr-x 2 root root 4096 Feb 10 2017 srv
lrwxrwxrwx 1 root root 8 Feb 10 2017 sbin -> usr/sbin
ASKER
now all clear
ls -ltr just shows all the files and directories in current directory
ls -ltr / shows all files and directories under root
ls -ltr /tmp shows all files and directories under tmp
ls -ltr just shows all the files and directories in current directory
ls -ltr / shows all files and directories under root
ls -ltr /tmp shows all files and directories under tmp
This is NOT correct:
ls -ltr /tmp shows all files and directories under tmp
This would be correct:
ls -ltr tmp shows all files and directories under tmp
ls -ltr /tmp shows all files and directories under /tmp
ls -ltr /tmp shows all files and directories under tmp
This would be correct:
ls -ltr tmp shows all files and directories under tmp
ls -ltr /tmp shows all files and directories under /tmp
ASKER
still same permission denied coming
please advise