Thursday, September 27, 2018



üAutonomous 
üGoal-oriented 
üFlexible 
üAdaptive 
üCommunicative
üSelf-starting 

Wednesday, June 29, 2011

Computer Network Protocols

Computer Network Protocols

01. Transmission Control Protocol (TCP)

- The core protocols of the Internet Protocol Suite.

- TCP is one of the two original components of the suite, complementing the Internet Protocol (IP), and therefore the entire suite is commonly referred to as TCP/IP.

- TCP provides reliable, ordered delivery of a stream of bytes from a program on one computer to another program on another computer.

- TCP is the protocol that major Internet applications such as the World Wide Web, email, remote administration and file transfer rely on.

02. Internet Protocol (IP)

- The principal communications protocol used for relaying datagrams (packets) across an internetwork using the Internet Protocol Suite.

- Responsible for routing packets across network boundaries, it is the primary protocol that establishes the Internet.

- For this purpose, IP defines addressing methods and structures for datagram encapsulation.

- Historically, IP was the connectionless datagram service.

- Connection oriented - Transmission Control Protocol (TCP).

- The first major version - Internet Protocol (IPv4) and Internet Protocol (IPv6).

03. Hypertext Transfer Protocol (HTTP)

- Networking protocol for distributed, collaborative, hypermedia information systems.

Foundation of data communication for the World Wide Web.

04. File Transfer Protocol (FTP)

- Network protocol used to transfer files from one host to another over a TCP-based network, such as the Internet.

- FTP is built on client-server architecture and utilizes separate control and data connections between the client and server.

05. Dynamic Host Configuration Protocol (DHCP)

- Automatic configuration protocol used on IP networks.

- Computers that are connected to IP networks must be configured before they can communicate with other computers on the network.

- DHCP allows a computer to be configured automatically, eliminating the need for intervention by a network administrator.

- It also provides a central database for keeping track of computers that have been connected to the network. This prevents two computers from accidentally being configured with the same IP address.

06. Simple Mail Transfer Protocol (SMTP)

- Internet standard for electronic mail (e-mail) transmission across Internet Protocol (IP) networks.

- SMTP is specified for outgoing mail transport and uses TCP port 25.

- SMTP connections secured by SSL are known by the shorthand SMTPS.

07. Post Office Protocol (POP)

- Application-layer Internet standard protocol used by local e-mail clients to retrieve e-mail from a remote server over a TCP/IP connection.

- Like IMAP, POP3 is supported by most webmail services such as Hotmail, Gmail and Yahoo! Mail.

08. Internet message access protocol (IMAP)

- Internet standard protocols for e-mail retrieval.

09. Telnet

- Network protocol used on the Internet or local area networks to provide a bidirectional interactive text-oriented communications facility using a virtual terminal connection.

10. Point-to-Point Protocol (PPP)

- Protocol used in establishing a direct connection between two networking nodes.

- It can provide connection authentication, transmission encryption privacy, and compression.

- PPP is used over many types of physical networks including serial cable, phone line, trunk line, cellular telephone, etc.

- Most Internet service providers (ISPs) use PPP for customer dial-up access to the Internet.

Two encapsulated forms of PPP

- Point-to-Point Protocol over Ethernet (PPPoE)

- Point-to-Point Protocol over ATM (PPPoA) in Digital Subscriber Line (DSL).

11. Internet Control Message Protocol (ICMP)

- One of the core protocols of the Internet Protocol Suite.

- It is chiefly used by the operating systems of networked computers to send error messages indicating, for example, that a requested service is not available or that a host or router could not be reached.

- ICMP for Internet Protocol version 4 (IPv4) is also known as ICMPv4. IPv6 has a similar protocol, ICMPv6.

12. Address Resolution Protocol (ARP)

- Telecommunications protocol used for resolution of network layer addresses into link layer addresses during internetwork transmissions.

13. Reverse Address Resolution Protocol (RARP)

- Computer networking protocol used by a host computer to request its Internet Protocol (IPv4) address from an administrative host, when it has available its Link Layer or hardware address, such as a MAC address.

Linux apt-get software management

apt-get

apt-get is the command-line tool for handling packages for Debian Linux which is used to:

  • Install/manage individual packages
  • Upgrade packages
  • Apply security patch(s)
  • Keep Debian system up to date
  • Download source .deb files
  • Front-end to many GUI and other utilities

apt-get install {package} - Install the new package.

apt-get install zip
apt-get install lsof samba mysql-client

apt-get remove {package} - Remove/Delete an installed package except configuration files.

apt-get remove zip

apt-get --purge remove {package} - Remove/Delete everything including configuration files

apt-get --purge remove mysql-server

apt-get update
apt-get upgrade - Resynchronize the package index files and Upgrade the Debian Linux system including security update (Internet access required)

