Single Post

Header

Sunday, September 6, 2015

How to execute/run .sh or .bin or .run file in Linux/Unix

How to execute/run .sh or .bin or .run file in Linux/Unix

1.Give Execute permissions to .sh or .bin or .run  file
2.Execute the below command

 chmod +x jdk-6u35-linux-x64.bin      (bin file)
  ./jdk-6u35-linux-x64.bin

 chmod +x install.sh     (sh file)
 ./install.sh

 chmod +x  postgresql-9.2.1-1-linux-x64.run      (run file)
 ./postgresql-9.2.1-1-linux-x64.run

Wednesday, September 2, 2015

gunzip , tar , unzip commands in Unix/Linux - with Examples

gunzip and tar commands in Linux  (file.tar.gz)

[admin@localhost Desktop]$ ls
linux_grep      new       new file~        practice       test1.txt
linux_grep.txt  new file    sample.tar.gz
[admin@localhost Desktop]$ gunzip sample.tar.gz
[admin@localhost Desktop]$ ls
linux_grep      new       new file~        practice    test1.txt
linux_grep.txt  new file    sample.tar
[admin@localhost Desktop]$ tar -xvf sample.tar
sample/
sample/amiga/
sample/amiga/match.a
sample/amiga/Makefile.gcc
sample/amiga/Makefile.sasc
sample/amiga/tailor.c
sample/amiga/utime.h
sample/atari/

[admin@localhost Desktop]$ ls
sample      new          test1.txt
linux_grep      new file   practice      
linux_grep.txt  new file~  sample.tar
Unzip Command in Linux

[admin@localhost Desktop]$ cp testfolder.zip  practise/
[admin@localhost Desktop]$ cd practise/
[admin@localhost practise]$ ls
sample1.txt  test1  test1.txt  testfolder.zip

[admin@localhost practise]$ unzip testfolder.zip
Archive:  testfolder.zip
   creating: test folder/
 extracting: test folder/test1.txt 
 extracting: test folder/test2.txt

[admin@localhost practise]$ ls
sample1.txt  test1  test1.txt  test folder  testfolder.zip

Tuesday, September 1, 2015

How to use and save session - WinSCP Linux/Unix

How to use and save session - WinSCP  Linux/Unix


                              1.Give the IP Address , UserName and pwd. Click on Save button


                                 2.Give the session name and Click on "OK" button


 
3.Select the saved session and Click on  "Login" button

4.Enter the Password and Click on "OK"

5.We get the Local Computer folders on left side and Linux machine folders on right side


How to Use and Save Session - Putty Linux/Unix

How to Use and Save Session - Putty  Linux/Unix
 
1.Give IP Address and Session Name .Click on "Save" Button


2.After clicking "save" ,We can find the saved session in the list


3.Select the saved session and click on "Open" button



4.After clicking on "Open" button .We will find the command prompt



How to remove all the folders and files inside a folder in Linux/Unix

How to remove all the folders and files inside a folder in Linux/Unix


[admin@myhost test]$ ls
folder1  folder2  new file  sample.txt  sample.txt~  test1.txt  test1.txt~
[admin@myhost test]$ rm -rf *
[admin@myhost test]$ ls
[admin@myhost test]$

How To Change hostname in Linux

Change hostname in Linux

[venkatesh@localhost /]$ su
Password:
[root@localhost /]# hostname
localhost.localdomain
[root@localhost /]# hostname myhost.mydomain
[root@localhost /]# hostname
myhost.mydomain
[root@localhost /]#

Find and Grep Command in Unix/Linux - with Examples

Find Command in Unix/Linux:

[ivreddy@localhost practise]$ find -name test1.txt
./test1.txt
./test1/test1.txt
[ivreddy@localhost practise]$ find . -name test1.txt
./test1.txt
./test1/test1.txt
[ivreddy@localhost practise]$ cd ..
[ivreddy@localhost Desktop]$ cat >test1.txt
test
[ivreddy@localhost Desktop]$ cd practise/

[ivreddy@localhost practise]$ find . -name test1.txt
./test1.txt
./test1/test1.txt
[ivreddy@localhost practise]$ find ~ -name test1.txt
/home/ivreddy/Desktop/test1.txt
/home/ivreddy/Desktop/practise/test1.txt
/home/ivreddy/Desktop/practise/test1/test1.txt
[ivreddy@localhost practise]$

