Friday, 31 March 2017

Mount ISO image - CentOS

/opt/tmp
[root@centos tmp]# ls
V834394-01.iso
[root@centos tmp]# mkdir oraclelinux
[root@centos tmp]# mount -t iso9660 -o loop /opt/tmp/V834394-01.iso /opt/tmp/oraclelinux/
[root@centos tmp]# ls /opt/tmp/oraclelinux/
addons  EULA  images    LiveOS    RELEASE-NOTES-U3-en       repodata     RPM-GPG-KEY-oracle
EFI     GPL   isolinux  Packages  RELEASE-NOTES-U3-en.html  RPM-GPG-KEY  TRANS.TBL
[root@centos tmp]#

Thursday, 16 March 2017

Flush DNS cache on CentOS

To flush the DNS on CentOS:
# service nscd restart

or 

# nscd -i hosts

Tuesday, 21 February 2017

Permissions on /var/tmp CentOS 7

So you've screwed up the permissions on the /var/tmp folder. Here's how to fix it:
chmod 777 /var/tmp
chmod +t /var/tmp
chown root:root /var/tmp

Friday, 10 February 2017

How to encrypt the bind password in sssd.conf

You need to install sssd-tools:
# yum -y install sssd-tools
And use sss_obfuscate to encrypt the password. First make sure your /etc/sssd/sssd.conf is configured properly with the DOMAIN section filled. Then use the following command:
sss_obfuscate -d <domain_name>
You will then be prompted for the password that needs encrypting. The output will change the sssd.conf file with these two entries:
ldap_default_authtok_type = obfuscated_password
ldap_default_authtok = AAAQAGFQamU1Lg8qjuVPrtqVhOA652D3Sn43PYAH7T4W6CFatVtQSdB5687toLRWlgPVx7Uql96ZEfvpyVeW4T1a51gAAQID

Friday, 27 January 2017

Processing a JSON output

On most flavours of Linux you have a tool called jq:
#yum -y install jq
#man jq

JQ(1)                                                                                                                   JQ(1)

NAME
       jq - Command-line JSON processor

SYNOPSIS
       jq [options...] filter [files...]

       jq  can  transform  JSON in various ways, by selecting, iterating, reducing and otherwise mangling JSON documents. For
       instance, running the command jq ´map(.price) | add´ will take an array of JSON objects as input and return the sum of
       their "price" fields.

       jq can accept text input as well, but by default, jq reads a stream of JSON entities (including numbers and other lit‐
       erals) from stdin. Whitespace is only needed to separate entities such as 1 and 2, and true and  false.  One  or  more
       files may be specified, in which case jq will read input from those instead.

       The  options  are described in the INVOKING JQ section; they mostly concern input and output formatting. The filter is
       written in the jq language and specifies how to transform the input file or document.

For example:

jq '.resources[] | select(.type == "Class" and .title == "Userprefs").parameters' yourname .puppetlabs.vm.json
Otherwise, you can use Python:
cat somefile.json | python -m json.tool

Friday, 20 January 2017

How to set sticky bit in octal mode

This should help
$ find / -type f -perm /6000 -exec stat -c "%A %a %n" {} \;

-rwxr-sr-x 2755 /usr/bin/wall
-rwxr-sr-x 2755 /usr/bin/mlocate
-rwxr-sr-x 2755 /usr/bin/dotlockfile
-rwxr-sr-x 2755 /usr/bin/crontab
-rwsr-sr-x 6755 /usr/bin/at
-rwxr-sr-x 2755 /usr/bin/bsd-write
-rwxr-sr-x 2755 /usr/bin/ssh-agent
-rwsr-xr-x 4755 /usr/bin/mtr
-rwsr-xr-x 4755 /usr/bin/traceroute6.iputils
-rwsr-xr-x 4755 /usr/bin/passwd
-rwsr-xr-x 4755 /usr/bin/pkexec
-rwsr-sr-x 6755 /usr/bin/X

[...]

Friday, 23 December 2016

Set Timezone - Solaris 11

To get the current set timezone:
svccfg -s timezone:default listprop timezone/localtime
To set the timezone:
# svccfg -s timezone:default setprop timezone/localtime = Europe/London
# svcadm refresh timezone