The linux admins one useful command called Screen in Linux

screen

Screen command offers the ability to detach a long running process (or program, or shell-script) from a session and then attach it back at a later time.

When the session is detached, the process that was originally started from the screen is still running and managed by the screen. You can then re-attach the session at a later time, and your terminals are still there, the way you left them.

In this article, let us review the how to manage the virtual terminal sessions using screen command with examples.

Screen Command Example 1: Execute a command (or shell-script), and detach the screen

Typically you’ll execute a command or shell-script as shown below from the command.

$ unix-command-to-be-executed

$ ./unix-shell-script-to-be-executed

Instead, use the screen command as shown below.

$ screen unix-command-to-be-executed

$ screen ./unix-shell-script-to-be-executed

Once you’ve used the screen command, you can detach it from the terminal using any one of the following method.

Screen Detach Method 1: Detach the screen using CTRL+A d

When the command is executing, press CTRL+A followed by d to detach the screen.

Screen Detach Method 2: Detach the screen using -d option

When the command is running in another terminal, type the command as following.

$ screen -d SCREENID

Screen Command Example 2: List all the running screen processes

You can list all the running screen processes using screen -ls command.

For example:

On terminal 1 you did the following:

$ screen ./myscript.sh

From terminal 2 you can view the list of all screen processes. You can also detach it from terminal 2 as shown below.

$ screen -ls
There is a screen on:
	4491.pts-2.FC547	(Attached)
1 Socket in /var/run/screen/S-sathiya.

$ screen -d 4491.pts-2.FC547
[4491.pts-2.FC547 detached.]

Screen Command Example 3: Attach the Screen when required

You can attach the screen at anytime by specifying the screen id as shown below. You can get the screen id from the “screen -ls” command output.

$ screen -r 4491.pts-2.FC547

Screen Command Usage Scenario 1

When you have access to only one terminal, you can use screen command to multiplex the single terminal into multiple, and execute several commands. You might also find it very useful to combine the usage of screen command along with the usage of SSH ControlMaster.

Screen Command Usage Scenario 2

When you are working in a team environment, you might walk over to your colleagues desk and get few things clarified. At that time, if needed, you can even start some process from their machine using screen command and detach it when you are done. Later when you get back to your desk, you can login and attach the screen back to your terminal.

 source/reference

How to Invoke Script made using Bash

Invoking bash

So you made your script. Now you need to test it by running it. You can invoke it by sh <scriptname>, or alternatively bash <scriptname>.(Not recommended is using sh <scriptname>, since this effectively disables reading from stdin within the script.) Much more convenient is to make the script itself directly executable with a chmod.
Either:

chmod 555 scriptname

(gives everyone read/execute permission)

or

chmod +rx scriptname

(gives everyone read/execute permission)

 or

chmod u+rx scriptname

(gives only the script owner read/execute permission)

 

Having made the script executable, you may now test it by ./scriptname.  If it begins with a “sha−bang” line, invoking the script calls the correct command interpreter to run it.

As a final step, after testing and debugging, you would likely want to move it to /usr/local/bin (as root,of course), to make the script available to yourself and all other users as a system−wide executable. The script could then be invoked by simply typing scriptname[ENTER] from the command line.

How to connect Samsung Galaxy S4 to windows phone

Samsung Galaxy S4

I am not new using Android phones, in fact Samsung Galaxy S4 is the 3rd Android phone I have. I had Galaxy Note 1 and 2 before and backing up the photos and videos is just a piece of cake(Just plug the thing on your pc and then it will automatically detect it and connect as a normal USB device) . Now I’ve got my S4 and run out of memory I needed to backup my photos and videos before freeing up space, I was surprised. When I plugged it on my pc, it was not even get detected, I tried using 5 different USB’s and none of them connected my S4 to the PC. I searched the net and found one that helped me connect android phone to pc and this is how.

The Samsung Galaxy S4 is a monster smartphone. I will quickly walk you through how to connect your Samsung Galaxy S4 to a PC and transfer data between both devices.Once connectivity is achieved, you can transfer files using the interface of your operating system. In Windows, you can find the device listed as removable disk under Computer, while Mac users can find the device listed on the Finder.
 

KIES FOR ANDROID PHONES

KIES FOR ANDROID PHONES

Kies:
This is a graphical user interface that allows for transfer of music, photos, and videos between your Samsung Galaxy S4 and your PC. To download this App, for Windows or Mac, visit the Samsung website.

