Monday, February 14, 2011

chgrp linux command


The chgrp command is used to change the group that has access to files and directories. All files in linux belong to an owner, and a group. The owner is set by the chown command, and the group by the chgrp command.
Syntax:
chgrp newgroup filename(s) [-options]
Options :
       -c, --changes
              like verbose but report only when a change is made
       --dereference
              affect the referent of each symbolic link, rather than the symbolic link itself (this is the default)
       -h, --no-dereference
              affect each symbolic link instead of any referenced file (useful only on systems that can change the ownership of a symlink)
       --no-preserve-root do not treat '/' specially (the default)
       --preserve-root
              fail to operate recursively on '/'
       -f, --silent, --quiet
              suppress most error messages
       --reference=RFILE
              use RFILE's group rather than the specifying GROUP value
       -R, --recursive
              operate on files and directories recursively
       -v, --verbose
              output a diagnostic for every file processed
       The  following  options modify how a hierarchy is traversed when the -R option is also specified.  If more than one is specified, only the final
       one takes effect.
       -H     if a command line argument is a symbolic link to a directory, traverse it
       -L     traverse every symbolic link to a directory encountered
       -P     do not traverse any symbolic links (default)
       --help display this help and exit
       --version
              output version information and exit
Examples:
       1) chgrp tech /file.txt
              Change the group of /file.txt to "tech".
       2) chgrp -hR tech /file.txt
              Change the group of /file.txt and subfiles to "tech".


      

cat linux command

The cat command's primary function is to concatenate, or join, files, but you can also use it to display a file on the screen. The cat command takes one or more files that you specify, smashes them together, and then sends the resulting file to the standard output device (without changing any of the original files). The standard output device is your screen, but by using the greater-than (>) operator, you can redirect cat's output to another file. 


Syntax :


cat [option] [file name]


Options :
      -A, --show-all
              equivalent to -vET


       -b, --number-nonblank
              number nonblank output lines


       -e     equivalent to -vE


       -E, --show-ends
              display $ at end of each line


       -n, --number
              number all output lines


       -s, --squeeze-blank
              never more than one single blank line


       -t     equivalent to -vT


       -T, --show-tabs
              display TAB characters as ^I


       -u     (ignored)


       -v, --show-nonprinting
              use ^ and M- notation, except for LFD and TAB


       --help display this help and exit


       --version
              output version information and exit



Examples:



cat test.txt
Display the test.txt file on the screen.

cat test1.txt test2.txt
Join the files test1.txt and test2.txt and then displayt he result on the screen.

cat test1.txt test2.txt > test3.txt
Join the files test1.txt and test2.txt and save them in the file test3.txt.


what is port scan

A port scan is a series of messages sent by someone attempting to break into a computer to learn which computer network services. Essentially, a port scan consists of sending a message to each port, one at a time. The kind of response received indicates whether the port is used and can therefore be probed for weakness.



Types of port scans include:
  • vanilla - An attempt to connect to all ports (there are 65,536)
  • Strobe - An attempt to connect to only selected ports (typically, under 20)
  • Stealth scan - Several techniques for scanning that attempt to prevent the request for connection being logged
  • FTP Bounce Scan - Attempts that are directed through an File Transfer Protocol server to disguise the cracker's location
  • Fragmented Packets - Scans by sending packet fragments that can get through simple packet filters in a firewall
  • UDP - Scans for open User Datagram Protocol ports
  • Sweep - Scans the same port on a number of computers

cal linux command

Cal command displays a simple calendar.  If arguments are not specified, the current month is displayed.



Syntax :


     cal [options] [[month] year]


cal Options :


     The options of cal command are as follows:


     -1      Display single month output.  (This is the default.)


     -3      Display previous, current and next month output.


     -s      Display Sunday as the first day of the week.  (This is the default.)


     -m      Display Monday as the first day of the week.


     -j      Display Julian dates (days one-based, numbered from January 1).


     -y      Display a calendar for the current year.


Examples :


1) cal 2012
This example gives the calendar of the year 2012.
2) cal -3 9 2011
This example gives an output calendar of one month before and after September 2011.
3) cal 6 2011
It will gives the calender of june 2011.

Wednesday, February 2, 2011

bc linux command

You may be using bc command in command line for calculations. It can also be used for batch mode calculations as explained below.


Syntax
bc [-c] [-l] [file]




To perform addition using bc command

echo "56.8 + 77.7" | bc




Another way of executing bc calculation

bc <<< 4+2




Let say you want to convert decimal to hexadecimal, you can do this.
echo "obase=16; ibase=10; 56" | bc




A simply way to do calculation with floating point
echo 2/5 | bc -l