apt-get update
apt-get upgrade

apt-get update
apt-get dist-upgrade - Usually use to upgrade to Debian distribution. For example Woody to Sarge upgrade. 'dist-upgrade' in addition to performing the function of upgrade, also intelligently handles changing dependencies with new versions of packages; apt-get has a "smart" conflict resolution system, and it will attempt to upgrade the most important packages at the expense of less important ones if necessary.

apt-get update
apt-get dist-upgrade

Debian Linux apt-get package management

Both Debian and Ubuntu Linux provides a number of package management tools.

(1) apt-get : APT is acronym for Advanced Package Tool. It supports installing packages over internet (ftp or http). You can also upgrade all packages in single operations, which makes it even more attractive.

(2) dpkg : Debian packaging tool which can be use to install, query, uninstall packages.

(3) GUI tools:
You can also try GUI based or high level interface to the Debian GNU/Linux package system. Following list summaries them:
(1)
aptitude: It is a text-based interface to the Debian GNU/Linux package system.
(2)
synaptic: GUI front end for APT


apache_1.3.31-6_i386.deb

apache : Package name
1.3.31-6 : Version number
i386 : Hardware Platform on which this package will run (i386 == intel x86 based system)
.deb : Extension that suggest it is a Debian package

Remember whenever I refer .deb file it signifies complete file name, and whenever I refer package name it must be first part of .deb file. For example when I refer to package sudo it means sudo only and not the .deb file i.e. sudo_1.6.7p5-2_i386.deb. However do not worry you can find out complete debian package list with the following command:
apt-cache search {package-name}

apt-get add a new package

Add a new package called samba
Syntax: apt-get install {package-name}

# apt-get install samba

apt-get remove the package called samba but keep the configuration files

Syntax: apt-get remove {package-name}

# apt-get remove samba

apt-get remove (erase) package and configuration file

Syntax: apt-get --purge remove {package-name}

# apt-get --purge remove samba

apt-get Update (upgrade) package

Syntax: apt-get upgrade

To upgrade individual package called sudo, enter:
# apt-get install sudo

apt-get display available software updates

Following command will display the list of all available upgrades (updates) using -u option, if you decided to upgrade all of the shown packages just hit 'y'

# apt-get upgrade samba

However if you just wish to upgrade individual package then use apt-get command and it will take care of rest of your worries:
Syntax: apt-get install {package-name}

dpkg command to get package information such as description of package, version etc.

Syntax: dpkg --info {.deb-package-name}

# dpkg --info sudo_1.6.7p5-2_i386.deb | less

List all installed packages

Syntax: dpkg -l

# dpkg -l

To list individual package try such as apache

# dpkg -l apache

You can also use this command to see (verify) if package sudo is install or not (note that if package is installed then it displays package name along with small description):

# dpkg -l | grep -i 'sudo'

To list packages related to the apache:

# dpkg -l '*apache*'

List files provided (or owned) by the installed package (for example what files are provided by the installed samba package)
Syntax: dpkg -L {package-name}

# dpkg -L samba

(H) List files provided (or owned) by the package (for example what files are provided by the uninstalled sudo package)
Syntax: dpkg --contents {.deb-package-name}

# dpkg --contents sudo_1.6.7p5-2_i386.deb

Find, what package owns the file /bin/netstat?

Syntax: dpkg -S {/path/to/file}

# dpkg -S /bin/netstat

Search for package or package description

Some times you don’t know package name but aware of some keywords to search the package. Once you got package name you can install it using apt-get -i {package-name} command:
Syntax: apt-cache search "Text-to-search"

Find out all the Debian package which can be used for Intrusion Detection

# apt-cache search "Intrusion Detection"

Find out all sniffer packages

# apt-cache search sniffer

Find out if Debian package is installed or not (status)

Syntax: dpkg -s {package-name} | grep Status

# dpkg -s samba| grep Status

List ach dependency a package has...

Display a listing of each dependency a package has and all the possible other packages that can fulfill that dependency. You hardly use this command as apt-get does decent job fulfill all package dependencies.
Syntax: apt-cache depends package

Display dependencies for lsof and mysql-server packages:

# apt-cache depends lsof

# apt-cache depends mysql-server

Example uses of the Linux Command mount

The following examples illustrate typical uses of the command mount for attaching the file directory of a device or partition to the file directory tree of the Linux system.

mount /dev/fd0 /mnt/floppy

This command will connect the device "/dev/fd0" (usually the floopy drive) to the directory "/mnt/floppy" so that you can access the files and directories (folders) on the floppy disk in the floppy drive under the "/mnt/floppy" directory. The directory "/mnt/floppy" is also called the "mount point", which must already exist when this command is executed.

mount /dev/cdrom /mnt/cdrom

