1) How to find Red
Hot Linux Version:
cat
/etc/redhat-release
cat
/etc/os-release
cat
/etc/issue
$
hostnamectl
2) How to find my
redhot 32 or 64 bit:
You
can also do uname -i
Yours
will probably respond with i386 for 32bit
If
you had a 64 bit version of the OS installed, it would respond with x86_64
3) Wget comands
examples:
$
wget -O output.file http://nixcraft.com/some/path/file.name.tar.gz
4) Use ssh to login
to your remote servers without using a password:
--Step
1: Generate a public and private key pair
$
ssh-keygen -t rsa
Generating
public/private rsa key pair.
Enter
file in which to save the key (/Users/al/.ssh/id_rsa):
Enter
passphrase (empty for no passphrase):
Enter
same passphrase again:
Your
identification has been saved in /Users/al/.ssh/id_rsa.
Your
public key has been saved in /Users/al/.ssh/id_rsa.pub.
The
key fingerprint is:
6f:16:29:90:46:b6:88:34:3d:81:07:fc:bd:1a:fc:db
al@Al-Alexanders-MacBook.local
The
key's randomart image is:
+--[
RSA 2048]----+
|
.++..o |
|
.oo++ o |
| .o.o=
|
| ....
. |
| . .S
o |
| o .
o . |
| +
+ |
| . .. o
|
| ..E
|
+-----------------+
As
you can see from the output of this command:
Your
private key is in a file named ~/.ssh/id_rsa
Your
public key is in a file named ~/.ssh/id_rsa.pub
---
Step 2: Copy the ssh keys to all the nodes:
ssh-copy-id
usename@
---
Step 3: Test ssh to machine_hostname, it should not ask password:
ssh-copy-id
localhost
5) How to login sudo
user with out giving password:
visudo
(Add a line as below)
root
ALL =(ALL) : ALL
username
ALL=(ALL) NOPASSWORD: ALL
su
- username
then
now its comes from root user to my
username
6) How to Use Pscp
to Transfer/Copy Files to Multiple Linux Servers:
pscp
– is utility for copying files in parallel to a number of hosts.
prsync
– is a utility for efficiently copying files to multiple hosts in parallel.
pnuke
– it helps to kills processes on multiple remote hosts in parallel.
pslurp
– it helps to copy files from multiple remote hosts to a central host in
parallel.
Let’s
create a new file called “myscphosts.txt” and add the list of Linux hosts IP
address and SSH port (default 22) number as shown.
192.168.0.3:22
192.168.0.9:22
#
pscp -h myscphosts.txt -l User_name -Av wine-1.7.55.tar.bz2 /tmp/
OR
#
pscp.pssh -h myscphosts.txt -l User_name -Av wine-1.7.55.tar.bz2 /tmp/
Warning:
do not enter your password if anyone else has superuser
privileges
or access to your account.
Password:
[1]
17:48:25 [SUCCESS] 192.168.0.3:22
[2]
17:48:35 [SUCCESS] 192.168.0.9:22
Explanation
about the options used in the above command.
-h
switch used to read a hosts from a given file and location.
-l
switch reads a default username on all hosts that do not define a specific
user.
-A
switch tells pscp ask for a password and send to ssh.
-v
switch is used to run pscp in verbose mode.
7) How to get
Weblogic Version :
--
Command line: registry.xml
--
java -cp WLS_HOME/wlserver_10.3/server/lib/weblogic.jar weblogic.version
--
From Admin console:
Login
to WebLogic Administration Console and navigate to Servers –> AdminServer
–> Monitoring tab
here
it will shows , 1. Weblogic version 2. jdk vendor and version 3. OS name and
version
8) How to get the
Java Version:
--java
-version
java
version "1.6.0_16"
Java(TM)
SE Runtime Environment (build 1.6.0_16-b01)
Java
HotSpot(TM) Server VM (build 14.2-b01, mixed mode)
java
version "1.7.0_51"
OpenJDK
Runtime Environment (rhel-2.4.4.1.el6_5-x86_64 u51-b02)
OpenJDK
64-Bit Server VM (build 24.45-b08, mixed mode)
9) How to Replace a
string in Linux and VI Editor?
sed
"s/oldstring/newstring/g" filename and sed :%s/oldstring/newstring/g
10) How to display
TOP 10 disk space files?
du
-sh* | sort -nr|head -10
11) tar -cvf
filename.tar file1 file2 file3
How
to extract tar.bz2 files: tar jxvf filename.tar.bz2
How
to create tar.bz2 files: tar jcvf filename.tar.bz2 file1 file2 file3
TAR.BZ2
This
format has the best level of compression among all of the formats I’ve
mentioned here.
But
this comes at a cost – in time and in CPU. Here’s how you compress a directory
using tar.bz2:
#
tar -jcvf archive_name.tar.bz2 directory_to_compress
#
tar -jxvf archive_name.tar.bz2 -C /tmp/extract_here/
12) tar -xvf
filename.tar
13) tar -zcvf
filename.tar.gz file1 file2 file3 , tar -zxvf filename.tar.gz
14) Apache ---
httpd.conf , ssl.conf and mod_wl_22.so
15) OHS ---
mod_wl_ohs.conf , mod_wl_ohs.so
16) How to take the
Thread dump if server in hand state:(Server Hang)
1.
ps -ef | grep java
kill
-3
2.
Weblogic.Admin utilities
java
weblogic.admin t3://localhost:7001 -username=weblogic -password=weblogic123
THREAD_DUMP
3.
From Admin Console: Server-> Monitoring-> threads -> click on Dump
Thread Stuck.
4.
WLST
connect('weblogic','weblogic123','t3://localhost:7001')
cd
('servers')
cd
('AdminServer')
Thread
dump()
disconnect()
exit()
17) Server crash:
Resongs:
1.
Native IO
2.
SSL Native Libraries
3.
JVM
4.
Supported Configuration
5.
JDBC driver issue
Analysis:
1.
hr_err_p*.log
2.
pmap core or pstack
3.
debugger mode enable
1.
From Admin console :
Environment
-> Cluster ->name ->Configuration -> Server Start Sub-tab
->Arguments
2.
Copy the existing startWebLogic.sh script to a new script file,
startWebLogic_Debug.sh.
JAVA_OPTIONS="-Xdebug
-Djava.compiler=NONE -Xnoagent
-Xrunjdwp:transport=dt_socket,server=y,address=10171,suspend=n
$JAVA_OPTIONS"
18) Symbolic Links
$
ln -s {source-filename} {symbolic-filename}
s
means symbolic link not hard link
ln
-s /etc/httpd/vhosts/example.com /etc/httpd/sites-enabled/example.com
unlink
{symbolic-filename}
unlink /etc/httpd/vhosts/example.com
19) Examples of RPM
Commands in Linux:-
1-
How to Check an RPM Signature Package
#
rpm --checksig pidgin-2.7.9-5.el6.2.i686.rpm
2-
How to Install an RPM Package
#
rpm -ivh pidgin-2.7.9-5.el6.2.i686.rpm
3-
How to check dependencies of RPM Package before Installing
#
rpm -qpR BitTorrent-5.2.2-1-Python2.4.noarch.rpm
4-
How to Install a RPM Package Without Dependencies
#
rpm -ivh --nodeps BitTorrent-5.2.2-1-Python2.4.noarch.rpm
5-
How to check an Installed RPM Package
#
rpm -q BitTorrent
6-
How to List all files of an installed RPM package
#
rpm -ql BitTorrent
7-
How to List Recently Installed RPM Packages
#
rpm -qa --last
8-
How to List All Installed RPM Packages
#
rpm -qa
9-
How to Upgrade a RPM Package
#
rpm -Uvh nx-3.5.0-2.el6.centos.i686.rpm
10-
How to Remove a RPM Package
#
rpm -evv nx
11-
How to Remove an RPM Package Without Dependencies
#
rpm -ev --nodeps vsftpd
12-
How to Query a file that belongs which RPM Package
#
rpm -qf /usr/bin/htpasswd
13-
How to Query a Information of Installed RPM Package
#
rpm -qi vsftpd
14-
Get the Information of RPM Package Before Installing
#
rpm -qip sqlbuddy-1.3.3-1.noarch.rpm
15-
How to Query documentation of Installed RPM Package
#
rpm -qdf /usr/bin/vmstat
16-
How to Verify a RPM Package
#
rpm -Vp sqlbuddy-1.3.3-1.noarch.rpm
17-
How to Verify all RPM Packages
#
rpm -Va
18-
How to Import an RPM GPG key
#
rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
19-
How to List all Imported RPM GPG keys
#
rpm -qa gpg-pubkey*
20-
How To rebuild Corrupted RPM Database
[root@tecmint]#
cd /var/lib
[root@tecmint]#
rm __db*
[root@tecmint]#
rpm --rebuilddb
[root@tecmint]#
rpmdb_verify Packages
rpm
–ivh httpd-2.4.x-1.i686.rpm
rpm
–Uvh httpd-2.4.x-1.i686.rpm
20)
find – search for files in a directory hierarchy
Usage: find [OPTION] [path] [pattern]
eg. find file1.txt, find name file1.txt
21)
history – prints recently used commands
Usage: history
22)
3 types of file permissions – read, write, execute
•
10 bit format from 'ls l' command
1 2 3 4 5 6 7 8 9 10
file type owner group others
eg. drwxrwr means owner has all three permissions,
group has read and write, others have only read
permission
•
read permission – 4, write – 2, execute 1
eg. rwxrwr = 764
673 = rwrwxwx
23)
chmod – change file access permissions
Usage: chmod [OPTION] [MODE] [FILE]
eg. chmod 744 calculate.sh
24)
chown – change file owner and group
Usage: chown [OPTION]... OWNER[:[GROUP]] FILE...
eg. chown remo myfile.txt
25)
du – estimate file space usage
Usage: du [OPTION]... [FILE]...
eg. du
-sh
26)
df – report filesystem disk space usage
Usage: df [OPTION]... [FILE]...
eg. df
-h
27)
quota – display disk usage and limits
Usage: quota [OPTION]
eg. quota v
28)
reboot – reboot the system
Usage: reboot [OPTION]
eg. reboot
29)
poweroff – power off the system
Usage: poweroff [OPTION]
eg. poweroff
30)
locate – find or locate a file
Usage: locate [OPTION]... FILE...
eg. locate file1.txt
31) File Commands
------------------
ls
– directory listing
ls
-al – formatted listing with hidden files
cd
dir - change directory to dir
cd
– change to home
pwd
– show current directory
mkdir
dir – create a directory dir
rm
file – delete file
rm
-r dir – delete directory dir
rm
-f file – force remove file
rm
-rf dir – force remove directory dir *
cp
file1 file2 – copy file1 to file2
cp
-r dir1 dir2 – copy dir1 to dir2; create dir2 if it
doesn't
exist
mv
file1 file2 – rename or move file1 to file2
if
file2 is an existing directory, moves file1 into
directory
file2
ln
-s file link – create symbolic link link to file
touch
file – create or update file
cat
> file – places standard input into file
more
file – output the contents of file
head
file – output the first 10 lines of file
tail
file – output the last 10 lines of file
tail
-f file – output the contents of file as it
grows,
starting with the last 10 lines
32) Process
Management
-----------------------
ps
– display your currently active processes
top
– display all running processes
kill
pid – kill process id pid
killall
proc – kill all processes named proc *
bg
– lists stopped or background jobs; resume a
stopped
job in the background
fg
– brings the most recent job to foreground
fg
n – brings job n to the foreground
33) File Permissions
-------------------------
chmod
octal file – change the permissions of file
to
octal, which can be found separately for user,
group,
and world by adding:
●
4 – read (r)
●
2 – write (w)
●
1 – execute (x)
Examples:
chmod
777 – read, write, execute for all
chmod
755 – rwx for owner, rx for group and world/others
For
more options, see man chmod.
34) System Info
--------------------
date
– show the current date and time
cal
– show this month's calendar
uptime
– show current uptime
w
– display who is online
whoami
– who you are logged in as
finger
user – display information about user
uname
-a – show kernel information
cat
/proc/cpuinfo – cpu information
cat
/proc/meminfo – memory information
man
command – show the manual for command
df
– show disk usage
du
– show directory space usage
free
– show memory and swap usage
whereis
app – show possible locations of app
which
app – show which app will be run by default
35) Compression
-------------------------
tar
cf file.tar files – create a tar named
file.tar
containing files
tar
xf file.tar – extract the files from file.tar
tar
czf file.tar.gz files – create a tar with
Gzip
compression
tar
xzf file.tar.gz – extract a tar using Gzip
tar
cjf file.tar.bz2 – create a tar with Bzip2
compression
tar
xjf file.tar.bz2 – extract a tar using Bzip2
gzip
file – compresses file and renames it to file.gz
gzip
-d file.gz – decompresses file.gz back
to file
36) Network
------------------------
ping
host – ping host and output results
whois
domain – get whois information for domain
dig
domain – get DNS information for domain
dig
-x host – reverse lookup host
wget
file – download file
wget
-c file – continue a stopped download
37) Installation
---------------------
Install
from source:
./configure
make
make
install
dpkg
-i pkg.deb – install a package (Debian)
rpm
-Uvh pkg.rpm – install a package (RPM)
38) SSH
---------------------
ssh
user@host – connect to host as user
ssh
-p port user@host – connect to host on port
port
as user
ssh-copy-id
user@host – add your key to host for
user
to enable a keyed or passwordless login
39) Searching
-------------------
grep
pattern files – search for pattern in files
grep
-r pattern dir – search recursively for
pattern
in dir
command
| grep pattern – search for pattern in the
output
of command
locate
file – find all instances of file
40) Shortcuts
--------------------
Ctrl+C
– halts the current command
Ctrl+Z
– stops the current command, resume with
fg
in the foreground or bg in the background
Ctrl+D
– log out of current session, similar to exit
Ctrl+W
– erases one word in the current line
Ctrl+U
– erases the whole line
Ctrl+R
– type to bring up a recent command
!!
- repeats the last command
exit
– log out of current session
41) vmstat
vmstat
reports virtual memory statistics and is used to help identify performance
bottlenecks
vmstat
reports information about processes, memory, paging, block IO, traps, disks and
cpu activityactivity.
vmstat
syntax: vmstat [options] [delay [count]]
$
vmstat
procs
-----------memory---------- ---swap-- -----io---- --system-- -----cpu------
r b
swpd free buff
cache si so
bi bo in cs us sy id wa st
0 0 305416 260688 29160 2356920 2
2 4 1
0 0 6 1 92
No comments:
Post a Comment