Build your professional network on facebook via our app Go to app
 
 
 
Industry : IT Services Functional Area : New Technologies
Activity:  0 comments  50 views  last activity : 07 06 2010 20:18:04 +0000
 Refer 14
Share
 
 
 

Mainfeatures of unix :

 Multi user -  More than one user can use the machine

 Multitasking- More thanone program can be run at a time.

 Portability – Thismeans  the operating system can be easilyconverted to run on different browsers.

 Commands

ls      

wheninvoked without any arguments, lists the files in the current workingdirectory. A directory that is not the current working directory can bespecified and ls willlist the files there. The user also may specify any list of files anddirectories. In this case, all files and all contents of specified directorieswill be listed.

Fileswhose names start with "." are notlisted, unless the -a flag is specified orthe files are specified explicitly.

Withoutoptions, lsdisplays files in a bare format. This bare format however makes it difficult toestablish the type, permissions, and size of the files. The most common optionsto reveal this information or change the list of files are:

-l   long format, displaying Unix file type, permissions, number of hard links,owner,     group, size, date, andfilename

-F   appends a character revealing the nature of a file, for example, * foran executable, or / for a directory. Regular files have no suffix.

-a  lists all files in the given directory,including those whose names start with "." By default, these filesare excluded from the list.

-R recursively lists subdirectories. The command ls -R / would thereforelist all files.

  

cd

Isa command line command used to change the current working directory in the Unixand DOS operating systems. It is also available for use in Unix shell scriptsor DOS batch files. cd is frequently included built into certain shells such as the Bourne shell,tcsh, bash (where it calls the chdir() POSIX C function) and in DOS'sCOMMAND.COM.

Adirectory is a logical section of a filesystem used to hold files. Directoriesmay also contain other directories. The cd command can be used to change into a subdirectory,move back into the parent directory, move all the way back to the root (/ inUNIX, \ in DOS) or move to any given directory.

 

pwd

command(print working directory) is used to print the name ofcurrent working directory from a computer's command-line interface. If theshell prompt does not already show this, the user can use this command to findtheir place in the directory tree. This command is found in the Unix family ofoperating systems and other flavors as well. The DOS equivalent is "CD" with no arguments.

Itis a command which is sometimes included built into certain shells such as sh,and bash. It can be implemented easily with the POSIX C functions getcwd() and/or getwd().

Example:

$ pwd

/home/foobar

 

mkdir

commandin the Unix operating system is used to make a new Directory. Normal usage isas straightforward as follows:

mkdirname_of_directory

Wherename_of_directory is the name of the directory one wants to create. When typed as above (ie.normal usage), the new directory would be created within the current directory.

rm (shortfor remove)

isa Unix command used to delete files from a filesystem. Common options that rm accepts include:

-r, whichprocesses subdirectories recursively

-i, whichasks for every deletion to be confirmed

-f, whichignores non-existent files and overrides any confirmation prompts("force")

rmis often aliased to "rm -i" so asto avoid accidental deletion of files. If a user still wishes to delete a largenumber of files without confirmation, they can manually cancel out the -iargument by adding the -f option.

"rm -rf" (variously, "rm -rf /","rm -rf *", and others) is frequently used in jokes and anecdotesabout Unix disasters. The "rm -rf /" variant of the command, if runby an administrator, would cause the contents of every mounted disk on thecomputer to be deleted.

 

rmdir

isa command which will remove an empty directory on a Unix-system. It cannot becapitalized. Normal usage is straightforward where one types:

rmdirname_of_directory

Wherename_of_directory corresponds with the name of the directory one wishes todelete. There are options to this command such as -p which removesparent directories if they are also empty.

For example:

rmdir –pfoo/bar/baz

Willfirst remove baz/, then bar/ and finally foo/ thus removing the entiredirectory tree specified in the command argument.

Oftenrmdir will not remove a directory if there is still files present in thedirectory. To force the removal of the directory even if files are presentusually the -rf flag can be used. For example:

rmdir -Rffor/bar/baz

 

cp

isthe command entered in a Unix shell to copy a file from one place to another,possibly on a different filesystem. The original file remains unchanged, andthe new file may have the same or a different name.

ToCopy a File to another File

