SlideShare a Scribd company logo
UNIX BASICS - Beginners guide for Unix commands
                           - by Meenakshi

For more software testing articles visit: http://www.softwaretestinghelp.com


Main features of unix :

Multi user - More than one user can use the machine

Multitasking- More than one program can be run at a time.

Portability – This means the operating system can be easily converted to run on
different browsers.


Commands
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 explicitly.
Without options, ls displays files in a bare format. This bare format however makes it
difficult to establish the type, permissions, and size of the files. The most common
options to 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, and filename
-F    appends a character revealing the nature of a file, for example, * for an 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 files are excluded from the list.
-R 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 Unix
and DOS operating systems. It is also available for use in Unix shell scripts or 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's COMMAND.COM.

A directory is a logical section of a filesystem used to hold files. Directories may 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 (/ in UNIX,  in
DOS) or move to any given directory.


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

It is 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

command in the Unix operating system is used to make a new Directory. Normal usage is
as straightforward as follows:
mkdir name_of_directory
Where name_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 (short for remove)
is a Unix command used to delete files from a filesystem. Common options that rm
accepts include:
-r, which processes subdirectories recursively
-i, which asks for every deletion to be confirmed
-f, which ignores non-existent files and overrides any confirmation prompts ("force")
rm is often aliased to "rm -i" so as to avoid accidental deletion of files. If a user still
wishes to delete a large number of files without confirmation, they can manually cancel
out the -i argument by adding the -f option.
"rm -rf" (variously, "rm -rf /", "rm -rf *", and others) is frequently used in jokes and
anecdotes about Unix disasters. The "rm -rf /" variant of the command, if run by an
administrator, would cause the contents of every mounted disk on the computer to be
deleted.


rmdir

is a command which will remove an empty directory on a Unix-system. It cannot be
capitalized. Normal usage is straightforward where one types:
rmdir name_of_directory
Where name_of_directory corresponds with the name of the directory one wishes to
delete. There are options to this command such as -p which removes parent directories if
they are also empty.
For example:
rmdir –p foo/bar/baz
Will first remove baz/, then bar/ and finally foo/ thus removing the entire directory tree
specified in the command argument.
Often rmdir will not remove a directory if there is still files present in the directory. To
force the removal of the directory even if files are present usually the -rf flag can be used.
For example:
rmdir -Rf for/bar/baz


cp
is the 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, and the new file may have
the same or a different name.
To Copy a File to another File
cp [ -f ] [ -h ] [ -i ] [ -p ][ -- ] SourceFile TargetFile
To Copy a File to a Directory
cp [ -f ] [ -h ] [ -i ] [ -p ] [ -r | -R ] [ -- ] SourceFile ... TargetDirectory
To Copy 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 write operations.
The removal precedes any copying performed by the cp command.
-h – makes the cp command copy symbolic links. The default is to follow symbolic links,
that is, to copy files to which symbolic links point.
-i (interactive) – prompts you with the name of a file to be overwritten. This occurs if the
TargetDirectory or TargetFile parameter contains a file with the same 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. Any other answer prevents the cp command
from overwriting the file.
-p (preserve) – duplicates the following characteristics of each
SourceFile/SourceDirectory in the corresponding TargetFile and/or TargetDirectory:
Examples
To make a copy of a file in the current directory, enter:
  cp prog.c prog.bak
This copies prog.c to prog.bak. If the prog.bak file does not already exist, the cp
command creates it. If it does exist, the cp command replaces it with a copy of the prog.c
file.
To copy a file in your current directory into another directory, enter:
  cp jones /home/nick/clients
This copies the jones file to /home/nick/clients/jones.
To copy a file to a new file and preserve the modification date, time, and access control
list associated with the source file, enter:
  cp -p smith smith.jr
