Posts from 2014-11

XFCE: scroll background windows
posted on 2014-11-30 01:15:48

To change XFCE mouse scrolling behaviour, such that always the window under cursor is scrolled, even though it's not in the foreground, do this:

Applications Menu
Settings
Window Manager Tweaks
Tab: Accessibility
Uncheck: "Raise windows when any mouse button is pressed"

Done.

linux logrotate
posted on 2014-11-28 17:42:24

To avoid overflowing harddisks, use logrotate. It consists of two parts.

config file

First, a config entry either in /etc/logrotate.conf, or in a dedicated file in /etc/logrotate.d/<filename>. (This works since logrotate.d is refeferenced from logrotate.conf.)

Here's an example from mysql:

/var/log/mysql.log /var/log/mysql/mysql.log /var/log/mysql/mysql-slow.log /var/log/mysql/error.log {
    daily
    rotate 7
    missingok
    create 640 mysql adm
    compress
    sharedscripts
    postrotate
        test -x /usr/bin/mysqladmin || exit 0
        # If this fails, check debian.conf! 
        MYADMIN="/usr/bin/mysqladmin --defaults-file=/etc/mysql/debian.cnf"
        if [ -z "`$MYADMIN ping 2>/dev/null`" ]; then
            # Really no mysqld or rather a missing debian-sys-maint user?
            # If this occurs and is not a error please report a bug.
            #if ps cax | grep -q mysqld; then
            if killall -q -s0 -umysql mysqld; then
                exit 1
            fi 
        else
            $MYADMIN flush-logs
        fi
    endscript
}

In the first line the files to be rotated are specified, in the body all options are stated. This is also an example for a 'script' to run after the rotation (this is what the postrotate section is for).

Usually these are fine:

rotate 7
daily
missingok
notifempty
delaycompress

In case you get an error along the lines of '... has insecure permissions. ... . Set the "su" directive...' simply specify the user/group like this:

# like this
su mysql adm

# this is just here for illustration
rotate 7
daily
missingok
notifempty
delaycompress

cronjob

To run the logrotate regularily, a cron has to be installed.

I.e. in /etc/cron.d/my_cronjob_for_logrotate:

1 23 * * * root /usr/sbin/logrotate -f /etc/logrotate.conf > /dev/null 2>&1

apache: logrotate or rotatelogs?

The apache web server can take care of the logs himself, too. This is easiest done through an option in the vhost config. See here. That way you do not need to set up external logrotating afterwards.

Show /proc contents
posted on 2014-11-27 08:52:22

To easily look and search the contents of the /proc folder in linux, try this one-liner:

temp=`mktemp`; \
for i in \
partitions diskstats crypto key-users keys softirqs version uptime stat meminfo loadavg \
interrupts devices cpuinfo consoles cmdline locks filesystems swaps slabinfo zoneinfo \
vmstat pagetypeinfo buddyinfo modules dma timer_stats timer_list sched_debug iomem ioports \
execdomains mdstat misc fb mtrr cgroups; \
do echo -e "\n\n\n\n\n"$"\e[1;33m/proc/"$i$"\e[0m""\n\n" >> $temp; \
cat /proc/$i >> $temp; \
done; \
less -RNS $temp && rm -rf $temp
  • pasteable into shell and will work
  • it will leave no file on disk
  • will color the name of each file its contents will print
  • result is searchable as it is displayed via less
  • memory stuff files were left out, since you really should not need them usually
  • process files (all numbers) were also omitted

Running as root helps, if you are not allowed to see something.

linux hardware specs via dmidecode
posted on 2014-11-26 10:40:35

Using dmidecode is easiest used via the keywords, e.g. dmidecode -t memory. Else use the numbers: dmidecode -t 3,4.

Keyword     Types
──────────────────────────────
bios        0, 13
system      1, 12, 15, 23, 32
baseboard   2, 10, 41
chassis     3
processor   4
memory      5, 6, 16, 17
cache       7
connector   8
slot        9

Further info from the man page:

The SMBIOS specification defines the following DMI types:


Type   Information
────────────────────────────────────────
0   BIOS
1   System
2   Base Board
3   Chassis
4   Processor
5   Memory Controller
6   Memory Module
7   Cache
8   Port Connector
9   System Slots
10   On Board Devices
11   OEM Strings
12   System Configuration Options
13   BIOS Language
14   Group Associations
15   System Event Log
16   Physical Memory Array
17   Memory Device
18   32-bit Memory Error
19   Memory Array Mapped Address
20   Memory Device Mapped Address
21   Built-in Pointing Device
22   Portable Battery
23   System Reset
24   Hardware Security
25   System Power Controls
26   Voltage Probe
27   Cooling Device
28   Temperature Probe

29   Electrical Current Probe
30   Out-of-band Remote Access
31   Boot Integrity Services
32   System Boot
33   64-bit Memory Error
34   Management Device
35   Management Device Component
36   Management Device Threshold Data
37   Memory Channel
38   IPMI Device
39   Power Supply
40   Additional Information
41   Onboard Device

Additionally,  type  126  is  used for disabled entries and type 127 is an end-of-table marker. Types 128 to 255 are for
OEM-specific data.  dmidecode will display these entries by default, but it can only decode them when the  vendors  have
contributed documentation or code for them.
create SSH session via a proxy server
posted on 2014-11-24 00:23:16

If i want to connect from my computer via my workstation at work to another computer, this is how it is done:

ssh -t work_station ssh another_computer

work_station and another_computer in the above example are either IP's or aliases in the ~/.ssh/config file.

If there are more hops in between your destination workstation and your local computer, just add these via -t hop1 -t hop2 etc. into the line above.

SQLite shell
posted on 2014-11-23 17:43:19

While fixing a broken Proxmox install (where a sqlite file is used for housekeeping of the configuration), I came across using sqlite. Which is basically an SQL Database contained within a single file.

Clients can be either console based (i.e. apt-get install sqlite3) or graphical (see here).

While the GUI stuff is nice, for working on the server... CLI.

Here's the usually needed stuff if you need from the official documentation: (Commands for the sqlite CLI)

Often used commands:

sqlite3                               ## open cli
sqlite3 /PATH/TO/DB                   ## open cli and load db
sqlite3 -line /PATH/TO/DB "COMMMAND"  ## run COMMAND on DATABASE, 'line'-d output

# create dumps
sqlite DB '.dump' > dumpfile.sql
# replay dump
sqlite3 DB < dumpfile.sql

COMMANDs in particular:

.quit                                 ## exit cli
.help                                 ## show help
.databases                            ## show available db's
.schema [TABLE]                       ## table create statement, think `describe` in mysql
.open PATH                            ## open database at filesystem PATH

.show                                 ## show settings
.mode                                 ## show available output modes
.mode line                            ## should be mostly needed when working with the cli, default is 'list'
.mode csv                             ## guess what, excel is your friend now
.stats on                             ## useful for debugging, 'off' to turn off again
.width col1 col2 col3 ... colN        ## set column size when using `.mode column`

pragma integrity_ceck                 ## db consistency check
reindex                               ## might help when db is inconsistent
analyze                               ## update statistics for the indexes
pragma foreign_key_check              ## validate foreign key constraints
pragma encoding                       ## show encoding of db
pragma locking_mode                   ## show locking mode (normal or exclusive)
pragma DB.locking_mode=exclusive      ## set locking mode to exclusive, needed for simultaneous db accesses
pragma query_only                     ## is db readonly?
pragma query_only=BOOL                ## set db to RW or RO
pragma compile_options                ## show options with which sqlite was compiled


.mode insert                          ## show insert statements for data, useful when creating dumps
.output /PATH/TO/FILE                 ## define dumpfile
.dump                                 ## create dump
.read /PATH/TO/FILE                   ## replay dump into current db

A lot of commands can be given by dashed commands, see the man page for these.

DNS Howto
posted on 2014-11-22 23:46:28

DNS entries, which are called RR's (Resource Records), come in may different flavours. This post is intended to bring the absolute minimum knowledge to the table.

For a usual DNS entry, you need a pair of an A record, and a PTR record, if you want to be able to do reverse lookups. That means, having an ip, being able to resolve it back to a domain.

For convenience, there also exist CNAME records. These just redirect a domain to another domain (not an ip!).

SOA, MX, TXT and others will not be part of this post here.

A

my_domain_name.tld           ---   A   ---> 10.0.0.1

PTR

1.0.0.10.in-addr.arpa        ---  PTR  ---> my_domain_name.tld

CNAME

subdomain.my_domain_name.tld --- CNAME ---> my_domain_name.tld
my_second_domain.tld         --- CNAME ---> my_domain_name.tld

The use case here ist, that you only have to change a single entry (the A record), when the IP changes, not all other (Sub-)Domains, too, as long as these are created as CNAME's.

This brings along a little increase in latency time, as technically looking up a domain will lead to two DNS lookups being processed.

On the other mentioned records some short words:

