Feeds:
Posts
Comments

Posts Tagged ‘linux command’

Screen, this command might not be well known to many people but but its one of those programs that you just can’t stop using once you’ve started. Previously I used VNC to connect the remote servers, but now i have stopped using VNC. Now I am using SCREEN on a regular daily basis and it’s really easy to use.

Screen program provides the following functionality:

  • Remote terminal session management (detaching or sharing terminal sessions)
  • Unlimited windows (unlike the hardcoded number of Linux virtual consoles)
  • Scrollback buffer (not limited to video memory like Linux virtual consoles)
  • Copy/paste between windows
  • Split terminal (horizontally) into multiple regions
  • Locking other users out of terminal
  • Screen is an easy way to allow processes to continue running after the session is terminated, if you lose connection screen will save your spot

Following is the content of my ~/.screenrc file
************************************************************
startup_message off
vbell off
caption always “%{= bb}%{+b w}%n %h %=%t %c”
hardstatus alwayslastline “%-Lw%{= BW}%50>%n%f* %t%{-}%+Lw%<”
activity “Activity in %t(%n)”
shell -/bin/bash
************************************************************
Screen Commands

screen Start screen

screen -x Connect to an existing screen session

screen -d detaching a screen session

screen -r reattaching the screen session

Ctrl+a c New window

Ctrl+a n Next Window

Ctrl+a p Previous Window

Ctrl+a ” Select window from list

Ctrl+a Ctrl+a Previous window viewed

Ctrl+a <0-9> Select the numbered window

Ctrl+a A Set window title

Ctrl+a K Kill window

Ctrl+a d Detach screen from terminal

Ctrl+a x Lock Session

Ctrl+a : Goto screen command prompt

Ctrl+a ? Show key binding/command names

Ctrl+s Pause the output on screen

Ctrl+q Resume the output on screen

Advertisements

Read Full Post »

Linux Cut command

Cut Command
————

Divide a file into several parts (columns)

syntax:
cut [-b] [-c] [-f] list [-n] [-d delim] [-s] [file]

Examples:
——–

1. Let say you have a file test.txt which has colon(:) seperated data

406378:Sales:Itorre:Jan
031762:Marketing:Nasium:Jim
636496:Research:Ancholie:Mel
396082:Sales:Jucacion:Ed

If you want to print first set of data from each row, you can use cut command as follow:

cut -d”:” -f1 test.txt

If you want to print just columns 1 to 6 of each line (the employee serial numbers), use the -c1-6 flag, as in this command

cut -c1-6 test.txt

Read Full Post »

Linux Tips

Display the top most process utilizing most CPU (top -b 1)
Show the working directory of a process ? (pwdx pid )
Display the parent/child tree of a process ? (ptree pid )
Display the no.of active established connections to localhost ? (netstat -a | grep EST)
How to create null file ? (cat /dev/null > filename1)
Display top ten largest files/directories ? (du -sk * | sort -nr | head)
Display disk usage (du -h)
How to save man pages to a file ? (man | col -b > filename )
Display the files in the directory by file size ? (ls -ltr | sort -nr -k 5)
Display the processes, which are running under yourusername ( ps -aef | grep username)
Display the all files recursively with path under current directory ? ( find . -depth -print)
Display the Disk Usage of file sizes under each directory in currentDirectory ? (du -k . | sort -nr)
List the files in current directory sorted by size ? (ls -l | grep ^- | sort -nr)

Read Full Post »

There are some variables which are set internally by the shell and which are available to the user:

$1 - $9   These variables are the positional parameters.
$0        The name of the command currently being executed.
$#        The number of positional arguments given to this invocation of the shell.
$?        The exit status of the last command executed is given as a decimal string.        When a command completes successfully, it returns the exit status of 0        (zero), otherwise it returns a non-zero exit status.
$$        The process number of this shell - useful for including in filenames, to        make them unique.
$!        The process id of the last command run in the background.
$-        The current options supplied to this invocation of the shell.
$*        A string containing all the arguments to the shell, starting at $1.
$@@       Same as above, except when quoted.

Read Full Post »