This command will connect the device "/dev/cdrom" (usually the CD ROM drive) to the directory "/mnt/cdrom" so that you can access the files and directories on the CD ROM disk in the CD ROM drive under the "/mnt/cdrom" directory, which must already exist when this command is executed.

umount /mnt/floppy

This command unmounts the floppy drive. After this command is executed the files and directories on the floppy will no longer be accessible from the directory tree of the Linux system.

umount /dev/fd0

This has the same effect as the previous command.

umount /mnt/cdrom

This command unmounts the CD ROM drive. After this command is executed the files and directories on the CD ROM will no longer be accessible from the directory tree of the Linux system.

umount /dev/cdrom

This has the same effect as the previous command.

The default mount points for the various devices are defined the file /etc/fstab. Some Linux distributions use a program called automount, which automatically mounts all the partitions and devices listed in /etc/fstab.

< How to mount filesystems in Linux - 1.1 >

Learn what is mounting and how to mount partitions and filesystems. You need to know how to mount if you want to, for example, access floppies or CD-ROMs or Windows partitions in Linux!

< What is mounting >

As you know, you can store your data in different physical storage devices, like floppies, CD-ROMs, and hard disk drives. Your hard disk or disks are also very likely split up into different partitions with different filesystems.

If you're migrating to Linux from Microsoft Windows, you're probably used to accessing all your filesystems very easily: you just boot up your puter, go to My Computer, and find all your Windows partitions there immediately. For example, if you have a second hard drive (or a second Windows partition), it automatically appears as D:\ and you can immediately access it. The same goes for floppies, CD-ROMs, digital cameras, and other storage devices - you just plug them in, and you'll be able to immediately access them. However, this isn't the case in Linux.

You're probably a bit confused at first: you put your floppy or CD into the drive and start wondering why you're not able to access it! This is because your floppies, CDs, hard disk partitions, and other storage devices must be attached to some existing directory on your system before they can be accessed. This attaching is called mounting, and the directory where the device is attached is called a mount point.

After the device is mounted, you can access the files on that device by accessing the directory where the device is attached. When you're done and want to remove the floppy or CD or other device, you need to detach, unmount, it before removing it.

$ mount /dev/fd0 /mnt/floppy

$ mount /mnt/floppy

$ umount /mnt/floppy
or
$ umount /dev/fd0

How to mount usb flash drives in linux.

First plug your usb card reader and to make sure your device was detected go to System Tools > Hardware Browser > enter root password and it will display your hardware information then go to > Hard Drives and it should be listed under /dev/sda.

Open your favorite terminal....btw this works in gnome and kde.

[imdeemvp@localhost imdeemvp]$ cd /mnt/ <-as user cd yourself to the mnt folder and become root to create directory
[imdeemvp@localhost mnt]$ su
Password:
[root@localhost mnt]# mkdir usbflash <- this created a directory in the mnt folder

[root@localhost mnt]# ls /mnt/ <-this command listed all my directories the mnt folder
cdrom cdrom1 floppy usbflash

[root@localhost mnt]# mount /dev/sda1 /mnt/usbflash <-this is the command to mount flash card reader

[root@localhost mnt]# ls usbflash <-this listed all the info in my usb flash card and this was the output:
bootex.log dns.bmp games and keys LinuxDocs01.21.04 pc's
dns2.bmp Documents LinuxDistributions_eBay my pics programs

then i just copied this to my home folder and i was done!

[root@localhost mnt]# umount /dev/sda1 /mnt/usbflash <-this unmounted my usb flash card
umount: /dev/sda1: not mounted
[root@localhost mnt]# exit
[imdeemvp@localhost mnt]$


THIS ALSO WORKED UNDER Mandrake 9.1, 9.2, and 10 official.

in terminal type as root: gedit /etc/fstab and NOW YOU CAN ADD THIS LINE TO FSTAB to auto mount it:

Code:
/dev/sda1 /mnt/usbflash vfat noauto,users,rw,umask=0 0 0

Checking running Process on the server. [ ps, pstree ]

ps
This command is used to check the process running on the server. " ps " command will list all the running process with there respective process ID.

Example:
root@server [~]$ ps
PID TTY TIME CMD
22438 pts/3 00:00:00 su
22439 pts/3 00:00:00 bash
22517 pts/3 00:00:00 ps

Use the following option to get more process information from the " ps " commands,
root@server [~]$ ps -aux

Also you can grep any particular process on the server.
root@server [~]$ ps -aux | grep exim

pstree
This command is also used the check the process on the server. " pstree " command will list all the running process in the form of a tree structure.

Example:
root@server [~]$ pstree

Load on a server [ top, w , uptime ]

top

This command is used to find the load on the server. " top " command can also be used to find the process and users that causes load on the server. It gives information about the total process, sleeping process, the zombie process etc.

Example:

