您的位置:首页 > 其它

Cool Commands for Unix and Windows (ZZ)

2012-02-21 13:39 316 查看
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
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