Showing posts with label computer tips. Show all posts
Showing posts with label computer tips. Show all posts

Monday, November 06, 2017

How to set a PIN password or a short password in Ubuntu Linux

If you are looking for a way to a PIN password or a short password in Ubuntu Linux, similar to Windows 10, you've come to the right place.
The way described here changes only the desktop login (lightdm service), but can be applied to other services as well if you wish.
Also, this allows you to have your original strong password for "sudo", while maintaining a fairly easy way to login to Ubuntu desktop.
Commands can be issued in the terminal program.

Installing pam_pwdfile.so

First of all, make sure you have installed the libpam-pwdfile package:
sudo apt-get install libpam-pwdfile

Creating the user/password file

You will be prompted to enter a new PIN password.
Your password will be encrypted and saved to a file named "passwd.like"


pinpass=$(mkpasswd -5)
echo "$pinpass" | sudo tee /etc/passwd.like


You will see the encrypted pin password echoed in the terminal. This password will be written to the /etc/passwd.like file.

Alternatively, you may use:
openssl passwd -1 yourpinpasswordhere


Setting up the desktop login service

The next step is to prepare the desktop login service to accept the PIN password before other password procedures. I've mentioned already the name of the desktop login service, lightdm .

Take a look at the file:

cat /etc/pam.d/lightdm

If you don't have this file, then your desktop (login) service is a different one, and you should find your desktop manager before going further. As explained before, this guide is for Ubuntu 16.04 but can be used for other login services as well.

It could be useful if you also create a backup:

sudo cp /etc/pam.d/lightdm /etc/pam.d/lightdm.backup

Now, you may edit the file using nano or gedit or any other  text editor:
sudo gedit /etc/pam.d/lightdm

At the top of the file mine had:



#%PAM-1.0
auth    requisite       pam_nologin.so
auth    sufficient      pam_succeed_if.so user ingroup nopasswdlogin
@include common-auth

I have modified it like so:




#%PAM-1.0
auth requisite pam_nologin.so
auth sufficient pam_succeed_if.so user ingroup nopasswdlogin
auth required pam_pwdfile.so pwdfile=/etc/passwd.like
auth required pam_permit.so
#
@include common-auth

Save the file and close your text editor.

Log out and log back in.

You should be able to use the PIN password you set. By following this guide, the PIN password is only used for the desktop login service, not for the password of sudo commands.

Sources:
This is a modified guide based on a pam pwdfile guide for vsftpd at: http://www.rollnorocks.com/2015/11/authenticating-vsftpd-virtual-users-with-pam_pwdfile-so/


Monday, August 24, 2015

How to issue a time resynchronization in Windows - cmd/batch

 Hello again, I'm back. I found some spare time to add some updated tricks concerning technology, and general tips for Windows or GNU/Linux. :)

I've been having some problems with the time synchronization in Windows 7, which required more often synchronization. So after some googling around, I came up with this little batch commands:
echo Current date/time: %date%_%time%
%windir%\system32\sc.exe start w32time task_started
%windir%\system32\w32tm.exe /resync
echo Fixed date/time: %date%_%time%
pause

Save it as a .bat file and run it as an administrator (right-click on file > Run as administrator).
It's nothing much, pretty dirty scripting I confess, but it does get the job done, at least in my case. I hope it will help someone else too.

See ya!

Thursday, October 11, 2012

Icon 'gtk-close' not present in theme

I recently started to use screenlets again, especially FreeMeteo for weather forecast. But on ubuntu 12.04 every time I login I get a crash message:

FreemeteoWeatherScreenlet.py crashed with GError in load_buttons(): Icon 'gtk-close' not present in theme

If you have a similar crash message, you can simply install the gnome-icon-theme-full package which contains the gtk-close.png file.

Source: https://bugs.launchpad.net/ubuntu/+source/indiv-screenlets/+bug/807129

Monday, April 02, 2012

Hiren's boot cd using unetbootin (missing boot options)



If you try to use unetbootin to copy Hiren's bootcd on a usb flash drive and you boot using the flash disk, you'll notice that some options are missing, especially the "mini windows xp" boot option.

To overcome this problem you have to copy the file "HBCD/isolinux.cfg" to the main folder and replace the file "syslinux.cfg"

Then everything will work as expected.

