"Think outside the [B0X]"

Handy unix commands

Ssh console login:

ssh JohnDoe@server

Count files in dir:

ls -l | wc -l

Use oracle's vi shell to access local file system.
oas_proces.x ohs_httpdconf -c container -a application

Then in vi:


note: escapen defaults to navigation mode in vi.

Remove files without confirmation:

rm -f *

Find a process, for example:

ps -ef | grep tomcat

(Ubuntu) Change a disk label depends on filesystem:

For FAT16 and FAT32 partitions, use mtools.
For NTFS partitions, use ntfsprogs.
For ext2 or ext3 partitions, use e2label.
For JFS partitions, use jfs_tune.
For ReiserFS (v3) partitions, use reiserfstune.
For XFS partitions, use xfs_admin

Find out disk space:

df -k

System load:


Delete dir recursively:

rm -rf

Count files in dir:

ls -1R | grep -i .*.mp3 | wc -l

Sync two dirs:

rsync -avz --stats  /tmp/dir1/ /tmp/dir2

Tar files:

tar -cvf <destination> <source>

Tar & gzip:

tar -cvf - . | gzip >

cpu stats:
on Ubuntu:


on Solaris:


sync time with ntp server:

sudo ntpdate ntp.ubuntu.com

Find out disk usage:

du -sk * | sort -nr | head

Compress/Uncompress (solaris):
To compress:

tar -cvf - <dir or files> | compress > <destination file>
tar -cvf - blahblah | compress > temp/abt.tar.Z

To uncompress:

uncompress -c abc.tar.Z > aaa.tar
tar -xvf abc.tar


ps aux | grep crond
crontab -l -u johndoe or sudo crontab -l -u root

Clean up some .svn dirs:

<code>find -name "\.svn" -exec rm -rf {} \;</code>

find files opened by processes:

lsof -p PID

Show dir sizes sorted by size:

du --max-depth=1 /home/ | sort -n -r

unrar all files in a directory:

for f in *.rar;do unrar e $f;done

send udp packages:

echo “hello” > /dev/udp/

where: = server
6021 = port

Category: Dev notes, server