cp [ -f ] [ -h ] [-i ] [ -p ][ -- ] SourceFile TargetFile

ToCopy a File to a Directory

cp [ -f ] [ -h ] [-i ] [ -p ] [ -r | -R ] [ -- ] SourceFile ... TargetDirectory

ToCopy a Directory to a Directory

cp [ -f ] [ -h ] [-i ] [ -p ] [ -- ] { -r | -R } SourceDirectory ... TargetDirectory

-f(force) – specifies removal of the target file if it cannot be opened for writeoperations. The removal precedes any copying performed by the cp command.

-h– makes the cp command copy symbolic links. The default is to follow symboliclinks, that is, to copy files to which symbolic links point.

-i(interactive) – prompts you with the name of a file to be overwritten. Thisoccurs if the TargetDirectory or TargetFile parameter contains a file with thesame name as a file specified in the SourceFile or SourceDirectory parameter.If you enter y or the locale's equivalent of y, the cp command continues. Anyother answer prevents the cp command from overwriting the file.

-p(preserve) – duplicates the following characteristics of eachSourceFile/SourceDirectory in the corresponding TargetFile and/or TargetDirectory:

Examples

Tomake a copy of a file in the current directory, enter:

    cp prog.c prog.bak

Thiscopies prog.c to prog.bak. If the prog.bak file does not already exist, the cpcommand creates it. If it does exist, the cp command replaces it with a copy ofthe prog.c file.

Tocopy a file in your current directory into another directory, enter:

    cp jones /home/nick/clients

Thiscopies the jones file to /home/nick/clients/jones.

Tocopy a file to a new file and preserve the modification date, time, and accesscontrol list associated with the source file, enter:

    cp -p smith smith.jr

Thiscopies the smith file to the smith.jr file. Instead of creating the file withthe current date and time stamp, the system gives the smith.jr file the samedate and time as the smith file. The smith.jr file also inherits the smithfile's access control protection.

