Wednesday, July 10, 2013

Frequently Used Linux Commands

For my easy reference,

find . -name *.jar | xargs grep -i 'ABC.class'
# Find a jar file which has ABC.class in it

printenv
# Environment variables

printenv | grep proxy
# Environment variables with proxy in name

export https_proxy=http://x.x.x.x:3128
# Set environment variable

sudo su
# Login as super user

rm -rf folderToDelete
# Delete the folder and the contents

netstat -anp|grep :7001
# Find a process binding a port

kill -9 21286
# Kill process

telnet hostA 1521
# Telnet a port

nslookup hostA
# 

uname -a
# kernel-name, nodename, processor, OS etc

lsb_release -a
# OS version

cat /etc/*release 
# OS version

df -h
# file system sizes & free space

du -s folderloc
# folder size

du --si -s file 
# File size shown in G,M

ssh root@serverA
# Connect to serverA as root

scp root@serverA.abc.com:/path/a.log b.log
# Copy a file from serverA

scp -r /path/folderA  userB@serverB:/path/folderB
# Copy a folder to serverB

tar -cf archive.tar foo bar
# Create archive.tar from files foo and bar.

tar -xf archive.tar
# Extract all files from archive.tar.

vpnc-connect
# VPN connect

date
# Current date

date +%T -s "15:22:13"
# Update time

split --bytes=50m largeFile.log splitFile_
# Split a file to files with 50m


Common Options

-f, --force
-r, -R, --recursive
-a, --all
-v, --verbose
--help
--version

No comments:

Post a Comment