Friday, June 26, 2015

How to execute/run a command from remote server in Linux/Unix

How to execute/run a command from remote server in Linux/Unix
==================================================

Syntax: 
ssh username_of_remote_server@remote_hostname/remote_hostipaddr -- <Command to execute on remote server>

ssh root@192.168.1.11 -- /sbin/ifconfig -a

How to display/list only folders/directories or only files in Linux/Unix (List all the zombie process & how to create alias)

Display/List only folders/directories or only files in Linux/Unix
===============================================

1) Display or list all directories in current location in Linux/Unix

Type the following command:

ls -ld */

ls -l | grep '^d'

ls -l | egrep '^d'

Display or list the hidden folder at current location, type the following command:

ls -ld .*/

ls -la | grep '^d'

ls -la | egrep '^d'

This command lists directories in the current path/folder: ls -d */

*/ is a pattern that matches all of the subfolders in the current folder (* would match all files and subfolders; the / restricts it to folders/directories). for e.g. to list all subfolders under /home/yogesh/, use ls -d /home/yogesh/*/


2) Display or list all files in current location in Linux/Unix

ls -l | grep -v '^d'

ls -l | egrep -v '^d'

ls -la | egrep -v '^d'


3) List all the directories at 1 Level depth in /etc including hidden folders with find command:

find /etc -maxdepth 1 -type d


4) You Can use find command to list either files or folders/directories:

The find command can be used as follows to list all directories in /etc

find /etc -type d

find /etc -type d -ls

find . -type d -ls


5) To list/see the zombie/defunct process in Linux/Unix:

pf -ef | grep -i defunct

ps -elf | grep -w Z


6) How to create alias to save the time:

alias lf="ls -ls | egrep -v '^d'"

alias ldir="ls -l | egrep '^d'"

TCP/UDP Protocols/Prots & important port numbers in Linux OS

TCP/UDP Protocols/Ports are ranging from 0-65535 so total we have 65536 ports & because of the limitation in TCP/IP stack where the por...