Bug report: https://bugs.launchpad.net/unetbootin/+bug/971403

Friday, March 02, 2012

Libreoffice recent documents - History manager extension

This solution works for Windows operating systems as well as Linux distributions (It's actually system independent)
If you need to clear or define how many items the recent documents list bears, you can install this easy-to-use extension/addon/plugin: History manager for Libreoffice/Openoffice

- Click "Get it" and download the .oxt file.
- Open Libreoffice writer, menu > Tools > Extension manager > press Add and open the .oxt file you've downloaded.
- Close Libreoffice and re-open it. Go to menu Tools > Add-ons > History manager

Tuesday, February 28, 2012

How to set default apps (aka how to use xdg-mime)

How to set default apps in Chromium / Chrome / Firefox / Ubuntu Linux

Situation: You hate the default app that opens when you double click a file or when you open it with chromium browser and you want to change it.

a) In Unity (and probably Gnome 3 Shell), some default apps can be changed through gnome-control-center: System settings > System info > Default applications



b) You can also right-click on a file > select Properties > Open with. See what applications/programs are listed there. You can also add them and set them as default.


c) If none of the above work, you can use xdg-utils (xdg-mime) to set a default application for a specific Mime Type

First, you have to figure out what text string to use as a "mime type". An easy way to find it is to look into the default application's desktop file.

Example: Chromium opens magnet links and bittorrent files with transmission-gtk by default. The .desktop files are usually in folder /usr/share/applications/. We use "cat" command to look into the file /usr/share/applications/transmission-gtk (a line that starts with "MimeType"):

$ cat /usr/share/applications/transmission-gtk.desktop
[Desktop Entry]
Name=Transmission
[...]
Exec=transmission-gtk %U
Icon=transmission
Terminal=false
TryExec=transmission-gtk
Type=Application
MimeType=application/x-bittorrent;x-scheme-handler/magnet;
Categories=Network;FileTransfer;P2P;GTK;

Bingo! x-scheme-handler/magnet and application/x-bittorrent are the mime types we're after.

How to use xdg-mime command? Simple: xdg-mime default myapp.desktop mymimetype

..where we substitute myapp.desktop and mymimetype with the values from above.

