Create swap on HP-UX

HP-UX
MBYTE=300
VG=vg00
LV=lv_swap2
LVOL=/dev/$VG/$LV
ORG_DSKS=/dev/dsk/c0t12d0
MIRR=1
MIR_DSKS=/dev/dsk/c2t12d0
PRI=1
Option -s only works if physical VGs are defined only in EMC or Clariion disk type

sudo lvcreate -n $LV -s y -r N /dev/$VG

If it is not EMC nor Clariion disk type

sudo lvcreate -n $LV -s y -C y /dev/$VG

Next steps:

sudo lvextend -l 1 $LVOL $ORG_DSKS
sudo lvextend -m $MIRR $LVOL $MIR_DSKS
sudo lvextend -L $MBYTE $LVOL $ORG_DSKS $MIR_DSKS
sudo swapon -p $PRI -u $LVOL
echo $LVOL …. swap pri=$PRI # add to /etc/fstab
Checks:

sudo swapinfo -tm

Posted in Linux | Comments Off on Create swap on HP-UX

Booting an HP 4440 up in Single User mode

Booting HP-UX in Single-User Mode
To boot to HP-UX in single-user mode, follow these steps:
1. At the BCH Main Menu, enter command or menu> bo pri.
The following message displays:
Interact with IPL (Y, N, or Cancel)?>
2. To interact with IPL, enter y.
3. At the ISL> prompt, enter hpux-is.

If you cannot log in at all then a hard reset will be needed. At console do
1)ctrl/b 2)rs 3)Y to confirm.
When system boots you will get a 10sec interupt boot process press a key at
this time.

01)Y – continue boot process
02)Y – to interact with isl
03)isl: hpux -is will boot to single user
fix whatever is needed then do
#/sbin/reboot

Posted in Linux | Comments Off on Booting an HP 4440 up in Single User mode

Editing ulimit variables permanently

If you want to edit ulimit variables that return with the ulimit -a command:

You can do it temporarily from the command line with the ulimit command, but to make it permanent, you have to put the change in /etc/security/limits.conf. The difficulty is determining the correct format. For pending signals, for example, I couldn’t find an example.

It works for me when I add this:

* soft sigpending 2103295
* hard sigpending 2103295

I then logout and back in and test with the ulimit command:

[root@ridus357 ~]# ulimit -a |grep sig
pending signals (-i) 2103295

Since they are not easy to find, I am listing them here:

core – limits the core file size (KB)
data – max data size (KB)
fsize – maximum filesize (KB)
memlock – max locked-in-memory address space (KB)
nofile – max number of open files
rss – max resident set size (KB)
stack – max stack size (KB)
cpu – max CPU time (MIN)
nproc – max number of processes
as – address space limit (KB)
maxlogins – max number of logins for this user
maxsyslogins – max number of logins on the system
priority – the priority to run user process with
locks – max number of file locks the user can hold
sigpending – max number of pending signals
msgqueue – max memory used by POSIX message queues (bytes)
nice – max nice priority allowed to raise to values: [-20, 19]
rtprio – max realtime priority

Posted in Linux | Comments Off on Editing ulimit variables permanently

Chage

1) Set the password expiry date for username (*-M will update both “Password expires” and “Maximum number of days between password change”):

chage -M number-of-days username

*If the password expiry date is reached and user doesn’t change his password, the system will force him to change the password before the login is executed.

2) Change the Account Expiry Date:

chage -E “2009-11-31” username

3) Force the user account to lock after 10 days:

chage -I 10 username

4) Turn off the password expiration for an user account, set the following:

-m 0 will set the minimum number of days between password change to 0
-M 99999 will set the maximum number of days between password change to 99999
-I -1 (number minus one) will set the “Password inactive” to never
-E -1 (number minus one) will set “Account expires” to never.

chage -m 0 -M 99999 -I -1 -E -1 username

Posted in Linux | Comments Off on Chage

How to determine the RHEL version

[root@vickistan ~]# cat /etc/redhat-release
CentOS release 6.6 (Final)

If that doesn’t produce results, try this:

[root@vickistan ~]# lsb_release -i -r
Distributor ID: RedHatEnterpriseServer
Release: 5.5

Posted in Linux | Comments Off on How to determine the RHEL version

How to check the version of an installed package

Ubuntu:
dpkg -s PKGNAME

Red Hat:
rpm -q PKGNAME

Arch Linux:
pacman -Si PKGNAME