SOA = Start of Authority, this RR authorizes this nameserver being authorative for the given domain

TXT = i.e. can be used for SPF (Sender Policy Framework), to determine allowed foreign mailservers which may send mails

MX = tells the location of the mailserver of this domain. Several RR's can exist.

On how RR's are structured, what the timings are for and how to configure a bind9 server, another post will eventually come.

IPMI cli
posted on 2014-11-21 21:29:36

Usually linux commands have a LOT of flags and options, the IPMI CLI tool being no exception.

Mostly you need these:

## hard reset, in case ipmi module hangs
./ipmicfg-linux.x86_64 -r

## show currently configured ipmi ip
./ipmicfg-linux.x86_64 -m

## clear chassis intrusion
./ipmicfg-linux.x86_64 -clrint
Linux: proper tempfiles
posted on 2014-11-20 10:24:43

mktemp creates randomly named files, a recurringly needed appliance.

create a tempfile and save name to a variable

VARIABLE_NAME=`mktemp`

(That was rather easy, wasn't it?)

Ethernet standards, cable lengths, throughputs
posted on 2014-11-19 10:30:45

Nowadays commonly used networking cables are of Standards Cat5 to Cat7e.

This shall serve as a rough overview, and omits unneeded information on purpose (!):

Cat 5   100m  100Base-TX (1GBase-T in newer ones, too, no idea about the cable length)
Cat 5e  100m   1GBase-T
Cat 6   100m   1GBase-T
Cat 6e   55m  10GBase-T
Cat 7   100m  10GBase-T
Cat 7e   ??m  10GBase-T, 40GBase-T, 100GBase-T

Old Cat5 cables could not transmit data with 1G, for that later Cat5e (extended) came along. But later on during a revision of the standards (around 2002/2003), Cat5e disappeared and was called solely 'Cat5' again. So in old networks, use a cable tester to make sure your cable is gigabit-capable.

Also is to be kept in mind, that for a cable length of altogether 100m you should not use more than 10 meters of patch cabling.

Further, Cat7/7e Cables have new plugs, which are of the GG45 standard. This is due to the distance between the cable conductors being too small, if RJ45 plugs were used. Cat7/7e cables with regular RJ45 plugs do not exist: They are copycat material which will not live up to the Cat7/7e specifications!

In GG45 jacks regular RJ45 plugs can be put into, but the overall throughput will be limited by the cable. Vice versa it will not work, since the plug got additional protrusion. Also GG45 has four additional conductors in the edges of the plug, which are missing in the RJ45 products.

Create load on a website with wget
posted on 2014-11-18 13:46:33

To create some load (i.e. to test your webserver / database settings), try wget:

wget -r --spider -l3 http://your.domain.name.here

To save the results, use the -o flag:

wget -r --spider -l3 http://your.domain.name.here -o linkliste.txt

Optionally, you may also get a linklist on the site in question, after using some cleanup.

A script, to copy paste:

echo "\nEnter URL to crawl, without http:\n"; read MYURL; echo "\n$MYURL is being crawled.\n"; MYTEMPFILE=mktemp; wget -r --spider -l3 $MYURL -o $MYTEMPFILE; egrep "^--" $MYTEMPFILE | cut -d' ' -f4 | sort | uniq

This will prompt you for a website / domain, and its output on the console are the links of the domain in question up to the third level. This is due to the -l flag in the wget part being set to 3. The maximum are five levels.

If you want a file, just pipe it into one. :)

create / delete raids with Adaptec's arcconf CLI
posted on 2014-11-17 18:11:41

When working with the CLI for the sole purpose of handling RAID's, usually these commands are needed:

  1. task
  2. create
  3. delete

This will be sort of a lazy posting, no screenpastes will find their way in here, I beg your pardon.

preparation

First make your live a lot easier:

alias asdf=/usr/StorMan/arcconf  ## or where your executable is located

Get an overview on what hardware is available:

asdf getconfig 1 pd | less

This is important, so you can locate the channels / slots of the drives you want to handle. The command is piped through less, since usually the output is too big to fit on a screen. (At least on an 19" 8-bay server, where all slots are filled.)

Similarily, you can see the already created RAID's via

asdf getconfig 1 ld

initialize drives

Once you got your information and you decided your layout, initialize the drives.

If you have nothing you need, and want to prepare all drives at once, do:

asdf task start 1 device all initialize

Else specify the channel and drive id, instead of using 'all':

asdf task start 1 device 0 0 initialize

This will erase the metadata from the drive in slot 0, if your setup is correctly assembled. (Else you are in for trouble, sooner or later, but if you do not know this, you might want to consider a different career path anyway...)

create a logical device

Lets have two examples, one raid1 spanning drives 0 0 and 0 1, and a raid10 on drives 0 4 to 0 7:

asdf create 1 logicaldrive name my_raid1 method quick max 1 0 0 0 1
asdf create 1 logicaldrive name my_raid10 method quick max 10 0 4 0 5 0 6 0 7

While the syntax is cryptical at first, this should become pretty clear once you did this several times.

create is self-explanatory, the first 1 means the controller, and in 99% of all cases you only have a setup with a single controller. logicaldrive is always a present keyword here (except you want to create a jbod), a name always helps. method quick initializing is usually also the best way to go. max specifies maximum size of the raid (that is, as big as the disks let it be).

The numbers afterwards are then:

  1. the raid level
  2. all the channel and slot number tuples

deleting a logical device

asdf delete 1 logicaldrive all

deletes all raids which were created prior.

asdf delete 1 logicaldrive 2

deletes the logical volume with the id 2. (Remember asdf getconfig 1 ld!)

That should be about it in short. modify for raid migration or online capacity expansion is reserved for another post for the time being.

Querying dd progress
posted on 2014-11-16 17:44:33

UPDATE: use pkill instead of kill: pkill -usr1 dd is all you need.


Usually dd will only show information about the transfer it did, AFTER its completion.

Or try a second shell, and sending a USR1 signal to the dd process.

First, lets startd a demo dd process:

[sjas@mb ~]$ dd if=/dev/random of=/dev/null

Then we need to find out the process id of this dd process. For this you can use pgrep, but i prefer grepping ps auxf:

[sjas@mb ~]$ ps auxf | grep dd
2:root         2  0.0  0.0      0     0 ?        S    06:25   0:00 [kthreadd]
91:sjas      3351  0.0  0.0  30588  1704 ?        Ss   06:25   0:01 /usr/bin/dbus-daemon --fork --print-pid 5 --print-address 7 --session
134:sjas      6501  0.0  0.0  31980  3496 pts/1    S+   17:43   0:00          \_ vim 180-querying-dd-for-progress.post
143:sjas      3580  0.0  0.0   9228  1248 ?        S    06:26   0:00  \_ ksysguardd
169:sjas      6560  0.0  0.0   9868   636 pts/2    S+   17:46   0:00  |   \_ dd if=/dev/random of=/dev/null
172:sjas      6660  0.0  0.0   7836   892 pts/3    S+   17:49   0:00      \_ grep -i -n --color dd
[sjas@mb ~]$ 

So in this example, the PID is 6560.

From the second shell:

kill -usr1 6560

will then show additionally this in the first shell:

0+99 records in
1+0 records out
512 bytes (512 B) copied, 250.022 s, 0.0 kB/s

Of course, you could also pipe the data through pv or bar, to have a continouus status bar. But maybe you don't want that (will slow down things a bit), or you just forgot, and so you still can query the process for the current progress.

LSI MegaCli flashing LED lights
posted on 2014-11-15 00:58:12

Blinking LED's with a LSI raid controller on linux?

In theory it is easy: (info taken straigh from the official manual)

MegaCli –PDLocate –PhysDrv[E0:S0,E1:S1....]
-aN|-a0,1,2|-aALL

Tricky part is, YOU HAVE TO ESCAPE THE BRACKETS IN THE SHELL. Well, FML? Further you are forbidden to use the logical count of your enclosure. (Like '0' or '1'.) You actually need the device id.

In short: (a0 for adapter, since I assume you only have only one raid controller, else choose the one you actually use, or use -aALL flag.)

First locate the device id of your enclosure via MegaCli encinfo a0, MegaCli version pd a0 or MegaCli pdlist a0.

my_server@01:02:39 ~ # ./MegaCli64 encinfo a0

    Number of enclosures on adapter 0 -- 1

    Enclosure 0:
    Device ID                     : 252
    Number of Slots               : 8
    Number of Power Supplies      : 0
    Number of Fans                : 0
    Number of Temperature Sensors : 0
    Number of Alarms              : 0
    Number of SIM Modules         : 1
    Number of Physical Drives     : 2
    Status                        : Normal
    Position                      : 1
    Connector Name                : Unavailable
    Enclosure type                : SGPIO
    FRU Part Number               : N/A
    Enclosure Serial Number       : N/A
    ESM Serial Number             : N/A
    Enclosure Zoning Mode         : N/A
    Partner Device Id             : Unavailable

    Inquiry data                  :
        Vendor Identification     : LSI
        Product Identification    : SGPIO
        Product Revision Level    : N/A
        Vendor Specific           :


Exit Code: 0x00
my_server@01:02:46 ~ #

or

my_server@01:14:02 ~ # ./MegaCli64 version pd a0

Location        Model           Fw Version
252 0           SAMSUNG MZ7WD2407W3QS16LNYAF401306      
252 1           SAMSUNG MZ7WD2407W3QS16LNYAF401299      

Exit Code: 0x00
my_server@01:14:55 ~ # 

Now you have the enclosure id (which is 252), which you need for the next step.

Start blinking: (Slot 1 in this example.)

./MegaCli64 pdlocate physdrv \[252:1\] a0

Stop blinking again:

./MegaCli64 pdlocate stop physdrv \[252:1\] a0

As you might already have noticed, MegaCli does not give a damn about case sensitivity or using dashes in front of flags.

If only someone would have told you this years earlier? ;)

lsi shell help page
posted on 2014-11-14 23:41:06

Without further ado, in case you should ever need this, maybe to print it out? (...)

      MegaCLI SAS RAID Management Tool  Ver 8.07.07 Dec 19, 2012

    (c)Copyright 2011, LSI Corporation, All Rights Reserved.


NOTE: The following options may be given at the end of any command below: 

    [-Silent] [-AppLogFile filename] [-NoLog] [-page[N]] 
                 [-] is optional. 
                  N - Number of lines per page. 

MegaCli -v 
MegaCli -help|-h|? 
MegaCli -adpCount 
MegaCli -AdpSetProp {CacheFlushInterval -val} | { RebuildRate -val} 
    | {PatrolReadRate -val} | {BgiRate -val} | {CCRate -val} | {ForceSGPIO -val}
    | {ReconRate -val} | {SpinupDriveCount -val} | {SpinupDelay -val} 
    | {CoercionMode -val} | {ClusterEnable -val} | {PredFailPollInterval -val} 
    | {BatWarnDsbl -val} | {EccBucketSize -val} | {EccBucketLeakRate -val} 
    | {AbortCCOnError -val} | AlarmEnbl | AlarmDsbl | AlarmSilence 
    | {SMARTCpyBkEnbl -val} | {SSDSMARTCpyBkEnbl -val} | NCQEnbl | NCQDsbl 
    | {MaintainPdFailHistoryEnbl -val} | {RstrHotSpareOnInsert -val} 
    | {DisableOCR -val} | {BootWithPinnedCache -val} | {enblPI -val} |{PreventPIImport -val} 
    | AutoEnhancedImportEnbl | AutoEnhancedImportDsbl 
    | {EnblSpinDownUnConfigDrvs -val}|{UseDiskActivityforLocate -val} -aN|-a0,1,2|-aALL 
    | {ExposeEnclDevicesEnbl -val} | {SpinDownTime -val} 
    | {SpinUpEncDrvCnt -val} | {SpinUpEncDelay -val} | {Perfmode -val} -aN|-a0,1,2|-aALL 
    | {PerfMode -val –MaxFlushLines -val –NumIOsToOrder -val} -aN|-a0,1,2|-aALL 
MegaCli -AdpSetProp -AutoDetectBackPlaneDsbl -val -aN|-a0,1,2|-aALL 
       val - 0=Enable Auto Detect of SGPIO and i2c SEP. 
             1=Disable Auto Detect of SGPIO. 
             2=Disable Auto Detect of i2c SEP. 
             3=Disable Auto Detect of SGPIO and i2c SEP. 
MegaCli -AdpSetProp -CopyBackDsbl -val -aN|-a0,1,2|-aALL 
       val - 0=Enable Copyback. 
             1=Disable Copyback. 
MegaCli -AdpSetProp -EnableJBOD -val -aN|-a0,1,2|-aALL 
       val - 0=Disable JBOD mode. 
             1=Enable JBOD mode. 
MegaCli -AdpSetProp -DsblCacheBypass -val -aN|-a0,1,2|-aALL 
       val - 0=Enable Cache Bypass. 
             1=Disable Cache Bypass. 
MegaCli -AdpSetProp -LoadBalanceMode -val -aN|-a0,1,2|-aALL 
       val - 0=Auto Load balance mode. 
             1=Disable Load balance mode. 
MegaCli -AdpSetProp -UseFDEOnlyEncrypt -val -aN|-a0,1,2|-aALL 
       val - 0=FDE and controller encryption (if HW supports) is allowed. 
             1=Only support FDE encryption, disallow controller encryption. 
MegaCli -AdpSetProp -PrCorrectUncfgdAreas -val -aN|-a0,1,2|-aALL 
       val - 0= Correcting Media error during PR is disabled. 
             1=Correcting Media error during PR is allowed. 
MegaCli -AdpSetProp -DsblSpinDownHSP -val -aN|-a0,1,2|-aALL 
       val - 0= Spinning down the Hot Spare is enabled. 
             1=Spinning down the Hot Spare is disabled. 
MegaCli -AdpSetProp -DefaultLdPSPolicy -Automatic| -None | -Maximum| -MaximumWithoutCaching -aN|-a0,1,2|-aALL 
MegaCli -AdpSetProp -DisableLdPS -interval n1 -time n2 -aN|-a0,1,2|-aALL 
       where n1 is the number of hours beginning at time n2 
       where n2 is the number of minutes from 12:00am 
MegaCli -AdpSetProp -ENABLEEGHSP -val -aN|-a0,1,2|-aALL 
       val - 0= Disabled Emergency GHSP. 
             1= Enabled Emergency GHSP. 
MegaCli -AdpSetProp -ENABLEEUG -val -aN|-a0,1,2|-aALL 
       val - 0= Disabled Emergency UG as Spare. 
             1= Enabled Emergency UG as Spare. 
MegaCli -AdpSetProp -ENABLEESMARTER -val -aN|-a0,1,2|-aALL 
       val - 0= Disabled Emergency Spare as Smarter. 
             1= Enabled Emergency Spare as Smarter. 
MegaCli -AdpSetProp -DPMenable -val -aN|-a0,1,2|-aALL 
       val - 0=Disable Drive Performance Monitoring . 
             1=Enable Drive Performance Monitoring. 
MegaCli -AdpSetProp -SupportSSDPatrolRead -val -aN|-a0,1,2|-aALL 
       val - 0=Disable Patrol read for SSD drives . 
             1=Enable Patrol read for SSD drives. 
MegaCli -AdpGetProp CacheFlushInterval | RebuildRate | PatrolReadRate | ForceSGPIO
    | BgiRate | CCRate | ReconRate | SpinupDriveCount | SpinupDelay 
    | CoercionMode | ClusterEnable | PredFailPollInterval | BatWarnDsbl 
    | EccBucketSize | EccBucketLeakRate | EccBucketCount | AbortCCOnError 
    | AlarmDsply | SMARTCpyBkEnbl | SSDSMARTCpyBkEnbl | NCQDsply 
    | MaintainPdFailHistoryEnbl | RstrHotSpareOnInsert 
    | EnblSpinDownUnConfigDrvs  | DisableOCR 
    | BootWithPinnedCache | enblPI  |PreventPIImport | AutoEnhancedImportDsply | AutoDetectBackPlaneDsbl 
    | CopyBackDsbl | LoadBalanceMode | UseFDEOnlyEncrypt | WBSupport | EnableJBOD 
    | DsblCacheBypass | ExposeEnclDevicesEnbl | SpinDownTime | PrCorrectUncfgdAreas 
    | UseDiskActivityforLocate | ENABLEEGHSP | ENABLEEUG | ENABLEESMARTER | Perfmode | PerfModeValues 
    | -DPMenable -aN|-a0,1,2|-aALL 
    | DefaultLdPSPolicy | DisableLdPsInterval | DisableLdPsTime | SpinUpEncDrvCnt 
    | SpinUpEncDelay | PrCorrectUncfgdAreas 
    | DsblSpinDownHSP | SupportSSDPatrolRead -aN|-a0,1,2|-aALL 
MegaCli -AdpAllInfo -aN|-a0,1,2|-aALL  
MegaCli -AdpGetTime -aN|-a0,1,2|-aALL  
MegaCli -AdpSetTime yyyymmdd hh:mm:ss -aN   
MegaCli -AdpSetVerify -f fileName -aN|-a0,1,2|-aALL  
MegaCli -AdpBIOS -Enbl |-Dsbl | -SOE | -BE |  -HCOE | - HSM | EnblAutoSelectBootLd | DsblAutoSelectBootLd | -Dsply -aN|-a0,1,2|-aALL 
MegaCli -AdpBootDrive {-Set {-Lx | -physdrv[E0:S0]}} | {-Unset {-Lx | -physdrv[E0:S0]}} |-Get -aN|-a0,1,2|-aALL 
MegaCli -AdpAutoRbld -Enbl|-Dsbl|-Dsply -aN|-a0,1,2|-aALL
MegaCli -AdpCacheFlush -aN|-a0,1,2|-aALL
MegaCli -AdpPR -Dsbl|EnblAuto|EnblMan|Start|Suspend|Resume|Stop|Info|SSDPatrolReadEnbl |SSDPatrolReadDsbl  
         |{SetDelay Val}|{-SetStartTime yyyymmdd hh}|{maxConcurrentPD Val} -aN|-a0,1,2|-aALL
MegaCli -AdpCcSched -Dsbl|-Info|{-ModeConc | -ModeSeq [-ExcludeLD -LN|-L0,1,2]
   [-SetStartTime yyyymmdd hh ] [-SetDelay val ] } -aN|-a0,1,2|-aALL
MegaCli -AdpCcSched -SetStartTime yyyymmdd hh -aN|-a0,1,2|-aALL
MegaCli -AdpCcSched -SetDelay val  -aN|-a0,1,2|-aALL
MegaCli -FwTermLog -BBUoff|BBUoffTemp|BBUon|BBUGet|Dsply|Clear -aN|-a0,1,2|-aALL
MegaCli -AdpAlILog -aN|-a0,1,2|-aALL 
MegaCli -AdpDiag [val] -aN|-a0,1,2|-aALL
          val - Time in second.
MegaCli -AdpGetPciInfo -aN|-a0,1,2|-aALL 
MegaCli -AdpShutDown -aN|-a0,1,2|-aALL
MegaCli -AdpDowngrade -aN|-a0,1,2|-aALL
MegaCli -PDList -aN|-a0,1,2|-aALL 
MegaCli -PDGetNum -aN|-a0,1,2|-aALL 
MegaCli -pdInfo -PhysDrv[E0:S0,E1:S1,...] -aN|-a0,1,2|-aALL  
MegaCli -PDOnline  -PhysDrv[E0:S0,E1:S1,...] -aN|-a0,1,2|-aALL 
MegaCli -PDOffline -PhysDrv[E0:S0,E1:S1,...] -aN|-a0,1,2|-aALL 
MegaCli -PDMakeGood -PhysDrv[E0:S0,E1:S1,...] | [-Force] -aN|-a0,1,2|-aALL 
MegaCli -PDMakeJBOD -PhysDrv[E0:S0,E1:S1,...] -aN|-a0,1,2|-aALL 
MegaCli -PDHSP {-Set [-Dedicated [-ArrayN|-Array0,1,2...]] [-EnclAffinity] [-nonRevertible]} 
     |-Rmv -PhysDrv[E0:S0,E1:S1,...] -aN|-a0,1,2|-aALL 
MegaCli -PDRbld -Start|-Stop|-Suspend|-Resume|-ShowProg |-ProgDsply 
        -PhysDrv [E0:S0,E1:S1,...] -aN|-a0,1,2|-aALL  
MegaCli -PDClear -Start|-Stop|-ShowProg |-ProgDsply 
        -PhysDrv [E0:S0,E1:S1,...] -aN|-a0,1,2|-aALL  
MegaCli -PdLocate {[-start] | -stop} -physdrv[E0:S0,E1:S1,...] -aN|-a0,1,2|-aALL 
MegaCli -PdMarkMissing -physdrv[E0:S0,E1:S1,...] -aN|-a0,1,2|-aALL 
MegaCli -PdGetMissing -aN|-a0,1,2|-aALL 
MegaCli -PdReplaceMissing -physdrv[E0:S0] -arrayA, -rowB -aN 
MegaCli -PdPrpRmv [-UnDo] -physdrv[E0:S0] -aN|-a0,1,2|-aALL  
MegaCli -EncInfo -aN|-a0,1,2|-aALL 
MegaCli -EncStatus -aN|-a0,1,2|-aALL 
MegaCli -PhyInfo -phyM -aN|-a0,1,2|-aALL  
MegaCli -PhySetLinkSpeed -phyM -speed -aN|-a0,1,2|-aALL
MegaCli -PdFwDownload [offline][ForceActivate] {[-SataBridge] -PhysDrv[0:1] }|{-EncdevId[devId1]} -f <filename> -aN|-a0,1,2|-aALL 
MegaCli -LDInfo -Lx|-L0,1,2|-Lall -aN|-a0,1,2|-aALL 
MegaCli -LDSetProp  {-Name LdNamestring} | -RW|RO|Blocked|RemoveBlocked | WT|WB|ForcedWB [-Immediate] |RA|NORA|ADRA | DsblPI 
        | Cached|Direct | -EnDskCache|DisDskCache | CachedBadBBU|NoCachedBadBBU
        -Lx|-L0,1,2|-Lall -aN|-a0,1,2|-aALL 
MegaCli -LDSetPowerPolicy -Default| -Automatic| -None| -Maximum| -MaximumWithoutCaching 
        -Lx|-L0,1,2|-Lall -aN|-a0,1,2|-aALL 
MegaCli -LDGetProp  -Cache | -Access | -Name | -DskCache | -PSPolicy | Consistency -Lx|-L0,1,2|-LALL  
        -aN|-a0,1,2|-aALL 
MegaCli -LDInit {-Start [-full]}|-Abort|-ShowProg|-ProgDsply -Lx|-L0,1,2|-LALL -aN|-a0,1,2|-aALL 
MegaCli -LDCC {-Start [-force]}|-Abort|-Suspend|-Resume|-ShowProg|-ProgDsply -Lx|-L0,1,2|-LALL -aN|-a0,1,2|-aALL 
MegaCli -LDBI -Enbl|-Dsbl|-getSetting|-Abort|-Suspend|-Resume|-ShowProg|-ProgDsply -Lx|-L0,1,2|-LALL -aN|-a0,1,2|-aALL  
MegaCli -LDRecon {-Start -rX [{-Add | -Rmv} -Physdrv[E0:S0,...]]}|-ShowProg|-ProgDsply 
        -Lx -aN 
MegaCli -LdPdInfo -aN|-a0,1,2|-aALL 
MegaCli -LDGetNum -aN|-a0,1,2|-aALL 
MegaCli -LDBBMClr -Lx|-L0,1,2,...|-Lall -aN|-a0,1,2|-aALL 
MegaCli -getLdExpansionInfo -Lx|-L0,1,2|-Lall -aN|-a0,1,2|-aALL 
MegaCli -LdExpansion -pN -dontExpandArray -Lx|-L0,1,2|-Lall -aN|-a0,1,2|-aALL 
MegaCli -GetBbtEntries -Lx|-L0,1,2|-Lall -aN|-a0,1,2|-aALL 
MegaCli -Cachecade -assign|-remove -Lx|-L0,1,2|-LALL -aN|-a0,1,2|-aALL
MegaCli -CfgLdAdd -rX[E0:S0,E1:S1,...] [WT|WB] [NORA|RA|ADRA] [Direct|Cached]
        [CachedBadBBU|NoCachedBadBBU] [-szXXX [-szYYY ...]]
        [-strpszM] [-Hsp[E0:S0,...]] [-AfterLdX] | [FDE|CtrlBased]  
        [-Default| -Automatic| -None| -Maximum| -MaximumWithoutCaching] [-Cache] [-enblPI] [-Force]-aN 
MegaCli -CfgCacheCadeAdd [-rX] -Physdrv[E0:S0,...] {-Name LdNamestring} [WT|WB|ForcedWB] [-assign -LX|L0,2,5..|LALL] -aN|-a0,1,2|-aALL 
MegaCli -CfgEachDskRaid0 [WT|WB] [NORA|RA|ADRA] [Direct|Cached] [-enblPI] 
        [CachedBadBBU|NoCachedBadBBU] [-strpszM]|[FDE|CtrlBased] [-Default| -Automatic| -None| -Maximum| -MaximumWithoutCaching] [-Cache] -aN|-a0,1,2|-aALL
MegaCli -CfgClr [-Force] -aN|-a0,1,2|-aALL 
MegaCli -CfgDsply -aN|-a0,1,2|-aALL 
MegaCli -CfgCacheCadeDsply -aN|-a0,1,2|-aALL 
MegaCli -CfgLdDel -LX|-L0,2,5...|-LALL [-Force] -aN|-a0,1,2|-aALL 
MegaCli -CfgCacheCadeDel -LX|-L0,2,5...|-LALL -aN|-a0,1,2|-aALL 
MegaCli -CfgFreeSpaceinfo -aN|-a0,1,2|-aALL 
MegaCli -CfgSpanAdd -r10 -Array0[E0:S0,E1:S1] -Array1[E0:S0,E1:S1] [-ArrayX[E0:S0,E1:S1] ...] 
        [WT|WB] [NORA|RA|ADRA] [Direct|Cached] [CachedBadBBU|NoCachedBadBBU]
        [-szXXX[-szYYY ...]][-strpszM][-AfterLdX]| [FDE|CtrlBased] 
        [-Default| -Automatic| -None| -Maximum| -MaximumWithoutCaching] [-Cache] [-enblPI] [-Force] -aN 
MegaCli -CfgSpanAdd -r50 -Array0[E0:S0,E1:S1,E2:S2,...] -Array1[E0:S0,E1:S1,E2:S2,...] 
        [-ArrayX[E0:S0,E1:S1,E2:S2,...] ...] [WT|WB] [NORA|RA|ADRA] [Direct|Cached] 
        [CachedBadBBU|NoCachedBadBBU][-szXXX[-szYYY ...]][-strpszM][-AfterLdX] 
        [FDE|CtrlBased] [-Default| -Automatic| -None| -Maximum| -MaximumWithoutCaching] [-Cache] [-enblPI] [-Force] -aN
MegaCli -CfgSpanAdd -r60 -Array0[E0:S0,E1:S1,E2:S2,E3,S3...] -Array1[E0:S0,E1:S1,E2:S2,E3,S3...] 
        [-ArrayX[E0:S0,E1:S1,E2:S2,E3,S3...] ...] [WT|WB] [NORA|RA|ADRA] [Direct|Cached] 
        [CachedBadBBU|NoCachedBadBBU][-szXXX[-szYYY ...]][-strpszM][-AfterLdX]| 
        [FDE|CtrlBased] [-Default| -Automatic| -None| -Maximum| -MaximumWithoutCaching] [-Cache] [-enblPI] [-Force] -aN
MegaCli -CfgAllFreeDrv -rX [-SATAOnly] [-SpanCount XXX] [WT|WB] [NORA|RA|ADRA] 
        [Direct|Cached] [CachedBadBBU|NoCachedBadBBU] [-strpszM]
        [-HspCount XX [-HspType -Dedicated|-EnclAffinity|-nonRevertible]]| 
        [FDE|CtrlBased] [-Default| -Automatic| -None| -Maximum| -MaximumWithoutCaching] [-Cache] [-enblPI] -aN 
MegaCli -CfgSave -f filename -aN   
MegaCli -CfgRestore -f filename -aN   
MegaCli -CfgForeign -Scan | [-SecurityKey sssssssssss] -aN|-a0,1,2|-aALL    
MegaCli -CfgForeign -Dsply [x] | [-SecurityKey sssssssssss] -aN|-a0,1,2|-aALL    
MegaCli -CfgForeign -Preview [x] | [-SecurityKey sssssssssss] -aN|-a0,1,2|-aALL    
MegaCli -CfgForeign -Import [x] | [-SecurityKey sssssssssss] -aN|-a0,1,2|-aALL    
MegaCli -CfgForeign -Clear [x]|[-SecurityKey sssssssssss] -aN|-a0,1,2|-aALL    
        x - index of foreign configurations. Optional. All by default. 
MegaCli -AdpEventLog -GetEventLogInfo -aN|-a0,1,2|-aALL 
MegaCli -AdpEventLog -GetEvents {-info -warning -critical -fatal} {-f <fileName>} -aN|-a0,1,2|-aALL 
MegaCli -AdpEventLog -GetSinceShutdown {-info -warning -critical -fatal} {-f <fileName>} -aN|-a0,1,2|-aALL 
MegaCli -AdpEventLog -GetSinceReboot {-info -warning -critical -fatal} {-f <fileName>} -aN|-a0,1,2|-aALL 
MegaCli -AdpEventLog -IncludeDeleted {-info -warning -critical -fatal} {-f <fileName>} -aN|-a0,1,2|-aALL 
MegaCli -AdpEventLog -GetLatest n {-info -warning -critical -fatal} {-f <fileName>} -aN|-a0,1,2|-aALL 
MegaCli -AdpEventLog -GetCCIncon -f <fileName> -LX|-L0,2,5...|-LALL -aN|-a0,1,2|-aALL 
MegaCli -AdpEventLog -Clear -aN|-a0,1,2|-aALL 
MegaCli -AdpBbuCmd -aN|-a0,1,2|-aALL  
MegaCli -AdpBbuCmd -GetBbuStatus -aN|-a0,1,2|-aALL  
MegaCli -AdpBbuCmd -GetBbuCapacityInfo -aN|-a0,1,2|-aALL  
MegaCli -AdpBbuCmd -GetBbuDesignInfo -aN|-a0,1,2|-aALL  
MegaCli -AdpBbuCmd -GetBbuProperties -aN|-a0,1,2|-aALL  
MegaCli -AdpBbuCmd -BbuLearn -aN|-a0,1,2|-aALL  
MegaCli -AdpBbuCmd -BbuMfgSleep -aN|-a0,1,2|-aALL  
MegaCli -AdpBbuCmd -BbuMfgSeal -aN|-a0,1,2|-aALL  
MegaCli -AdpBbuCmd -getBbumodes  -aN|-a0,1,2|-aALL  
MegaCli -AdpBbuCmd -SetBbuProperties -f <fileName> -aN|-a0,1,2|-aALL 
MegaCli -AdpBbuCmd -GetGGEEPData offset [Hexaddress] NumBytes n -aN|-a0,1,2|-aALL 
MegaCli -AdpBbuCmd -ScheduleLearn -Dsbl|-Info|[-STARTTIME DDD hh] -aN|-a0,1,2|-aALL 
MegaCli -AdpFacDefSet -aN 
MegaCli -AdpFwFlash -f filename [-ResetNow] [-NoSigChk] [-NoVerChk] [-FWTYPE n] -aN|-a0,1,2|-aALL  
MegaCli -AdpGetConnectorMode -ConnectorN|-Connector0,1|-ConnectorAll -aN|-a0,1,2|-aALL  
MegaCli -AdpSetConnectorMode -Internal|-External|-Auto -ConnectorN|-Connector0,1|-ConnectorAll -aN|-a0,1,2|-aALL  
MegaCli -PhyErrorCounters -aN|-a0,1,2|-aALL  
MegaCli -DirectPdMapping -Enbl|-Dsbl|-Dsply -aN|-a0,1,2|-aALL  
MegaCli -PDCpyBk -Start -PhysDrv[E0:S0,E1:S1] -aN|-a0,1,2|-aALL 
MegaCli -PDCpyBk -Stop|-Suspend|-Resume|-ShowProg|-ProgDsply -PhysDrv[E0:S0] -aN|-a0,1,2|-aALL 
MegaCli -PDInstantSecureErase -PhysDrv[E0:S0,E1:S1,...] | [-Force] -aN|-a0,1,2|-aALL 
MegaCli -CfgSpanAdd -rX -array0[E0:S1,E1:S1.....] array1[E0:S1,E1:S1.....] -szxxx -enblPI -aN|-a0,1,2|-aALL 
MegaCli -LDMakeSecure -Lx|-L0,1,2,...|-Lall -aN|-a0,1,2|-aALL 
MegaCli -DestroySecurityKey | [-Force] -aN 
MegaCli -CreateSecurityKey -SecurityKey sssssssssss | [-Passphrase sssssssssss] |[-KeyID kkkkkkkkkkk] -aN 
MegaCli -CreateSecurityKey useEKMS -aN 
MegaCli -ChangeSecurityKey -OldSecurityKey sssssssssss | -SecurityKey sssssssssss| 
          [-Passphrase sssssssssss] | [-KeyID kkkkkkkkkkk] -aN
MegaCli -ChangeSecurityKey -SecurityKey sssssssssss| 
          [-Passphrase sssssssssss] | [-KeyID kkkkkkkkkkk] -aN
MegaCli -ChangeSecurityKey useEKMS -OldSecurityKey sssssssssss -aN
MegaCli -ChangeSecurityKey -useEKMS -aN
MegaCli -GetKeyID [-PhysDrv[E0:S0]] -aN 
MegaCli -SetKeyID -KeyID kkkkkkkkkkk -aN 
MegaCli -VerifySecurityKey -SecurityKey sssssssssss -aN 
MegaCli -GetPreservedCacheList -aN|-a0,1,2|-aALL 
MegaCli -DiscardPreservedCache -Lx|-L0,1,2|-Lall -force -aN|-a0,1,2|-aALL 

       sssssssssss  - It must be between eight and thirty-two 
                      characters and contain at least one number, 
                      one lowercase letter, one uppercase 
                      letter and one non-alphanumeric character.
       kkkkkkkkkkk -  Must be less than 256 characters. 
MegaCli -ShowSummary [-f filename] -aN
MegaCli -ELF -GetSafeId -aN|-a0,1,2|-aALL
MegaCli -ELF -ControllerFeatures -aN|-a0,1,2|-aALL
MegaCli -ELF -Applykey key <val> [Preview] -aN|-a0,1,2|-aALL
MegaCli -ELF -TransferToVault -aN|-a0,1,2|-aALL
MegaCli -ELF -DeactivateTrialKey -aN|-a0,1,2|-aALL
MegaCli -ELF -ReHostInfo -aN|-a0,1,2|-aALL
MegaCli -ELF -ReHostComplete -aN|-a0,1,2|-aALL
MegaCli -LDViewMirror -Lx|-L0,1,2,...|-Lall -aN|-a0,1,2|-aALL 
MegaCli -LDJoinMirror -DataSrc <val> [-force] -Lx|-L0,1,2,...|-Lall -aN|-a0,1,2|-aALL 
MegaCli -SecureErase 
    Start[
        Simple|
        [Normal   [ |ErasePattern ErasePatternA|ErasePattern ErasePatternA ErasePattern ErasePatternB]]|
        [Thorough [ |ErasePattern ErasePatternA|ErasePattern ErasePatternA ErasePattern ErasePatternB]]]
    | Stop
    | ShowProg
    | ProgDsply 
    [-PhysDrv [E0:S0,E1:S1,...] | -Lx|-L0,1,2|-LALL] -aN|-a0,1,2|-aALL
MegaCli -Version -Cli|-Ctrl|-Driver|-Pd   -aN|-a0,1,2|-aALL
MegaCli -Perfmon {-start -interval <val>} | {stop} | {-getresults -f <Filename>} -aN 
MegaCli -DpmStat -Dsply {lct | hist | ra | ext } [-physdrv[E0:S0]] -aN|-a0,1,2|-aALL  
MegaCli -DpmStat -Clear {lct | hist | ra | ext } -aN|-a0,1,2|-aALL  

    Note: The directly connected drives can be specified as [:S] 

    Wildcard '?' can be used to specify the enclosure ID for the drive in the 
      only enclosure without direct connected device or the direct connected 
      drives with no enclosure in the system.

    Note:[-aALL] option assumes that the parameters specified are valid 
       for all the Adapters. 

    Note:ProgDsply option is not supported in VMWARE-COSLESS.

    The following options may be given at the end of any command above: 

    [-Silent] [-AppLogFile filename] [-NoLog] [-page[N]] 
                 [-] is optional. 
                  N - Number of lines per page. 
MegaCli XD -AddVd <devList>
MegaCli XD -RemVd <devList>
MegaCli XD -AddCdev <devList> | -force
MegaCli XD -RemCdev <devList>
MegaCli XD -VdList | -Configured | -Unconfigured
MegaCli XD -CdevList | -Configured | -Unconfigured
MegaCli XD -ConfigInfo
MegaCli XD -PerfStats
MegaCli XD -OnlineVd
MegaCli XD -WarpDriveInfo -iN | -iALL
MegaCli XD -FetchSafeId -iN | -iALL
MegaCli XD -ApplyActivationKey <key> -iN

Exit Code: 0x00

In case you should need the manual, see here.

bash ranging
posted on 2014-11-13 12:05:02

Using ranges in bash, you can avoid more complicated for loop constructs (which aren't needed 99% of the time anyway...):

[sjas@mb ~]$ for i in {1..5}; do echo $i; done
1
2
3
4
5
[sjas@mb ~]$ 

This also works with characters:

[sjas@mb ~]$ for i in {z..q}; do echo $i; done
z
y
x
w
v
u
t
s
r
q
[sjas@mb ~]$ 

Even backwards!

macbook fan control
posted on 2014-11-12 01:43:17

After a while I noticed that the fans kept pretty quiet on my macbook, which seemed rather odd considering the temperature on its underside.

After some googling it seemed that this is a bug, due to nobody ever having cared enough to release proper drivers.

Thanks to the wonderful conveniences of life on github there was help to be found: https://github.com/dgraziotin/Fan-Control-Daemon

Prerequisites:

sudo aptitude install g++ make lm-sensors

git clone https://github.com/dgraziotin/Fan-Control-Daemon
cd Fan-Control-Daemon
sudo make
sudo make install
sudo make test

After this, the program is installed halfways. To have it properly set up so it starts during boot process, have a look at the readme where it is very well explained for your distro of choice.

To see what is currently up, try: (Ctrl-C to escape)

watch -n.2 sensors

Which will give you your current temps and fan speed:

coretemp-isa-0000
Adapter: ISA adapter
Core 0:       +55.0°C  (high = +105.0°C, crit = +105.0°C)
Core 1:       +54.0°C  (high = +105.0°C, crit = +105.0°C)

nouveau-pci-0200
Adapter: PCI adapter
temp1:        +60.0°C  (high = +100.0°C, crit = +95.0°C)

applesmc-isa-0300
Adapter: ISA adapter
Exhaust  :   4164 RPM  (min = 2000 RPM, max = 6200 RPM)
TB0T:         +35.5°C  
TB1T:         +35.5°C  
TB2T:         +33.2°C  
TB3T:         +35.8°C  
TC0D:         +59.2°C  
TC0P:         +53.0°C  
TN0D:         +59.2°C  
TN0P:         +53.8°C  
TTF0:         +65.0°C  
Th0H:         +57.8°C  
Th1H:         +50.5°C  
ThFH:         +50.8°C  
Ts0P:         +32.8°C  
Ts0S:         +41.5°C  

To change the settings, have a look at /etc/mbpfan.conf, here is my current one:

[general]
min_fan_speed = 3000    # default is 2000
max_fan_speed = 6200    # default is 6200
low_temp = 50           # try ranges 55-63, default is 63
high_temp = 55          # try ranges 58-66, default is 66
max_temp = 65           # do not set it > 90, default is 86
polling_interval = 7    # default is 7

Maybe the fan speeds are a little too high still, but lets see how battery life changes. Temperature is down by 15 degrees Celsius, which I consider an improvement.

Mac's hidden Fn keys
posted on 2014-11-11 09:14:20

Since the mac keyboards tend to be fancy, there are some keys missing. Or not?

Delete      Fn + Backspace
Insert      Fn + Enter
Page Up     Fn + Uparrow
Page Down   Fn + Downarrow
Home        Fn + Leftarrow
End         Fn + Rightarrow
Apple Fn Keys Switching
posted on 2014-11-10 23:23:25

Usually the F1 to F12 keys are reachable on a mac only via the Fn modifier key. Instead of these the brightness control keys and the like are preferred by default.

Of course I want alt+f4 (where alt is already on left cmd, of course) to work without Fn...

sudo vim /etc/modprobe.d/hid_apple.conf:

options hid_apple fnmode=2

After saving, type this into your shell:

sudo update-initramfs -u

Reboot and revel in awe. :)

Apache redirecting
posted on 2014-11-09 17:35:27

A sample for apache redirecting, very useable snippet for use from within a .htaccess:

RewriteEngine On
RewriteCond %{REQUEST_URI} ^/$
RewriteRule (.*) http://blog.sjas.de [L,R=301]

You might want to change the URL. ;)

udev in ubuntu 14.04
posted on 2014-11-08 16:19:45

If you want to rename your NIC's in linux, especially in ubuntu 14.04 (important!), you got to know that as of 11/2014 the official documentation is plain wrong. (See here.)

Edit /etc/udev/rules.d/75-persistent-net-generator.rules like:

SUBSYSTEM=="net", ACTION=="add", ATTR{address}=="0c:c4:7a:0b:67:b6", NAME="eth0"
SUBSYSTEM=="net", ACTION=="add", ATTR{address}=="0c:c4:7a:0b:67:b7", NAME="eth1"

Of course, you have to use the proper MAC address from the interface in question, get it via ip a.

Unban IP from Fail2Ban
posted on 2014-11-07 12:26:50

If you want to remove an IP from the fail2ban ban list, i.e. the second one in this excerpt:

(Output of iptables -L -n)

...

Chain fail2ban-ssh (1 references)
target     prot opt source               destination         
DROP       all  --  10.0.0.33            0.0.0.0/0           
DROP       all  --  10.0.3.234           0.0.0.0/0           
RETURN     all  --  0.0.0.0/0            0.0.0.0/0           

First do a fail2ban-client status to determine the jailname fail2ban uses:

Status
|- Number of jail:  1
`- Jail list:   ssh-iptables

It's ssh-iptables here.

Now simply unban the ip:

fail2ban-client set ssh-iptables unbanip 10.0.3.234
Minimal dotfiles
posted on 2014-11-06 05:40:21

Without further ado, this is put here for documentary reasons. I paste this into the current configs and am glad.

.bashrc

#######################################################################################################################
### aliases
#######################################################################################################################
alias l='ls -lahF --color'
alias ..='cd ..'
alias lsblk='lsblk -o name,label,mountpoint,fstype,model,size,type,state,uuid'
alias v='vim'
alias grep='grep -i -n --color'
alias ev='vim ~/.vimrc'
alias eb='vim ~/.bashrc'
alias eg='vim ~/.gitconfig'
alias ggfc='git add .; git commit -m "fastcommit"; git pull origin master; git push origin master'


#######################################################################################################################
### env
#######################################################################################################################
export EDITOR=vim
export VISUAL=vim
export PS1='\[\e[31;1m\][\[\e[37;1m\]\u\[\e[33;1m\]@\[\e[37;1m\]\H \[\e[32;1m\]\w\[\e[31;1m\]]\[\e[36;1m\]\$ \[\e[0m\]'
export PATH=/home/sjas/bin:$PATH
export LESS_TERMCAP_mb=$'\E[1;31m'
# COMMAND AND FLAG COLOR
export LESS_TERMCAP_md=$'\E[1;32m'
# PARAMETER COLOR
export LESS_TERMCAP_us=$'\E[1;33m'
export LESS_TERMCAP_me=$'\E[0m'
export LESS_TERMCAP_se=$'\E[0m'
export LESS_TERMCAP_so=$'\E[38m'
export LESS_TERMCAP_ue=$'\E[0m'

#######################################################################################################################
# blogging
#######################################################################################################################
function createpost() {
    if [ $# -ne 1 ]
    then 
        echo "Usage :: post filename as parameter without .post extension"
        exit 1
    fi

    cat << EOHD > ~/blog/$1.post
;;;;;
title: 
tags: 
date: 
format: md
;;;;;
content
EOHD
}

.vimrc

let mapleader=' '
let maplocalleader=' '
syn on
se hls
se is
se ic
se gd
se ai
se et
se sts=4
se ts=4
se sw=4
se backspace=indent,eol,start
se sm
se wildmenu
se wildmode=list:longest,full


nnoremap s/ :s/
nnoremap ss/ :%s/
vnoremap s/ :s/
nnoremap <leader><backspace> /qwerqwerasdfasdf<cr><esc>
nnoremap <leader>ul yypVr=0<cr>
nnoremap <leader>fs :.!date --rfc-3339=seconds<cr><esc>$xxxxxx
nnoremap <leader><leader>fs Sdate:<esc>o<esc>:.!date --rfc-3339=seconds<cr><esc>kJ$xxxxxx
nnoremap <leader><leader>i :%s/^\s*<cr>/qwerqwer<cr><esc>
vnoremap <leader><leader>i :s/^\s*<cr>/qwerqwer<cr><esc>
nnoremap <leader><leader>s :%s/\s*$<cr>/qwerqwer<cr><esc>
vnoremap <leader><leader>s :s/\s*$<cr>/qwerqwer<cr><esc>
vnoremap <leader>ln !nl -ba<cr>
nnoremap <leader>n :next<cr>
nnoremap <leader>b :prev<cr>
nnoremap <leader><c-d> :sh<cr>

nnoremap <Leader>wq :wq<CR>
nnoremap <Leader>fw :se bt=<cr>:w<CR>
nnoremap <Leader>fa :wa<CR>
nnoremap <Leader>fq :q<CR>
nnoremap <Leader>rq :q!<CR>

cmap w!! w !sudo tee % > /dev/null
Linux: show all block devices with lsblk
posted on 2014-11-05 00:01:23

To see all currently connected devices like HDD's, SSD's, CD-Rom's and USB sticks, try lsblk.

Usually it looks like this:

sjas@mb:~/ISO/UBCD$ lsblk
NAME                         MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sda                            8:0    0  29.8G  0 disk
|─sda1                         8:1    0   487M  0 part /boot/efi
|─sda2                         8:2    0  25.6G  0 part /
`─sda3                         8:3    0   3.8G  0 part [SWAP]
sr0                           11:0    1 589.2M  0 rom
sdb                            8:16   0 596.2G  0 disk
|─sdb1                         8:17   0   200M  0 part
|─sdb2                         8:18   0   500M  0 part
`─sdb3                         8:19   0 595.5G  0 part
  |─fedora_debra-root (dm-0) 254:0    0    50G  0 lvm
  |─fedora_debra-home (dm-1) 254:1    0   542G  0 lvm
  `─fedora_debra-swap (dm-2) 254:2    0   3.5G  0 lvm
sjas@mb:~/ISO/UBCD$

For a better overview, try a better selection of -o flags. Heres an overview on the possible options on an arbitrary system:

[jl@jerrylee ~]% \lsblk --help | \grep Available -A999 | sed -e '1d' -e '$d' | sed '$d'
        NAME  device name
       KNAME  internal kernel device name
     MAJ:MIN  major:minor device number
      FSTYPE  filesystem type
  MOUNTPOINT  where the device is mounted
       LABEL  filesystem LABEL
        UUID  filesystem UUID
   PARTLABEL  partition LABEL
    PARTUUID  partition UUID
          RA  read-ahead of the device
          RO  read-only device
          RM  removable device
       MODEL  device identifier
      SERIAL  disk serial number
        SIZE  size of the device
       STATE  state of the device
       OWNER  user name
       GROUP  group name
        MODE  device node permissions
   ALIGNMENT  alignment offset
      MIN-IO  minimum I/O size
      OPT-IO  optimal I/O size
     PHY-SEC  physical sector size
     LOG-SEC  logical sector size
        ROTA  rotational device
       SCHED  I/O scheduler name
     RQ-SIZE  request queue size
        TYPE  device type
    DISC-ALN  discard alignment offset
   DISC-GRAN  discard granularity
    DISC-MAX  discard max bytes
   DISC-ZERO  discard zeroes data
       WSAME  write same max bytes
         WWN  unique storage identifier
        RAND  adds randomness
      PKNAME  internal parent kernel device name
        HCTL  Host:Channel:Target:Lun for SCSI
        TRAN  device transport type
         REV  device revision
      VENDOR  device vendor

You can of course take this listing and try it directly:

\lsblk -o$(\lsblk --help | \grep Available -A999 | sed -e '1d' -e '$d' | sed '$d' | awk '{print $1}' | tr '\n' ',' | sed 's/,$//')

But if you do not have two widescreen monitors and a PTY shell drawn across it, you wont be recognizing much. Just for the record, on a Kali LIVE the above command won't even show all the output but jsut die gracefully without even showing an error.

So you might try this:

root@mb:/home/sjas/ISO/UBCD# lsblk -i -o name,label,mountpoint,fstype,model,size,type,state,uuid
NAME                         LABEL    MOUNTPOINT FSTYPE      MODEL              SIZE TYPE STATE   UUID
sda                                                          SSDSA2SH032G1GN   29.8G disk running
|─sda1                                /boot/efi  vfat                           487M part         5604-FDAF
|─sda2                                /          ext4                          25.6G part         ded0e7a8-23af-4deb-9b9d-9d63a26904aa
`─sda3                                [SWAP]     swap                           3.8G part         b022846d-e4b5-475b-b087-c4d5b486601f
sr0                          UBCD532             iso9660     DVDRW  GS21N     589.2M rom  running
sdb                                                          Name             596.2G disk running
|─sdb1                       untitled            hfsplus                        200M part         0fdc7456-f171-3490-9d41-671b43d70db3
|─sdb2                                           ext4                           500M part         66a8ed1c-e56e-4707-bbd5-15bcde2fa5a0
`─sdb3                                           LVM2_member                  595.5G part         BIC2hD-zS3w-yvtC-oNEG-yec1-4Q7h-qb4gwN
  |─fedora_debra-root (dm-0)                     ext4                            50G lvm  running e35f5406-0cc0-4646-86f8-c4031005580a
  |─fedora_debra-home (dm-1)                     ext4                           542G lvm  running 8bc9c1a4-a5c1-4e1b-9dfc-7aeb6437c708
  `─fedora_debra-swap (dm-2)                     swap                           3.5G lvm  running 2ddddb46-8b6d-4fb4-ae19-6390e1015b76
root@mb:/home/sjas/ISO/UBCD#

Of course, I have lsblk -o name,label,mountpoint,fstype,model,size,type,state,uuid aliased in my .bashrc:

alias lsblk='lsblk -o name,label,mountpoint,fstype,model,size,type,state,uuid'

UPDATE:

lsblk -i -o kname,mountpoint,fstype,size,maj:min,rm,name,state,rota,ro,type,label,model,serial

is what i stick with.

Enable wireless module in debian on a Aluminium Macbook (non-pro)
posted on 2014-11-04 21:14:18

Hardware being used:

[sjas@mb ~]$ lspci -nn -d 14e4:
03:00.0 Network controller [0280]: Broadcom Corporation BCM4322 802.11a/b/g/n Wireless LAN Controller [14e4:432b] (rev 01)
[sjas@mb ~]$

After some googling i found out which drivers work for this version of the Hardware (mind the brackets stuff and the revision!), and all to do was:

  sudo apt-cache search b43
  sudo apt-get update
  lspci -nn -d 14e4:
  sudo apt-get install firmware-b43-installer
  sudo reboot
MacBook synaptics touchpad linux settings
posted on 2014-11-04 08:21:03

To get some proper settings for your macbook's trackpad after having installed a proper OS on it, try the following synaptics settings.

#!/bin/bash

## ENABLING FUNCTIONS
# all set to '0' previously
# tapping, two fingers = mouse2, three = mouse3 ... 
synclient TapButton1=1
synclient TapButton2=3
synclient TapButton3=2
# ... and palm detection...
synclient PalmDetect=1
# ... and horizontal scrolling
synclient HorizTwoFingerScroll=1

## SETTING SENSITIVITIES AND SPEEDS
# '30' prior, less touch sensitivity
synclient FingerHigh=50
# '1.75' prior, faster
synclient MaxSpeed=2.25
# '235' prior`, faster
synclient VertScrollDelta=110

