SlideShare una empresa de Scribd logo
1 de 8
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

Más contenido relacionado

La actualidad más candente

RESTful services on IBM Domino/XWork
RESTful services on IBM Domino/XWorkRESTful services on IBM Domino/XWork
RESTful services on IBM Domino/XWork
John Dalsgaard
 
The Rise of ZStandard: Apache Spark/Parquet/ORC/Avro
The Rise of ZStandard: Apache Spark/Parquet/ORC/AvroThe Rise of ZStandard: Apache Spark/Parquet/ORC/Avro
The Rise of ZStandard: Apache Spark/Parquet/ORC/Avro
Databricks
 
Linux presentation
Linux presentationLinux presentation
Linux presentation
Nikhil Jain
 

La actualidad más candente (20)

Linux commands
Linux commandsLinux commands
Linux commands
 
Linux: LVM
Linux: LVMLinux: LVM
Linux: LVM
 
Flexible and Real-Time Stream Processing with Apache Flink
Flexible and Real-Time Stream Processing with Apache FlinkFlexible and Real-Time Stream Processing with Apache Flink
Flexible and Real-Time Stream Processing with Apache Flink
 
Adaptive Query Execution: Speeding Up Spark SQL at Runtime
Adaptive Query Execution: Speeding Up Spark SQL at RuntimeAdaptive Query Execution: Speeding Up Spark SQL at Runtime
Adaptive Query Execution: Speeding Up Spark SQL at Runtime
 
Apache Hadoop YARN – Multi-Tenancy, Capacity Scheduler & Preemption - Stamped...
Apache Hadoop YARN – Multi-Tenancy, Capacity Scheduler & Preemption - Stamped...Apache Hadoop YARN – Multi-Tenancy, Capacity Scheduler & Preemption - Stamped...
Apache Hadoop YARN – Multi-Tenancy, Capacity Scheduler & Preemption - Stamped...
 
Real time big data stream processing
Real time big data stream processing Real time big data stream processing
Real time big data stream processing
 
LLAP: Sub-Second Analytical Queries in Hive
LLAP: Sub-Second Analytical Queries in HiveLLAP: Sub-Second Analytical Queries in Hive
LLAP: Sub-Second Analytical Queries in Hive
 
RESTful services on IBM Domino/XWork
RESTful services on IBM Domino/XWorkRESTful services on IBM Domino/XWork
RESTful services on IBM Domino/XWork
 
The Rise of ZStandard: Apache Spark/Parquet/ORC/Avro
The Rise of ZStandard: Apache Spark/Parquet/ORC/AvroThe Rise of ZStandard: Apache Spark/Parquet/ORC/Avro
The Rise of ZStandard: Apache Spark/Parquet/ORC/Avro
 
Tuning and Debugging in Apache Spark
Tuning and Debugging in Apache SparkTuning and Debugging in Apache Spark
Tuning and Debugging in Apache Spark
 
Linux presentation
Linux presentationLinux presentation
Linux presentation
 
Apache Tez: Accelerating Hadoop Query Processing
Apache Tez: Accelerating Hadoop Query Processing Apache Tez: Accelerating Hadoop Query Processing
Apache Tez: Accelerating Hadoop Query Processing
 
Dynamic filtering for presto join optimisation
Dynamic filtering for presto join optimisationDynamic filtering for presto join optimisation
Dynamic filtering for presto join optimisation
 
Hadoop Hive Tutorial | Hive Fundamentals | Hive Architecture
Hadoop Hive Tutorial | Hive Fundamentals | Hive ArchitectureHadoop Hive Tutorial | Hive Fundamentals | Hive Architecture
Hadoop Hive Tutorial | Hive Fundamentals | Hive Architecture
 
Hadoop Summit 2012 | Optimizing MapReduce Job Performance
Hadoop Summit 2012 | Optimizing MapReduce Job PerformanceHadoop Summit 2012 | Optimizing MapReduce Job Performance
Hadoop Summit 2012 | Optimizing MapReduce Job Performance
 
YOW2021 Computing Performance
YOW2021 Computing PerformanceYOW2021 Computing Performance
YOW2021 Computing Performance
 
LLAP: Building Cloud First BI
LLAP: Building Cloud First BILLAP: Building Cloud First BI
LLAP: Building Cloud First BI
 
Apache Flink internals
Apache Flink internalsApache Flink internals
Apache Flink internals
 
Kafka at half the price with JBOD setup
Kafka at half the price with JBOD setupKafka at half the price with JBOD setup
Kafka at half the price with JBOD setup
 
Hadoop Overview kdd2011
Hadoop Overview kdd2011Hadoop Overview kdd2011
Hadoop Overview kdd2011
 

Destacado

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
 
Vsam interview questions and answers.
Vsam interview questions and answers.Vsam interview questions and answers.
Vsam interview questions and answers.
Sweta Singh
 
Cobol questions and answers
Cobol questions and answersCobol questions and answers
Cobol questions and answers
Sweta Singh
 
Project manager interview questions and answers
Project manager interview questions and answersProject manager interview questions and answers
Project manager interview questions and answers
Sweta Singh
 
Linux or unix interview questions
Linux or unix interview questionsLinux or unix interview questions
Linux or unix interview questions
Teja Bheemanapally
 
Manual testing interview questions and answers
Manual testing interview questions and answersManual testing interview questions and answers
Manual testing interview questions and answers
karanmca
 
Ibm db2 interview questions and answers
Ibm db2 interview questions and answersIbm db2 interview questions and answers
Ibm db2 interview questions and answers
Sweta Singh
 
Practical unix utilities for text processing
Practical unix utilities for text processingPractical unix utilities for text processing
Practical unix utilities for text processing
Anton Arhipov
 
Linux User Space Debugging & Profiling
Linux User Space Debugging & ProfilingLinux User Space Debugging & Profiling
Linux User Space Debugging & Profiling
Anil Kumar Pugalia
 
Cts informatica interview question answers
Cts informatica interview question answersCts informatica interview question answers
Cts informatica interview question answers
Sweta Singh
 

Destacado (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 a Unix Basics For Testers

Similar a 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
 
Unix Linux Commands Presentation 2013
Unix Linux Commands Presentation 2013Unix Linux Commands Presentation 2013
Unix Linux Commands Presentation 2013
 
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
 

Último

The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
heathfieldcps1
 

Último (20)

How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentation
 
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptxCOMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docx
 
Food safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfFood safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdf
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and Modifications
 
How to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptxHow to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptx
 
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxHMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17
 
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfUGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
 
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptxHMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
 
Single or Multiple melodic lines structure
Single or Multiple melodic lines structureSingle or Multiple melodic lines structure
Single or Multiple melodic lines structure
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)
 
How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17
 
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptxOn_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
 
Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 

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