bugged.be

"Think outside the [B0X]"
Icon

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:

:sh

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:

top

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:

top

on Solaris:

prstats

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>
or
tar -cvf - blahblah | compress > temp/abt.tar.Z

To uncompress:

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

Cron:

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/127.0.0.1/6021

where:
127.0.0.1 = server
6021 = port

Category: Dev notes, server

Tagged: