Sunday 4 November 2012

UNIX COMMANDS


         UNIX COMMANDS

1) Tail     :   Displays last 10 lines from ending

Syntax : $ tail file-name



2) Ch mod : Change Mod

Syntax : $ ch-mod [user/group/others/all]+[permission] file-name



----> User : read , write , execute (r,w,x)

----> Group : read , execute (r,x)


----> Others : No Permissions.



a) Read : 4

b) Write : 2


c) Execute : 1





3) Top : View CPU usage for all processes

Syntax : $ top



4) Kill : Used for terminating process



Syntax : $ kill [-signal] [process id]

ex: $ kill -9 process id




5) $ kill -0 : Terminates all current process except your shell



6) Who : List all users who are currently on the system.

Syntax : $ who



7) who am i : Reports the details about the command user.

Syntax : $ who am i




DISK COMMANDS : 



1) du : Gives amount of disk space usage

Syntax : $ du [options] [directory or file]




2) $du –sh file/dir
      ----> Gives the size of the file/dir

3) df -kh : Gives Available space mounted on file system.

4) du -sm : Shows in no of blocks.




LS COMMANDS :

1) ls -al   :  To show all files in Current directory.

2) ls -ltr  :  List the files in directory with the Newest files last.

3) ls - l | grep "^d" : Only users created directories in your system.

4) ls -of -i  : 9080 To check the port

5) less  : To view tar files without untar.




COMPRESS COMMANDS : 

1) gzip  :  Used to compress the file.

2) gunzip : Decompress a file.




PROCESS COMMANDS :



1) ps -ef : All ports will be displayed.

2) ps -ef | grep java : Show all Java processes.

3) ps -ef | grep java | wc -l  : To show how many java processes are running on system.

4) ps -ef | grep java | wc -c  : Display one line Character Count.




SEARCH COMMANDS :



1) Find  : The find command is used to find the files in the hard drive.

Example: $ find *.pl



2) Locate  :  The locate command is much faster than the find command.

-----> Finding a file using locate is faster when compared to the find command


Example : $ locate



Q)   How to check a particular port is working or not in unix?



A)  netstat -a | grep 80




Q) What is the present LINUX VERSION  ?



A) VERSION 5.0


Q)  In ls -lrt, what t stands for and r stands for l stands for?



A)  -l shows you huge amounts of information (permissions, owners, size, and when last modified.)
     -r reverses the order of how the files are displayed.
     -t shows you the files in modification time


Q)  How to check WAS is running or not through PS?

A)  Ps -grep


Q)  How to check the multiple NIC in Unix or linux? (NIC NETWORK INTERFACE CARD)

A)  ifconfig -a


Q)  
How to identify and kill a process ID?


A) ps -ef



Q)  How will you Check Application Status  ?

A)  ps -ef |grep appservername ( from AdminConsole  ------>  Enterprise Applications )



Q) How will you Check the Port Status   ?

A)  using netstat command




Q) What information you get with command ps -ef |grep httpd  ?

A)  We get all Web Servers information with Process ID



Q)  To repeat a Command continuously  ?


A) netstat -a| grep



Q) How to Check Physical Memory RAM in the System  ?

A) bootinf-r Will give you Physical Memory details of Unix Box.



Q) If we want to see the last 7 days data which command we have to use ?

A)Find /home -atime +7
  
  • -atime +7: All files that were last accessed more than 7 days ago
  • -atime 7: All files that were last accessed exactly 7 days ago
  • -atime -7: All files that were last accessed less than7 days ago
Q) Display list of all files in /home directory that were not last modified less than then days ago.

A) find /home -mtime -7

Q) To find file in last 2 months (60 days) you need to use ?

A)  -mtime +60 means you are looking for a file modified 60 days ago.
      -mtime -60 means less than 60 days.
      -mtime 60 If you skip + or - it means exactly 60 days.

Q)  search for just files that have been modified in the last seven days ?

A) find .  -mtime  -7  -type -f

Q)  search for just directories that have been modified in the last seven days ?

A) find .  -mtime  -7  -type -d


Q)  you want to search the "/tmp" directory instead of the current directory for files modified in the last three days ?

A) find  /tmp  -mtime  -3  -type  -d

Q) find a file or directory that has been modified in the last seven days ?

A) find .  -mtime  -7

0 comments:

Post a Comment