Following the example above, we want magnet links and bittorrent files to open with Deluge (deluge-gtk) application. First you have to install the deluge-gtk package (otherwise the .desktop file won't exist). Then you have to execute:

xdg-mime default deluge.desktop x-scheme-handler/magnet
xdg-mime default deluge.desktop application/x-bittorrent
grep -i deluge ~/.local/share/applications/*

The last command (grep) should return "application/x-bittorrent=deluge.desktop" and the other mime type for magnet. Otherwise, something went wrong (maybe the desktop file didn't exist?).

And that's about it! Close and open chromium-browser again (or logout/login).

For the sake of documentation, the files that have to do with mime types and default apps are:

~/.local/share/applications/defaults.list
~/.local/share/applications/mimeapps.list
~/.local/share/applications/mimeinfo.cache
/usr/share/applications/mimeinfo.cache
/usr/share/applications/mimeapps.list
/usr/share/applications/defaults.list

Error creating XPS file


Error creating XPS file: Source _rels/.rels not found in archive
If you see the above error when trying to use xpstopng, xpstopdf, xpsto* tools provided by libgxps, then you probably suffer from this bug:
https://bugzilla.gnome.org/show_bug.cgi?id=670895

In short, the problem lies with libarchive versions prior to 3.x and zip files created by windows.
Solution?
a) Just update to 3.x or newer and you'll be good to go.
b) As a workaround, you can recreate the zip file:

unzip lorem-ipsum-and-image.xps -d temp/
cd temp/
zip ../newfile.xps *
cd ..


You now have a working copy of your XPS document.

Saturday, February 11, 2012

How to install 1385:5f01 Netgear WPN111 (ar5523 driver)

Bus 002 Device 004: ID 1385:5f01 Netgear, Inc WPN111 (no firmware)
If you have the above device or a usb wifi dongle that requires ar5523 driver, you can try the commands and packages I've documented in order to make it work.

The weird thing with this device is that the firmware adds +1 to its ID. If you look at the code (SVN repository), you'll see that it's registered as "1385:5f00".

How to install the device driver
1. Install this package, depending on the version of ubuntu you may have:

2. Execute the following commands, copy-paste them one by one:
sudo apt-get update
sudo apt-get -f install
sudo apt-get upgrade
sudo apt-get install build-essential linux-headers-generic module-assistant
sudo m-a a-i ar5523-source
wget http://verein.lst.de/~hch/ar5523.tgz
tar xvf ar5523.tgz ar5523/uath-ar5523.bin --strip 1
sudo mv uath-ar5523.bin /lib/firmware

3. Restart your computer and replug your usb dongle. Hopefully it works. :)


Source(s):

Friday, January 27, 2012

Ubuntu Server Guide στα ελληνικά


 Μετά από παρότρυνση ενός μέλους του ubuntu-gr στην ταχυδρομική λίστα (ubuntu-gr mailing list) και με λίγη βοήθεια από τον Σίμο, καταφέραμε να δημιουργήσουμε τον οδηγό "Ubuntu server guide" ως PDF στα ελληνικά.

 Φυσικά, η μετάφραση ήδη υπάρχει ως HTML: http://help.ubuntu-gr.org/10.04/serverguide/el/

 Το πρόβλημα φαίνεται να ήταν με τη δημιουργία PDF αρχείου. Εμφάνιζε "####" χαρακτήρες αντί τους ελληνικούς.

 Το serverguide διασπάστηκε πριν λίγο καιρό από το ubuntu-docs και δημιουργήθηκε καινούργιο project: https://launchpad.net/serverguide
 Aπό εκεί βρήκα τις πιο πρόσφατες μεταφράσεις:

https://translations.launchpad.net/serverguide/

https://translations.launchpad.net/serverguide/oneiric/+pots/serverguide/el/+details

 Τώρα, πώς μεταφράζουμε τον οδηγό και πώς δημιουργούμε το pdf; Εκτελούμε τις εξής εντολές:

sudo apt-get install xsltproc bzr fop gnome-doc-utils docbook-xsl libservlet2.5-java
bzr branch lp:serverguide
cd serverguide
mkdir po

Μετά πάτε στο https://translations.launchpad.net/serverguide/oneiric/+pots/serverguide/el/+export
Ζητάτε το αρχείο ως .po (PO format). Θα σταλεί στο email.

Μετονομάζετε το αρχείο ως el.po
Μεταφέρετε το el.po στο φάκελο po/

Patch-άρετε το bzr tree:

wget http://people.ubuntu.com/~medigeek/serverguide_el/bzrpatch.diff -O bzrpatch.diff
bzr patch bzrpatch.diff

Για να δημιουργήσετε html:
make serverguide LN=el

Για να δημιουργήσετε pdf:

make serverguide-pdf LN=el

 Το pdf στα ελληνικά με Ubuntu fonts: http://people.ubuntu.com/~medigeek/serverguide_el/pdf/serverguide.pdf

  Το πρόβλημα με τα fonts αναφέρθηκε ως σφάλμα:

https://bugs.launchpad.net/serverguide/+bug/922251

Tuesday, September 01, 2009

How to enable man pages search in Google

 I was messing around with Google this morning, when I realised that you can actually "subscribe" yourself to a custom search for linux manpages. You have to be logged in of course. :-)

 I say "subscribed" in quotes, because it's not really a subscription, but rather a pointless (my opinion) feature. The only good thing about it is the icon that you notice directly what you want to search, giving a simple explanation of what the command does - in other words, the title of the manpage.

 The steps are quite easy! You go to http://www.google.com/search?q=man+nmap and press the "Sign in" link on the top right corner. You log in with your Google account, then you are redirected back to the Google search page.

  Afterwards, you go to Settings ⟶ Search settings.

 Next, scroll down to "Subscribed Links" and click on the Subscribe button next to the "Unix Manpages". Click "Save preferences" and you're redirected back to the "man nmap" search. The search result is listed third here, so the result might be different than yours.



 Finally, let me justify why I consider this pointless. If you use Firefox, you can easily integrate a quick search keyword with your favourite operating system's manpages website. Not all of them have this feature/website, but Debian and Ubuntu have it!
 - Head on to http://manpages.debian.net.
 - Select Man -> All sections -> Debian Sid.
 - Right-click in the white text box next to "Man Page or Keyword Search".
 - Select "Add a keyword for this search".
 - Name: Manpages, Keyword: man
 - Click Save.
 - Head to your location bar text box and type in "man nmap".

Voila! Have fun keyword-ing!

Monday, August 24, 2009

Blogger and Firefox - How to save your password

 Some websites don't allow you to save your password in Firefox built-in password manager, for example Yahoo and Blogger. Really irritating!

 One beautiful day (my irony tends to build up under 35 degrees Celsius), I noticed that the Blogger page actually redirects you to a Google account sign in. Therefore, I've come up with this little link that will allow you to save your password and take you back to Blogger:


https://www.google.com/accounts/ServiceLogin?service=blogger&continue=http://www.blogger.com/

Someone might make a good use of it. I also hope someone will find a way or fix the yahoo login page. Enjoy!

P.S. Make sure you install Secure Login add-on - it's a really handy application that allows one-click installs!

Wednesday, August 19, 2009

Workaround: brasero - slow speeds while burning

Brasero is a cd/dvd writing application for the Gnome desktop manager. Its advantages are ease of use, a lot of burning options and support for plugins!

Currently in Ubuntu 9.04, if you try to burn a disc, you might notice that:

  • Everything goes well until about 50%.
  • Afterwards, it continues, but the report does not show anything (empty progress bar).
  • The speed is less than 2x, from 600 KiB/s to 800KiB/s, but the burning keeps going.
  • Somewhere in the end, brasero shows progress again, but starts from 0%!!
  • Burn was successful.
Note: You should consider that this might not always be your issue with slow speeds. For example, maybe your drive is not working well, or maybe your power supply unit (PSU) does not have enough "W" to supply all your hardware with adequate power.

The bug information is extensively reported here:
http://bugzilla.gnome.org/show_bug.cgi?id=582261

One of the developers detected and corrected the problem, which seems that it was using the wrong plugin ("wodim" instead of "growisofs"). Since Ubuntu's binary package brasero has wodim as a dependency, it might cause problems if you try to remove wodim.

There is a workaround though that seems to do the trick:

Don't forget to install the package for growisofs: dvd+rw-tools

1. Tell brasero to use growisof:
  - Press Alt+F2, and execute this command:
gconf-editor 

  - Head to apps ⟶ brasero ⟶ config ⟶ priority.
  - Change the number "0" next to wodim-burn to "-1" in order to disable it.
  - Change the number "0" next to growisofs-burn to "1" in order to set a higher priority.



2. Instead of using "Max" in speed burning options, set it manually at a high speed - e.g. choose 16x for a DVD or 52x for a CD.

That's it!


Credits go to:
https://bugs.launchpad.net/ubuntu/+source/brasero/+bug/370999/comments/15
https://bugs.launchpad.net/ubuntu/+source/brasero/+bug/370999/comments/16

Thursday, April 16, 2009

Unable to connect server irc.ubuntu.com port 6667

Yesterday I received a message like one of the following:
Unable to connect server irc.ubuntu.com port 6667 [Name or service not known]
Could not resolve irc.ubuntu.com/6667: Name or service not known
Connection to 192.168.1.1#53(192.168.1.1) for irc.ubuntu.com failed: connection refused.

If the same has happened to you, I suggest using chat.freenode.net for a better IRC experience. :)

P.S. I know, I know - long time no blog.

Monday, December 29, 2008

How to change default locale (Ubuntu GNOME)

  I have always been a fan of English as my main language while using the computer or computer-related terminology. Recently I've stumbled upon the screenlets package (see picture or install debian package).
The only problem is that using United States' default date is shown as Month/Date/Year (i.e. 29/12/2008), which is rather unattractive (hey - my eyes, my brain, my opinion, my choice!).
  After many unsuccessful tries of various commands, I've come up with a rather graphical-based solution to use the locale I preferred. Obviously, the best choice for me would be en_GB (Great Britain/United Kingdom), since I wanted to stick with English, but use the date format Date/Month/Year.
  1. System > Admnistration > Language Support
Or you can simply run the command: gnome-language-selector
  2. Type in your password if asked to do so. (Make sure you're the adminsitrator, it might involve installing extra packages)
  3. Install your language of preference.
  4. Choose the language of your choice again as the "Default language".
  5. Press "Apply" and click "OK".
  6. Log out (System > Log out).
  7. While viewing the Login screen, click "Options" (lower left corner in Ubuntu), then "Set Language" and select "System Default". It will ask you to restart the login screen (press "Yes").
  8. When the login screen is restarted, you will be using the language of your preference with the appropriate locale! :) You should be able to check this out when you run the following command in Terminal (Applications > Accessories > Terminal):
locale

LANG=en_GB.UTF-8
LC_CTYPE="en_GB.UTF-8"
LC_NUMERIC="en_GB.UTF-8"
LC_TIME="en_GB.UTF-8"
LC_COLLATE="en_GB.UTF-8"
LC_MONETARY="en_GB.UTF-8"
LC_MESSAGES="en_GB.UTF-8"
LC_PAPER="en_GB.UTF-8"
LC_NAME="en_GB.UTF-8"
LC_ADDRESS="en_GB.UTF-8"
LC_TELEPHONE="en_GB.UTF-8"
LC_MEASUREMENT="en_GB.UTF-8"
LC_IDENTIFICATION="en_GB.UTF-8"
LC_ALL=


Now, if you notice any problems:
1. Execute these commands in terminal:
sudo -s

echo 'PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games"' > /etc/environment

2. Reboot your computer.
3. Run the gnome language selector again, choose "English (United States)" (or whatever was the default language). Press Apply and OK. Run it once more and set it again to the language you want it to be ("English (United Kingdom)"), press Apply and OK.
4. Follow the steps 6, 7 and 8 above.
You ought to be able to have the default language and locale you selected!

Monday, November 24, 2008

non-ASCII characters in usernames

Ever wanted a user name that is localised to the language you want, with your original name or surname and not only using Latin characters? Well, today I made a beautiful discovery!

Although a lot of people claim it is not possible yet for GNU/Linux to understand characters other than ASCII, I've found that it can concerning user names - using the useradd command (not adduser).

The actual problem seems to be a standard the unix commands have to follow:
http://www.opengroup.org/onlinepubs/009695399/basedefs/xbd_chap03.html

But it looks like the useradd accepts arbitrary usernames, which is cool! So I've tried my name in Greek:
sudo useradd -m Σάββας

Then adding a password:
sudo passwd Σάββας

And that is all that is required!! Maybe some programs aren't ready yet, but so far I've tried: terminal, console, firefox, rhythmbox, totem player. None of them returned any errors nor did they crash.

Wednesday, October 15, 2008

Google - 403 Forbidden - "We're sorry"

If you got the "We're sorry" webpage I believe you came to the right place.. I have noticed this error myself :(

Error

We're sorry...

... but your query looks similar to automated requests from a computer virus or spyware application. To protect our users, we can't process your request right now.
We'll restore your access as quickly as possible, so try again soon. In the meantime, if you suspect that your computer or network has been infected, you might want to run a virus checker or spyware remover to make sure that your systems are free of viruses and other spurious software.
If you're continually receiving this error, you may be able to resolve the problem by deleting your Google cookie and revisiting Google. For browser-specific instructions, please consult your browser's online support center.
If your entire network is affected, more information is available in the Google Web Search Help Center.
We apologize for the inconvenience, and hope we'll see you again on Google.

At first I thought that they blacklisted Serbian IP addresses (that would be really spicy!). They may suggest some mumbo-jumbo procedure in Google FAQ, but that didn't do the trick.

The solution was rather easy, I went to http://www.google.com/sorry typed in some characters and voila - redirected to Google web search :)

Monday, September 29, 2008

Firefox: "Secure connection Failed"

Visiting websites with secure connection enabled can sometimes lead to problems in Firefox. Websites just link their https certificate to whatever sub-domain they want or they redirect to another website without registering it properly. Mozilla Firefox 3 detects that "glitch" and adds an extra protection layer by stating the following error:
Page load error
Secure connection Failed

*site* uses an invalid security certificate
The certificate is only valid for *another site*
(Error code: ssl_error_bad_cert_domain)

There's an easy way to resolve this, if you click on "Or you can add an exception" → "Add exception" → "Get certificate" → Read the reason it was invalid and if you're OK with the reason → "Confirm security exception".

Tuesday, September 23, 2008

How to install Folding@home in Ubuntu using origami

This is a quick "how to" tutorial in order to provide some of your CPU time for a good cause, which is called Folding@home. As they explain it at the F@h website:
Folding@home is a distributed computing project -- people from throughout the world download and run software to band together to make one of the largest supercomputers in the world. Every computer takes the project closer to our goals. Folding@home uses novel computational methods coupled to distributed computing, to simulate problems millions of times more challenging than previously achieved.

There are other projects out there, like BOINC. In that case, I suggest to install boinc-manager (menu Applications → Add/Remove) and check out Rosetta.

Now let's get down to business. You need to pick a name, which can be anything you like, as long as it's not taken - you can also pick a team, but that's optional. You do not need a password for a username, but you need one in order to create your own team.
Tip #1: A person is called a "Donor" in F@h.

Next is the application. Ubuntu is based on GNU/Linux, and the (good? :P) people of Stanford have created a console client. Despite the fact that we are left without a graphical interface, we can still get the client program and use it.

It's time to visit our good ol' friend, the Terminal (or Konsole for KDE users). Once you start terminal (menu Applications → Accessories → Terminal) we will install the origami package:
sudo apt-get install origami
Tip #2: Type in your password and press enter if you are asked to do so

The following step is to download and install the f@h client program.
The origami manual has several examples:
origami install -u Joe -t 45104
This example will install the Folding @ Home client to the local
machine, reporting data as the Joe user as part of the 45104
(TeamUbuntu) Team.

origami install -u Joe -t 45104 -c1
This example will install the Folding @ home client to the local
machine, reporting data as the Joe user as part of the 45104
(TeamUbuntu) Team, using the i386 Folding @ Home client and
toggling the cron option to auto-stop between the hours of 8:00am
and 5:00pm.

origami install -u Joe -t 45104 -p amd64
This example will install the Folding @ home client to the local
machine, reporting data as the Joe user as part of the 45104
(TeamUbuntu) Team, using the amd64 Folding @ Home client and
toggling the cron option to auto-stop between the hours of 8:00am
and 5:00pm.

Tip: If you are on your own and don't have a team, I urge you to join TeamUbuntu ( 45104 ) or UbuntuForums ( 45399 ).

Tip #3: Don't know whether you have a 32-bit or 64-bit operating system (OS)? If you're not sure, execute this:
uname -m
It shows whether you have 32-bit (x86/i386) or 64-bit (x86_64/amd64) OS. 64-bit users will want to fully use their processors, so they need to use the -p amd64 argument.

In short, the recommended command for 32-bit is:
sudo origami install -u YourName -t 45104 -c1
..and for 64-bit is:
sudo origami install -u YourName -t 45104 -c1

Tip #4: origami installs a crontab if you use -c1 in its own system user 'origami'. If you want to edit the hours it starts/stops (after you install it), execute: sudo crontab -u origami -e

Once your f@h client is installed, you have finished the installation! You can see how your folding process goes:
sudo origami status

Tip #5: Your origami configuration files are found in the /var/lib/origami/ folder. For example, my current CPU #1 configuration file is /var/lib/origami/foldingathome/CPU1/client.cfg

Tip #6: You can give a small boost to your folding process by making it use really low CPU instead of running when it's just idle. Execute:
sudo origami 
Wait for it to stop, then run your text editor to edit the configuration file:
gksu gedit /var/lib/origami/foldingathome/CPU1/client.cfg
Add the following at the bottom of the file:
[core]
priority=96
Save and close your text editor, and restart origami:
sudo origami start

Enjoy folding proteins folks! :) You'll actually be helping out various medical fields, such as Alzheimer's and Huntington's disease researching.

Finally, take a look at these sites:
http://en.wikipedia.org/wiki/List_of_distributed_computing_projects
http://www.gridrepublic.org/
http://game.bakerlab.org/portal/

Monday, September 01, 2008

Keeping your Ubuntu clean

GNU/Linux is said to be one of the most stable operating systems in the market, which is why a lot of people prefer it as their server solution. But as a desktop, Linux and especially Ubuntu with GNOME, can get easily oversized without the proper care and before you know it, you end up with 1% free disk size of your root (or "/") partition; and taking up stress-relieve medicaments just doesn't seem right...

Here's a list of things I tend to do when such crisis strikes:
  1. Clear your Recent documents using the menu Places → Recent Documents → Clear Recent Documents
  2. If you use chat (IRC or Instant messaging), clear your log files.
    The following list contains client applications and their default folder log location:
    I strongly recommend closing your applications before removing any log files!!

    irssi$HOME/irclogs
    xchat$HOME/.xchat2/xchatlogs/
    pidgin$HOME/.purple/logs/

  3. After constantly installing and removing software, some leftover information might be just clogging your disk space for no apparent reason. The apt-based package management has two commands when you remove packages: remove and purge. The difference is that purge actually deletes the configuration files that are deliberately left there when you used remove, in case you want to install it again.
    a) But which packages have their configuration files left over? Run Terminal (head to menu Applications → Accessories → Terminal) and execute the following command:
    dpkg -l | grep -i '^rc' | tr -s ' ' | cut -d ' ' -f 2
    Another way to find these out it to head to System → Administration → Synaptic Package Manager → Click "Status" (lower left corner) → Select "Not Installed (residual config)"
    Now in the package list, right-click on the package that you wish to completely remove (aka purge) and select "Mark for Complete Removal". Then you press "Apply" and let it flow.
    Tip: Press SHIFT+A to select them all.

    b) Leftover package dependencies that were installed with your applications might still be around. You can clear them all out by executing the following in terminal:
    sudo apt-get autoremove --purge

    c) Ubuntu packages are cached in the folder /var/cache/apt/archives/, which can also get clogged up by numerous packages that are either updated or not used anymore. You can solve that by executing in terminal:
    sudo apt-get autoclean
    sudo apt-get update
    If you really want to clear all the packages archived:
    sudo apt-get clean
    sudo apt-get update
    

    d) To remove obsolete packages go to System → Administration → Synaptic Package Manager → Click "Status" → Installed (local or obsolete) → Mark the packages you wished to be completely removed (or preferably removed).
    Warning: These section includes packages that have been manually installed by third-party packages (not from ubuntu repositories), if you need them, don't remove them!
  4. A lot of linux kernel versions in your GRUB boot menu? Time to get rid of them! Use step 3(d), and mark packages that begin with linux- for complete removal
    Warning: These section includes packages that have been manually installed by third-party packages (not from ubuntu repositories), if you need them, don't remove them!

  5. Clear the temporary files created with gedit - to do this, you have to search for them.
    Go to menu Places → Search → Click "Select more options".
    Now select "Show hidden and backup files" and click "Add".
    Also add the "Name matches regular expression". Next to this last one you will type ~$, which will find all filenames that end with "~" character and most of them are temporarily created by gedit (gnome's text editor). Press "Find".
    Now you can select the files you want to delete and right-click → Move to trash.

    Warning: Some files are temporary application files that are deleted when you end the application. It might be best not to mess around a lot with this one.

Update:
6. Clear your temporary flash-related cached files found in .macromedia folder by executing this command in terminal:
rm -rf $HOME/.macromedia/
(thanks Simon!)

Friday, July 04, 2008

How to run simple local php script files without apache

Some said it's not possible. I've busted my head trying to figure out an easy way to test simple php/html scripts, which would run locally using only php, but wouldn't require running an apache server locally.




Well using two packages (which can be stripped to only one) I managed to create a bash script that will take the php script file and transform it to html (which is saved temporarily in the current directory), thus being able to run it easily in firefox. Here we go!

Firstly, install the packages, in Ubuntu:

sudo apt-get install php5-cli debianutils

From these packages we'll use the php command (php5-cli) and the tempfile command (debianutils)



Next we create the bash "phpview" convert script. Fire up the terminal (Applications > Accessories > Terminal):

gedit $HOME/phpview.sh

Inside place the following code:

#!/bin/bash
file=`tempfile -d . -s .html`
echo "Creating file: $file"
php5 $1 > $file
firefox $file
echo "Press any key to delete the temporary html file or ctrl-c to stop this script and keep it"
read
echo "Removing $file"
rm $file



Save and close the gedit text editor and make phpview.sh executable:

chmod +x $HOME/phpview.sh



That's about it, we can create a test php/html file:

gedit $HOME/Desktop/hi.php

Place in the following:

#!/usr/bin/php5 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="en">
<head><title>Moo</title></head>
<body><?php echo "Hello world!"; ?></body>
</html>



Save and close.

Now let's test it!!

cd $HOME/Desktop
~/phpview.sh hi.php



Woo!