Skip to main content

Linux Commands




Network

Wget

wget is a http client

wget http://digitalvellum.next.xxxx-labs.com/ping

Curl

Make a web request
curl -v ppe.courseadmin.he.pearsoncmg.com/console/launch?courseId=y

File Upload
curl -v -u username:password --upload-file he-mypearson-parent-3.6.pom https://devops-tools.xxxx.com/nexus-deps/service/local/repositories/Releases/content/com/ltg/3.6-SNAPSHOT/he-myson-parent-3.6.pom

nc

Ping to a port
nc -zv 10.20.238.210 1521

Netstat


Show all network connections

netstat


netstat -cnulp

netstat -a -n | grep "LIST"

Get number of connections

netstat --tcp | wc -l

Get ports with pid

netstat -lnptu

Route

route -n

Telnet

telnet 10.52.208.59
telnet 10.52.208.59 9080


network trace

mtr 10.32.149.159

Server ………….


Get shared server info
df -h

#number of cores
nproc

# CPU architecture information
lscpu

#restart ubunutu
sudo reboot

#linux os version
uname -a

cat /etc/*-release

creating a link
ln -sf /usr/lib/firefox/firefox /usr/bin/firefox


#show all env variables sorted
env | sort

sort
ll -t
 

process

linux you can find the application pid by using
>> netstat -tulpn

process details
ps -ef | grep 4377

show running processors
ps -ef

kill process id 3071
kill -9 3071
>>kill whatever process using 61521 port
      lsof -ti:61521 | xargs kill -9

##kill process
pkill -f vmstat
pkill -f pidstat

Permissions


change ownership of a folder and sub
chown -R aravinda:aravinda eclipse_sts

change file permission
chmod ugo+rwx file4

#change chmod
chmod o-rw myfile

Compression


ZIP

tar -zcvf compressFileName.tar.gz folderToCompress

#extract to destination_folder
tar -xvzf env.tar.gz -C destination_folder

unzip compressFileName.zip -d folderToCompress

#unzip
tar xvzf bos03-prod-env.tar.gz

#view only
vim xxx.tar.gz

#open file
press enter on line of the file to open

#search a file in jar
                find *.jar | xargs grep className.class


Copy

scp -- ssh copy

scp courseDetails.min.js portweb@10.52.129.12:/install/tomcat/webapps/media/javascript

ENVIRONMENT VARIABLES

SET ENVIRONMENT VARIABLES
vi /etc/environment
>> JAVA_HOME="/usr/lib/jvm/open-jdk"
source /etc/environment

#set java per session
export PATH=$PATH:/export/home/apps/jdk1.7.0_51/bin
--get java location by >>ps -ef

#show env variables
env


vi editor

show line numbers
>> :set nu

Edit File

scripts to edit file in linux

#replace 8443 with 8080
sed -i.bak 's/8443/8080/g' server.xml

#add code after using the shared thread pool'
sed -i.bak '/using the shared thread pool/r ssh_properties.txt' server.xml

DISK SPACE


#list free disk space:
df -h

#which sub-folders spend how much disk space
du -h --max-depth=1

#top 10 largest file/directories:
du -a /var | sort -n -r | head -n 10

#memory usage per process
ps -aux


iptables


//GET request for "http://cert.coursemgmt.he.xxxx.com/course/epa38191":Connection reset
//java.net.SocketException: Connection reset

#from source - should connect to the source
telnet 10.52.208.59 9080

#from destination, reset ports
iptables -F

iptables -nL

memory


#free memory > buffers/cache
free -m
#processors using resources
top

Cron Tab


#cron logs
grep CRON /var/log/syslog

Disable the cronjob.
30 3 * * * bash /export/home/portal/sync_portal_enrollments.sh

SSH Tunneling

ssh -f -L 61521:dbs-b3-0301:1521 usenanu@bridge.xxxx.com -N

SSH


ssh portaltest01

Nohup


nohup /export/home/portal/shared/app/jdk1.7.0_45/bin/java -jar /machineagent.jar &

service

#staring course managemtn simulator
    cd /etc
    sudo service httpd start

memcache

#memcache restart
pkill -f memcached

nohup /export/home/apps/memcached-1.4.15/bin/memcached -v -m 1024 -p 11211 -u portweb -l $HOSTNAME > /dev/null &


or

sudo /etc/init.d/memcached start

#check memchached status
 netstat -tulpn | grep 11211

  ps -e | grep memcached

Comments

Popular posts from this blog

Oracle Database 12c installation on Ubuntu 16.04

This article describes how to install Oracle 12c 64bit database on Ubuntu 16.04 64bit. Download software  Download the Oracle software from OTN or MOS or get a downloaded zip file. OTN: Oracle Database 12c Release 1 (12.1.0.2) Software (64-bit). edelivery: Oracle Database 12c Release 1 (12.1.0.2) Software (64-bit)   Unpacking  You should have following two files downloaded now. linuxamd64_12102_database_1of2.zip linuxamd64_12102_database_2of2.zip Unzip and copy them to \tmp\databases NOTE: you might have to merge two unzipped folders to create a single folder. Create new groups and users Open a terminal and execute following commands. you might need root permission. groupadd -g 502 oinstall groupadd -g 503 dba groupadd -g 504 oper groupadd -g 505 asmadmin Now create the oracle user useradd -u 502 -g oinstall -G dba,asmadmin,oper -s /bin/bash -m oracle You will prompt to set to password. set a momorable password and write it down. (mine is orac

DBCA : No Protocol specified

when trying to execute dbca from linux terminal got this error message. now execute the command xhost, you probably receiving No protocol specified xhost:  unable to open display ":0" issue is your user is not allowed to access the x server. You can use xhost to limit access for X server for security reasons. probably you are logged in as oracle user. switch back to default user and execute xhost again. you should see something like SI:localuser:nuwan solution is adding the oracle to access control list xhost +SI:localuser:oracle now go back to oracle user and try dbca it should be working

Java Head Dump Vs Thread Dump

JVM head dump is a snapshot of a JVM heap memory in a given time. So its simply a heap representation of JVM. That is the state of the objects. JVM thread dump is a snapshot of a JVM threads at a given time. So thats what were threads doing at any given time. This is the state of threads. This helps understanding such as locked threads, hanged threads and running threads. Head dump has more information of java class level information than a thread dump. For example Head dump is good to analyse JVM heap memory issues and OutOfMemoryError errors. JVM head dump is generated automatically when there is something like OutOfMemoryError has taken place.  Heap dump can be created manually by killing the process using kill -3 . Generating a heap dump is a intensive computing task, which will probably hang your jvm. so itsn't a methond to use offetenly. Heap can be analysed using tools such as eclipse memory analyser. Core dump is a os level memory usage of objects. It has more informaiton t