# service nscd restart or # nscd -i hosts
Thursday, 16 March 2017
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-toolsAnd 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.jsonOtherwise, 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/localtimeTo set the timezone:
# svccfg -s timezone:default setprop timezone/localtime = Europe/London # svcadm refresh timezone
Wednesday, 14 December 2016
Breaking a ZFS mirror - Solaris 11
So you've mirrored your system disk wrongly! This is how you would break it and fix the problem before re-mirroring:
root@solaris11server:~$ zpool status pool: rpool state: ONLINE status: The pool is formatted using an older on-disk format. The pool can still be used, but some features are unavailable. action: Upgrade the pool using 'zpool upgrade'. Once this is done, the pool will no longer be accessible on older software versions. scan: resilvered 108G in 20m20s with 0 errors on Fri Dec 2 10:16:44 2016 config: NAME STATE READ WRITE CKSUM rpool ONLINE 0 0 0 mirror-0 ONLINE 0 0 0 c0t5000CCA0166ED0ECd0s0 ONLINE 0 0 0 c0t5000CCA0166F8C50d0 ONLINE 0 0 0 errors: No known data errorsAdded mirror as disk not slice. Turned disk into an EFI/GPT tabled disk. Using format and selecting the disk gives this messsage:
selecting c0t5000CCA0166F8C50d0 [disk formatted] /dev/dsk/c0t5000CCA0166F8C50d0s0 is part of active ZFS pool rpool. Please see zpool(1M). Reading the primary EFI GPT label failed. Using backup label. Use the 'backup' command to restore the primary label.Do we use the back command? Don't know. We must break the mirror first though - using zpool detach:
root@solaris11server:~# zpool detach rpool c0t5000CCA0166F8C50d0 root@solaris11server:~# zpool status pool: rpool state: ONLINE status: The pool is formatted using an older on-disk format. The pool can still be used, but some features are unavailable. action: Upgrade the pool using 'zpool upgrade'. Once this is done, the pool will no longer be accessible on older software versions. scan: resilvered 108G in 20m20s with 0 errors on Fri Dec 2 10:16:44 2016 config: NAME STATE READ WRITE CKSUM rpool ONLINE 0 0 0 c0t5000CCA0166ED0ECd0s0 ONLINE 0 0 0 errors: No known data errorsNow look at the partition map on our good disk:
root@solaris11server:~# prtvtoc /dev/rdsk/c0t5000CCA0166ED0ECd0s0 * /dev/rdsk/c0t5000CCA0166ED0ECd0s0 (volume "solaris") partition map * * Dimensions: * 512 bytes/sector * 625 sectors/track * 20 tracks/cylinder * 12500 sectors/cylinder * 46875 cylinders * 46873 accessible cylinders * * Flags: * 1: unmountable * 10: read-only * * Unallocated space: * First Sector Last * Sector Count Sector * 0 12500 12499 * * First Sector Last * Partition Tag Flags Sector Count Sector Mount Directory 0 2 00 12500 585900000 585912499 2 5 01 0 585912500 585912499And compare it with our bad disk:
root@solaris11server:~# prtvtoc /dev/rdsk/c0t5000CCA0166F8C50d0s0 * /dev/rdsk/c0t5000CCA0166F8C50d0s0 partition map * * Dimensions: * 512 bytes/sector * 585937500 sectors * 585937433 accessible sectors * * Flags: * 1: unmountable * 10: read-only * * Unallocated space: * First Sector Last * Sector Count Sector * 34 222 255 * * First Sector Last * Partition Tag Flags Sector Count Sector Mount Directory 0 4 00 256 585920827 585921082 8 11 00 585921083 16384 585937466So let us label our bad disk with the proper SMI label - not the EFI one:
root@solaris11server:~# format -e /dev/rdsk/c0t5000CCA0166F8C50d0 selecting /dev/rdsk/c0t5000CCA0166F8C50d0 [disk formatted] FORMAT MENU: disk - select a disk type - select (define) a disk type partition - select (define) a partition table current - describe the current disk format - format and analyze the disk repair - repair a defective sector label - write label to the disk analyze - surface analysis defect - defect list management backup - search for backup labels verify - read and display labels inquiry - show disk ID scsi - independent SCSI mode selects cache - enable, disable or query SCSI disk cache volname - set 8-character volume name !Now, let's copy the partition table of our good disk over to our bad one:- execute , then return quit format> label [0] SMI Label [1] EFI Label Specify Label type[1]: 0 Auto configuration via format.dat[no]? Auto configuration via generic SCSI-2[no]? format> p PARTITION MENU: 0 - change `0' partition 1 - change `1' partition 2 - change `2' partition 3 - change `3' partition 4 - change `4' partition 5 - change `5' partition 6 - change `6' partition 7 - change `7' partition select - select a predefined table modify - modify a predefined partition table name - name the current table print - display the current table label - write partition map and label to the disk ! - execute , then return quit partition> p Current partition table (default): Total disk cylinders available: 46873 + 2 (reserved cylinders) Part Tag Flag Cylinders Size Blocks 0 root wm 0 - 20 128.17MB (21/0/0) 262500 1 swap wu 21 - 41 128.17MB (21/0/0) 262500 2 backup wu 0 - 46872 279.38GB (46873/0/0) 585912500 3 unassigned wm 0 0 (0/0/0) 0 4 unassigned wm 0 0 (0/0/0) 0 5 unassigned wm 0 0 (0/0/0) 0 6 usr wm 42 - 46872 279.13GB (46831/0/0) 585387500 7 unassigned wm 0 0 (0/0/0) 0 partition> q
root@solaris11server:~# prtvtoc /dev/rdsk/c0t5000CCA0166ED0ECd0s0 | fmthard -s - /dev/rdsk/c0t5000CCA0166F8C50d0s2 fmthard: New volume table of contents now in place. root@solaris11server:~# prtvtoc /dev/rdsk/c0t5000CCA0166F8C50d0s0 * /dev/rdsk/c0t5000CCA0166F8C50d0s0 partition map * * Dimensions: * 512 bytes/sector * 625 sectors/track * 20 tracks/cylinder * 12500 sectors/cylinder * 46875 cylinders * 46873 accessible cylinders * * Flags: * 1: unmountable * 10: read-only * * Unallocated space: * First Sector Last * Sector Count Sector * 0 12500 12499 * * First Sector Last * Partition Tag Flags Sector Count Sector Mount Directory 0 2 00 12500 585900000 585912499 2 5 01 0 585912500 585912499All is now good, so let's attach (mirror) our system disks:
root@solaris11server:~# zpool attach rpool c0t5000CCA0166ED0ECd0s0 c0t5000CCA0166F8C50d0s0 Make sure to wait until resilver is done before rebooting. root@solaris11server:~# zpool status pool: rpool state: DEGRADED status: One or more devices is currently being resilvered. The pool will continue to function in a degraded state. action: Wait for the resilver to complete. Run 'zpool status -v' to see device specific details. scan: resilver in progress since Wed Dec 14 10:13:36 2016 1.52G scanned out of 108G at 58.9M/s, 30m52s to go 1.52G resilvered, 1.41% done config: NAME STATE READ WRITE CKSUM rpool DEGRADED 0 0 0 mirror-0 DEGRADED 0 0 0 c0t5000CCA0166ED0ECd0s0 ONLINE 0 0 0 c0t5000CCA0166F8C50d0s0 DEGRADED 0 0 0 (resilvering) errors: No known data errorsAfter the resilvering has finished, our system is mirrored correctly! :)
Subscribe to:
Posts (Atom)