Posted in Linux | Comments Off on How to check the version of an installed package

Systemd

This is how to stop a running service temporarily:

# systemctl stop servicename.service

This stops it from starting at boot, but does not stop a running service:

# systemctl disable servicename.service

That also prevents it from being started by anything else, such as plugging in some hardware, or by socket or bus activation

There is one way to stop a service for good without uninstalling it, and that is by linking it to /dev/null:



# ln -s /dev/null /etc/systemd/system/servicename.service
# systemctl daemon-reload

When you want it back:

delete the symlink to /dev/null and run systemctl enable servicename.service

Posted in Linux | Comments Off on Systemd

MySQL Indexing Stuff

#Determine whether a table is indexed
show index from [table name]

#Display a table’s index
mysql> show index from mysql.user;
+——-+————+———-+————–+————-+———–+————-+———-+——–+——+————+———+—————+
| Table | Non_unique | Key_name | Seq_in_index | Column_name | Collation | Cardinality | Sub_part | Packed | Null | Index_type | Comment | Index_comment |
+——-+————+———-+————–+————-+———–+————-+———-+——–+——+————+———+—————+
| user | 0 | PRIMARY | 1 | Host | A | NULL | NULL | NULL | | BTREE | | |
| user | 0 | PRIMARY | 2 | User | A | 6 | NULL | NULL | | BTREE | | |
+——-+————+———-+————–+————-+———–+————-+———-+——–+——+————+———+—————+
2 rows in set (0.01 sec)

#Add an index to a table
Turn on the slow log, and look for a slow query to index. Use the Describe command.

DESCRIBE

* It will tell you how many rows it had to examine and what method it used for matching. 
* Using the where method, mysql will scan the entire table to find a match, pulling up each row and 
* checking to see if the columns match its criteria.
* This is SLOW

To actually create the index
* Use CREATE INDEX to create an index on the table as follows:
CREATE INDEX <index_name> on <tbl_name> (<column_name>)
Posted in Linux, MySQL | Comments Off on MySQL Indexing Stuff

How to create a local yum repository

Yum Server Side

Take a look at the available repositories with the repolist option to yum:

$yum repolist
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
epel/metalink | 13 kB 00:00
* base: mirror.symnds.com
* epel: epel.mirror.constant.com
* extras: mirrors.advancedhosters.com
* updates: mirrors.lga7.us.voxel.net
base | 3.7 kB 00:00
epel | 4.4 kB 00:00
epel/primary_db | 6.4 MB 00:00
extras | 3.4 kB 00:00
newrelic | 951 B 00:00
shells_fish_release_2 | 1.2 kB 00:00
updates | 3.4 kB 00:00
virtualbox

Add required supporting packages:
$yum install libxml2-python deltarpm python-deltarpm vsftpd

Create a directory to store the rpm files or mount a directory which contains them.
$mkdir /var/ftp/pub/localrepo

Copy rpms to /var/ftp/pub/localrepo
$cp /mnt/disk/*.rpm /var/ftp/pub/localrepo/

Add the repo config file:
$vim /etc/yum.repos.d/localrepo.repo
Add the following lines:

[localrepo]
name=Local Repository
baseurl=file:///var/ftp/pub/localrepo
gpgcheck=0
enabled=1

Build the local repository:
$createrepo -v /var/ftp/pub/localrepo

Now use the yum command that we used above to verify that yum sees the new repo:
$yum repolist

As a good practice, run clean all and update:

$yum clean all
$yum update

Remember to add the repo to any client machine that should have access to it:

Client Side Configuration
Now, go to your client systems. Create a new repository file as shown above under /etc/yum.repos.d/ directory.

$vim /etc/yum.repos.d/localrepo.repo
and add the following contents:

[localrepo]
name=Local Repository
baseurl=ftp://{IP OF LOCALREPO}/pub/localrepo
gpgcheck=0
enabled=1

Now, list out the repositories using the following command:
$yum repolist

Clean the Yum cache and update the repository lists:

$yum clean all
$yum update

Posted in Linux | Comments Off on How to create a local yum repository

Understanding rpm Verify output

rpm -V output:
S file Size differs
M Mode differs (includes permissions and file type)
5 MD5 sum differs
D Device major/minor number mismatch
L readLink(2) path mismatch
U User ownership differs
G Group ownership differs
T mTime differs

Posted in Linux | Comments Off on Understanding rpm Verify output