root@server [~]$ top -cd3

w

This command is also find the load and users on the server. " w " command will provide a brief description about the load, time, number of users and the uptime of the server.

Example:

root@server [~]$ w w

This command is also find the load and users on the server. " w " command will provide a brief description about the load, time, number of users and the uptime of the server.

Example:

root@server [~]$ w

uptime

This command gives the basic information about the uptime and load of the server.

Example:

root@server [~]$ uptime

Killing process on a server [ kill, pkill, killall -9 ]

kill

This command is used to kill a running process on the server. You need to process id to execute the kill command. Consider you run " pstree -p " which will list all the process with its respective process id. To kill a particular process use the command " kill ".

Example:

root@server [~]$ kill 27209

or

root@server [~]$ kill -9 27209

The above command will kill the process id 27209.

pkill

This command will kill the child processes of a particular process. Consider you want kill httpd on the server.

Example:

root@server [~]$ pkill httpd

or

root@server [~]$ pkill -9 httpd

or

root@server [~]$ pkill -HUP httpd

The above command will only kill all the child process of " httpd ". Using this command the parent process will be running and all the child process will be killed.

killall

This command is used to kill all the processes ( parent process and child process ).

Example:

root@server [~]$ killall -9 httpd

Checking the number of connection's to the server [ netstat, mysqladmin processlist ]

netstat

This command is used to find the number of connections to the server. " netstat " command will list all the connections using httpd, exim, ftp etc. You can grep the needed port and find the number of connections to a particular port. You can find the Local Address, Foreign Address, State, port etc of all the connections.

Example:

root@server [~]$ netstat -plan

or

root@server [~]$ netstat -plan | grep ":80"

Blocking IP [ apf, csf ]

APF and CSF are firewall software’s.

You can use these commands to block a particular IP from connecting to the server. This command is mainly used when you find too many connections from a particular IP. Normally too many connection might be a attack to the server. So it is important to block such IP before it interrupts the balance of the server.

Check which firewall is installed on your server and use it accordingly.

Example:

root@server [~]$ apf -d

or

root@server [~]$ csf -d

Checking the port if open or not [ telnet, nmap ]

telnet

TELNET (TELecommunication NETwork) is a network protocol used on the Internet. TELNET is a client-server protocol, based on a reliable connection-oriented transport. This command will help us to find if a particular port on the server is open or not.

Example:

root@server [~]$ telnet google.com 80

Linux System Commands





Command

cal

Purpose

Displays a calendar

Synopsis

cal [-mjy] [month [year]]



Description:

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


Options:

-m

Display Monday as the first day of the week.

-j

Display julian dates (clays one-based, numbered from January 1).

-y

Display a calendar for the current year.


A single parameter specifies the year (1 - 9999) to be displayed; note the year must be fully specified: "cal 89" will not display a calendar for 1989. Two parameters denote the month (1 -12) and year. If no parameters are specified, the current month's calendar is displayed.

Command

date

Purpose

Print or set system date and time

Synopsis

date [OPTION]... [+FORMAT]



Description:

The date command with no arguments prints the current time and date, in the format of the %c directive (described below).



Options:

-d

Print date in the format d days or m months d days

-s

Set date

-u

Set date to GMT

Command

du

Purpose

Estimate file space usage

Synopsis

du [OPTION] ... [FILE] ...



Description:

The du command reports the amount of disk space used by the specified files and for each subdirectory (of directory arguments).


With no arguments, du reports the disk space for the current directory. Normally the disk space is printed in units of 1024 bytes.


Options:

-a

Show counts for all files, not just directories.

-b

Print sizes in bytes, overriding the default block size.

-c

Print a grand total of all arguments after all arguments have been processed. This can be used to find out the total disk usage of a given set of files or directories.

-h

Append a size letter such as 'M' for megabytes to each size. Powers of 1024 are used, not 1000; 'M' stands for 1,048,576 bytes.

-k

Print sizes in 1024-byte blocks, overriding the default block size

-m

Print sizes in megabyte (that is, 1,048,576-byte) blocks.

Command

ps

Purpose

Report process status

Synopsis

ps [options]


Description:

The ps command gives a snapshot of the current processes. If you want a repetitive update of this status, use top. This man page documents the /proc-based version of ps, or tries to.


Options:

-A

Selects all processes

-e

Selects all processes

-T

Select all processes on this terminal

-a

Select ail processes on a terminal, including those of other users

-C

Select by command name

-p

Select by PID

-t

Select by tty

-u

Select by effective user ID (supports names)

-U

Select processes for specified users

-l

Long format

Command

kill

Purpose

Terminate a process

Synopsis

kill [options] IDs


Description:

The kill command sends the specified signal to the specified process. If no signal is specified, the TERM signal is sent.


Options:

-p

