Showing posts with label REL. Show all posts
Showing posts with label REL. Show all posts

Dealing with “No space left on device” when partition is not full

When you get the “No space left on device” error on linux, first thing you do it to check your disk space usage.  Often times you notice you still have space, so what could be wrong?

Although your partition is not nearly full, most likely you have too many small or zero-sized files on your disk. So while you have enough disk space, all your available inodes have been exhausted. 

To check this run:
df -ih
If IUse percentage is at or near 100%, then huge number of small files is the reason for “No space left on device” errors.

To find out where inodes are being used run:
echo "Detailed Inode usage for: $(pwd)" ; for d in `find -maxdepth 1 -type d |cut -d\/ -f2 |grep -xv . |sort`; do c=$(find $d |wc -l) ; printf "$c\t\t- $d\n" ; done ; printf "Total: \t\t$(find $(pwd) | wc -l)\n"
After finding the directory with largest number of files, delete any unwanted files to free up some inodes. 

NOTE : If a process is using the files you are deleting, you will need a reboot to free the inodes used.

How to run a command on a filtered file list returned by grep

I often find myself passing a file list returned by some linux command to grep for filtering like below :
ls *.jar | grep test 

Sometimes i like to run a certain command on these filtered results. I achieve this by :

ls *.jar | grep test | while read line; do sha1sum "$line"; done

The generic form is :
<command generating a file list>   |   grep <filter keyword> | while read line; do <command> "$line"; done  

How to zip files with a pattern in name into a single zip file

To zip files with a certain pattern in their name in a directory, we can combine find and zip command like below :

find <DIRECTORY_PATH> -name \*<PATTERN>\* | zip <ZIP_FILE_NAME>.zip -@ 

How to setup SSH private and public keys

  • 1)
    ssh-keygen -t rsa -b 4096 Generating public/private rsa key pair.
    Enter file in which to save the key (~/.ssh/id_dsa): 
    (just press Enter) 
    Enter passphrase (empty for no passphrase): 
    (enter a passphrase and then press Enter or if you don't want want one just press Enter) 
    Enter same passphrase again: 
    (repeat last action) 
    Your identification has been saved in ~/.ssh/id_rsa
    Your public key has been saved in ~/.ssh/id_rsa.pub
    The key fingerprint is:
    A long string appears here
    %
  • 2)
    Paste the content of the  ~/.ssh/id_dsa.pub file that just got generated on your local host into the file ~/.ssh/authorized_keys on the remote host and save.
  • 3)
    Set proper permissions on your local host keys and .ssh directory:
    chmod 700 ~/.ssh
    chmod 644 ~/.ssh/id_rsa.pub
    chmod 600 ~/.ssh/id_rsa
    set proper permissions on your remote host authorized_keys and .ssh directory
    chmod 700 ~/.ssh
    chmod 644 ~/.ssh/authorized_keys

Fixing "authentication is required to set the network proxy ..." on Redhat/REL/OEL

Whenever i started  a vncsession i would get an popup window stating :
authentication is required to set the network proxy used for downloading packages.  An
application is attempting to perform an action that requires privileges.
Authentication as the super user is required to perform this action" and asking
for the root password.

I didn't have the root password for this machine and hitting cancel would just bring back the pop-up in a few minutes. After googling here is the best way i found to fix this problem:

From a terminal window run "gnome-session-properties" and un-check "PackageKit
Update Applet"

Finally restart your vncserver and the issue should be gone.