You are on page 1of 13

Naveenkumar +91 8553557585

LINUX COMMANDS

1) What is the default Telnet Port Number?


23
2) What is the default SSH Port Number?
22
3) Command to check Host Name?
hostname
4) What is the output of ls command?
List of directory Structure
O/P: NAVEEN RAM SOFTWARES NEWFOLDER
WASRES.TXT IHS.TXT PLUGIN.TXT KUMAR.TXT
5) What is the command to find hidden files?
ls -a
6) What is the output of ls l and explain the output?
Long List Format.
7) What is output of ls lrt and explain the output?
Recent modified files= ls -lrt

8) How to find free disk space and explain the output?


df -m (m=megabyte, k=kilobyte)
Used space du -m
9) How to change file permissions and what is the syntax to change file permissions?
chmod 777 <file name> (or) chomd -R 777 <file name>

1
Naveenkumar +91 8553557585

10) What is the syntax to change ownership of a file?


chown <user name>:<group name> <file name>
To change entire directory:
chown -R <username>:<password> <Path of the directory>
11) What is the command to check how many users are currently logged into the box?
users (or) who
12) What is the command to check, what are the processes that are currently running with a
particular user?
ps u <root name>
13) What is the use of sudo , su and syntax?
SUDO: The Run a Single Command with root privileges when you execute SUDO
command, the system prompts you for your current user accounts password before
running command as the root user.
Su: The su command switches to the super user or root when you execute it with it with
no additional options. You ha e to e ter the root a ou t s Pass ord.
14) How to rename a file or directory, syntax?
mv <old file name > <new file name>
Ex: mv apple.txt naveen.txt
15) How to remove a file and director, syntax, create a directory and syntax?
Remove a file and director rm r <file name >
Create a Director mkdir <file name>
16) How to search a file abc.txt, syntax (Ref: http://www.tecmint.com/35-practical-
examples-of-linux-find-command/ ---- Execute all the commands)
find . <directory path> -name <file name>
Ex= find . /root/Desktop/ -name naveen.txt
17) Command search a file which is modified older than 10 days.?
find <directory path> -atime +10
Access Time= -atime Change Time= -ctime Modify Time= -mtime
18) Command search a file which is modified older than 10 days and delete that files?
find <directory path> -mtime +10
19) Command to find empty directories?
find . -type d -empty
find / -type f -empty
20) Command to find the files which are owned by a particular user?
Syntax: find <Direct Path> -name -user <user name>
Ex: find /root/Desktop/NAVEEN/ -user root
21) Command to find and delete multiple files which ends with .txt?
rm f <file name1.txt> <file name2.txt><file name3.txt>
22) Command to find the file which are more than 100mb in size?
find . -size +100M
(.)= indicates current Directory (/)= indicate entire system

2
Naveenkumar +91 8553557585

23) Command to find the file which are more than 100mb in size delete that files?
find . -type f -name -size +100m -exec rm rm
find / -size +100M -exec rm -rm
The Between 50mb to 100mb
find / -size +50M -size +100/M
24) What is the use of Symbolic Link and hardlink files?
Softlink It create a separate in ode for linked file. We should not delete the original
file to access the softlink.
Hardlink It does t ha e a separate i ode. Hard link file will be deleted when we
delete the original file.
25) Command to find a string in a file?
find . <Directory path> -name <file name>
26) Command to find particular file in a directory?
find . -name <file name>
27) Command to check NIC cards are enabled or not?
Enable: The NIC sta ds for Net ork I terfa e Card. The up or ifup flag ith
Interface name (eth0) activates an Network Interface.
Ifconfig eth0 up
Desible: The do or ifdo flag ith i terfa e eth0 Dea ti ates the spe ified
Network interface.
Ifconfig eth0 down
28) What is the use of FTP?
The File Transfer Protocol (FTP) is a Standard Network Protocol used to Transfer
Computer files from one host to another host over a TCP such as the Internet. The FTP is
built on a Client Server Architecture and users separate Control and data Connections
between the Client and Server.
ftp <ip address>
ftp> <username>
ftp> <password>
ftp> mput <file1> <file2> .<file n> /dirput multiple files to unix box a particular
dir.
ftp> get <filename> get a file from unix box to windows.
ftp> mget <file1> <file2> .<file n> get multiple file from unix box to windows
ftp> quit used to quit from unix box.
29) Explain the procedure to transfer files from one UNIX box to other unix box by using
FTP?
scp <filename1> <username>@<ip address or hostname>:<path where to
copy>
Eg: scp naveen.txt kumar@192.168.32.64:/root/Desktop/naveen.txt
Copy file sample.txt to 192.168.32.64 box /root/Desktop/raj directory.

3
Naveenkumar +91 8553557585

30) What are different Run levels in Linux?


Run Level 0: Halt System (To shutdown the system)
Run Level 1: Single user mode
Run Level 2: Basic multi user mode without NFS
Run Level 3: Full multi user mode (text based)
Run Level 4: unused
Run Level 5: Multi user mode with Graphical User Interface
Run Level 6: Reboot System
31) Command to display number of lines in a file?
wc -l <file name> (Number of Lines Displayed)
wc -c <filename> (Number of Characters Displayed)
wc -w <filename> (Number of Words Displayed)
wc <filename> (Displayed the line no and words and characters)
32) How to insert a line numbers in a file?
Press esc :set nu Ex= :set nu
33) How to insert a blank line in VI editor?
Open file in vi mode
Ex= vi naveen.txt
o(alpha et o above empty line inserted)
O(alpha et O below empty line inserted)
34) How to delete a line in VI editor?
Open the file in vi editor
Press ecs :g/^$/d Presenter
35) How to delete a string in a file?
sed -i /<stri g a e>/d <file a e>
36) How to save and quit in Vi editor?
Press ecs :wq (q! without saving)
37) What is the use of pfiles?
The pfiles Information about all open Files in a particular User or PID
pfiles <pid> or pfiles
38) What is the use of ptree?
Information about Running Processes in a Tree Structured in a Particular USER or PID
ptree <pid> (or) ptree
39) How to find detailed description about a running process?
ps
40) What is the use of cat and touch command?
cat command is used to create a file
touch command is used to we can create multiple files
Ex= touch naveen.txt, kumar.txt, ram.txt, guru.txt
41) What is the use of man?
The man command is used to format and display the man pages. The man pages are
a user manual that is by default built into Linux distributions.
man -help

4
Naveenkumar +91 8553557585

42) How to check which user is logged in?


who am i
43) What is the use of a k o a d?
Awk is most useful when handling text files that are formatted in a predictable way. For
instance, it is excellent at parsing and manipulating tabular data. It operates on a line-by-
line basis and iterates through the entire file.
a k {gsu apple , filename }=to use the delete the ord
a k {gsu a , <filename> ; pri t}=to use the All letters ill e deleted
44) What is the use of sar Command?
Using sar you can monitor performance of various Linux subsystems
(CPU, Memory, I/O) in real time.
Syntax= sar (or) sar -u (or) sar -S
45) Full command to copy a file from One unix box to other unix box?
scp <filename> <username>@ <hostname> : <Directory Path>
46) What is the use of sticky bit?
The Owner or Super User only can Delete and rename the Files. If you enable a sticky
it o a file, group users others o l a read, rite a d e e ute that files ut a t
Delete
Ex: chmod +t <file name> To enable the sticky bit.
chmod t <file name> To disable the sticky bit.
47) Command to check ipaddress, free disk space, free memory?
ip address-> ifconfig free disk space-> df-m
free memory-> free-m
48) How to move a cursor to end of the file in Vi editor?
G
49) How to move a cursor to end of the line in Vi editor?
$
50) How to move a cursor to start of the file in Vi editor?
1G
51) How to move a cursor to start of the line and search in a string in Vi editor?
Move a Curer to the Start of the line= ZERO (0)
Search the string In Vi editor = /string name to forward and ?
52) How to change a file permission for a file?
Chmod 777 <filename>
53) What indicates chmod 723 f1.txt?
-rwx ---w ---wx root root November 20 2015 naveen.txt
54) How to find the given OS is 32 bit or 64 bit and Os version?
arch (or) uname -m
i686 is 32bit x86_64 is 64 bit
Find the given Operating System Version?
more /etc/*release
55) What is the difference between 32 bit OS and 64 bit OS?
The 32 bit Architecture is i686
The 64 bit Architecture is x86_64

5
Naveenkumar +91 8553557585

56) I want to execute a script, everyday at 5:00 p.m. Write a cronjob Syntax to achieve that?
<Min> <Hour> <Date of the Month> <Month> <Day of the Week> <path of
script>*17***<Path of the script>
57) How to list and edit the crontabs?
Crontab Command manages the cron table that is used by the cron to execute the cron
jobs. This article explain the various command line options of the crontab command.
crontab -l (-l stands for list. This displays the crontab of the current user.
i e I logged i as root, this ill displa the ro jo s of root user.
crontab -e(-e stands for edit. This allows you to edit the crontab of the
current user
ccrontab -r(-r stands for remove. This will remove all the cron job
entries of the current user as shown below.
58) What is the cronjob syntax?
crontab -i <direct path > <file name>
59) What is the difference between kill -3, kill -9 and kill -15?
Kill 3 <PID> To ge erate the Thread du ps
kill 9 <PID> To kill the process forcibly
kill 15 <PID> It will wait to kill the process until the child processes are
killed.
60) How to check port is opened or not by using telnet and how to use telnet a d hat s the
output?
The Port Numbers Opened= netstat -an
netstat -a | fi d
Out Put= telnet 192.168.131.128 23
61) How to find a process id with a port number?
netstat -antp|grep <portno>
62) How to find a port number with a process id?
netstat -antp|grep <pid>
63) What is the command to create a tar file and extract a tar file?
tar -cvf <filename>.tar <path of the desired folder>
Extract the tar file
tar -xvf <filename>.tar /<directory to extract>
64) How to set javapath in linux?
Edit ~/ .bashrc and place below two lines in that file and save the file
Vi ~/.bashrc
JAVA_HOME = /user/lib/jvm/jre-1.6.0 openjdk
Export $JAVA_HOME
65) What is the differe e et ee diff a d p commands?
Cmp: it o pares t o files a d gi es the output like Li e o. a d B te
which indicates the first difference.
Syn: cmp
Diff: it compares two files or directories and gives the output which words are
different when comparing the files, which files are different when comparing the
directories.

6
Naveenkumar +91 8553557585

66) What is the difference between tail and head Commands?


headDisplay the list of the top files.
Eg: - head -5 NAVEEN.TXT
tail Display the list of the Bottom files.
Eg: - tail -5 NAVEEN>TXT
67) How to add a new user and Delete the user?
User Add= Useradd <username> ex: useradd naveenkumar root
Delete the User= userdell r <user name> ex: userdell -r naveenkumar
68) How to change the password
password <newpassword>
69) How to check the connectivity between to unix boxes?
ping <ipaddress>
70) What is the difference between find and grep commands?
Find-> To Search the word recursively in a particular file
Syntax= find . <directory path> - a e <file a e>
find . a e <file a e> To search goes to Current Directory
find / - a e <file a e> To Search goes to all Directory
find ~ - a e <file a e> To search goes the root Directory
grep To searh the word in a particular file
ta = grep <stri g> <filename>
E = grep a ee ku ar /root/Desktop/NAVEEN/ram.txt
71) Command to list running java process?
ps -ef|grep java
72) Command count number of java of running java processes?
netstat -antp
73) Command to find Websphere running or not?
ps -auxww| grep dmgr or node agent or application name or server name
74) How to check Web server is running or not?
ps aux|grep httpd (or) ps auxf|grep httpd
75) How to run a process in the background?
put & at the end of the command.
76) How to bring a process to foreground?
fg <pid>
77) How to find and replace a string in a file?
sed -i s/<old stri g>/< e stri g>g <filename>
Ex= sed -i s/ a ee /ku ar/g ram.txt
78) What is the use of sudo?
79) How to Rename a file and Move the file?
Rename the File= mv <oldfilename> <newfilename>
Ex= mv naveen naveenkumar
Move the File = mv <file name> <Directory Path>
Ex: mv NAVEEN.txt /root/Desktop
80) Command to find files which are older than 15 days?
find <directory path> -atime +15

7
Naveenkumar +91 8553557585

81) Command to find Recent Modified Files?


ls -lrt
82) What is the use of UMASK and what is the default UMASK value?
The umask specifies the permissions you do not want given by default to newly
created files and directories.
To reset the values. Default umask value is 022.
How to set umask ?
umask 022
83) How to mount a file system?
mount <file system name> <where to mount>
Eg: mount /dev/cdrom /mnt/cdrom
Mou t: A File ste a e ou ted o our Li u s ste I tera ti el or
automatically at startup. Then the file System is just jest as accessible as any
other file System on your Computer.
84) Command to find top 8 processes which consumes high cpu utilization?
ps auxf|sort -nr -k 3|head -8
ps auxf|sort -nr -k 3|tail -8
85) Command to find top 8 files which consume high disk usage?
ps auxf|sort -nr -k 3 | head -8
du -sm *|sort -nr|head -8
Here i di ate u arizes all the reports M i di ate size of MB
86) What is the command to find the files size more than 100 mb?
find . -size +100
87) What is the use of lsof command?
lsof stands for list the open files, which will list all the open files in the system.
The open files include network connection, devices and directories.
Syntax: lsof | more (or) lsof
Particular user= lsof -u <user name> Ex: lsof -u root
88) What is the difference between softlink and hardlink?
SoftlinkIt create a separate inode for linked file. We should not delete the
original file to access the softlink.
HardlinkIt does t have a separate inode. Hard link file will be deleted when
we delete the original file.
89) How to copy a file with in the box and syntax?
cp <file1> <file2> copy file1 to file 2 within the directory.
Cp <file1> /tmp copy file1 to /tmp directory with same name.
How to copy the file in windows to linus?
WINSCP (or) X---MANAGER (or) Reflection ---X
90) What is SCP syntax to copy a file from localbox to remote box?
scp <filename1> <username>@<ip address or hostname>:<path where to copy>
Ex: scp sample.txt 192.168.32.64 : /root/Desktop/naveen
91) What is SCP syntax to copy a file from remote box to local box?
scp <filename1> <username>@<ip address or hostname>:<path where to copy>
Eg: scp sample.txt rajkumar@192.168.32.64:/root/Desktop/naveen

8
Naveenkumar +91 8553557585

92) In netstat an what is the difference between listening and established?


The netstat an is When you dont want the name of the host, port or user to be
displayed, use netstat n option. This will display in numbers, instead of resolving the
host name, port name, user name.
The listing port no will be displayed
93) How to check listening port numbers?
netstat -listen
94) What is zombie process?
Zombie Process is a Process state when the Child dies before the parent Process. In this
Case the Structural Information of the process is Still in the Process Table.
95) How to check CPU utilization and what is the Output of top command and explain each
column?
Ans) top

PID= Display the Process ID.


USER= Running the Users.
PR=Priority of the Process.
NI= Nice Value Idle CPU Time.
VIRT= Virtual size Process which is the sum of memory RAM.
RES= Resident size which accurate representation of how much actual Physical Memory.
SHR= How much of the VIRT size in actually sharable memory.
S= Process Status. The : indicate SLEEPING and R: i di ate UNNING .
%CPU= It s Take CPU ti e used di ided the ti e pro ess.
%MEM=Memory Usage (RES). Its take currently used Share of available Physical
Memory.
TIME+= Total CPU Ti e the task has used si e it s Started.
Command= Command Name or Command Line.
MEM= Refers to your RAM.
SWAP= The Disk Partition the system uses as an extension to you Memory. Data that
was not recently used can be moved (swapped) to disk to your RAM.

9
Naveenkumar +91 8553557585

96) Command to find and replace a string in multiple files?


sed -i s/<old stri g>/< e stri g>g .t t
Ex= sed -i s/ a ee /ku ar/g ra .t t, naveen.txt,
97) Command to search a string in a file?
grep . <stri g a e> <file a e>
E = grep . a ee a ee ku ar.t t
fi d . <stri g a e> <file a e>
fi d . a ee a ee ku ar.t t
98) How to install an rpm file?
RPM Stands for Red Hot Package Manager
rpm -ivh <file name>.ram
-I indicate Install package -p indicate verbose for nicer display
-h indicate print hash marks as package archive is unpacked
99) What is the output of ps ef and ps aef and explain the output?
The ps -ef command display the all process. The following command wills a full list of
Process. The -f Indicate Open the Detailed Information about the Process.
100) Command to find free memory?
free -m
101) Difference between SFTP & FTP?
FTP Stands for File Transfer Protocol and SFTP stands for Secure File Transfer Protocol.
The FTP is Not Secure. The SFTP is Secure
The main difference is that most version of SFTP are able to deliver a much richer and
more detailed set of data about the files, Such as the permissions, date, time, size and
other information not normally available to FTP, thanks to the more robust request
protocol of the SFTP
102) How to command to read running Log files?
tail -f <Directory Path>
Ex= tail -f /temp/log.txt
103) Whenever we excute ps -ef|grep httppd it will show 3 process? And what are the 3
root 2928 0.0 0.6 1768 7120 ? SS Nov20 0.00 /opt/httpserver/bin/apache k start
nobody 292 0.0 0.6 1768 7120 ? SS Nov20 0.00 /opt/httpserver/bin/apache k start
root 1850 0.0 0.6 1768 6880 ? S+ Nov20 0.00 /opt/httpserver/bin/apache k start
104) What is the use of umask?
The umask Specifies the permissions you do not want given by default to newly
Created files and Directories
To reset the values. Default umask value is 022.
105) What is the use of nohub?
If standard input is a terminal, nohup redirects it from /dev/null. If standard output is a
terminal, append output to nohup.out if possible, $HOME/nohup.out otherwise. If
standard error is a terminal, redirect it to standard output. To save output to file FILE
nohub -help or -version
106) How to find last Command Executed or not?
echo $?
The Out Put is= Zero it is Success. and It s is NON ZERO Indicate NOT Success.

10
Naveenkumar +91 8553557585

107) What is the use of LAST Command?


The LAST command is used to show who ha recently used the server and logged in.
And out date/time. To find out the when a particular user last logged in to the Linux
Server. To find out who has recently logged in and out on your server.
By default year is now displayed by last command. You can force last
command to display full login and logout times.
Last -F
108) How to add Particular user Particular user group?
Useradd <user name> <group name>
Delete the User: userdel -r <user name> <group name>
109) How to find Command Hardware Information?
lscpu
110) What is the Opt put of the ls CPU?
Architecture : x86_64
CPU Mode : 32 bit
CPU :8
CPU Sockets : 2
Vender Id : Genuine Intel
CPU MHZ : 1866.669
111) What is the use of Less and lsof Command?
Lsof: Stands for list the open files, which will list all the open files in the system.
The open files include network connection, devices and directories.
Syntax = lsof | <file name>
Less: Less can be invoked with options to change its behavior, for example, the
number of lines to Display on the Screen. A few options very depending on, the
Operating System. While less is displaying the file,
Syntax= less -M <file Name>
112) What is the command to Delete the Particular Line and Delete the Lines from 50 to 75
Lines?
Delete the Entire line in curser position without blank lines the Vi Editor= dd
Delete the Entire line in curser position with auto edit of blank lines the Vi Editor= cc
Delete the Right side portal of the curser position Vi Editor= D
Delete the Line in Particular File
Syntax= sed -i 50D <file name>
Ex = sed -i 5 D ku ar.t t
Delete the Lines between the 50 to 75 Lines in a Particular File
Syntax= sed -i <li e no, line no>D <file a e>
Ex= sed -i 5 ,75D a ee .t t
113) How to change Time stamp of a file?
stat <file name> or touch -a <file name> ( -m -t)
114) How to copy the lines from 50 to 75 lines?
Open the file in vi editor
Press esc: 50 co 75 Press Enter
Ex= :50 co 75

11
Naveenkumar +91 8553557585

115) How to move the Lines from 50th Line?


Open the file in vi editor
Press esc: 50 mo 5
116) What is the use of nslookup and Syntax and output of nslookup?
The nslookup command is used to query internet Name Service Interactively for
Information. Nslookup Name Service lookup It is useful tool for Finding out
Information about named Domain.
By default, nslookup will translate a domain name to an IP address.
Perform a reverse lookup of the PI Address 192.168.128.131 domain server will
respond with the Current information and ti will be displayed on your terminal screen.
Syntax= nslookup [ -option] [name | -] [server]
nslookup <IP Address>
Ex: nslookup 192.168.41.128
Server: 8.8.8.8
Address: 8.8.8.8#53
Non-authoritative answer:
46.185.170.134.in-arpa
Name= grv.redhat.com
117) What is the use of cal command?
The cal Command is used to Display the Calendar
Syntax: cal <date> <month> <year>
Ex: cal 12 12 2012
118) What is the use of Date Command?
The Date Command is used to Display the Date and Time. The Command is= date
Change Time= date -s No 5 : :
Change Time= date +%T%p -s HH:MM:PM EX: date +%T%p -s : : AM
119) We are using putty terminal access the Admin Console what is the Command?
Particular Port No Access= iptables -I INPUT -p tcp --dport 9060 --syn --j ACCEPT
All Port No We Can Access= iptables -F
120) How to find Port no Displayed in the Windows Environment?
netstat -aon|findstr <pid>

12
Naveenkumar +91 8553557585

Abbreviations In WAS

API: Application Programming Interface


CVS: Concurrent Version System
CIM: Centralize Installation Manager
DMGR: Deployment Manager
FFDC: First Failure Data Capture
GUI: Graphical User Interface
GC: Garbage Collector
HTTP: Hyper Text Transfer Protocol
HTTPS: Hyper Text Transfer Protocol Secure
IBM: International Business Machines
IM: Initialization Manager
IMCL: Initialization Manager Command Line
JAR: Java Archive
JDK: Java Development Kit
J2SE: Java to Stan lone Edition
J2EE: Java to Enterprise Edition
J2ME: Java to Micro Edition
JDBC: Java Data Base Configure
JVM: Java Virtual Machine
JMS: Java Message Service
LDAP: Light weight Directory Access Protocol
LTPA: Light weight Thread Party Authentication
ND Package: Network Deployment Package
PHD: Portable Heap Dump
PS: Process Status
PMT: Profile Management Tool
PMR: Problem Maintenance Record
PMI: Performance Monitoring Infrastructure
SO: Shared Object
SDLC: Software Deployment Life Cycle
SOAP: Simple Object Access Protocol
SSO: Single Sign On
SSL: Secure Socket Layer
TPV: Tivoli Performance Viewer
TCP: Transfer Control Protocol
WAS: Web Sphere Application Server

13

You might also like