Cool Commands for Unix and Windows (ZZ)

These are some commands that I use in Windows and Unix/Linux for various purposes.

Windows (//z 2012-2-21 13:42:23 PM IS2120@CSDN)

ipconfigShow my IP address
ipconfig \allShow my host name, IP addr, MAC addr, subnet mask, DNS servers, etc.
netstatList all TCP connections
netstat -aList all active ports
nslookup hostGet IP addr for host
ping hostSee if a host is accessible


Unix/Linux


System related
uptimeShow how long the system has been up
uname -aShow the OS name and version
hostnameShows the machine's name
ps -f -u usernameLists all the processes I'm running
echo $0Shows what shell I'm using
echo $pathShows my path (or any environment variable)

Network related
netstatList all TCP connections
netstat -aList all active ports
nslookup hostGet IP addr for host
ping hostSee if a host is accessible
telnet domain_name 80Use telnet to make an HTTP request
Example to view http://www.harding.edu/comp/:
telnet www.harding.edu 80
GET /comp/ HTTP/1.1
Host: www.harding.edu

Disk space (//z 2012-2-21 13:42:23 PM IS2120@CSDN)
dfShows the amount of disk space in use
df /node_or_dirnameShows detailed information about the file system node or dir name
duShows the amount of disk space used in every dir from current location
du -ks ~fmccownShows the amount of disk space user fmccown is using (in KB)
cd;du -k | sort -nr | moreShows the disk space used (in KB) for every directory in sorted order

File processing
file myfileShort summary of what type of file myfile is
cat file1 file2 > file3Concatenates file1 and file2 and stores the result in file3
sort file.txtSorts a file
uniq file.txtRemove duplicate lines from a sorted file
wc file.txtCounts number of lines, words, and characters in a file
grep search_str file.txtSearch for a search_str in a files
tail -f file.txtList the contents of a file as it is being added to
tail -n 100 file.txtList the last 100 lines of a file
find . -name "*html"Find all files named *html starting in the current dir
find . -exec grep "hello" '{}' \; -printRun grep on all files starting in the current dir
cat myfile | hexdump -CProduce a hexdump of myfile

File compression
tar cfz my.tar.gz *.htmlCreates a gzipped tar file for all .html files
tar -tzf my.tar.gzLists the contents of my.tar.gz
tar xvfz my.tar.gzUncompresses and untars my.tar.gz
gzip myfile.txtCompresses myfile.txt creating myfile.txt.gz
gzip -d myfile.txt.gzUncompresses myfile.txt.gz creating myfile.txt
bzip2 myfile.txtCompresses myfile.txt creating myfile.txt.bz2 (Use -k to keep myfile.txt)
bzip2 -d myfile.txt.bz2Uncompresses myfile.txt.bz2 creating myfile.txt

I/O redirection
cmd > log.txtRedirect cmd output (stdout) to log.txt
cmd >> log.txtAppend stdout to log.txt
cmd 1> out_log.txt  2> err_log.txtSend stdout to out_log.txt and stderr to err_log.txt
cmd &> log.txtRedirect stdout and stderr to log.txt. Note: use >& for C shell.

Running processes
./cmd &Run process in the background
nohup ./cmd &Run process in the background, and don't terminate when shell is terminated
//z 2012-2-21 13:42:23 PM IS2120@CSDN
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值