LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 02-12-2008, 01:35 PM   #1
Steve W
Member
 
Registered: Mar 2007
Distribution: Ubuntu 12.04, XUbuntu 12.04
Posts: 504

Rep: Reputation: 44
Problems deleting files


I tried compiling a program from source but it didn't work; I wasn't that bothered, so I tried to delete the directory in /home that contained all the files relating to this program. However, Ubuntu will not permit me to delete any folders inside this directory, or the unwanted directory itself (but I can delete the files inside them) and tells me:

"main.Po" cannot be deleted because you do not have permissions to modify its parent folder.

Hmm. Can I just delete this program's main folder from my /home directory as root, or will this cause untold problems? I mean, I had to "make install" as root, so is the system expecting me to delete the unwanted folders as root too?

Steve Wylie
Unsuccessful compiler!
 
Old 02-12-2008, 02:04 PM   #2
waelaltaqi
Member
 
Registered: Sep 2005
Location: USA, TN
Distribution: CentOS & Ubuntu for Desktop
Posts: 454

Rep: Reputation: 31
it seems that you complied the source as root or unpacked the tar file as root. When you do that the files are not owned by the your regular user anymore but they'll be owned by root. If the root account owns the file then you're user account doesn't have permissions to delete.

You need to open a shell do something like:
Code:
su root                            #Use the shell as root
password:                          #Type root password
cd /$FolderIWantToDeleteStuffFrom  #Browse into my folder
ls -al                             #Make sure that what i want to delete
rm -rf *                           #Delete everything
su $MyUserName                     #Stay secure and go back to my user
that will delete all the files in that folder. The text after the # are comments for the commands in the same line. You could also use sudo to achieve the same result but i thought su explains what's going on better.
I wish you've posted your complie trail. Post errors from your compilation process.

Last edited by waelaltaqi; 02-12-2008 at 02:23 PM.
 
Old 02-13-2008, 06:35 PM   #3
Steve W
Member
 
Registered: Mar 2007
Distribution: Ubuntu 12.04, XUbuntu 12.04
Posts: 504

Original Poster
Rep: Reputation: 44
Ah, that explains that. I thought you had to do "sudo make install" to get it to work. Or is it only the install that needs to be carried out at root?

Also, off topic question: Can I stop Ubuntu (using Gnome) from creating little backup files of every document I change, as a hidden file?
 
Old 02-13-2008, 06:58 PM   #4
cybersekkin
LQ Newbie
 
Registered: Jan 2005
Location: Japan
Distribution: suse, debian, libranet, slack
Posts: 12

Rep: Reputation: 0
please do not get used to su -

2 notes on the preceding.

use sudo to run commands with elevated permissions and only use su - in rare cases (basically the less the better) I have a terrible habbit developed for years of su'ing to root and its being a pain to break.

the second and more serious never and I mean NEVER "rm -rf *" first change into the install dir you want to remove. "cd /usr/local/" where the "app_to_delete" dir exist. From there run "sudo rm -rf ./app_to_delete/" It looks very similar I know but never run rm -rf without the starting ./ and best done using tab completion to ensure you don't have any stray or misunderstood input. one badly placed / with a rm -rf and you will have a VERY bad day.
 
Old 02-13-2008, 07:22 PM   #5
Steve W
Member
 
Registered: Mar 2007
Distribution: Ubuntu 12.04, XUbuntu 12.04
Posts: 504

Original Poster
Rep: Reputation: 44
Not something I've ever needed to worry about as this su lark doesn't seem to work on Ubuntu. Sudo does though. If I try the suggestion 'waelaltaqi' gives above, I get:

steve@steve-desktop:~$ su root
Password: [I type it in...]
su: Authentication failure
Sorry.
steve@steve-desktop:~$

I get your point about the power "rm -rf" has, and can't believe Linux doesn't have a similar arrangement to Windows/DOS, like rd that removes directories (after a warning).

Come to think of it... what's rmdir in Linux for then?
 
Old 02-13-2008, 07:28 PM   #6
cybersekkin
LQ Newbie
 
Registered: Jan 2005
Location: Japan
Distribution: suse, debian, libranet, slack
Posts: 12

Rep: Reputation: 0
always one to help someone shoot themselves in the foot:
to su to root on Ubuntu (please don't use too often) the command you need is
sudo su -
 
Old 02-13-2008, 07:33 PM   #7
Steve W
Member
 
Registered: Mar 2007
Distribution: Ubuntu 12.04, XUbuntu 12.04
Posts: 504

Original Poster
Rep: Reputation: 44
Ah, thanks for that. What's the "minus" for after the command? "sudo su" seems to do exactly the same thing...
 
Old 02-13-2008, 07:42 PM   #8
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.9, Centos 7.3
Posts: 17,417

Rep: Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397
su newuser
switch to newuser, BUT, maintain callers env eg $PATH etc
su - newuser
switch to newuser, inc newuser's env ie exactly as if you logged in as newuser.
Note that you do not
su - olduser
to get back.
Each 'su' opens a new shell from the prev one ie to get back to olduser, use 'exit' instead.

Ps rmdir only removes empty dirs
 
Old 02-14-2008, 09:56 AM   #9
waelaltaqi
Member
 
Registered: Sep 2005
Location: USA, TN
Distribution: CentOS & Ubuntu for Desktop
Posts: 454

Rep: Reputation: 31
Two very big differences:

1- SU swithces completely to another user. Not recommended if you're going to do a simple administrative task. Use if you're only doing long administrative task that requires multiple commands that need root privileges.
Be carefully downloading files from the internt when you're under that user.

2- sudo let's you execute a certain command AS root.
say you're logged in as myuser and you want to delete a file from the /root folder then using sudo let's excute that single command once AS root.
 
Old 02-14-2008, 01:09 PM   #10
Steve W
Member
 
Registered: Mar 2007
Distribution: Ubuntu 12.04, XUbuntu 12.04
Posts: 504

Original Poster
Rep: Reputation: 44
OK, thanks everyone for the info and advice. At this early stage in my Linux knowledge, I think I will stick with "sudo" for those occasions when I need to execute the odd command as root. I presume once I close the shell all root privileges are terminated, and if I open another shell I start back as an ordinary user again?

Steve
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
About deleting a files combilli Linux - Newbie 1 01-09-2007 11:54 PM
Deleting files in C monil Programming 4 03-13-2005 11:33 AM
Deleting files! a_priebe47 Slackware 6 10-17-2004 10:58 PM
Deleting files ShakyJake Linux - Newbie 12 05-08-2003 04:07 PM
Deleting files Tingle Linux - Newbie 4 01-16-2003 05:19 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 08:38 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration