How ‘show full processlist’ in postgres?

February 6th, 2014

postgres=# SELECT * from pg_stat_activity ;
Отменить/убить запрос можно:
SELECT pg_cancel_backend(pid of the postgres process);

How to delete saved passwords for network drives in Windows

February 6th, 2014

If you saved a password for a network drive in windows and want to remove it, press the keys [Windows] + [R] to open the windows command line. Then enter
control keymgr.dll
This procedure works for Windows XP, Vista and Windows 7.
Источник

NVRAM reset for the HP LaserJet 400 colorMFP M475dn

February 6th, 2014

Finally got a viable response from HP!
NVRAM reset for the HP LaserJet 400 colorMFP M475dn (Confirmed functional)

1: Print configuration page before beginning reset
2: Disconnect all cables except for power
3: While printer is in ready state, note the position of “Ready” message
on the screen (Probably bottom right)
4: Power off the printer via power button
5: Touch the location on the screen where “Ready” message appeared.
6: while touching the screen, power on the printer. Continue to hold the
screen.
7: When “Memory Limit Reached” message appears, release the screen.
8: Printer will reboot, clean and calibrate
9: Return cables to their appropriate ports
10: Print configuration page to confirm settings are cleared. Restore
settings desired manually.

Finally have access back!
Источник

GET HDD serial number from Freebsd

July 8th, 2013

smartctl -a /dev/ad4

RAMDisk Freebsd 8

June 10th, 2011

#mdmfs -s 4G md10 /mnt/ramdisk

Mustek BearPaw 1200 CU Plus

June 6th, 2011

drivers for vista and windows 7 link

sourse: http://mustekdriver.murashkin.biz/load/2-1-0-1

Не удаляемые файлы.

April 15th, 2011

Как защитит наиболее важные файлы от случайного удаления или изменения (так что бы даже root не смог их удалить)?

The chflags utility modifies the file flags of the listed files as specified by the flags operand.FreeBSD offers write protection, you need to to set special bit call immutable. Once this bit is setup no one can delete or modify file including root. And only root can clear the File immutable bit.

You must be a root user to setup or clear the immutable bit.
Setup file immutable bit

Use chflags command as follows:
[sourcecode language=”bash”]# chflags schg /tmp/test.doc[/sourcecode]
Try to remove or moify file file with rm or vi:
[sourcecode language=”bash”]# rm -f /tmp/test.doc[/sourcecode]
Output:
[sourcecode language=”bash”]rm: /tmp/test.doc: Operation not permitted[/sourcecode]
Now root user is not allowed to remove or modify file. This is useful to protect important file such as /etc/passwd, /etc/master.passwd etc.
Display if file immutable bit is on or off
[sourcecode language=”bash”]ls -lo /tmp/test.doc
-rw-r–r– 1 root wheel schg 19 Jun 29 22:22 /tmp/test.doc[/sourcecode]
Clear or remove file immutable bit
[sourcecode language=”bash”]#chflags noschg /tmp/test.doc[/sourcecode]
Now you can remove or modify file. Please note that immutable flag can be set by root user only. chflags also supports few other interesting flags.

* arch: set the archived flag
* nodump: set the nodump flag
* sappnd: set the system append-only flag
* schg: set the system immutable flag
* sunlnk: set the system undeletable flag
* uappnd: set the user append-only flag
* uchg: set the user immutable flag
* uunlnk: set the user undeletable flag

Putting the letters no before an option causes the flag to be turned off.

Please note Linux also supports immutable flag to write protect files using chattr command.

See man page chflags and ls commands for more information.

Want to stay up to date with the latest Linux tips, news and announcements? Subscribe to our free e-mail newsletter or full RSS feed to get all updates. You can Email this page to a friend.

———————————————————–

Protect harddisk-based backup from accidental removal

If you store a backup on hard disk, the risk of rm -rf does exists.

Use chattr command changes the file attributes on a Linux second extended file system so that you will stay away from accidentally removing your backup files with rm -rf.

chattr command write protect the backup directory so that no one can delete it (including root). This is also known as making file immutable. For example your backup directory is /backup, type the following command to write protect directory /backup (only root can set or remove these flags):
[sourcecode language=”bash”]# chattr -R +i /backup[/sourcecode]
To remove immutable flag, type the following command:
[sourcecode language=”bash”]# chattr -R -i /backup[/sourcecode]
If you are using FreeBSD use chflags command to setup immutable flag:
[sourcecode language=”bash”]# chflags -R schg /backup[/sourcecode]
To remove immutable flag, type the following command:
[sourcecode language=”bash”]# chflags -R noschg /backup[/sourcecode]
These commands will keep you from accidentally removing your backup files with rm -rf 😀

перенос /usr или /var с / на другой диск/радел

April 15th, 2011

[sourcecode language=”bash”]cd /usr
tar -cvf /user/usr.tar .
cd /user
tar -xvpf ./usr.tar[/sourcecode]

change MAC on link freebsd

April 15th, 2011

добавляем в /etc/rc.conf
[sourcecode language=”bash”]ifconfig_em0="inet 192.168.1.1 netmask 255.255.255.0"
ifconfig_em0_alias0="link 00:12:34:56:78:90"[/sourcecode]

exim frozen message

April 7th, 2011

Sometimes there can be so many frozen mails in the Exim mail queue.
To know the number of frozen mails in the mail queue, you can use the following command
[sourcecode language=”bash”]exim -bpr | grep frozen | wc -l[/sourcecode]
In order to remove all frozen mails from the Exim mail queue, use the following command
[sourcecode language=”bash”]exim -bpr | grep frozen | awk {‘print $3’} | xargs exim -Mrm[/sourcecode]
You can also use the command given below to delete all frozen mails
[sourcecode language=”bash”]exiqgrep -z -i | xargs exim -Mrm[/sourcecode]
If you want to only delete frozen messages older than a day, you can try the following
[sourcecode language=”bash”]exiqgrep -zi -o 86400[/sourcecode]
where you can change the value 86400 depending on the time frame you want to keep (1 day = 86400 seconds).
source