Grep command in Unix/Linux

[ivreddy@localhost practise]$ cat test1.txt
welcome to linux
goto linux commands
check the commands
learn grep and find
vi search word
one more linux
learn well
[ivreddy@localhost practise]$ grep learn test1.txt
learn grep and find
learn well

Kill command in Unix/Linux - with Examples

How to kill a process like opened new file in Linux

[ivreddy@localhost practice]$ ps -ef | grep new
ivreddy   3072     1  3 23:00 ?        00:00:00 gedit

/home/ivreddy/Desktop/new file
ivreddy   3076  2901  1 23:00 pts/0    00:00:00 grep new
[ivreddy@localhost practice]$ kill -9 3072
[ivreddy@localhost practice]$ ps -ef | grep new
ivreddy   3099  2901  0 23:01 pts/0    00:00:00 grep new
[ivreddy@localhost practice]$

How to kill a browser in Linux


[ivreddy@localhost ~]$ ps -ef | grep firefox
ivreddy  26674     1  3 12:49 ?        00:00:10 /usr/lib/firefox-3.6/firefox
ivreddy  26832 26298  0 12:54 pts/1    00:00:00 grep firefox
[ivreddy@localhost ~]$ kill -9 26674
[ivreddy@localhost ~]$ ps -ef | grep firefox
ivreddy  26837 26298  0 12:54 pts/1    00:00:00 grep firefox

Note : Use kill -9 <process id> to kill forcely

Copy and Remove Files/Folders in Unix/Linux - wiht Examples

Simple Copy Command in Linux :


[ivreddy@localhost practice]$ mkdir test
[ivreddy@localhost practice]$ ls
sample1.txt  test  test1  test1.txt  testfolder.rar
[ivreddy@localhost practice]$ cp sample1.txt test1.txt test
[ivreddy@localhost practice]$ cd test
[ivreddy@localhost test]$ ls
sample1.txt  test1.txt

[ivreddy@localhost test]$ cp test1.txt test2.txt
[ivreddy@localhost test]$ ls
sample1.txt  test1.txt  test2.txt

Copy with Recursive and Force in Linux:

[ivreddy@localhost practice]$ cp -rf test test2
[ivreddy@localhost practice]$ ls
sample1.txt  test  test1  test1.txt  test2  testfolder.rar
[ivreddy@localhost practice]$ cd test2
[ivreddy@localhost test2]$ ls
sample1.txt  test1.txt  test2.txt

Remove with Recursive and Force in Linux


[ivreddy@localhost practice]$ ls
sample1.txt  test  test1  test1.txt  test2  test3  testfolder.rar
[ivreddy@localhost practice]$ rm test1.txt sample1.txt
[ivreddy@localhost practice]$ ls
test  test1  test2  test3  testfolder.rar
[ivreddy@localhost practice]$ rm -rf test3
[ivreddy@localhost practice]$ ls
test  test1  test2  testfolder.rar
[ivreddy@localhost practice]$

Linux/Unix Simple Commands

Interview Linux/Unix Command Examples


1.Grep Command in Linux/Unix Examples :

a.Find the word present in a file

grep <word> <filename>

b.Find the word present in the current and sub directories

grep -r <word> .

"." <dot> represents the current directory and "-r" represents recursive

2.df command for disk free space in linux


[ivreddy@localhost test]$ df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/sda2              16G  4.0G   11G  27% /
tmpfs                1012M  432K 1012M   1% /dev/shm
/dev/sda1             291M   30M  247M  11% /boot
/dev/sr0               46M   46M     0 100% /media/Reliance
[ivreddy@localhost test]$

3.top command gives an ongoing look at processor activity in real time. It displays a listing of the most CPU-intensive tasks on the system

[admin@localhost test]$ top
  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND        
 1942 root      20   0 75076  26m 8372 S 10.3  1.3   2:34.03 Xorg            
 2381 admin   20   0  315m  55m  23m S  3.3  2.7   4:56.94 firefox        
 2357 admin   20   0 51096  12m 9496 S  2.3  0.6   0:12.77 gnome-terminal  
 8161 admin   20   0  2676 1116  868 R  0.7  0.1   0:00.20 top            
 2242 admin   20   0 91836  21m  16m S  0.3  1.1   0:44.49 vmtoolsd        
    1 root      20   0  2852 1408 1192 S  0.0  0.1   0:02.27 init

4.sort command in linux

[ivreddy@localhost Desktop]$ cat file
linux
dos
unix
windows
unix
[ivreddy@localhost Desktop]$ sort file
dos
linux
unix
unix
windows
// sort -u <file> will display the uniq records
[ivreddy@localhost Desktop]$ sort -u file
dos
linux
unix
windows
// sort -r <file> will display the  records in reverse order
[ivreddy@localhost Desktop]$ sort -r file
windows
unix
unix
linux
dos
[ivreddy@localhost Desktop]$

ls commands in Unix.Linux - with Examples

Different ls commands in Linux:

[admin@localhost Desktop]$ pwd
/home/admin/Desktop
[admin@localhost Desktop]$ ls
linux_grep      new file   new file (copy)  test1.txt       testfolder.zip
linux_grep.txt  new file~  practice         testfolder.rar  zip unzip.txt

[admin@localhost Desktop]$ ls -l
total 48
-rw-rw-r--. 1 admin admin  1286 Aug 22 22:05 linux_grep
-rw-rw-r--. 1 admin admin  3758 Aug 22 22:26 linux_grep.txt
-rw-rw-r--. 1 admin admin    20 Sep 20 12:50 new file
-rw-rw-r--. 1 admin admin     0 Sep 20 12:50 new file~
-rw-rw-r--. 1 admin admin     0 Oct  1 23:00 new file (copy)
drwxrwxr-x. 5 admin admin  4096 Oct  1 22:49 practice
-rw-rw-r--. 1 admin admin   184 Sep 20 12:41 test1.txt
-rw-rw-r--. 1 admin admin   220 Sep 20 17:38 testfolder.rar
-rw-rw-r--. 1 admin admin   390 Sep 20 12:59 testfolder.zip
-rw-rw-r--. 1 admin admin 20190 Oct  1 22:31 zip unzip.txt

[admin@localhost Desktop]$ ls -lt
total 48
-rw-rw-r--. 1 admin admin     0 Oct  1 23:00 new file (copy)
drwxrwxr-x. 5 admin admin  4096 Oct  1 22:49 practice
-rw-rw-r--. 1 admin admin 20190 Oct  1 22:31 zip unzip.txt
-rw-rw-r--. 1 admin admin   220 Sep 20 17:38 testfolder.rar
-rw-rw-r--. 1 admin admin   390 Sep 20 12:59 testfolder.zip
-rw-rw-r--. 1 admin admin    20 Sep 20 12:50 new file
-rw-rw-r--. 1 admin admin     0 Sep 20 12:50 new file~
-rw-rw-r--. 1 admin admin   184 Sep 20 12:41 test1.txt
-rw-rw-r--. 1 admin admin  3758 Aug 22 22:26 linux_grep.txt
-rw-rw-r--. 1 admin admin  1286 Aug 22 22:05 linux_grep

[admin@localhost Desktop]$ ls -lrt
total 48
-rw-rw-r--. 1 admin admin  1286 Aug 22 22:05 linux_grep
-rw-rw-r--. 1 admin admin  3758 Aug 22 22:26 linux_grep.txt
-rw-rw-r--. 1 admin admin   184 Sep 20 12:41 test1.txt
-rw-rw-r--. 1 admin admin     0 Sep 20 12:50 new file~
-rw-rw-r--. 1 admin admin    20 Sep 20 12:50 new file
-rw-rw-r--. 1 admin admin   390 Sep 20 12:59 testfolder.zip
-rw-rw-r--. 1 admin admin   220 Sep 20 17:38 testfolder.rar
-rw-rw-r--. 1 admin admin 20190 Oct  1 22:31 zip unzip.txt
drwxrwxr-x. 5 admin admin  4096 Oct  1 22:49 practice
-rw-rw-r--. 1 admin admin     0 Oct  1 23:00 new file (copy)

[admin@localhost Desktop]$ ls -ls
total 48
 4 -rw-rw-r--. 1 admin admin  1286 Aug 22 22:05 linux_grep
 4 -rw-rw-r--. 1 admin admin  3758 Aug 22 22:26 linux_grep.txt
 4 -rw-rw-r--. 1 admin admin    20 Sep 20 12:50 new file
 0 -rw-rw-r--. 1 admin admin     0 Sep 20 12:50 new file~
 0 -rw-rw-r--. 1 admin admin     0 Oct  1 23:00 new file (copy)
 4 drwxrwxr-x. 5 admin admin  4096 Oct  1 22:49 practice
 4 -rw-rw-r--. 1 admin admin   184 Sep 20 12:41 test1.txt
 4 -rw-rw-r--. 1 admin admin   220 Sep 20 17:38 testfolder.rar
 4 -rw-rw-r--. 1 admin admin   390 Sep 20 12:59 testfolder.zip
20 -rw-rw-r--. 1 admin admin 20190 Oct  1 22:31 zip unzip.txt

[admin@localhost Desktop]$ ls -lrs
total 48
20 -rw-rw-r--. 1 admin admin 20190 Oct  1 22:31 zip unzip.txt
 4 -rw-rw-r--. 1 admin admin   390 Sep 20 12:59 testfolder.zip
 4 -rw-rw-r--. 1 admin admin   220 Sep 20 17:38 testfolder.rar
 4 -rw-rw-r--. 1 admin admin   184 Sep 20 12:41 test1.txt
 4 drwxrwxr-x. 5 admin admin  4096 Oct  1 22:49 practice
 0 -rw-rw-r--. 1 admin admin     0 Oct  1 23:00 new file (copy)
 0 -rw-rw-r--. 1 admin admin     0 Sep 20 12:50 new file~
 4 -rw-rw-r--. 1 admin admin    20 Sep 20 12:50 new file
 4 -rw-rw-r--. 1 admin admin  3758 Aug 22 22:26 linux_grep.txt
 4 -rw-rw-r--. 1 admin admin  1286 Aug 22 22:05 linux_grep

[admin@localhost Desktop]$ ls -lsrt
total 48
 4 -rw-rw-r--. 1 admin admin  1286 Aug 22 22:05 linux_grep
 4 -rw-rw-r--. 1 admin admin  3758 Aug 22 22:26 linux_grep.txt
 4 -rw-rw-r--. 1 admin admin   184 Sep 20 12:41 test1.txt
 0 -rw-rw-r--. 1 admin admin     0 Sep 20 12:50 new file~
 4 -rw-rw-r--. 1 admin admin    20 Sep 20 12:50 new file
 4 -rw-rw-r--. 1 admin admin   390 Sep 20 12:59 testfolder.zip
 4 -rw-rw-r--. 1 admin admin   220 Sep 20 17:38 testfolder.rar
20 -rw-rw-r--. 1 admin admin 20190 Oct  1 22:31 zip unzip.txt
 4 drwxrwxr-x. 5 admin admin  4096 Oct  1 22:49 practice
 0 -rw-rw-r--. 1 admin admin     0 Oct  1 23:00 new file (copy)

[admin@localhost Desktop]$ ls -la
total 56
drwxr-xr-x.  3 admin admin  4096 Oct  1 23:00 .
drwx------. 28 admin admin  4096 Oct  2 12:01 ..
-rw-rw-r--.  1 admin admin  1286 Aug 22 22:05 linux_grep
-rw-rw-r--.  1 admin admin  3758 Aug 22 22:26 linux_grep.txt
-rw-rw-r--.  1 admin admin    20 Sep 20 12:50 new file
-rw-rw-r--.  1 admin admin     0 Sep 20 12:50 new file~
-rw-rw-r--.  1 admin admin     0 Oct  1 23:00 new file (copy)
drwxrwxr-x.  5 admin admin  4096 Oct  1 22:49 practice
-rw-rw-r--.  1 admin admin   184 Sep 20 12:41 test1.txt
-rw-rw-r--.  1 admin admin   220 Sep 20 17:38 testfolder.rar
-rw-rw-r--.  1 admin admin   390 Sep 20 12:59 testfolder.zip
-rw-rw-r--.  1 admin admin 20190 Oct  1 22:31 zip unzip.txt
[admin@localhost Desktop]$