Archive for the ‘Linux’ Category

Linux testing disk speed with dd

April 21, 2017 Leave a comment

Best way is to use dd and try the following:

dd bs=1M count=256 if=/dev/zero of=test conv=fdatasync

“fdatasync” tells dd to write physically to disk before providing the output. Increase to 1024, 2048 if you want 1G or 2G file size. Bigger sizing will produce a more normalized speed.

Categories: Linux, Redhat

RHEL increasing size of LVOL after LUN expansion

March 6, 2017 Leave a comment

Quick steps (validated on RHEL 5.x) on expanding your lvol when the underlining LUN has been expanded.

Ensure first you have rescanned the scsi devices to pick up on the physical changes to the LUNs. Next, from multipath you should be able to see that the LUN indeed have been expanded. In this case, the new size is 3.5T, original size was 3.0T.

# multipath -ll

vgnetapp1 (3600a09803830344a503f464a4d302f41) dm-3 NETAPP,LUN C-Mode
size=3.5T features=’1 queue_if_no_path’ hwhandler=’0′ wp=rw

Next, the pv has to be resized:
# pvresize /dev/mapper/vgnetapp1

Now, resize the lvol:
# lvresize /dev/mapper/vgnetapp1-lvol1 -l +100%FREE

Finally, resize the underlying filesystem on the lvol:
# resize2fs /dev/mapper/vgnetapp1-lvol1

Expect this to take several minutes depending on the size of your LUN. Run “df -h” to see this operation has indeed increased the lvol and filesystem size. Note, you can run these commands while the LUN is mounted. No need to “umount” at all.

Categories: Linux, Redhat

Linux: place line numbering on output of file (nl)

February 21, 2017 Leave a comment

Simple command (nl)to add line numbers to a file on the output:

$ nl /etc/passwd
1 root:x:0:0:root:/root:/bin/bash
2 daemon:x:1:1:daemon:/usr/sbin:/usr/sbin/nologin
3 bin:x:2:2:bin:/bin:/usr/sbin/nologin
4 sys:x:3:3:sys:/dev:/usr/sbin/nologin
5 sync:x:4:65534:sync:/bin:/bin/sync
6 games:x:5:60:games:/usr/games:/usr/sbin/nologin
7 man:x:6:12:man:/var/cache/man:/usr/sbin/nologin
8 lp:x:7:7:lp:/var/spool/lpd:/usr/sbin/nologin
9 mail:x:8:8:mail:/var/mail:/usr/sbin/nologin
10 news:x:9:9:news:/var/spool/news:/usr/sbin/nologin
11 uucp:x:10:10:uucp:/var/spool/uucp:/usr/sbin/nologin
12 proxy:x:13:13:proxy:/bin:/usr/sbin/nologin
13 www-data:x:33:33:www-data:/var/www:/usr/sbin/nologin
14 backup:x:34:34:backup:/var/backups:/usr/sbin/nologin
15 list:x:38:38:Mailing List Manager:/var/list:/usr/sbin/nologin
16 irc:x:39:39:ircd:/var/run/ircd:/usr/sbin/nologin
17 gnats:x:41:41:Gnats Bug-Reporting System (admin):/var/lib/gnats:/usr/sbin/nologin
18 nobody:x:65534:65534:nobody:/nonexistent:/usr/sbin/nologin
19 libuuid:x:100:101::/var/lib/libuuid:
20 syslog:x:101:104::/home/syslog:/bin/false
21 messagebus:x:102:106::/var/run/dbus:/bin/false
22 landscape:x:103:109::/var/lib/landscape:/bin/false
23 sshd:x:104:65534::/var/run/sshd:/usr/sbin/nologin
24 pollinate:x:105:1::/var/cache/pollinate:/bin/false
25 vagrant:x:1000:1000::/home/vagrant:/bin/bash
26 colord:x:106:112:colord colour management daemon,,,:/var/lib/colord:/bin/false
27 statd:x:107:65534::/var/lib/nfs:/bin/false
28 puppet:x:108:114:Puppet configuration management daemon,,,:/var/lib/puppet:/bin/false
29 ubuntu:x:1001:1001:Ubuntu:/home/ubuntu:/bin/bash

