Open Source Technical Information: locate command

Monday, 24 October 2011

locate command

,
First we should know that commands are case-sensitive,and most commands take arguments(parameters).
LOCATE:

The locate command is used to search a file by its name.

Eg: locate hello.txt
this will print the path where it finds hello.txt file in your system.

The pwd,mkdir,rmdir.


PWD:
The ‘pwd’ command is used to display or print the present working directory.
Eg: pwd

/home/parthi/Documents/


MKDIR:
The ‘mkdir’ command is used to create a new directory.
Eg: mkdir new
A new directory named ‘new’ will be created.
you can also create multiple new directories.
Eg: mkdir hello abcd xyz
new directories named ‘hello’ ,’abcd’ , ‘xyz’ will be created.

RMDIR:
The ‘rmdir’ command is used to delete or remove empty directory.
Eg: rmdir new
this deletes the directory called ‘new’ if its empty.
Eg: rmdir hello abcd xyz
multiple directories can also be deleted like this.

 paste – A command to combine columns of two different files.


(word.txt)
hello
how’s
where’s
(word1.txt)
dude
life!!!
everyone????

$ paste word.txt word1.txt

o/p:
hello      dude.
how’s     life!!!
where’s  everyone???

 Sending files using SCP command

scp(secure copy) is used to copy files across an ssh connection that will be encrypted by  algorithms. so its more secure.
To use this command you need to have open-ssh installed in the hosts.

so lets see how to use it,

scp [[user1@]from-host:]source-file [[user2@]to-host:][destination-file]

where:-
user1 = the user1 is the one who owns the file i.e to be transferred.

user2 = user 2 is the one whom you are trying to send the file.

from-host = is the user1 ip address.

to-host = is the user2 ip address.

source-file = is where the file is the user1′s computer.

destination-file = where you want to store the file in user2′s computer after copying.

there are few options

-p    preserves the modification and access time,and also the permission of the source-file in                      destination-file
-q    wont show the progress indicator
-r     recursive,i.e it copies all the contents in the source-file (directory)
-v     shows debug messages

eg:

scp -r parthi@198.122.2.1:/home/parthi/books student@198.122.2.5:/home/student/
this copies the entire directory…

 ‘echo’ command…


The echo command is used to display or print its arguments(parameters)
Eg: echo basic linux commands
basic linux commands
ok now it prints its arguments as it is,
lets try echo itself as a argument…

Eg: $ echo echo
echo

ok it just prints echo. so echo prints the arguments, whatever it may be…

CAT:
The cat command is used to create and display the contents of a file. after entering the contents press ctrl+d.
Eg: $ cat > hello.txt
hello world
any one there
$ cat hello.txt
hello world
any one there


so,it “cat > filename” is used to create a file and “cat filename” is used to display the contents in the terminal.

LS:
The ls command is used to list the files and directories in the current working directory.
Eg: $ ls
hello.txt
word.txt
nitin

RM:
The rm command is used to remove the file or folder.
Eg: rm hello.txt

no output message appears. that s because it does its job silently.only throws messages when there is some problem in deleting the given file.
let s see when we try to delete a file which is not there.
Eg: rm hello.txt
rm: cannot remove `hello.txt’: No such file or directory

fine. lets move on to cp (i.e) copy command…

CP:
The cp command is used to copy file from one file to another or one place to another

Eg: cp word.txt hello.txt

since there is no file named hello.txt in present folder cp commands creates and copies the contents from word.txt. if the file hello.txt is already present in directory it overwrites the file.

0 comments to “locate command”

Post a Comment

Write your tips here...

Deal of the Day

Advertisement here

Advertisement here