Specify that kill should only print the process id (pid) of the named process, and should not send it a signal.

-l

Print a list of signal names. These are found in /usr/include/linux/signal.h

Command

killall

Purpose

Kill processes by name

Synopsis

killall [option] name


Description:

The killall command sends a signal to all processes running any of the specified commands. If no signal name is specified, SIGTERM is sent.


Options:

-e

Require an exact match for very long names. If a command name is longer than 15 characters, the full name may be unavailable (i.e. it is swapped out). In this case, killall will kill everything that matches within the first 15 characters. With -e, such entries are skipped, killall prints a message for each skipped entry if -v is specified in addition to -e,

-i

Interactively ask for confirmation before killing.

-l

List all known signal names.

-q

Do not complain of no processes were killed.

-v

Report if the signal was successfully sent.

-V

Display version information.

-w

Wait for all killed processes to die.

Command

uptime

Purpose

Tells how long the system has been running

Synopsis

uptime


Description: The uptime command gives a one line display of the following information. The current time, how long the system has been running, how many users are currently logged on, and the system load averages for the past 1, 5, and 15 minutes.

Command

uname

Purpose

Prints system information

Synopsis

uname [OPTION] ...


Description: The uname command prints information about the machine and operating system it is run on. If no options are given, uname acts as if the ­ -s option were given.


Options:

-a

Print all of the below information.

-m

Print the machine (hardware) type.

-n

Print the machine's network node hostname.

-p

Print the machine's processor type

-r

Print the operating system release.

-s

Print the operating system name.

-v

Print the operating system version.

Command

hostname

Purpose

Print or set system name

Synopsis

hostname [NAME]


Description:

The hostname command with no arguments prints the name of the current host system . With one argument, it sets the current host name to the specified string. You must have appropriate privileges to set the host name.

Command

who

Purpose

Print effective user id

Synopsis

- -


Description:

The whoami command prints the user name associated with the current effective user id. It is equivalent to the command id -un .

Command

whoami

Purpose

Print who is currently logged in

Synopsis

who [OPTION] [FILE] [am i]


Description:

The who command prints information about users who are currently logged on.

If given no non-option arguments, 'who' prints the following information for each user currently logged on: login name, terminal line, login time, and remote hostname or X display.


Options:

-m

Same as who am i .

-q

Print only the login names and the number of users logged on Overrides all other options.

-s

Ignored; for compatibility with other versions of who .

Command

users

Purpose

Print login names of users currently logged in

Synopsis

users


Description:

The users command prints on a single line a blank-separated list of user names of users currently logged in to the current host.

Command

groups

Purpose

Print names of group(s) a user is in

Synopsis

groups [username]...


Description:

The groups command prints the names of the primary and any supplementary groups for each given USERNAME, or the current process if no names are given. If names are given, the name of each user is printed before the list of that user's groups.


The group lists are equivalent to the output of the command id –Gn.

Command

clear

Purpose

Clears the terminal screen

Synopsis

clear

Description:

The clear command clears your screen. It looks in the environment for the terminal type and then in the terminfo database to figure out how to clear the screen.

Command

pwd

Purpose

Prints the working directory

Synopsis

pwd

Description:

The pwd prints the fully resolved name of the current directory.

Command

echo

Purpose

Prints a line of text

Synopsis

Echo [options] ... [string] ...

Description:

The echo writes each given STRING to standard output, with a space between each and a newline after the last one.

Linux Operation Commands

PDF

Print

E-mail

Command

mkdir

Purpose

Make directories

Synopsis

mkdir [option] ... NAME ...

Description:

The mkdir creates directories with the specified names.


Options:

-m MODE

Set the mode of created directories to MODE.

-p

Make any missing parent directories for each argument.

Command

rmdir

Purpose

Remove empty directories

Synopsis

rmdir [option] ... DIRECTORY ...

Description:

The rmdir removes empty directories. If any DIRECTORY argument does not refer to an existing empty directory, it is an error.


Options:

-p

Remove any parent directories that become empty after an argument DIRECTORY is removed.

Command

cd

Purpose

Changes the working directory

Synopsis

cd dirName

Description:

Change the current working directory to dirName.

Command

ls

Purpose

List directory contents

Synopsis

ls [options] [names]

Description:

The ls command program lists information about files (of any type, including directories). Options and file arguments can be intermixed arbitrarily, as usual.


For non-option command-line arguments that are directories, by default ls lists the contents of directories.


Options:

-a

List all files in directories, including files that start with '.'.

-L

In a long listing, show file information (e.g., times and permissions) for the referents of symbolic links rather than for the symbolic links themselves.

-I

In addition to the name of each file, print the file type, permissions, number of hard links, owner name, group name, size in bytes, and timestamp (by default, the modification time).

-t