Categories: Linux, Redhat, Uncategorized

How to background a process and have it run after you logout

December 1, 2016 Leave a comment

Assuming that you have a program running in the foreground, press ctrl-Z, then:

[1]+  Stopped                 myprogram
$ disown -h %1
$ bg 1
[1]+ myprogram &
$ logout
Categories: Linux, Redhat, Uncategorized

Create encrypted password using OpenSSL

June 28, 2016 Leave a comment

# openssl passwd –salt ew yourpass


Categories: Linux, Redhat, Uncategorized

Setting up GIT Repository

April 15, 2016 Leave a comment

## Create and initialize new repo

$ cd /opt/git
$ mkdir project.git
$ cd project.git
$ git init --bare
Initialized empty Git repository in /opt/git/project.git/
## Necessry, or you might run into permission errors with users trying to "push"
cd /opt/git/project.git
chgrp -R groupname .
chmod -R g+rwX .
find . -type d -exec chmod g+s '{}' +

## On a user's GIT client
# on User's computer
$ cd myproject
$ git init
$ git add .
$ git commit -m 'initial commit'
$ git remote add origin git@gitserver:/opt/git/project.git
$ git push origin master

## clone repo and then push changes:

$ git clone git@gitserver:/opt/git/project.git
$ cd project
$ vim README
$ git commit -am 'fix for the README file'
$ git push origin master
Categories: Linux, Uncategorized

Ansible Installation and Configuration

January 28, 2016 2 comments

Working on an OEL 6.2, this was the quickest way to get Ansible running:

Reference for all material:

## Download & Install EPEL RPM for your major release:

rpm -ivh epel-release-6-8.noarch.rpm

## Install Ansible using yum

yum install ansible

## Set up initial hosts

cd /etc/ansible/
cp hosts hosts.orig

## Edit host file

vi /etc/ansible/hosts

## remote, will call all children hosts in group

## variables to be used later

cm-dev-01 nickname=engineering vm=1
cm-test-01 nickname=engineering vm=1

## shortcut for 01,02,03

## Alias example
# jumper ansible_port=5555 ansible_host=

## Edit Ansible config to not check SSH host key

vi /etc/ansible/ansible.cfg

# uncomment this to disable SSH key host checking
host_key_checking = False


## Copy ssh key from Ansible server to all clients
# If necesseary, create your RSA keys

ssh-keygen -t rsa
 ssh-copy-id -i ~/.ssh/ <user>@<host>

## Very basic ping to check all is in order

ansible all -m ping
 ansible engineering -m ping
 ansible costamesa -m ping

## Ansible variables can be defined in the var 

## Pattern usage, using [all|*] is equivalent; the “:” separates groups, like OR
## Intersection of multiple groups uses “&engineering”, or use “!engineering” for NOT
## Ansible is very flexible here in its use of regex and globs
ansible <pattern_goes_here> -m <module_name> -a <arguments>
ansible webservers -m service -a “name=httpd state=restarted”
ansible engineering:sit-servers -m service -a “name=httpd state=restarted”
Ex: one*.com:dbservers ; webservers:&staging

## Ad-hoc commands, forking in parallel, 5 is default, memory is the constraint
ansible atlanta -a “/sbin/reboot” -f 10

## Using other user than you logged in as
ansible atlanta -a “/usr/bin/foo” -u username –sudo [–ask-sudo-pass]

## Commands entered do not source ENV variables. If you wish to run it as you would in a shell
ansible raleigh -m shell -a ‘echo $TERM’

## Quick copy
ansible atlanta -m copy -a “src=/etc/hosts dest=/tmp/hosts”

## Allowing for file property manipulation
ansible webservers -m file -a “dest=/srv/foo/b.txt mode=600 owner=<uid> group=<group>”

 ## Create, delete directory recursively
ansible webservers -m file -a “dest=/path/to/c mode=755 owner=<uid> group=<gid> state=directory”
ansible webservers -m file -a “dest=/path/to/c state=absent”






Categories: Linux, Redhat, Virtualization