Page 2 of 2 FirstFirst 12
Results 11 to 17 of 17

Thread: How to clean up unnecessary junk files using terminal

  1. #11

    Lightbulb Re: How Clean up all those unnecessary junk files Using Terminal

    Quote Originally Posted by Habitual View Post
    clarify "not needed". Specific examples?

    We can't read minds.
    Of course, but unnecessary junk files, and Free cache, delete cookies, clear Internet history, shred temporary files, delete logs, and discard junk, the main thing is to free more disk space, and improve performances.

    hope I did explain better.
    Thanks and regards
    Sharif Aly

  2. #12
    Join Date
    Nov 2007
    Location
    Newry, Northern Ireland
    Beans
    1,258

    Re: How Clean up all those unnecessary junk files Using Terminal

    Quote Originally Posted by sharif_aly View Post
    Of course, but unnecessary junk files, and Free cache, delete cookies, clear Internet history, shred temporary files, delete logs, and discard junk, the main thing is to free more disk space, and improve performances.

    hope I did explain better.
    Well, the internet related stuff like Cookies, internet history etc is not likely to be much of an issue on a CLI only machine, right? Unless you're using a CLI browser, but then you'd be able to control it's behaviour separately anyway.

    All the other things like shredding temp files can be done with a little bit of scripting or even using cron to schedule it at a time when no-one will be using the machine.

    Rotating and deleting logs is normally done by syslog, have a look at it's man pages to see if that will do what you want.
    Can't think of anything profound or witty.
    My Blog: http://gonzothegeek.blogspot.co.uk/

  3. #13
    Join Date
    Dec 2012
    Location
    Canada
    Beans
    187
    Distro
    Ubuntu 12.04 Precise Pangolin

    Re: How Clean up all those unnecessary junk files Using Terminal

    Quote Originally Posted by sharif_aly View Post
    Of course, but unnecessary junk files, and Free cache, delete cookies, clear Internet history, shred temporary files, delete logs, and discard junk, the main thing is to free more disk space, and improve performances.

    hope I did explain better.
    It sounds like you're looking for something along the lines of BleachBit, but...

    1. I've seen a few comments on these forums suggesting that the use of (or perhaps abuse of) BleachBit can cause problems itself, and

    2. While it does have a command-line interface it strikes me as being more suited to cleaning up the "junk" that collects on desktop systems (as opposed to servers).

  4. #14
    Join Date
    Nov 2012
    Location
    Halloween Town
    Beans
    Hidden!
    Distro
    Xubuntu Development Release

    Re: How to clean up unnecessary junk files using terminal

    There is a script for Ubuntu named Ubucleaner that keeps the system pretty clean.

    Code:
    wget http://www.opendesktop.org/CONTENT/content-files/71529-ubucleaner.sh
    sudo chmod +x 71529-ubucleaner.sh
    ./71529-ubucleaner.sh
    Please mark your thread as solved if you get a satisfactory response
    PopularPages - A Ubuntu Documentation Search Tool
    Ubuntu membership via Forums contributions

  5. #15
    Join Date
    Oct 2011
    Location
    ZZ9 Plural Z Alpha
    Beans
    Hidden!
    Distro
    Ubuntu

    Re: How to clean up unnecessary junk files using terminal

    Frankly, a server running a CLI only system simply shouldn't acquire much in the way of "unecessary files". Like spynappels said, no cookies or browser related junk and nothing related to any graphics libraries (GTK, QT). I personally wouldn't be very excited about running a mystery "cleanup script" on my server.

  6. #16
    Join Date
    Feb 2013
    Beans
    Hidden!

    Re: How to clean up unnecessary junk files using terminal

    I've looked into the script and cleaned it up a bit. The result is below:
    Code:
    #!/bin/sh
    set -e
    
    cur=$(uname -r)
    prev=$(readlink -f /vmlinuz.old) && prev=${prev#*-} || prev=@
    keepkernels="^linux-(headers|image|image-extra)-($cur|$prev)"
    allkernels='^linux-(headers|image|image-extra)-[0-9]'
    
    [ root != "$USER" ] && { echo Error: must be root, aborting... >&2; exit 1; }
    echo Cleaning apt cache...
    apt-get clean
    
    echo Removing no longer needed automatically installed packages...
    apt-get autoremove
    
    echo Removing old config files...
    dpkg --get-selections | sed -n 's/\<deinstall$/purge/p' | dpkg --set-selections
    dpkg -Pa
    
    echo Removing old kernels...
    apt-get --only-upgrade purge "$allkernels" "$keepkernels"+
    
    echo Emptying every trashes...
    rm -rf /home/*/.local/share/Trash/*/* >/dev/null 2>&1
    rm -rf /root/.local/share/Trash/*/*   >/dev/null 2>&1
    
    echo Script Finished!
    Last edited by schragge; May 1st, 2013 at 02:35 PM.

  7. #17
    Join Date
    Sep 2008
    Location
    Bangalore
    Beans
    24
    Distro
    Ubuntu 10.10 Maverick Meerkat

    Re: How to clean up unnecessary junk files using terminal

    Quote Originally Posted by schragge View Post
    I've looked into the script and cleaned it up a bit. The result is below:
    Code:
    #!/bin/sh
    set -e
    
    cur=$(uname -r)
    prev=$(readlink -f /vmlinuz.old) && prev=${prev#*-} || prev=@
    keepkernels="^linux-(headers|image|image-extra)-($cur|$prev)"
    allkernels='^linux-(headers|image|image-extra)-[0-9]'
    
    [ root != "$USER" ] && { echo Error: must be root, aborting... >&2; exit 1; }
    echo Cleaning apt cache...
    apt-get clean
    
    echo Removing no longer needed automatically installed packages...
    apt-get autoremove
    
    echo Removing old config files...
    dpkg --get-selections | sed -n 's/\<deinstall$/purge/p' | dpkg --set-selections
    dpkg -Pa
    
    echo Removing old kernels...
    apt-get --only-upgrade purge "$allkernels" "$keepkernels"+
    
    echo Emptying every trashes...
    rm -rf /home/*/.local/share/Trash/*/* >/dev/null 2>&1
    rm -rf /root/.local/share/Trash/*/*   >/dev/null 2>&1
    
    echo Script Finished!

    Thanks it worked like a charm. from 70.5% to 40% of usage

    Thank you.
    God bless

Page 2 of 2 FirstFirst 12

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •