Categories
SecOps SysOps

How to check established TCP connections

Display established TCP connections inside the terminal.

Categories
Uncategorized

How to force sudo to forget password

When you want to leave terminal open but force sudo to forget password then enter command:

$ sudo -K
Categories
Uncategorized

How to use sudo from within Vim to save file

It is very annoying to see message “E212: Can’t open file for writing” when trying to save file.

Hopefully there is a simple solution (a bit longer but without “W12 Warning“):

:execute ':w !sudo tee % > /dev/null' | :edit!

Look at commandlinefu.com for more solutions like :W command below:

:command W :execute ':silent w !sudo tee % > /dev/null' | :edit!
Categories
Uncategorized

Secure personal data management

I tend to forget passwords from time to time so I installed KeePassX today. Now I can store them in one place, organize and perform auto type.

Categories
Uncategorized

CentOS 6.2, phpMyAdmin, Apache 2.2 – Segmentation fault (11)

Today I installed phpMyAdmin on fresh CentOS 6.2 (with EPEL repository) and it was not working. Looking at Apache logs revealed only notice:

[notice] child pid 41292 exit signal Segmentation fault (11)

My Apache and PHP versions:

$ httpd -v
Server version: Apache/2.2.15 (Unix)
Server built:   Dec  8 2011 18:07:26
$ php -v
PHP 5.3.3 (cli) (built: Jan 11 2012 19:30:40)
Copyright (c) 1997-2010 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies

The problem was with eAccelerator PHP module.

There are two simple solutions. First requires to edit /etc/php.d/eaccelerator.ini file and comment out one line:

extension="eaccelerator.so"

Second is to remove eAccelerator PHP module:

# rpm -e php-eaccelerator

Don’t forget to restart Apache.

Categories
Uncategorized

Audible ping

If you don’t look at console output and want to hear that host is reachable then just add -a parameter to ping command (Linux).

$ ping -V
ping utility, iputils-sss20101006
$ ping -a 8.8.8.8
PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.
64 bytes from 8.8.8.8: icmp_req=1 ttl=44 time=38.9 ms (beep)
64 bytes from 8.8.8.8: icmp_req=2 ttl=44 time=39.3 ms (beep)
64 bytes from 8.8.8.8: icmp_req=3 ttl=44 time=39.0 ms (beep)
^C
--- 8.8.8.8 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2003ms
rtt min/avg/max/mdev = 38.997/39.138/39.346/0.273 ms
Categories
Uncategorized

How to access Ubiquiti Beta Program

Ubiquiti Beta Program provides access to beta versions of AirOS releases.

Categories
Uncategorized

How to count files or directories

For this example I will use such tree:

.
├── dir1/
│   ├── dir6/
│   ├── dir7/
│   ├── dir8/
│   ├── file4
│   └── file5
├── dir2/
│   └── dir9/
│       ├── dir10/
│       │   ├── file9
│       │   └── file10
│       ├── file6
│       ├── file7
│       └── file8
├── dir3/
├── dir4/
├── dir5/
├── file1
├── file2
└── file3

List of all files and directories:

$ find . | sort | grep -v ^.$
./dir1
./dir1/dir6
./dir1/dir7
./dir1/dir8
./dir1/file4
./dir1/file5
./dir2
./dir2/dir9
./dir2/dir9/dir10
./dir2/dir9/dir10/file9
./dir2/dir9/dir10/file10
./dir2/dir9/file6
./dir2/dir9/file7
./dir2/dir9/file8
./dir3
./dir4
./dir5
./file1
./file2
./file3

Number of all files and directories:

$ find . | grep -v ^.$ | wc -l
20

List of all directories:

$ find . -type d | grep -v ^.$
./dir3
./dir5
./dir1
./dir1/dir6
./dir1/dir8
./dir1/dir7
./dir2
./dir2/dir9
./dir2/dir9/dir10
./dir4

Count of all directories:

$ find . -type d | grep -v ^.$ |wc -l
10

List of subdirectories in current directory:

$ find . -maxdepth 1 -type d | sort | grep -v ^.$
./dir1
./dir2
./dir3
./dir4
./dir5

Count of subdirectories in current directory:

$ find . -maxdepth 1 -type d | grep -v ^.$ | wc -l
5

List of all files:

$ find . -type f | sort
./dir1/file4
./dir1/file5
./dir2/dir9/dir10/file9
./dir2/dir9/dir10/file10
./dir2/dir9/file6
./dir2/dir9/file7
./dir2/dir9/file8
./file1
./file2
./file3

Count of all files:

$ find . -type f | wc -l
10

List of files only in current directory:

$ find . -maxdepth 1 -type f | sort
./file1
./file2
./file3

Count of files only in current directory:

$ find . -maxdepth 1 -type f | wc -l
3
Categories
Uncategorized

Redshift – adjust the color temperature of your screen

Recently I started using Redshift. It is small application that changes color temperature of your screen. It is really good idea as eyes don’t get tired so quickly at night.

Categories
Uncategorized

How to create live Linux USB using Windows

Download and run Universal USB Installer as it offers wide range of Linux distributions and easy automatic process.