-3

I use this command but it didn't work

rm test123

note 1 :

menna@ubuntu:/etc$ l -ltr
total 1116

drwxr-xr-x  7 root  root    4096 Mar 18 06:11 apparmor.d/
drwxr-xr-x  3 root  root    4096 Mar 18 06:11 firefox/
drwxr-xr-x  3 root  root    4096 Mar 18 06:11 ssh/
drwxr-xr-x  2 root  root    4096 Mar 18 08:01 cron.daily/
-rw-rw-r--  1 root  root    1063 Mar 18 08:01 group
-rw-r-----  1 root  shadow   886 Mar 18 08:01 gshadow
drwxr-xr-x  2 root  root    4096 Mar 18 23:56 ImageMagick-6/
drwxr-xr-x  2 root  root    4096 Mar 18 23:56 alternatives/
-rw-r--r--  1 root  root   47812 Mar 18 23:56 mailcap
-rw-r--r--  1 root  root   65910 Mar 18 23:56 ld.so.cache
drwxr-xr-x  5 root  lp      4096 Mar 19 05:14 cups/
-rwxrwxrwx  1 menna menna      0 Mar 19 06:48 test123*

note 2: I give the file "test123" all the permissions

**note 3:**menna@ubuntu:/etc$ ls -ld /etc drwxr-xr-x 131 root root 12288 Mar 19 06:48 /etc

4
  • 2
    This is your second question with downvotes. Please read How to Ask and then edit your question to provide specific detail. You might also take the opportunity at the same time to learn how to structure your question to make it readable. – 24601 Mar 19 at 14:15
  • 1
    You need to be root to create or remove files in /etc. This is not really related to Ubuntu, but basic Posix filesystem knowledge. – Artur Meinild Mar 19 at 14:20
  • Do you have rights to delete files in / etc ? Please update your question with the output of ls -ld /etc . – Soren A Mar 19 at 14:21
  • @ArturMeinild but i changed the owner of the file test123 .. I did it menna – Menna Shaaban Mar 19 at 14:26
4

I suppose the output you are receiving is a "Permission Denied" error as you are trying to delete a file in the etc directory which is owned by root.

When deleting a file, you aren't modifying the file itself, however, you are modifying the contents of the directory. So in order to delete the file, you need to have a user that has "write" permission on the directory not the file.

Since you're in the /etc directory and since you shouldn't modify permission of the /etc directory then you need to use the root user in order to delete the file.

So in order to delete the file, you need to run the rm command with sudo.

sudo rm test123
0

Not the answer you're looking for? Browse other questions tagged or ask your own question.