This copies the smith file to the smith.jr file. Instead of creating the file with the current
date and time stamp, the system gives the smith.jr file the same date and time as the smith
file. The smith.jr file also inherits the smith file's access control protection.
To copy all the files in a directory to a new directory, enter:
  cp /home/janet/clients/* /home/nick/customers
This copies only the files in the clients directory to the customers directory.
To copy a directory, including all its files and subdirectories, to another directory, enter:
  cp -R /home/nick/clients /home/nick/customers
This copies the clients directory, including all its files, subdirectories, and the files in
those subdirectories, to the customers/clients directory.
To copy a specific set of files to another directory, enter:
  cp jones lewis smith /home/nick/clients
This copies the jones, lewis, and smith files in your current working directory to the
/home/nick/clients directory.
To use pattern-matching characters to copy files, enter:
  cp programs/*.c .
This copies the files in the programs directory that end with .c to the current directory,
signified by the single . (dot). You must type a space between the c and the final dot.




find

program is a search utility, mostly found on Unix-like platforms. It searches through a
directory tree of a filesystem, locating files based on some user-specified criteria. By
default, find returns all files below the current working directory. Further, find allows
the user to specify an action to be taken on each matched file. Thus, it is an extremely
powerful program for applying actions to many files. It also supports regexp matching.

Examples

From current directory
find . -name my*
This searches in the current directory (represented by a period) and below it, for files and
directories with names starting with my. The backslash before the star is needed to avoid
the shell expansion. Without the backslash, the shell would replace my* with the list of
files whose names begin with my in the current directory. An alternative is to enclose the
the arguments in quotes: find . -name "my*"

Files only
find . -name "my*" -type f
This limits the results of the above search to only regular files, therefore excluding
directories, special files, pipes, symbolic links, etc. my* is enclosed in quotes as
otherwise the shell would replace it with the list of files in the current directory starting
with my

Commands
The previous 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 bewilderment of naïve
users.)
find . -name "my*" -type f -ls
This prints an extended file information.
Search all directories
find / -name "myfile" -type f -print
This searches every file on the computer for a file with the name myfile. It is generally
not a good idea to look for data files this way. This can take a considerable amount of
time, so it is best to specify the directory more precisely.

Specify a directory
find /home/brian -name "myfile" -type f -print
This searches for files named myfile in the /home/brian directory, which is the home
directory for the user brian. You should always specify 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
This prints 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
parentheses must be escaped with a backslash, "(" and ")", to prevent them from being
interpreted as special shell characters.


touch
is a program on Unix and Unix-like systems used to change a file's date- and time-stamp.
It can also be used to create an empty file. The command-syntax is:
touch [options] <file_name>
If the file exists, its access and modification time-stamps are set to the system's current
date and time, as if the file had been changed. To touch a file simulates a change to the
file. If the file does not exist, an empty file of that name is created with its access and
modification time-stamps set to the system's current date and time. If no file path is
specified, the current directory is assumed.
touch can be invoked with options to change its behaviour, which may vary from one
Unix to another. One option makes it possible to set the file's time-stamp to something
other than the current system date and time, but this action is normally restricted to the
owner of the file or the system's superuser.


echo
is a command in Unix (and by extension, its descendants, such as Linux) and MS-DOS
that places a string on the terminal. It is typically used in shell scripts and batch programs
to output status text to the screen or a file.
$ echo This is a test.
This is a test.
$ echo "This is a test." > ./test.txt
$ cat ./test.txt
This is a test.

cat

program concatenates the contents of files, reading from a list of files and/or standard
input in sequence and writing their contents in order to standard output. cat takes the list
of files as arguments but also interprets the argument "-" as standard input.
Example:          cat filename


who
The Unix command who displays a list of users who are currently logged into a computer.
The command accepts various options that vary by system to further specify the
information that is returned, such as the length of time a particular user has been
connected or what pseudo-teletype a user is connected to. The who command is related to
the command w, which provides the same information but also displays 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)
is a Unix computer program to display the amount of disk space used under a particular
directory or files on a file system.
du counts the disk space by walking the directory tree. 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.
In Linux, it is a part of the GNU Coreutils package.
The du utility first appeared in version 1 of AT&T UNIX.

Example
The -k flag will show the sizes in 1K blocks, rather than the default of 512 byte blocks.
$du -k /seclog
4    /seclog/lost+found
132 /seclog/backup/aix7
136 /seclog/backup
44044 /seclog/temp
439264 /seclog

We will discuss more advanced commands in the next article.



For more software testing resources visit following pages:
Software Testing articles: http://www.softwaretestinghelp.com/sitemap/
QA/Testing Job openings: http://www.softwaretestinghelp.com/jobs/
Software Testing Help: http://www.softwaretestinghelp.com/


Copyright 2008: http://www.softwaretestinghelp.com

More Related Content

What's hot

Shell scripting
Shell scriptingShell scripting
Shell scripting
Manav Prasad
 
Unix/Linux Basic Commands and Shell Script
Unix/Linux Basic Commands and Shell ScriptUnix/Linux Basic Commands and Shell Script
Unix/Linux Basic Commands and Shell Script
sbmguys
 
Unix - An Introduction
Unix - An IntroductionUnix - An Introduction
Unix - An Introduction
Deepanshu Gahlaut
 
Linux basic commands
Linux basic commandsLinux basic commands
Linux basic commands
Sagar Kumar
 
Linux basic commands with examples
Linux basic commands with examplesLinux basic commands with examples
Linux basic commands with examples
abclearnn
 
Basics of shell programming
Basics of shell programmingBasics of shell programming
Basics of shell programming
Chandan Kumar Rana
 
Linux architecture
Linux architectureLinux architecture
Linux architecture
ICI Bucharest - roTLD
 
Introduction to the linux command line.pdf
Introduction to the linux command line.pdfIntroduction to the linux command line.pdf
Introduction to the linux command line.pdf
CesleySCruz
 
Linux Basic Commands
Linux Basic CommandsLinux Basic Commands
Linux Basic Commands
Hanan Nmr
 
Basic unix commands
Basic unix commandsBasic unix commands
Basic unix commands
swtjerin4u
 
Bash shell
Bash shellBash shell
Bash shellxylas121
 
Lesson 2 Understanding Linux File System
Lesson 2 Understanding Linux File SystemLesson 2 Understanding Linux File System
Lesson 2 Understanding Linux File System
Sadia Bashir
 
Quick Guide with Linux Command Line
Quick Guide with Linux Command LineQuick Guide with Linux Command Line
Quick Guide with Linux Command Line
Anuchit Chalothorn
 
Shell scripting
Shell scriptingShell scripting
Shell scripting
Geeks Anonymes
 
Unix Linux Commands Presentation 2013
Unix Linux Commands Presentation 2013Unix Linux Commands Presentation 2013
Unix Linux Commands Presentation 2013
Wave Digitech
 
Bash Shell Scripting
Bash Shell ScriptingBash Shell Scripting
Bash Shell Scripting
Raghu nath
 
Linux basics part 1
Linux basics part 1Linux basics part 1
Linux basics part 1
Lilesh Pathe
 

What's hot (20)

Shell scripting
Shell scriptingShell scripting
Shell scripting
 
Unix/Linux Basic Commands and Shell Script
Unix/Linux Basic Commands and Shell ScriptUnix/Linux Basic Commands and Shell Script
Unix/Linux Basic Commands and Shell Script
 
Unix - An Introduction
Unix - An IntroductionUnix - An Introduction
Unix - An Introduction
 
Linux basic commands
Linux basic commandsLinux basic commands
Linux basic commands
 
Linux basic commands with examples
Linux basic commands with examplesLinux basic commands with examples
Linux basic commands with examples
 
Basic 50 linus command
Basic 50 linus commandBasic 50 linus command
Basic 50 linus command
 
Basics of shell programming
Basics of shell programmingBasics of shell programming
Basics of shell programming
 
Linux architecture
Linux architectureLinux architecture
Linux architecture
 
Introduction to the linux command line.pdf
Introduction to the linux command line.pdfIntroduction to the linux command line.pdf
Introduction to the linux command line.pdf
 
Linux Basic Commands
Linux Basic CommandsLinux Basic Commands
Linux Basic Commands
 
Linux cheat-sheet
Linux cheat-sheetLinux cheat-sheet
Linux cheat-sheet
 
Basic unix commands
Basic unix commandsBasic unix commands
Basic unix commands
 
Bash shell
Bash shellBash shell
Bash shell
 
Lesson 2 Understanding Linux File System
Lesson 2 Understanding Linux File SystemLesson 2 Understanding Linux File System
Lesson 2 Understanding Linux File System
 
Quick Guide with Linux Command Line
Quick Guide with Linux Command LineQuick Guide with Linux Command Line
Quick Guide with Linux Command Line
 
Shell scripting
Shell scriptingShell scripting
Shell scripting
 
Unix Linux Commands Presentation 2013
Unix Linux Commands Presentation 2013Unix Linux Commands Presentation 2013
Unix Linux Commands Presentation 2013
 
Bash Shell Scripting
Bash Shell ScriptingBash Shell Scripting
Bash Shell Scripting
 
Linux basics part 1
Linux basics part 1Linux basics part 1
Linux basics part 1
 
Linux file system
Linux file systemLinux file system
Linux file system
 

Viewers also liked

PowerPoint Presentation (shared using http://VisualBee.com). (shared using Vi...
PowerPoint Presentation (shared using http://VisualBee.com). (shared using Vi...PowerPoint Presentation (shared using http://VisualBee.com). (shared using Vi...
PowerPoint Presentation (shared using http://VisualBee.com). (shared using Vi...VisualBee.com
 
Spsl II unit
Spsl   II unitSpsl   II unit
Spsl II unit
Sasidhar Kothuru
 
Scripting Recipes for Testers
Scripting Recipes for TestersScripting Recipes for Testers
Scripting Recipes for Testers
Adam Goucher
 
Vsam interview questions and answers.
Vsam interview questions and answers.Vsam interview questions and answers.
Vsam interview questions and answers.Sweta Singh
 
Unix shell scripting basics
Unix shell scripting basicsUnix shell scripting basics
Unix shell scripting basics
Manav Prasad
 
Manual software-testing-interview-questions-with-answers
Manual software-testing-interview-questions-with-answersManual software-testing-interview-questions-with-answers
Manual software-testing-interview-questions-with-answers
Tripti Shergill
 
Quality center interview questions and answers
Quality center interview questions and answersQuality center interview questions and answers
Quality center interview questions and answers
Garuda Trainings
 
3, regular expression
3, regular expression3, regular expression
3, regular expression
ted-xu
 
Cobol questions and answers
Cobol questions and answersCobol questions and answers
Cobol questions and answersSweta Singh
 
Project manager interview questions and answers
Project manager interview questions and answersProject manager interview questions and answers
Project manager interview questions and answersSweta Singh
 
Linux or unix interview questions
Linux or unix interview questionsLinux or unix interview questions
Linux or unix interview questionsTeja Bheemanapally
 
Manual testing interview questions and answers
Manual testing interview questions and answersManual testing interview questions and answers
Manual testing interview questions and answerskaranmca
 
QA interview questions and answers
QA interview questions and answersQA interview questions and answers
QA interview questions and answers
Mehul Chauhan
 
Ibm db2 interview questions and answers
Ibm db2 interview questions and answersIbm db2 interview questions and answers
Ibm db2 interview questions and answersSweta Singh
 
Advanced Shell Scripting
Advanced Shell ScriptingAdvanced Shell Scripting
Advanced Shell Scripting
Alessandro Manfredi
 
Practical unix utilities for text processing
Practical unix utilities for text processingPractical unix utilities for text processing
Practical unix utilities for text processingAnton Arhipov
 
Siebel 8.1 Certifications Question Answers
Siebel 8.1 Certifications Question AnswersSiebel 8.1 Certifications Question Answers
Siebel 8.1 Certifications Question Answers
Sweta Singh
 
Linux User Space Debugging & Profiling
Linux User Space Debugging & ProfilingLinux User Space Debugging & Profiling
Linux User Space Debugging & ProfilingAnil Kumar Pugalia
 
Cts informatica interview question answers
Cts informatica interview question answersCts informatica interview question answers
Cts informatica interview question answersSweta Singh
 

Viewers also liked (20)

PowerPoint Presentation (shared using http://VisualBee.com). (shared using Vi...
PowerPoint Presentation (shared using http://VisualBee.com). (shared using Vi...PowerPoint Presentation (shared using http://VisualBee.com). (shared using Vi...
PowerPoint Presentation (shared using http://VisualBee.com). (shared using Vi...
 
Spsl II unit
Spsl   II unitSpsl   II unit
Spsl II unit
 
Scripting Recipes for Testers
Scripting Recipes for TestersScripting Recipes for Testers
Scripting Recipes for Testers
 
Vsam interview questions and answers.
Vsam interview questions and answers.Vsam interview questions and answers.
Vsam interview questions and answers.
 
Unix shell scripting basics
Unix shell scripting basicsUnix shell scripting basics
Unix shell scripting basics
 
Manual software-testing-interview-questions-with-answers
Manual software-testing-interview-questions-with-answersManual software-testing-interview-questions-with-answers
Manual software-testing-interview-questions-with-answers
 
Quality center interview questions and answers
Quality center interview questions and answersQuality center interview questions and answers
Quality center interview questions and answers
 
3, regular expression
3, regular expression3, regular expression
3, regular expression
 
Cobol questions and answers
Cobol questions and answersCobol questions and answers
Cobol questions and answers
 
Project manager interview questions and answers
Project manager interview questions and answersProject manager interview questions and answers
Project manager interview questions and answers
 
Linux or unix interview questions
Linux or unix interview questionsLinux or unix interview questions
Linux or unix interview questions
 
Manual testing interview questions and answers
Manual testing interview questions and answersManual testing interview questions and answers
Manual testing interview questions and answers
 
QA interview questions and answers
QA interview questions and answersQA interview questions and answers
QA interview questions and answers
 
Ibm db2 interview questions and answers
Ibm db2 interview questions and answersIbm db2 interview questions and answers
Ibm db2 interview questions and answers
 
Advanced Shell Scripting
Advanced Shell ScriptingAdvanced Shell Scripting
Advanced Shell Scripting
 
Practical unix utilities for text processing
Practical unix utilities for text processingPractical unix utilities for text processing
Practical unix utilities for text processing
 
"make" system
"make" system"make" system
"make" system
 
Siebel 8.1 Certifications Question Answers
Siebel 8.1 Certifications Question AnswersSiebel 8.1 Certifications Question Answers
Siebel 8.1 Certifications Question Answers
 
Linux User Space Debugging & Profiling
Linux User Space Debugging & ProfilingLinux User Space Debugging & Profiling
Linux User Space Debugging & Profiling
 
Cts informatica interview question answers
Cts informatica interview question answersCts informatica interview question answers
Cts informatica interview question answers
 

Similar to Unix Basics For Testers

BITS: Introduction to Linux - Text manipulation tools for bioinformatics
BITS: Introduction to Linux - Text manipulation tools for bioinformaticsBITS: Introduction to Linux - Text manipulation tools for bioinformatics
BITS: Introduction to Linux - Text manipulation tools for bioinformatics
BITS
 
Command Line Tools
Command Line ToolsCommand Line Tools
Command Line Tools
David Harris
 
Directories description
Directories descriptionDirectories description
Directories description
Dr.M.Karthika parthasarathy
 
Basic linux commands
Basic linux commandsBasic linux commands
Basic linux commands
Dheeraj Nambiar
 
Linux commands and file structure
Linux commands and file structureLinux commands and file structure
Linux commands and file structure
Sreenatha Reddy K R
 
linux-lecture4.ppt
linux-lecture4.pptlinux-lecture4.ppt
linux-lecture4.ppt
LuigysToro
 
Linux file commands and shell scripts
Linux file commands and shell scriptsLinux file commands and shell scripts
Linux file commands and shell scripts
PrashantTechment
 
Linux Commands
Linux CommandsLinux Commands
Linux Commands
Ramasubbu .P
 
Basic shell programs assignment 1_solution_manual
Basic shell programs assignment 1_solution_manualBasic shell programs assignment 1_solution_manual
Basic shell programs assignment 1_solution_manual
Kuntal Bhowmick
 
linux-file-system01.ppt
linux-file-system01.pptlinux-file-system01.ppt
linux-file-system01.ppt
MeesanRaza
 
Ppt
PptPpt
Chapter 2 Linux File System and net.pptx
Chapter 2 Linux File System and net.pptxChapter 2 Linux File System and net.pptx
Chapter 2 Linux File System and net.pptx
alehegn9
 
Examples -partII
Examples -partIIExamples -partII
Examples -partII
Kedar Bhandari
 
Basic unix commands_1
Basic unix commands_1Basic unix commands_1
Basic unix commands_1
thakor bharati
 
Nguyễn Vũ Hưng: Basic Linux Power Tools
Nguyễn Vũ Hưng: Basic Linux Power Tools Nguyễn Vũ Hưng: Basic Linux Power Tools
Nguyễn Vũ Hưng: Basic Linux Power Tools
Vu Hung Nguyen
 
Karkha unix shell scritping
Karkha unix shell scritpingKarkha unix shell scritping
Karkha unix shell scritping
chockit88
 
Linux introduction-commands2338
Linux introduction-commands2338Linux introduction-commands2338
Linux introduction-commands2338Cam YP Co., Ltd
 
Linux introduction-commands2338
Linux introduction-commands2338Linux introduction-commands2338
Linux introduction-commands2338
Cam YP Co., Ltd
 

Similar to Unix Basics For Testers (20)

Linux ppt
Linux pptLinux ppt
Linux ppt
 
BITS: Introduction to Linux - Text manipulation tools for bioinformatics
BITS: Introduction to Linux - Text manipulation tools for bioinformaticsBITS: Introduction to Linux - Text manipulation tools for bioinformatics
BITS: Introduction to Linux - Text manipulation tools for bioinformatics
 
Command Line Tools
Command Line ToolsCommand Line Tools
Command Line Tools
 
Directories description
Directories descriptionDirectories description
Directories description
 
Basic linux commands
Basic linux commandsBasic linux commands
Basic linux commands
 
Linux commands and file structure
Linux commands and file structureLinux commands and file structure
Linux commands and file structure
 
linux-lecture4.ppt
linux-lecture4.pptlinux-lecture4.ppt
linux-lecture4.ppt
 
Linux shell scripting
Linux shell scriptingLinux shell scripting
Linux shell scripting
 
Linux file commands and shell scripts
Linux file commands and shell scriptsLinux file commands and shell scripts
Linux file commands and shell scripts
 
Linux Commands
Linux CommandsLinux Commands
Linux Commands
 
Basic shell programs assignment 1_solution_manual
Basic shell programs assignment 1_solution_manualBasic shell programs assignment 1_solution_manual
Basic shell programs assignment 1_solution_manual
 
linux-file-system01.ppt
linux-file-system01.pptlinux-file-system01.ppt
linux-file-system01.ppt
 
Ppt
PptPpt
Ppt
 
Chapter 2 Linux File System and net.pptx
Chapter 2 Linux File System and net.pptxChapter 2 Linux File System and net.pptx
Chapter 2 Linux File System and net.pptx
 
Examples -partII
Examples -partIIExamples -partII
Examples -partII
 
Basic unix commands_1
Basic unix commands_1Basic unix commands_1
Basic unix commands_1
 
Nguyễn Vũ Hưng: Basic Linux Power Tools
Nguyễn Vũ Hưng: Basic Linux Power Tools Nguyễn Vũ Hưng: Basic Linux Power Tools
Nguyễn Vũ Hưng: Basic Linux Power Tools
 
Karkha unix shell scritping
Karkha unix shell scritpingKarkha unix shell scritping
Karkha unix shell scritping
 
Linux introduction-commands2338
Linux introduction-commands2338Linux introduction-commands2338
Linux introduction-commands2338
 
Linux introduction-commands2338
Linux introduction-commands2338Linux introduction-commands2338
Linux introduction-commands2338
 

Recently uploaded

Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
EverAndrsGuerraGuerr
 
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdfUnit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Thiyagu K
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
Thiyagu K
 
S1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptxS1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptx
tarandeep35
 
Best Digital Marketing Institute In NOIDA
Best Digital Marketing Institute In NOIDABest Digital Marketing Institute In NOIDA
Best Digital Marketing Institute In NOIDA
deeptiverma2406
 
"Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe..."Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe...
SACHIN R KONDAGURI
 
Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.
Ashokrao Mane college of Pharmacy Peth-Vadgaon
 
2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...
Sandy Millin
 
Delivering Micro-Credentials in Technical and Vocational Education and Training
Delivering Micro-Credentials in Technical and Vocational Education and TrainingDelivering Micro-Credentials in Technical and Vocational Education and Training
Delivering Micro-Credentials in Technical and Vocational Education and Training
AG2 Design
 
Assignment_4_ArianaBusciglio Marvel(1).docx
Assignment_4_ArianaBusciglio Marvel(1).docxAssignment_4_ArianaBusciglio Marvel(1).docx
Assignment_4_ArianaBusciglio Marvel(1).docx
ArianaBusciglio
 
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdfANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
Priyankaranawat4
 
MATATAG CURRICULUM: ASSESSING THE READINESS OF ELEM. PUBLIC SCHOOL TEACHERS I...
MATATAG CURRICULUM: ASSESSING THE READINESS OF ELEM. PUBLIC SCHOOL TEACHERS I...MATATAG CURRICULUM: ASSESSING THE READINESS OF ELEM. PUBLIC SCHOOL TEACHERS I...
MATATAG CURRICULUM: ASSESSING THE READINESS OF ELEM. PUBLIC SCHOOL TEACHERS I...
NelTorrente
 
Lapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdfLapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdf
Jean Carlos Nunes Paixão
 
The simplified electron and muon model, Oscillating Spacetime: The Foundation...
The simplified electron and muon model, Oscillating Spacetime: The Foundation...The simplified electron and muon model, Oscillating Spacetime: The Foundation...
The simplified electron and muon model, Oscillating Spacetime: The Foundation...
RitikBhardwaj56
 
Top five deadliest dog breeds in America
Top five deadliest dog breeds in AmericaTop five deadliest dog breeds in America
Top five deadliest dog breeds in America
Bisnar Chase Personal Injury Attorneys
 
A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
Peter Windle
 
Azure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHatAzure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHat
Scholarhat
 
Executive Directors Chat Leveraging AI for Diversity, Equity, and Inclusion
Executive Directors Chat  Leveraging AI for Diversity, Equity, and InclusionExecutive Directors Chat  Leveraging AI for Diversity, Equity, and Inclusion
Executive Directors Chat Leveraging AI for Diversity, Equity, and Inclusion
TechSoup
 
The basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptxThe basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptx
heathfieldcps1
 
Pride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School DistrictPride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School District
David Douglas School District
 

Recently uploaded (20)

Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
 
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdfUnit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdf
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
 
S1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptxS1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptx
 
Best Digital Marketing Institute In NOIDA
Best Digital Marketing Institute In NOIDABest Digital Marketing Institute In NOIDA
Best Digital Marketing Institute In NOIDA
 
"Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe..."Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe...
 
Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.
 
2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...
 
Delivering Micro-Credentials in Technical and Vocational Education and Training
Delivering Micro-Credentials in Technical and Vocational Education and TrainingDelivering Micro-Credentials in Technical and Vocational Education and Training
Delivering Micro-Credentials in Technical and Vocational Education and Training
 
Assignment_4_ArianaBusciglio Marvel(1).docx
Assignment_4_ArianaBusciglio Marvel(1).docxAssignment_4_ArianaBusciglio Marvel(1).docx
Assignment_4_ArianaBusciglio Marvel(1).docx
 
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdfANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
 
MATATAG CURRICULUM: ASSESSING THE READINESS OF ELEM. PUBLIC SCHOOL TEACHERS I...
MATATAG CURRICULUM: ASSESSING THE READINESS OF ELEM. PUBLIC SCHOOL TEACHERS I...MATATAG CURRICULUM: ASSESSING THE READINESS OF ELEM. PUBLIC SCHOOL TEACHERS I...
MATATAG CURRICULUM: ASSESSING THE READINESS OF ELEM. PUBLIC SCHOOL TEACHERS I...
 
Lapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdfLapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdf
 
The simplified electron and muon model, Oscillating Spacetime: The Foundation...
The simplified electron and muon model, Oscillating Spacetime: The Foundation...The simplified electron and muon model, Oscillating Spacetime: The Foundation...
The simplified electron and muon model, Oscillating Spacetime: The Foundation...
 
Top five deadliest dog breeds in America
Top five deadliest dog breeds in AmericaTop five deadliest dog breeds in America
Top five deadliest dog breeds in America
 
A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
 
Azure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHatAzure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHat
 
Executive Directors Chat Leveraging AI for Diversity, Equity, and Inclusion
Executive Directors Chat  Leveraging AI for Diversity, Equity, and InclusionExecutive Directors Chat  Leveraging AI for Diversity, Equity, and Inclusion
Executive Directors Chat Leveraging AI for Diversity, Equity, and Inclusion
 
The basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptxThe basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptx
 
Pride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School DistrictPride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School District
 

Unix Basics For Testers

  • 1. UNIX BASICS - Beginners guide for Unix commands - by Meenakshi For more software testing articles visit: http://www.softwaretestinghelp.com Main features of unix : Multi user - More than one user can use the machine Multitasking- More than one program can be run at a time. Portability – This means the operating system can be easily converted to run on different browsers. Commands 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 explicitly. Without options, ls displays files in a bare format. This bare format however makes it difficult to establish the type, permissions, and size of the files. The most common options to 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, and filename -F appends a character revealing the nature of a file, for example, * for an 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 files are excluded from the list. -R recursively lists subdirectories. The command ls -R / would therefore list all files. cd
  • 2. Is a command line command used to change the current working directory in the Unix and DOS operating systems. It is also available for use in Unix shell scripts or 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's COMMAND.COM. A directory is a logical section of a filesystem used to hold files. Directories may 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 (/ in UNIX, in DOS) or move to any given directory. pwd command (print working directory) is used to print the name of current working directory from a computer's command-line interface. If the shell prompt does not already show this, the user can use this command to find their place in the directory tree. This command is found in the Unix family of operating systems and other flavors as well. The DOS equivalent is "CD" with no arguments. It is 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 command in the Unix operating system is used to make a new Directory. Normal usage is as straightforward as follows: mkdir name_of_directory Where name_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 (short for remove) is a Unix command used to delete files from a filesystem. Common options that rm accepts include: -r, which processes subdirectories recursively -i, which asks for every deletion to be confirmed -f, which ignores non-existent files and overrides any confirmation prompts ("force")
  • 3. rm is often aliased to "rm -i" so as to avoid accidental deletion of files. If a user still wishes to delete a large number of files without confirmation, they can manually cancel out the -i argument by adding the -f option. "rm -rf" (variously, "rm -rf /", "rm -rf *", and others) is frequently used in jokes and anecdotes about Unix disasters. The "rm -rf /" variant of the command, if run by an administrator, would cause the contents of every mounted disk on the computer to be deleted. rmdir is a command which will remove an empty directory on a Unix-system. It cannot be capitalized. Normal usage is straightforward where one types: rmdir name_of_directory Where name_of_directory corresponds with the name of the directory one wishes to delete. There are options to this command such as -p which removes parent directories if they are also empty. For example: rmdir –p foo/bar/baz Will first remove baz/, then bar/ and finally foo/ thus removing the entire directory tree specified in the command argument. Often rmdir will not remove a directory if there is still files present in the directory. To force the removal of the directory even if files are present usually the -rf flag can be used. For example: rmdir -Rf for/bar/baz cp is the 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, and the new file may have the same or a different name. To Copy a File to another File cp [ -f ] [ -h ] [ -i ] [ -p ][ -- ] SourceFile TargetFile To Copy a File to a Directory cp [ -f ] [ -h ] [ -i ] [ -p ] [ -r | -R ] [ -- ] SourceFile ... TargetDirectory To Copy 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 write operations.
  • 4. The removal precedes any copying performed by the cp command. -h – makes the cp command copy symbolic links. The default is to follow symbolic links, that is, to copy files to which symbolic links point. -i (interactive) – prompts you with the name of a file to be overwritten. This occurs if the TargetDirectory or TargetFile parameter contains a file with the same 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. Any other answer prevents the cp command from overwriting the file. -p (preserve) – duplicates the following characteristics of each SourceFile/SourceDirectory in the corresponding TargetFile and/or TargetDirectory: Examples To make a copy of a file in the current directory, enter: cp prog.c prog.bak This copies prog.c to prog.bak. If the prog.bak file does not already exist, the cp command creates it. If it does exist, the cp command replaces it with a copy of the prog.c file. To copy a file in your current directory into another directory, enter: cp jones /home/nick/clients This copies the jones file to /home/nick/clients/jones. To copy a file to a new file and preserve the modification date, time, and access control list associated with the source file, enter: cp -p smith smith.jr This copies the smith file to the smith.jr file. Instead of creating the file with the current date and time stamp, the system gives the smith.jr file the same date and time as the smith file. The smith.jr file also inherits the smith file's access control protection. To copy all the files in a directory to a new directory, enter: cp /home/janet/clients/* /home/nick/customers This copies only the files in the clients directory to the customers directory. To copy a directory, including all its files and subdirectories, to another directory, enter: cp -R /home/nick/clients /home/nick/customers This copies the clients directory, including all its files, subdirectories, and the files in those subdirectories, to the customers/clients directory. To copy a specific set of files to another directory, enter: cp jones lewis smith /home/nick/clients This copies the jones, lewis, and smith files in your current working directory to the
  • 5. /home/nick/clients directory. To use pattern-matching characters to copy files, enter: cp programs/*.c . This copies the files in the programs directory that end with .c to the current directory, signified by the single . (dot). You must type a space between the c and the final dot. find program is a search utility, mostly found on Unix-like platforms. It searches through a directory tree of a filesystem, locating files based on some user-specified criteria. By default, find returns all files below the current working directory. Further, find allows the user to specify an action to be taken on each matched file. Thus, it is an extremely powerful program for applying actions to many files. It also supports regexp matching. Examples From current directory find . -name my* This searches in the current directory (represented by a period) and below it, for files and directories with names starting with my. The backslash before the star is needed to avoid the shell expansion. Without the backslash, the shell would replace my* with the list of files whose names begin with my in the current directory. An alternative is to enclose the the arguments in quotes: find . -name "my*" Files only find . -name "my*" -type f This limits the results of the above search to only regular files, therefore excluding directories, special files, pipes, symbolic links, etc. my* is enclosed in quotes as otherwise the shell would replace it with the list of files in the current directory starting with my Commands The previous 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 bewilderment of naïve users.) find . -name "my*" -type f -ls This prints an extended file information.
  • 6. Search all directories find / -name "myfile" -type f -print This searches every file on the computer for a file with the name myfile. It is generally not a good idea to look for data files this way. This can take a considerable amount of time, so it is best to specify the directory more precisely. Specify a directory find /home/brian -name "myfile" -type f -print This searches for files named myfile in the /home/brian directory, which is the home directory for the user brian. You should always specify 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 This prints 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 parentheses must be escaped with a backslash, "(" and ")", to prevent them from being interpreted as special shell characters. touch is a program on Unix and Unix-like systems used to change a file's date- and time-stamp. It can also be used to create an empty file. The command-syntax is: touch [options] <file_name> If the file exists, its access and modification time-stamps are set to the system's current date and time, as if the file had been changed. To touch a file simulates a change to the file. If the file does not exist, an empty file of that name is created with its access and modification time-stamps set to the system's current date and time. If no file path is specified, the current directory is assumed. touch can be invoked with options to change its behaviour, which may vary from one Unix to another. One option makes it possible to set the file's time-stamp to something other than the current system date and time, but this action is normally restricted to the owner of the file or the system's superuser. echo is a command in Unix (and by extension, its descendants, such as Linux) and MS-DOS that places a string on the terminal. It is typically used in shell scripts and batch programs to output status text to the screen or a file.
  • 7. $ echo This is a test. This is a test. $ echo "This is a test." > ./test.txt $ cat ./test.txt This is a test. cat program concatenates the contents of files, reading from a list of files and/or standard input in sequence and writing their contents in order to standard output. cat takes the list of files as arguments but also interprets the argument "-" as standard input. Example: cat filename who The Unix command who displays a list of users who are currently logged into a computer. The command accepts various options that vary by system to further specify the information that is returned, such as the length of time a particular user has been connected or what pseudo-teletype a user is connected to. The who command is related to the command w, which provides the same information but also displays 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) is a Unix computer program to display the amount of disk space used under a particular directory or files on a file system. du counts the disk space by walking the directory tree. 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. In Linux, it is a part of the GNU Coreutils package. The du utility first appeared in version 1 of AT&T UNIX. Example The -k flag will show the sizes in 1K blocks, rather than the default of 512 byte blocks. $du -k /seclog 4 /seclog/lost+found
  • 8. 132 /seclog/backup/aix7 136 /seclog/backup 44044 /seclog/temp 439264 /seclog We will discuss more advanced commands in the next article. For more software testing resources visit following pages: Software Testing articles: http://www.softwaretestinghelp.com/sitemap/ QA/Testing Job openings: http://www.softwaretestinghelp.com/jobs/ Software Testing Help: http://www.softwaretestinghelp.com/ Copyright 2008: http://www.softwaretestinghelp.com