Tag Archives: linux

Creating Command Aliases for Terminal command line usage

Quick recap of creating aliases on terminal –

alias alias_name_separated_by_underscores=’actual command’

Keep in mind –

  1. No space between alias name, equals and actual command
  2. alias name if consists of multiple strings use underscore to join
  3. actual command to be enclosed in quotes

For a session specific alias, typing this command on terminal prompt would do.

For a persistent alias across sessions, include this alias statement in your bash_profile like so –

vi ~/.bash_profile

Mount | Sharing bet Windows & Linux server

Libraries to be installed are samba-client, samba-common, cifs-utils

yum install samba-client samba-common cifs-utils

Create directory for shared drive

sudo mkdir -p /mnt/sharedDrive

Mount the Windows drive on CentOS server

sudo mount -t cifs //machinename/shareName -o username=<username>,password=<password> /mnt/sharedDrive

View a list of mounted drives

cat /proc/mounts

Un-mount an existing mounted drive

umount /mnt/sharedDrive

To permanently remove the share

rm -rf /mnt/sharedDrive

To mount a DFS share, add following in /etc/request-key.conf file

create cifs.spnego * * /usr/sbin/cifs.upcall -c %k
create dns_resolver * * /usr/sbin/cifs.upcall %k

  • DFS share mount may not work using cifs-utils since its valid for CentOS-6 (or later) only

View the available shares on a non-DFS machine like so-

smbclient -L ‘//machinename’ -U ieams/nraj

Incase of non-DFS share mounting, one can use IP if machine name mounting doesnt work.

Reference:
http://www.cyberciti.biz/faq/mounting-windows-partition-onto-ubuntu-linux/
http://mikemstech.blogspot.in/2012/10/how-to-mount-dfs-share-in-linux.html

http://wiki.centos.org/TipsAndTricks/WindowsShares

http://www.thatsquality.com/articles/mounting-windows-smb-file-shares-using-cifs

Linux Drives / Partitions /Volumes

Linux Drives / Partitions /Volumes

Straight from this SO Issue

  1. A drive is a physical block disk. For example: /dev/sda.
  2. A partition A drive can be divided into some logic block disk. These logic block disk are named partition. For example: /dev/sda1/dev/sda2.
  3. A volume is also a logic block disk. Volume is a concept involved with partition. A volume can contain many partition. You can take a look at LVM project to understand the concept of a volume.http://sourceware.org/lvm2/.

For example: vg0/lvol0

Tmux installation on CentOS

Here is how I installed TMUX, the wonder feature –
  1. Install libevent which is a pre-req for tmux installation

wget https://github.com/downloads/libevent/libevent/libevent-2.0.21-stable.tar.gz

sudo tar xzvf libevent-2.0.21-stable.tar.gz

cd libevent-2.0.21-stable

sudo ./configure && make

sudo make install

2. Now install tmux by downloading from http://tmux.sourceforge.net/

sudo tar xzvf tmux-1.8.tar.gz

cd tmux-1.8

sudo ./configure && make

sudo make install

3. Confirm tmux installation like so –

whereis tmux

4. If you get the following error after installation –

tmux: error while loading shared libraries: libevent-2.0.so.5: cannot open shared object file: No such file or directory

Solution:

sudo vi ~/.bashrc

Append

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:”/usr/local/lib”

source ~/.bashrc

Ref: http://superuser.com/questions/324613/installing-a-library-locally-in-home-directory-but-program-doesnt-recognize-it

Pointer to debug Apache Virtual hosts

Know your apache binary location:

$whereis httpd

httpd: /usr/sbin/httpd.event /usr/sbin/httpd.worker /usr/sbin/httpd

Enlist your virtual host details:

/usr/sbin/httpd -S

This would help you debug your virtual host configuration.

Reference: http://httpd.apache.org/docs/2.2/vhosts/

Apache Command line options: http://httpd.apache.org/docs/2.2/programs/httpd.html

Using special characters in *nix proxy passwords

We quite commonly set http proxy in the firewalled *nix systems like so –

export http_proxy=http://username:password@proxy_name:proxy_port

How do you embed special characters in such passwords?

Option 1: Use backspace as escape character

For instance, use password – asd123)jags&as( as asd123\)jags&as\(

Option 2: If backspace does not work in your situation, percent-encode your password

%}[Rlx can be percent encoded as %25%7D%5BRlx

Reference: http://en.wikipedia.org/wiki/Percent-encoding

Online application for Encoding/decoding – http://www.url-encode-decode.com/

Debugging Cron tasks /Crontab

Debugging Cron tasks /Crontab

1. Check the contents of crontab

 crontab -e

2. Check the permissions of script/directory locations being referred in the crontab.

3. Ensure the appropriate users are configured for crontab

vi /etc/cron.deny

vi /etc/cron.allow

4. Is the crond running?

service crond status

5. Confirm there are no exceptions/messages

sudo tail -f /var/log/cron

sudo tail -f /var/log/messages

6. sudo cat /etc/pam.d/crond

Expected output :

auth       sufficient pam_env.so

auth       required   pam_rootok.so

auth       include    system-auth

account    required   pam_access.so

account    include    system-auth

session    required   pam_loginuid.so

session    include    system-auth

7. Ensure there are no unread status mails for you sent by crond –
cat /var/spool/mail/nraj
Following the above steps, helped me debug the error in my crontab which was that I had an extra * (6 parameters instead of the required 5) while defining the frequency of the cron script…DUH!!!

Reference: https://forums.oracle.com/forums/thread.jspa?threadID=2209522&start=15&tstart=0