File Format Supported By Samsung Galaxy S4: The Galaxy S4 supports audio files in WAV, MP3, AAC, AAC+, eAAC+, AMR-NB, AMR-WB, MIDI, XMF, EVRC, QCELP, WMA, FLAC, OGG formats and video files in Divx, H.263, H.264, MPEG4, VP8, VC–1 (Format: 3gp, 3g2, mp4, wmv.

3 Easy Steps To Connect Samsung Galaxy S4 To PC

 

kies

1. If you are a Windows user, simply download and install the USB drivers for the Galaxy S4. Mac users do not need to install any software.

2. Connect the device to an available USB port using any generic USB cable.

Drag
3. A prompt will appear on the screen of the phone. Drag the notification area down, and make a selection of your choice. That’s it. Have a happy time backing up your phone.

ASCII – Special Characters – Alt Keyboard Shortcuts

extend
ASCII

To type a special character, using an Alt keyboard sequence

1. Make sure that the Num Lock key has been pressed, to activate the numeric key section of the keyboard.

2. Press and hold down the Alt key.                        3. While the Alt key is pressed, type the sequence of numbers (on the numeric keypad) from the Alt code in the above table.

4. Release the Alt key, and the character will appear.

Some sequence from the above table skipped since no symbol representation or duplicate symbol.

How to Install memcached in Centos 6

memcached

I was building a website of my own and was onmy testing phase when I noticed its a little bit slow. It might be because i have too many graphics loading and heavy database when doing some searching. I searched Google ways to speed up websites and i found out about memcached and found some article on how to install the said application. I tried it and I noticed a big difference on my website’s performance.

MEMCACHED DEFINITION

Memcached is a distributed, high-performance, in-memory caching system that is primarily used to speed up sites that make heavy use of databases. It can however be used to store objects of any kind. Nearly every popular CMS has a plugin or module to take advantage of memcached, and many programming languages have a memcached library, including PHP, Perl, Ruby, and Python. Memcached runs in-memory and is thus quite speedy, since it does not need

to write to disk.

Here’s how to install it on CentOS 6:

Memcached does have some dependencies that need to be in place. Install libevent using yum:

yum install libevent libevent-devel

The memcached install itself starts with

To start installing memcached, change your working directory to /usr/local/src and download the latest memcached source:

cd /usr/local/src 
wget http://memcached.googlecode.com/files/memcached-1.4.15.tar.gz

Uncompress the tarball you downloaded and change into the directory that is created:

tar xvzf memcached-1.4.15.tar.gz
cd memcached-1.4.15

Note:

Check memcached.org for a newer version before proceeding with the installation. Their might be newer version existing after the publication of this post. Please note the tarball version we are using is 1.4.15.

Next, configure your Makefile. The simplest way is to run:

./configure

Additional configure flags are available and can improve performance if your server is capable. For 64-bit OSes, you can enable memcached to utilize a larger memory allocation than is possible with 32-bit OSes:

./configure --enable-64bit

If your server has multiple CPUs or uses multi-core CPUs, enable threading:

./configure --enable-threads

If your server supports it, you can use both flags:

./configure --enable-threads --enable-64bit

n.b.: if the configure script does not run, you may have to install compiling tools on your server. That is as simple as

yum install gcc
yum install make

Once the configure script completes, build and install memcached:

make && make install

Last but not least, start a memcached server:

memcached -d -u nobody -m 512 -p 11211 127.0.0.1

Put another way, the previous command can be laid out like this:

memcached -d -u [user] -m [memory size] -p [port] [listening IP]

Let’s go over what each switch does in the above command:

-d
Tell memcached to start up as a backgrounded daemon process
-u
Specify the user that you want to run memcached
-m
Set the memory that you want to be allocated my memcached
-p
The port on which memcached will listen.

Now your site is ready for a fast run literally.

Resources:

http://memcached.org/

http://www.liquidweb.com/kb/how-to-install-memcached-on-centos-6/

How to flush memory in windows without rebooting!

sluggish windows

When your computer is being sluggish,  you need to free up ram by flushing it. The usual way is to reboot, but try this first before rebooting.

In Windows:
Click on the “Start” button.
Select “Run”
Type the following and press “OK”

 %windir%\system32\rundll32.exe advapi32.dll,ProcessIdleTasks

This should clear your ram without rebooting.