Wednesday 26 March 2014

Important Linux Commands

lets make a sheet of all day to day commands we Use in our Linux Related Work ...

 

1. tar command examples

i.)Create a new tar archive.

$ tar cvf archive_name.tar dirname/

ii.)Extract from an existing tar archive.
 
$ tar xvf archive_name.tar
iii)View an existing tar archive.
$ tar tvf archive_name.tar
 
 

2. grep command examples

Search for a given string in a file (case in-sensitive search).

$ grep -i "the" demo_file

Search for a given string in all files recursively
$ grep -r "ramesh" *
 
 
 

3. SSH command examples

 
 
4 basic command line usage of the ssh client.
  1. Identify SSH client version
  2. Login to remote host
  3. Transfer Files to/from remote host
  4. Debug SSH client connection

1. SSH Client Version:

$ ssh -V
OpenSSH_3.9p1, OpenSSL 0.9.7a Feb 19 2003 
 
 

2. Login to remote host:

localhost$ ssh -l jsmith remotehost.example.com
 
 

3. File transfer to/from remote host:

 
Copy file from the remotehost to the localhost:
 scp user@IP:/home/related/file.txt remotehostfile.txt
 
Copy file from the localhost to the remotehos  
   scp localfile.txt user@IP:/home/path/file.txt

 

4. Debug SSH Client: 


localhost$ ssh -l user remotehost.example.com

 

 

 --------------------------------------------------------------------------

 

Touch Commands :

The touch command is the easiest way to create new, empty files. It is also used to change the timestamps (i.e., dates and times of the most recent access and modification) on existing files and directories.
touch's syntax is
touch [option] file_name(s)
Thus, for example, the following command would create three new, empty files named file1, file2 and file3:
touch file1 file2 file3
A nice feature of touch is that, in contrast to some commands such as cp (which is used to copy files and directories) and mv (which is used to move or rename files and directories), it does not automatically overwrite (i.e., erase the contents of) existing files with the same name. Rather, it merely changes the last access times for such files to the current time.