Sort by modification time (the 'mtime 1 in the inode), newest first.

-u

Sort by access time (the atime in the inode). If the long listing format is being used, print the last access time.

-C

List files in columns, sorted vertically. This is the default for 'Is' if standard output is a terminal. It is always the default for the 'dir' and 'd' programs. GNU 'Is' uses variable width columns to display as many files as possible in the fewest lines.

Command

cp

Purpose

Copy files and directories

Synopsis

cp [option]... SOURCE DEST

cp [option]... SOURCE... DIRECTORY

Description:

The cp command copies files (or, optionally, directories). The copy is completely independent of the original. You can either copy one file to another, or copy arbitrarily many files to a destination directory.


If the last argument names an existing directory, cp copies each SOURCE file into that directory (retaining the same name). Otherwise, if only two files are given, it copies the first onto the second. It is an error if the last argument is not a directory and more than two non-option arguments are given.


By default, cp does not copy directories (see -r below).


The cp command generally refuses to copy a file onto itself, with the following exception: if--force --backup is specified with SOURCE and DEST identical, and referring to a regular file, cp will make a backup file, either regular or numbered, as specified in the usual ways.

Options:

-a

Preserve as much as possible of the structure and attributes original files in the copy (but do not preserve directory structure). Equivalent to -dpR.

-b

Make a backup of each file that would otherwise be overwritten or removed.

-d

Copy symbolic links as symbolic links rather than copying the files that they point to, and preserve hard links between source files in the copies.

-f

Remove existing destination files.

-i

Prompt whether to overwrite existing regular destination files.

-l

Make hard links instead of copies of non-directories.

-p

Preserve the original files' owner, group, permissions, and timestamps.

Command

mv

Purpose

Move (rename) files

Synopsis

mv [option] SOURCE DEST

Description:

The mv command moves or renames files (or directories). If the last argument names an existing directory, mv moves each other given file into a file with the same name in that directory. Otherwise, if only two files are given, it renames the first as the second. It is an error if the last argument is not a directory and more than two files are given.


Options:

-i

Prompt whether to overwrite each existing destination file, regardless of its permissions. If the response does not begin with y or Y , the file is skipped.

-u

Do not move a non directory that has an existing destination with the same

or newer modification time.

Command

rm

Purpose

Remove files or directories

Synopsis

rm [option] ... [file] ...

Description:

The rm command removes each given FILE. By default, it does not remove directories.


Options:

-d

Remove directories with unlink instead of rmdir, and don't require a directory to be empty before trying to unlink it. Only works if you have appropriate privileges. Because unlinking a directory causes any files in the deleted directory to become unreferenced, it is wise to fsck the filesystem after doing this.

-I

Prompt whether to remove each file. If the response does not begin with 'y'

or 'Y', the file is skipped.

-r

Remove the contents of directories recursively.

Command

cat

Purpose

Concatenate and write files

Synopsis

cat [option] [file] ...

Description:

The cat command copies each FILE (means standard input), or standard input if none are given, to standard output.


Options:

-A

Show-all

-n

Number all output lines, starting with 1

-s

Replace multiple adjacent blank lines with a single blank line.

-T

Display characters as ' ^l '.

Command

more

Purpose

File perusal filter for crt viewing

Synopsis

more [options] [files] ...

Description:

The more command is a filter for paging through text one screen length at a time.


Options:

-num

This option specifies an integer which is the screen size (in lines).

-l

more usually treats ^L (form feed) as a special character, and will pause after any line that contains a form feed. The -I option will prevent this behavior.

-p

Do not scroll. Instead, clear the whole screen and then display the text.

-c

Do not scroll. Instead, paint each screen from the top, clearing the remainder of each line as it is displayed.

-s

Squeeze multiple blank lines into one.

Command

less

Purpose

Opposite of more

Synopsis

less [options] [filename] ...

Description:

The less command is a program similar to more, but which allows backward movement in the file as well as forward movement.


Options:

-c

Causes full screen repaints to be painted from the top line down.

-e

Causes less to automatically exit the second time it reaches end-of-file. By default, the only way to exit less is via the q command.

Command

head

Purpose

Output the first part of files

Synopsis

head [option] ... [file] ...

Description:

The head command prints the first part (10 lines by default) of each FILE; it reads from standard input if no files are given.

If more than one FILE is specified, head prints a one-line header consisting of ==> FILE NAME <== before the output for each FILE.


Options:

-c BYTES

Print the first BYTES bytes, instead of initial lines.

-n N

Output the first N lines.

Command

tail

Purpose

Output the last part of files

Synopsis

tail [option] ... [file] ...

Description:

The tail command prints the last part (10 lines by default) of each FILE.

If more than one FILE is specified, tail prints a one-line header consisting of ==> FILE NAME <== before the output for each FILE.


Options:

-COUNT

This option is only recognized if it is specified first. COUNT is a decimal number optionally followed by a size letter ( b , k , m ) as in -c , or l to mean count by lines, or other option letters ( cfqv ).

-n N

Output the last N lines.

Command

tailf

Purpose

Follows the growth of a log file

Synopsis

diff file1 file2

Description:

The tailf command will print out the last 10 lines of a file and then wait for the file to grow, tailf is extremely useful for monitoring log files on a laptop when logging is infrequent and the user desires that the hard disk spin down to conserve battery life.

Command

diff

Purpose

Finds differences between two files

Synopsis

tailf

Description:

In the simplest case, diff compares the contents of the two files from-file and to file. A file name of - stands for text read from the standard input. As a special case, diff compares a copy of standard input to itself.


Options:

-a

Treat all files as text and compare them line by line, even if they do not seem to be text.

-b

Ignore changes in amount of white space.

-B

Ignore changes that just insert or delete blank lines.

Command

grep

Purpose

Search one or more files that match a regular expression.

Synopsis

grep [options] pat [files]

Description:

The GREP command searches the input files for lines containing a match to a given pattern list. When it finds a match in a line, it copies the line to standard output (by default), or does whatever other sort of output you have requested with options. GREP expects to do the matching on text. Since newline is also a separator for the list of patterns, there is no.way to match newline characters in a text.


Options:

-c

Suppress normal output; instead print a count of matching lines for

each input file.

-e PATTERN

Use PATTERN as the pattern; useful to protect patterns beginning with a'-'.

-f FILE

Obtain patterns from FILE, one per line.

Command

cut

Purpose

Remove sections from each line of files

Synopsis

cut [options] ... [files] ...

Description:

This manual page documents the GNU version of cut. The cut command prints sections of each line of each input file, or the standard input if no files are given. A filename of - means standard input. The sections to be printed are selected by the options.


Options:

-b

Output only these bytes

-c

Output only these characters

-d

Use DELIM instead of TAB for field delimiter

Command

touch

Purpose

Change file access and modification time

Synopsis

touch [OPTION] ... FILE ...

Description:

Utility for updating access/modification times of a file to current system time or other specified time, but also useful for creating a new file. The command touch zzz will create a new file of zero length, named zzz , assuming that zzz did not previously exist. Time-stamping empty files in this way is useful for storing date information, for example in keeping track of modification times on a project.


The touch command is equivalent to : >> newfile or >> newfile (for ordinary files).


Options:

-a

Change the access time only.

-c

Do not create files that do not exist.

- d

Use TIME instead of the current time.

-f

Ignored; for compatibility with BSD versions of touch.

-m

Change the modification time only.

-r FILE1

Use the times of the reference FILE instead of the current time.

Command

wc

Purpose

Print byte, word, and line counts

Synopsis

we [option] ... [file] ...

Description:

The we command counts the number of bytes, whitespace-separated words, and newlines in each given FILE, or standard input if none are given or for a FILE of ' - '.


The wc prints one line of counts for each file, and if the file was given as an argument, it prints the file name following the counts.


Options:

-c

Print only the byte counts

-w

Print only the word counts.

-l

Print only the newline counts.

Command

sort

Purpose

Sort text files

Synopsis

sort [option] ... [file] ...

Description:

The sort command sorts, merges, or compares all the lines from the given files, or standard input if none are given or for a FILE of ' - '. By default, sort writes the results to standard output.


The sort command has three modes of operation: sort (the default), merge, and check for sortedness.


The following options change the operation mode:

-c

Check whether the given files are already sorted: if they are not all sorted, print an error message and exit with a status of 1. Otherwise, exit successfully.

-m

Merge the given files by sorting them as a group. Each input file must always be individually sorted. It always works to sort instead of merge; merging is provided because it is faster, in the case where it works.

Options:

-b

Ignore leading blanks when finding sort keys in each line.

-d

Sort in "phone directory" order: ignore all characters except letters, digits and blanks when sorting.

-f

Fold lowercase characters into the equivalent uppercase characters when sorting so that, for example, 'b' and 'B' sort as equal.

-i

Ignore characters outside the printable ASCII range 040-0176 octal (inclusive) when sorting.

-r

Reverse .the result of comparison, so that lines with greater key values appear earlier in the output instead of later.

Command

which

Purpose

Shows the full path of (shell) commands.

Synopsis

which [programname]

Description:

It prints to stdout the full path of the executables that would have been executed when this argument had been entered at the shell prompt.

Command

whatis

Purpose

Search the whatis database for complete words.

Synopsis

whatis [keyword]

Description:

The whatis command searches a set of database files containing short descriptions of system commands for keywords and displays the result on the standard output. Only complete word matches are displayed.


The whatis database is created using the command /usr/sbin/makewhatis.

Command

whereis

Purpose

Locate the binary, source, and manual page files for a command

Synopsis

whereis [filename]

Description:

Description whereis locates source/binary and manuals sections for specified files. The supplied names are first stripped of leading pathname components and any (single) trailing extension.

Command

mount

Purpose

Mounts a file system

Synopsis

mount [-hV]
mount -a [-fFnrsvw] [-t vfstype]
mount [-fnrsvw] [-0 options [,...]] device f dir
mount [-fnrsvw] [-t vfstype] [-0 options] device dir

Description:

All files accessible in a Unix system are arranged in one big tree, the file hierarchy, rooted at / These files can be spread out over several devices. The mount command serves to attach the file system found on some device to the big file tree. Conversely, the umount(8) command will detach it again.


The standard form of the mount command, is mount -t type device dir This tells the kernel to attach the file system found on device (which is of type type) at the directory dir. The previous contents (if any) and owner and mode of dir become invisible, and as long as this file system remains mounted, the pathname dir refers to the root of the file system on device.

The file /etc/fstab, may contain lines describing what devices are usually mounted where, using which options. This file is used in three ways:


The command mount -a [-t type] (usually given in a bootscript) causes all file systems mentioned in fstab (of the proper type) to be mounted as indicated, except for those whose line contains the noauto keyword. Adding the -F option will make mount fork, so that the filesystems are mounted simultaneously.


When mounting a file system mentioned in fstab, it suffices to give only the device, or only the mount point.

Normally, only the superuser can mount file systems. However, when fstab contains the user option on a line, then anybody can mount the corresponding system.


Thus, given a line /dev/cdrom /cd iso9660 ro, user, noauto, unhide any user can mount the iso9660 file system found on his CDROM using the command.


mount /dev/cdrom or mount /cd


For more details, only the user that mounted a filesystem can unmount it again. If any user should be able to unmount, then use users instead of user in the fstab line.

Command

umount

Purpose

Un-mounts file systems

Synopsis

umount [-hV]
umount -a [-nrv] [-t v fstype]
umount [-nrv] device | dir [...]

Description:

The umount command detaches the file system(s) mentioned from the file hierarchy. A file system is specified either by giving the directory where it has been mounted, or by giving the special device on which it lives.

Command

find

Purpose

Finds groups of files

Synopsis

find [pathnames] [conditions]

Description:

The find command is an extremely useful command for finding particular groups of files, find descends the directory tree beginning at each pathname and locates the files that meet the specified conditions. The default pathname is the current directory.


Options:

-group gname

Find files belonging to group gname. gname can be a group name or group ID.

-newer file

Find files that have been modified more recently than file.

-print

Print the matching files and directories, using their full pathnames.

-name pattern

Find files whose names match pattern.

-mtime +n | -n j n

Find files that were last modified more than n, less than n, or exactly n days ago.

-user user

Find files belonging to user (name or ID)

Command

fdformat

Purpose

Low-level formats a floppy disk

Synopsis

fdformat [‑n] device

Description:

The fdformat command does a low level format on a floppy disk. The generic floppy devices, /dev/fd0 and /dev/fd1 , will fail to work with fdformat when a non-standard format is being used, or if the format has not been autodetected earlier.


Options:

-n

No verify. This option will disable the verification that is performed after the format.

Command

mke2fs

Purpose

Create a Linux second extended file system

Synopsis

mke2fs [-c / -/ filename] [-b block-size] [-f frag-ment-size] [-V] , device

Description:

The mke2fs command is used to create a Linux second extended file system on a device (usually a disk partition).


Options:

-b block-size

Specify the size of blocks in bytes. Valid block size vales are

1024, 2048 and 4096 bytes per block

-c

Check the device for bad blocks before creating the file system, using a fast read-only test.

-f fragment-size

Specify the size of fragments in bytes.

‑F

Force mke2fs to run, even if the specified device is not a block special device, or appears to be mounted.

‑l filename

Read the bad blocks list from filename.

Set the volume label for the filesystem.

-q

Quiet execution. Useful if mke2fs is run in a script.

-v

Verbose execution.

Command

mkbootdisk

Purpose

Creates a stand-alone boot floppy for the running system

Synopsis

mkbootdisk

Description:

The mkbootdisk command creates a boot floppy appropriate for the running system. The created boot disk looks for the root filesystem on the device suggested by /etc/fstab. The only required argument is the kernel version put onto the boot floppy.

Command

init

Purpose

Process control initialization

Synopsis

- -

Description:

Init is the parent of all processes. Its primary role is to create processes from a script stored in the file /etc/inittab. This file usually has entries, which cause init to spawn gettys on each line that users can log in. It also controls autonomous processes required by any particular system. New entries can be added to this file at any time. However, init still waits for one of the above three conditions to occur. To provide for an instantaneous response.