Skip to content

Category «Linux»

Script to chmod file and folder with different access

#!/bin/sh # recursive chmod with arguments for files and directories # save internal field separator IFS_save=$IFS # set internal field separator, thx to matthias IFS=$’ ‘ # read arguments chmodf=$1 # chmod for files chmodd=$2 # chmod for directories dir=$3    # start directory # test for arguments $1 and $2 if [ -z “$chmodf” -o …

Dumping and importing from/to MySQL in an UTF-8 safe way

In a nutshell: to avoid your shell character set from messing with imports, use -r to export and SOURCE when importing. Dumping safely Do not do this, since it might screw up encoding: mysqldump -uroot -p database > utf8.dump # this is bad Better do: mysqldump -uroot -p database -r utf8.dump Note that when your …

Release memory in Linux (Unused or Cached)

In computer science, Memory Leakage occurs when a computer software or  program consumes required memory but unable to memory after completing its task  or when no longer needed to Operating System. There are two types of Memory Leakage. One is  Virtual Memory Leakage and another is Real Memory Leakage. Now first Identify cached memory or …

OOM killer exception

With the following command you can create and exception on OOM killer so that it will not kill specified PID process # OOM_DISABLE on $PID echo -17 > /proc/$PID/oom_adj To automate the exception creation you can use the following command to retrive the pid of specific process pgrep -f “/usr/sbin/sshd” | while read PID; do …

Bash test operator

File type tests These options test for particular types of files. All cases will only return True (0) if the file exists. `-b file’ True if file is a Block special device. `-c file’ True if file is a Character special device. `-d file’ True if file is a Directory. `-e file’ True if file …

Disabling SELINUX on CentOS6

If you really need to disable SELinux on CentOS 6 type: # vi /etc/selinux/config and change SELINUX=enforcing # This file controls the state of SELinux on the system. # SELINUX= can take one of these three values: # enforcing – SELinux security policy is enforced. # permissive – SELinux prints warnings instead of enforcing. # …

CentOs6/RHEL6 ssh without PAM problem

If you want to disable PAM authentication on ssh, you can get error that are unable to find shadow for the user. You need to disable/remove selinux because it’s blocking sshd to access /etc/shadow

Show progress during dd

If you need to show progress during dd copy, you can firstly find PID with ps -A|grep dd then you can send signal USR1 to this process with the following command kill -USR1 “DDPID” If you like to run automaticaly every x second you can use the command watch as watch -n 5 kill -USR1 …

driver ath9k is slow or not responding – BUG #735171

As reported on bugs.launchpad.net, Ubuntu 11.04 soffer of kernel bug on ath9k module. The bug consist in a very slow or not responding wireless connection (https://bugs.launchpad.net/ubuntu/natty/+source/linux/+bug/735171) The kernel was rebuild to correct the problem and now is in proposed repository. To enable this repo, you can follow the link https://wiki.ubuntu.com/Testing/EnableProposed