This action might not be possible to undo. Are you sure you want to continue?
For more software testing articles visit !tt" ##www$softwaretesting!el"$com
%ain features of unix
%ulti user - More than one user can use the machine %ultitas&ing- More than one program can be run at a time. 'ortability ( This means the operating system can be easily converted to run on different browsers.
ls when invoked without any arguments, lists the files in the current working directory. A directory that is not the current working directory can be specified and ls will list the files there. The user also may specify any list of files and directories. In this case, all files and all contents of specified directories will be listed. Files whose names start with . are not listed, unless the -a flag is specified or the files are specified e!plicitly. "ithout options, ls displays files in a bare format. This bare format however makes it difficult to establish the type, permissions, and si#e of the files. The most common options to reveal this information or change the list of files are$ long format, displaying %ni! file type, permissions, number of hard links, owner, si#e, date, and filename
-l -F -a -R
appends a character revealing the nature of a file, for e!ample, * for an e!ecutable, or / for a directory. &egular files have no suffi!. lists all files in the given directory, including those whose names start with . 'y default, these files are e!cluded from the list. recursively lists subdirectories. The command ls -R / would therefore list all files.
cd Is a command line command used to change the current working directory in the %ni! and ()* operating systems. It is also available for use in %ni! shell scripts or ()* batch files. cd is
It can be implemented easily with the -)*I. If a user still wishes to delete a large number of files without confirmation. rm ./)M. rm -rf 8 . 5!ample$ 6 pwd 3home3foobar mkdir command in the %ni! operating system is used to make a new (irectory. "wd command . / function0 and in ()*1s /)MMA2(. force 0 rm is often aliased to rm -i so as to avoid accidental deletion of files. "hen typed as above . and others0 is fre+uently used in 9okes and anecdotes about %ni! disasters. if run by an administrator."rint working directory0 is used to print the name of current working directory from a computer1s command-line interface. /ommon options that rm accepts include$ -r. move back into the parent directory. A directory is a logical section of a filesystem used to hold files. rm -rf .fre+uently included built into certain shells such as the 'ourne shell. tcsh. 4 in ()*0 or move to any given directory.3 in %2I. The ()* e+uivalent is CD with no arguments. rm -rf 3 .. the new directory would be created within the current directory. which processes subdirectories recursively -i. normal usage0. bash . The cd command can be used to change into a subdirectory.short for remove0 is a %ni! command used to delete files from a filesystem. and bash. It is a command which is sometimes included built into certain shells such as sh. The rm -rf 3 variant of the command. rmdir .ie. the user can use this command to find their place in the directory tree. would cause the contents of every mounted disk on the computer to be deleted. which asks for every deletion to be confirmed -f.variously. they can manually cancel out the -i argument by adding the -f option. This command is found in the %ni! family of operating systems and other flavors as well. (irectories may also contain other directories.where it calls the chdir() -)*I. If the shell prompt does not already show this. 2ormal usage is as straightforward as follows$ mkdir name7of7directory "here name_of_directory is the name of the directory one wants to create. / functions getcwd() and3or getwd(). which ignores non-e!istent files and overrides any confirmation prompts . move all the way back to the root .
-" . the cp command continues.c prog. -i < . )ften rmdir will not remove a directory if there is still files present in the directory. enter$ cp prog. then bar3 and finally foo3 thus removing the entire directory tree specified in the command argument. For e!ample$ rmdir -&f for3bar3ba# cp is the command entered in a %ni! shell to copy a file from one place to another.. -. This occurs if the Target(irectory or TargetFile parameter contains a file with the same name as a file specified in the *ourceFile or *ource(irectory parameter. possibly on a different filesystem.. -h < . -i . -f < . The original file remains unchanged. -p < . -h < . to copy files to which symbolic links point.< *ourceFile TargetFile To /opy a File to a (irectory cp . If you enter y or the locale1s e+uivalent of y.. 2ormal usage is straightforward where one types$ rmdir name7of7directory "here name7of7directory corresponds with the name of the directory one wishes to delete. -i < . The removal precedes any copying performed by the cp command. -r = -& < . -p <.< *ourceFile .preserve0 : duplicates the following characteristics of each *ourceFile3*ource(irectory in the corresponding TargetFile and3or Target(irectory$ )xam"les To make a copy of a file in the current directory.force0 : specifies removal of the target file if it cannot be opened for write operations. -f < ..interactive0 : prompts you with the name of a file to be overwritten.bak . For e!ample$ rmdir :p foo3bar3ba# "ill first remove ba#3. To /opy a File to another File cp . and the new file may have the same or a different name. The default is to follow symbolic links. Target(irectory -f . -p < . -h < .< > -r = -& ? *ource(irectory . -. Target(irectory To /opy a (irectory to a (irectory cp . Any other answer prevents the cp command from overwriting the file.is a command which will remove an empty directory on a %ni!-system. -. -! : makes the cp command copy symbolic links. There are options to this command such as -" which removes parent directories if they are also empty. To force the removal of the directory even if files are present usually the -rf flag can be used. -i < . -f < . that is. It cannot be capitali#ed.
Thus.9r file. subdirectories.bak file does not already e!ist.c . @ou must type a space between the c and the final dot. signified by the single . mostly found on %ni!-like platforms. time. the cp command creates it.c to prog. and the files in those subdirectories. . including all its files and subdirectories. enter$ cp -p smith smith. If it does e!ist. find program is a search utility. enter$ cp 9ones 3home3nick3clients This copies the 9ones file to 3home3nick3clients39ones.9r file the same date and time as the smith file. To copy a specific set of files to another directory.9r This copies the smith file to the smith. enter$ cp 3home39anet3clients38 3home3nick3customers This copies only the files in the clients directory to the customers directory. enter$ cp programs38. and smith files in your current working directory to the 3home3nick3clients directory. including all its files. find allows the user to specify an action to be taken on each matched file.This copies prog. it is an e!tremely powerful program for applying actions to many files. Instead of creating the file with the current date and time stamp.9r file also inherits the smith file1s access control protection. the system gives the smith. the cp command replaces it with a copy of the prog. It also supports rege!p matching.c to the current directory. enter$ cp 9ones lewis smith 3home3nick3clients This copies the 9ones. To copy a file to a new file and preserve the modification date. To copy a directory. and access control list associated with the source file.bak. to another directory. find returns all files below the current working directory. To copy a file in your current directory into another directory. If the prog.c file. to the customers3clients directory. . It searches through a directory tree of a filesystem. lewis. This copies the files in the programs directory that end with . To copy all the files in a directory to a new directory. enter$ cp -& 3home3nick3clients 3home3nick3customers This copies the clients directory. Further. The smith. locating files based on some user-specified criteria. 'y default. To use pattern-matching characters to copy files.dot0.
represented by a period0 and below it. therefore e!cluding directories. for files and directories with names starting with my. .0 find . -name "my*" Files only find . Searc! all directories find 3 -name myfile -type f -print This searches every file on the computer for a file with the name myfile. An alternative is to enclose the the arguments in +uotes$ find . the shell would replace my* with the list of files whose names begin with my in the current directory. -name 89sp -or -name 89ava 0 -type f -ls This prints e!tended information on any file whose name ends with either 19sp1 or 19ava1. find e!ecutes the 1-print1 action. . symbolic links. -name my8 -type f This limits the results of the above search to only regular files. 2ote that the parentheses are re+uired. The and operator is assumed where no operator is given. "ithout the backslash. pipes. 4. to prevent them from being interpreted as special shell characters. etc. and 40 . -name my48 This searches in the current directory .2ote that early versions of the find command had no default action at allA therefore the resulting list of files would be discarded. special files. Also note that the operator or can be abbreviated as o . to the bewilderment of naBve users.)xam"les From current directory find . It is generally not a good idea to look for data files this way. by default. This can take a considerable amount of time. The backslash before the star is needed to avoid the shell e!pansion. @ou should always specify the directory to the deepest level you can remember. -name my8 -type f -ls This prints an e!tended file information. so it is best to specify the directory more precisely. which is the home directory for the user brian. S"ecify a directory find 3home3brian -name myfile -type f -print This searches for files named myfile in the /home/brian directory. Find any one of differently named files find . my* is enclosed in +uotes as otherwise the shell would replace it with the list of files in the current directory starting with my Commands The previous e!amples created listings of results because. touc! . In many shells the parentheses must be escaped with a backslash.
and time-stamp. The who command is related to the command w. an empty file of that name is created with its access and modification time-stamps set to the system1s current date and time. )ne option makes it possible to set the file1s time-stamp to something other than the current system date and time. can be invoked with options to change its behaviour. which may vary from one %ni! to another. cat program concatenates the contents of files. its access and modification time-stamps are set to the system1s current date and time. 5!ample$ w!o The %ni! command who displays a list of users who are currently logged into a computer. but this action is normally restricted to the owner of the file or the system1s superuser. such as Einu!0 and M*-()* that places a string on the terminal. such as the length of time a particular user has been connected or what pseudo-teletype a user is connected to. touch ec!o is a command in %ni! .localhost0 cat filename . which provides the same information but also displays additional data and statistics. This is a test.3test.is a program on %ni! and %ni!-like systems used to change a file1s date. 6 echo This is a test.t!t 6 cat . To touch a file simulates a change to the file. If no file path is specified. reading from a list of files and3or standard input in se+uence and writing their contents in order to standard output. its descendants. The command accepts various options that vary by system to further specify the information that is returned. the current directory is assumed.3test. The command-synta! is$ touch . cat takes the list of files as arguments but also interprets the argument .t!t This is a test.as standard input. D . It is typically used in shell scripts and batch programs to output status te!t to the screen or a file.options< Cfile7nameD If the file e!ists. as if the file had been changed. It can also be used to create an empty file.localhost0 . If the file does not e!ist. )xam"le out"ut userFG userMJ pts3HI pts3MN Apr FJ KJ$LK Apr FJ KG$IK .and by e!tension. 6 echo This is a test.
com3 Copyright 2008: http$33www.com .softwaretestinghelp. it is a part of the O2% /oreutils package. The du utility first appeared in version F of ATPT %2I. du In Einu!. As such. the amount of space on a file system shown by du may vary from that shown by df if files have been deleted but their blocks not yet freed. counts the disk space by walking the directory tree. )xam"le The -& flag will show the si#es in FQ blocks.abbreviated from disk usage0 is a %ni! computer program to display the amount of disk space used under a particular directory or files on a file system.du .el" http$33www.softwaretestinghelp.com3sitemap3 .softwaretestinghelp.A#+esting -ob o"enings$ http$33www. 6du -k 3seclog L 3seclog3lostRfound FHM 3seclog3backup3ai!N FHS 3seclog3backup LLKLL 3seclog3temp LHGMSL 3seclog *e will discuss more advanced commands in t!e next article$ For more software testing resources visit following "ages Software +esting articles http$33www.softwaretestinghelp. rather than the default of IFM byte blocks..com39obs3 Software +esting .
This action might not be possible to undo. Are you sure you want to continue?
We've moved you to where you read on your other device.
Get the full title to continue reading from where you left off, or restart the preview.