1

I want to clear all files in my /tmp that is created by root user.

jenkins@hudson:/tmp$ ls -la | grep root
drwxrwxrwt 14 root    root     876544 Jan  7 11:50 .
drwxr-xr-x 29 root    root       4096 Jan  6 16:20 ..
drwxrwxrwt  2 root    root       4096 Nov 16 11:02 .ICE-unix
drwxrwxrwt  2 root    root       4096 Nov 16 11:02 .X11-unix
-rw-r--r--  1 root    root        856 Jan  6 16:27 deliveryOrderCSVDataGeneratorTest.2047035348.csv
-rw-r--r--  1 root    root          0 Jan  6 16:18 dome1_goods_return_note_item_GRN-00001.csv
-rw-r--r--  1 root    root        424 Jan  6 16:18 dome_credit_note_20160106-1618.csv
-rw-r--r--  1 root    root        319 Jan  6 16:18 dome_credit_note_items_20160106-1618.csv

I just want to remove all files with the extension of .csv and .dbf files since they're failing my php unit testing.

Those files were created in /tmp folder by root because I once accidentally ran the unit testing with sudo before.

So, I am wondering how I can delete all those files and to avoid folders (like '.' and '..') that is created or owned by root?

Note: I have sudo access. I am just still newb in ubuntu terminal commands.

Thanks for your help

2

You shouldn't delete random files owned by root without knowing what they are and the impact of deleting them.

The csv files owned by root can be removed with:-

/bin/rm $(find /tmp/*.csv -user root -print)

The two dot files .ICE-unix and .X11-unix will likely cause problems for graphical applications running under X or VNC if you delete them.

It looks like you're running some kind of Ubuntu server, so the dot files may be hanging around from an old VNC server which has long since been shutdown. If that's the case you can just remove them by name rm /tmp/.X11-unix /tmp/.ICE-unix.

| improve this answer | |
  • Hi popey, rm /tmp/*.csv will delete all csv files for all users. I just want to delete all .csv and .dbf files that is owned or created by root users. – choz Jan 7 '16 at 4:07
  • 1
    gotcha, thought it was a one off, but you want to do it more than once, I've edited to make it clearer. – popey Jan 7 '16 at 4:13
  • Yayy, Thank you so much.. This solution works for me. Sorry for my bad explaination btw. – choz Jan 7 '16 at 4:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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