Tocopy all the files in a directory to a new directory, enter:

    cp /home/janet/clients/*/home/nick/customers

Thiscopies only the files in the clients directory to the customers directory.

Tocopy a directory, including all its files and subdirectories, to anotherdirectory, enter:

    cp -R /home/nick/clients/home/nick/customers

Thiscopies the clients directory, including all its files, subdirectories, and thefiles in those subdirectories, to the customers/clients directory.

Tocopy a specific set of files to another directory, enter:

    cp jones lewis smith /home/nick/clients

Thiscopies the jones, lewis, and smith files in your current working directory tothe /home/nick/clients directory.

Touse pattern-matching characters to copy files, enter:

    cp programs/*.c .

Thiscopies the files in the programs directory that end with .c to the currentdirectory, signified by the single . (dot). You must type a space between the cand the final dot.

 find

 program is a search utility, mostly found on Unix-likeplatforms. It searches through a directory tree of a filesystem, locating filesbased on some user-specified criteria. By default, find returns all files below the currentworking directory. Further, findallows the user to specify an action to be taken on each matched file. Thus, itis an extremely powerful program for applying actions to many files. It alsosupports regexp matching.

 Examples

From current directory

find . -name my\*

Thissearches in the current directory (represented by a period) and below it, forfiles and directories with names starting with my. The backslash beforethe star is needed to avoid the shell expansion. Without the backslash, theshell would replace my* with the list of files whose names begin with myin the current directory. An alternative is to enclose the the arguments inquotes: find . -name "my*"

Files only

find . -name"my*" -type f

Thislimits the results of the above search to only regular files, thereforeexcluding directories, special files, pipes, symbolic links, etc. my* isenclosed in quotes as otherwise the shell would replace it with the list of filesin the current directory starting with my

Commands

Theprevious examples created listings of results because, by default, find executes the'-print' action. (Note that early versions of the find command had no default action at all;therefore the resulting list of files would be discarded, to the bewildermentof naïve users.)

find . -name"my*" -type f -ls

Thisprints an extended file information.

Search all directories

find / -name"myfile" -type f -print

Thissearches every file on the computer for a file with the name myfile. Itis generally not a good idea to look for data files this way. This can take aconsiderable amount of time, so it is best to specify the directory moreprecisely.

Specify a directory

find /home/brian-name "myfile" -type f -print

Thissearches for files named myfile in the /home/brian directory,which is the home directory for the user brian. You should alwaysspecify the directory to the deepest level you can remember.

Find any one of differently named files

find . ( -name"*jsp" -or -name "*java" ) -type f -ls

Thisprints extended information on any file whose name ends with either 'jsp' or'java'. Note that the parentheses are required. Also note that the operator"or" can be abbreviated as "o". The "and"operator is assumed where no operator is given. In many shells the parenthesesmust be escaped with a backslash, "\(" and "\)", to preventthem from being interpreted as special shell characters.

 touch

isa program on Unix and Unix-like systems used to change a file's date- andtime-stamp. It can also be used to create an empty file. The command-syntax is:

touch [options]<file_name>

Ifthe file exists, its access and modification time-stamps are set to thesystem's current date and time, as if the file had been changed. To touch a file simulates achange to the file. If the file does not exist, an empty file of that name iscreated with its access and modification time-stamps set to the system'scurrent date and time. If no file path is specified, the current directory isassumed.

touch can be invoked with options to change itsbehaviour, which may vary from one Unix to another. One option makes itpossible to set the file's time-stamp to something other than the currentsystem date and time, but this action is normally restricted to the owner ofthe file or the system's superuser.

 echo

isa command in Unix (and by extension, its descendants, such as Linux) and MS-DOSthat places a string on the terminal. It is typically used in shell scripts andbatch programs to output status text to the screen or a file.

$ echo This is atest.

This is a test.

$ echo "Thisis a test." > ./test.txt

$ cat ./test.txt

This is a test.

 

cat

programconcatenates the contents of files, reading from a list of files and/orstandard input in sequence and writing their contents in order to standardoutput. cattakes the list of files as arguments but also interprets the argument"-" as standard input.

 Example:          cat filename

 

who                         

TheUnix command who displays a list of users who are currently loggedinto a computer. The command accepts various options that vary by system tofurther specify the information that is returned, such as the length of time aparticular user has been connected or what pseudo-teletype a user is connectedto. The whocommand is related to the command w, which provides the same information but alsodisplays additional data and statistics.

Example output                                                                                       

user19    pts/35      Apr 18 08:40    (localhost)

user28    pts/27      Apr 18 09:50    (localhost)

du (abbreviated from disk usage)

isa Unix computer program to display the amount of disk space used under aparticular directory or files on a file system.

du counts the disk space by walking the directorytree. As such, the amount of space on a file system shown by du may vary from thatshown by df iffiles have been deleted but their blocks not yet freed.

InLinux, it is a part of the GNU Coreutils package.

Theduutility first appeared in version 1 of AT&T UNIX.

 
0 comments on "UNIX BASICS - Beginners guide for Unix commands"
Add your comment on "UNIX BASICS - Beginners guide for Unix commands"

Rate:
Submit
Leader in IT recruiting
Java/J2EE, oracle/sybase, spring/hibernate, job in Gurgaon, Leading IT Services Company, Gurgaon
Openings forOSB
Jobs forOSB
Viewers also viewed
Today in India the employee rate is increasing drastically. But are the employees aware of their...
 
397 referals 16 votes, 2759 views
Basic Structure of the Constitution                     THE CONSTITUTION OF INDIA           WE,...
 
0 referals 3 comments, 389 views
Hi friends !!!                               We know, every company today requires a software to...
 
826 referals 29 arguments, 832 views
more...  
Recent Knowledge (72)
The following is a reproduction of from an article I wrote in 2004. 1.  Harnessing the vast...
 
735 referals 18 comments, 325 views
No 1: India Since 1991, when economic liberalization unshackled India from the slow rate of...
 
202 referals 5 comments, 104 views
To all the guys who read this…..please read fully and understand…………..  This is a beautiful...
 
1450 referals 29 comments, 620 views
more...  
More From Author
Earn Rs.2000 daily. No Investment. Wanted Online Internet job workers. Job is only through Internet. Work part time. You can earn Rs.750-2000/- daily. These are genuine Internet jobs. No Investment required. Only serious enquires please. For...
more...