To make this work, place this into a script and make sure it will be ran during your login process. (.bashrc, .profile, whatever.) The other option is to put the settings directly into your synaptic config file.

My file in my system is located here:

[sjas@nb ~]$ find /usr/share/X11 -iname '*synaptic*'
/usr/share/X11/xorg.conf.d/50-synaptics.conf

And the changes are put in there, accordingly like the other options, i.e.

    Option "TapButton1" "1"
    Option "TapButton2" "3"
    Option "TapButton3" "2"

All this in the config section that actually references your Trackpad.

bash for loops like in C
posted on 2014-11-03 13:50:31

To have 'counting' bash loops, try the following.

Directly in a shell:

[sjas@ctr-014 ~]% for (( i=0; i<5; i++ )); do echo $i; done
0
1
2
3
4
[sjas@ctr-014 ~]%

As a script:

#!/bin/bash

for (( i=0; i<5; i++ ))
do
    echo $i
done
dd progress bar
posted on 2014-11-03 13:48:27

To get a proper progess bar when using dd, try using pv. Maybe apt-get install'ing it is needed, if yes, just go ahead.

Usage shown on the example of copying an .iso onto an usb stick:

[sjas@ctr-014 ~/Downloads]% pv -tpreb CentOS-6.6-x86_64-minimal.iso | dd of=/dev/sdc
 383MB 0:04:09 [1.53MB/s] [========================================>] 100%
 784384+0 records in
 784384+0 records out
 401604608 bytes (402 MB) copied, 265.133 s, 1.5 MB/s
[sjas@ctr-014 ~/Downloads]%

Usually you don't see the second+ lines, and would have to wait 4 minutes until you see your copying was successful.

For small devices this is fine, but when copying whole disks this behaviour becomes VERY annoying.

Another utility would be bar:

bar -if=CentOS-6.6-x86_64-minimal.iso | dd of=/dev/sdc

Same principle as pv, handing it an inputfile and piping it to dd.

This blog covers .csv, .htaccess, .pfx, .vmx, /etc/crypttab, /etc/network/interfaces, /etc/sudoers, /proc, 10.04, 14.04, AS, ASA, ControlPanel, DS1054Z, GPT, HWR, Hyper-V, IPSEC, KVM, LSI, LVM, LXC, MBR, MTU, MegaCli, PHP, PKI, R, RAID, S.M.A.R.T., SNMP, SSD, SSL, TLS, TRIM, VEEAM, VMware, VServer, VirtualBox, Virtuozzo, XenServer, acpi, adaptec, algorithm, ansible, apache, apachebench, apple, arcconf, arch, architecture, areca, arping, asa, asdm, awk, backup, bandit, bar, bash, benchmarking, binding, bitrate, blackarmor, blowfish, bochs, bond, bonding, booknotes, bootable, bsd, btrfs, buffer, c-states, cache, caching, ccl, centos, certificate, certtool, cgdisk, cheatsheet, chrome, chroot, cisco, clamav, cli, clp, clush, cluster, coleslaw, colorscheme, common lisp, console, container, containers, controller, cron, cryptsetup, csync2, cu, cups, cygwin, d-states, database, date, db2, dcfldd, dcim, dd, debian, debug, debugger, debugging, decimal, desktop, df, dhclient, dhcp, diff, dig, display manager, dm-crypt, dmesg, dmidecode, dns, docker, dos, drivers, dtrace, dtrace4linux, du, dynamictracing, e2fsck, eBPF, ebook, efi, egrep, emacs, encoding, env, error, ess, esx, esxcli, esxi, ethtool, evil, expect, exportfs, factory reset, factory_reset, factoryreset, fail2ban, fbsd, fedora, file, filesystem, find, fio, firewall, firmware, fish, flashrom, forensics, free, freebsd, freedos, fritzbox, fsck, fstrim, ftp, ftps, g-states, gentoo, ghostscript, git, git-filter-branch, github, gitolite, gnutls, gradle, grep, grml, grub, grub2, guacamole, hardware, haskell, hdd, hdparm, hellowor, hex, hexdump, history, howto, htop, htpasswd, http, httpd, https, i3, icmp, ifenslave, iftop, iis, imagemagick, imap, imaps, init, innoDB, innodb, inodes, intel, ioncube, ios, iostat, ip, iperf, iphone, ipmi, ipmitool, iproute2, ipsec, iptables, ipv6, irc, irssi, iw, iwconfig, iwlist, iwlwifi, jailbreak, jails, java, javascript, javaws, js, juniper, junit, kali, kde, kemp, kernel, keyremap, kill, kpartx, krypton, lacp, lamp, languages, ldap, ldapsearch, less, leviathan, liero, lightning, links, linux, linuxin3months, lisp, list, livedisk, lmctfy, loadbalancing, locale, log, logrotate, looback, loopback, losetup, lsblk, lsi, lsof, lsusb, lsyncd, luks, lvextend, lvm, lvm2, lvreduce, lxc, lxde, macbook, macro, magento, mailclient, mailing, mailq, manpages, markdown, mbr, mdadm, megacli, micro sd, microsoft, minicom, mkfs, mktemp, mod_pagespeed, mod_proxy, modbus, modprobe, mount, mouse, movement, mpstat, multitasking, myISAM, mysql, mysql 5.7, mysql workbench, mysqlcheck, mysqldump, nagios, nas, nat, nc, netfilter, networking, nfs, nginx, nmap, nocaps, nodejs, numberingsystem, numbers, od, onyx, opcode-cache, openVZ, openlierox, openssl, openvpn, openvswitch, openwrt, oracle linux, org-mode, os, oscilloscope, overview, parallel, parameter expansion, parted, partitioning, passwd, patch, pdf, performance, pfsense, php, php7, phpmyadmin, pi, pidgin, pidstat, pins, pkill, plesk, plugin, posix, postfix, postfixadmin, postgres, postgresql, poudriere, powershell, preview, profiling, prompt, proxmox, ps, puppet, pv, pvecm, pvresize, python, qemu, qemu-img, qm, qmrestore, quicklisp, r, racktables, raid, raspberry pi, raspberrypi, raspbian, rbpi, rdp, redhat, redirect, registry, requirements, resize2fs, rewrite, rewrites, rhel, rigol, roccat, routing, rs0485, rs232, rsync, s-states, s_client, samba, sar, sata, sbcl, scite, scp, screen, scripting, seafile, seagate, security, sed, serial, serial port, setup, sftp, sg300, shell, shopware, shortcuts, showmount, signals, slattach, slip, slow-query-log, smbclient, snmpget, snmpwalk, software RAID, software raid, softwareraid, sophos, spacemacs, spam, specification, speedport, spi, sqlite, squid, ssd, ssh, ssh-add, sshd, ssl, stats, storage, strace, stronswan, su, submodules, subzone, sudo, sudoers, sup, swaks, swap, switch, switching, synaptics, synergy, sysfs, systemd, systemtap, tar, tcpdump, tcsh, tee, telnet, terminal, terminator, testdisk, testing, throughput, tmux, todo, tomcat, top, tput, trafficshaping, ttl, tuning, tunnel, tunneling, typo3, uboot, ubuntu, ubuntu 16.04, udev, uefi, ulimit, uname, unetbootin, unit testing, upstart, uptime, usb, usbstick, utf8, utm, utm 220, ux305, vcs, vgchange, vim, vimdiff, virtualbox, virtualization, visual studio code, vlan, vmstat, vmware, vnc, vncviewer, voltage, vpn, vsphere, vzdump, w, w701, wakeonlan, wargames, web, webdav, weechat, wget, whois, wicd, wifi, windowmanager, windows, wine, wireshark, wpa, wpa_passphrase, wpa_supplicant, x2x, xfce, xfreerdp, xmodem, xterm, xxd, yum, zones, zsh

View posts from 2017-03, 2017-02, 2017-01, 2016-12, 2016-11, 2016-10, 2016-09, 2016-08, 2016-07, 2016-06, 2016-05, 2016-04, 2016-03, 2016-02, 2016-01, 2015-12, 2015-11, 2015-10, 2015-09, 2015-08, 2015-07, 2015-06, 2015-05, 2015-04, 2015-03, 2015-02, 2015-01, 2014-12, 2014-11, 2014-10, 2014-09, 2014-08, 2014-07, 2014-06, 2014-05, 2014-04, 2014-03, 2014-01, 2013-12, 2013-11, 2013-10


Unless otherwise credited all material Creative Commons License by sjas